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
+139
View File
@@ -0,0 +1,139 @@
# Admin2000 - Development Notes
## Aktuelles Problem: Save funktioniert nicht (2025-10-25)
### Problem-Analyse
- Customer Editor lädt korrekt, alle Daten werden angezeigt
- Beim Speichern: Error 500
- Debug-Log zeigt: Crash in Legacy `Customer->update()` (customer.class.php:1474)
- Keine weiteren Logs nach "Calling customer->save()"
### Root Cause
Legacy `Customer->update()` Methode:
- Baut dynamisch SQL UPDATE mit allen übergebenen Feldern
- Crasht wahrscheinlich bei nicht-existierenden DB-Spalten
- Problem-Felder: `pass1`, `pass2`, `admin_role_id` (0)
- `pass1`/`pass2` sind UI-only Felder (sollten zu `pass` gemapped werden)
- `admin_role_id` = 0 sollte gefiltert werden oder leer bleiben
- Kein Error-Handling, kein Logging im Legacy-Code
### Debug-Dateien
- `/var/www/vhosts/intelectra.de/httpdocs/admin2000_debug.log` - Live Debug Output
- Letzter Eintrag: "Calling customer->save()" - danach Crash
---
## Lösung: CustomerManager-Klasse (Grüne Wiese)
### Konzept
**Skalpell-Modus für Legacy:**
- Legacy Customer-Klasse bleibt READ-ONLY
- Nur `get_data()`, `get_by_id()` etc. nutzen
- KEINE Änderungen am Legacy-Code
**Neue Admin2000 CRUD-Logik:**
- Eigene CustomerManager-Klasse für Admin2000
- Sauberes Error-Handling + Logging
- UPDATE und CREATE sauber getrennt
- Nur existierende DB-Spalten updaten
### Geplante Struktur
```
/modules/admin2000/
├── admin2000.php (Controller)
└── classes/
└── CustomerManager.php (neue CRUD-Klasse)
├── get($id) - liest aus Legacy
├── update($id, $data) - eigene UPDATE-Logik
├── create($data) - eigene CREATE-Logik
├── validate($data) - Eingabe-Validierung
└── mapFormToDb($form_data) - Feld-Mapping
```
### CustomerManager Features
1. **Feld-Mapping:**
- `pass1` + `pass2` → `pass` (md5 hash)
- `admin_role_id` nur wenn > 0
- Leere Strings bei Datums-Feldern filtern ("0000-00-00")
2. **Whitelist für DB-Felder:**
- Nur Spalten updaten die wirklich existieren
- Schützt vor SQL Errors
3. **Error-Handling:**
- Try-Catch um SQL-Queries
- Logging in eigene Datei
- Sinnvolle Fehlermeldungen
4. **Validierung:**
- E-Mail Format
- Required Fields
- Duplikat-Check
---
## Nächste Schritte
### Phase 1: CustomerManager erstellen
- [ ] `modules/admin2000/classes/CustomerManager.php` erstellen
- [ ] Database-Spalten-Whitelist definieren
- [ ] `update()` Methode mit Error-Handling
- [ ] Feld-Mapping implementieren (`pass1`/`pass2` → `pass`)
### Phase 2: Integration
- [ ] In `admin2000.php` CustomerManager statt Legacy Customer nutzen
- [ ] `save_customer()` umbauen auf CustomerManager->update()
- [ ] Debug-Logging entfernen wenn fertig
### Phase 3: Testing
- [ ] Save testen mit verschiedenen Feldkombinationen
- [ ] Passwort-Änderung testen
- [ ] Leere Felder testen
- [ ] Admin-Role-Änderung testen
---
## DB-Spalten (customers Tabelle)
**Existierende Spalten (aus get_data() bekannt):**
- id, number, locked, group_id
- honorific, firstname, surname
- phone, mobile, fax, email, website
- show_tax, burth_date
- company, tax_number, tax_id, eu_business
- account_holder, account_number, bank, bank_number, iban, swift_bic
- direct_debit_active, rechnung_active, skonto
- freetextfield1-6, has_item_export, newsletter_sub, info
- pass (md5 hash)
- admin_role_id (vermutlich)
**UI-only Felder (nicht in DB):**
- pass1, pass2 (werden zu `pass` gemapped)
- customer_password_action (Dropdown für Passwort-Aktionen)
---
## Lessons Learned
1. **Legacy = READ ONLY:**
- Nie wieder Legacy CRUD-Methoden nutzen ohne Analyse
- Nur GET-Methoden sind safe
- UPDATE/CREATE = grüne Wiese
2. **Debugging:**
- `file_put_contents()` zu Debug-Datei funktioniert
- `error_log()` erscheint nicht in Plesk PHP-FPM Logs
- Browser DevTools zeigt nur "500" - kein Stack Trace
3. **Skalpell-Modus:**
- "Ich habe gedacht" = VERBOTEN
- Nur Fakten aus Legacy-Code nutzen
- Keine Annahmen, keine "Optimierungen"
---
## Kontakt / Fragen
Bei Fragen zu Admin2000:
- Debug-Log: `admin2000_debug.log` im httpdocs root
- Diese Datei: `/modules/ADMIN2000_NOTES.md`
+399
View File
@@ -0,0 +1,399 @@
<?php
/**
* Admin2000 - Modernes Admin-System
*
* Komplett neues, paralleles Admin-System mit:
* - Modernem CSS Layout
* - Responsive Design
* - Sauberer Code-Struktur
* - Keine Inline-Styles
*
* @package Admin2000
* @author Claude & Team
* @version 1.0.0
*/
class admin2000 {
private $base_object;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$debug_file = './admin2000_debug.log';
file_put_contents($debug_file, "\n=== RUN() START " . date('Y-m-d H:i:s') . " ===\n", FILE_APPEND);
file_put_contents($debug_file, "REQUEST_METHOD: " . $_SERVER['REQUEST_METHOD'] . "\n", FILE_APPEND);
file_put_contents($debug_file, "GET: " . print_r($_GET, true) . "\n", FILE_APPEND);
file_put_contents($debug_file, "POST keys: " . print_r(array_keys($_POST), true) . "\n", FILE_APPEND);
// Get section and page from URL
$section = isset($_GET['section']) ? $_GET['section'] : 'stammdaten';
$page = isset($_GET['page']) ? $_GET['page'] : 'kunden';
$action = isset($_GET['action']) ? $_GET['action'] : '';
file_put_contents($debug_file, "Section: $section, Page: $page, Action: $action\n", FILE_APPEND);
file_put_contents($debug_file, "POST action: " . (isset($_POST['action']) ? $_POST['action'] : 'NONE') . "\n", FILE_APPEND);
// Handle POST save action
if (isset($_POST['action']) && $_POST['action'] == 'save' && $page == 'kunden_editor') {
file_put_contents($debug_file, "Routing to save_customer()\n", FILE_APPEND);
return $this->save_customer();
}
// Handle AJAX requests (return partial HTML only)
if ($action == 'get_list_items') {
return $this->get_list_items($section, $page);
}
// Build navigation data
$navigation = $this->build_navigation($section, $page);
$this->layout_object->assign('admin2000_nav', $navigation);
$this->layout_object->assign('admin2000_section', $section);
$this->layout_object->assign('admin2000_page', $page);
// Pass admin user data to template
$this->layout_object->assign('admin_user', $this->base_object->customer);
// Load page content
$content = $this->load_page_content($section, $page);
$this->layout_object->assign('admin2000_content', $content);
// Load FULL standalone HTML layout (not wrapped in main.tpl)
return $this->layout_object->fetch('admin2000_layout.tpl');
}
/**
* Build navigation structure
*/
private function build_navigation($active_section, $active_page) {
$nav = array(
'stammdaten' => array(
'title' => 'Stammdaten',
'icon' => '📊',
'pages' => array(
'kunden' => array(
'title' => 'Kunden',
'url' => './index.php?admin_modul=admin2000&section=stammdaten&page=kunden',
'icon' => '👥',
'active' => ($active_section == 'stammdaten' && $active_page == 'kunden')
),
'artikel' => array(
'title' => 'Artikel',
'url' => './index.php?admin_modul=admin2000&section=stammdaten&page=artikel',
'icon' => '📦',
'active' => ($active_section == 'stammdaten' && $active_page == 'artikel')
),
'lieferanten' => array(
'title' => 'Lieferanten',
'url' => './index.php?admin_modul=admin2000&section=stammdaten&page=lieferanten',
'icon' => '🚚',
'active' => ($active_section == 'stammdaten' && $active_page == 'lieferanten')
)
)
)
);
return $nav;
}
/**
* Load page content based on section and page
*/
private function load_page_content($section, $page) {
// Load data for specific pages
if ($section == 'stammdaten' && $page == 'kunden') {
$this->load_customer_data();
} elseif ($section == 'stammdaten' && $page == 'kunden_editor') {
$this->load_customer_editor_data();
}
// Build template path
$template_file = "admin2000/{$section}_{$page}.tpl";
// Check if template exists
$template_path = ROOT_DIR . "/themes/admin/templates/{$template_file}";
if (!file_exists($template_path)) {
// Return placeholder if template doesn't exist yet
return $this->get_placeholder_content($section, $page);
}
// Load and return template
return $this->layout_object->fetch($template_file);
}
/**
* Get placeholder content for pages that don't exist yet
*/
private function get_placeholder_content($section, $page) {
return "
<div style='padding: 40px; text-align: center; background: #f8f9fa; border-radius: 8px; margin: 20px;'>
<h2 style='color: #333; margin-bottom: 20px;'>🚧 In Entwicklung</h2>
<p style='color: #666; font-size: 16px; margin-bottom: 30px;'>
Diese Seite wird gerade entwickelt.
</p>
<div style='background: white; padding: 20px; border-radius: 6px; display: inline-block;'>
<strong>Section:</strong> {$section}<br>
<strong>Page:</strong> {$page}<br>
<strong>Template:</strong> admin2000/{$section}_{$page}.tpl
</div>
</div>
";
}
/**
* Load customer data for the list
*/
private function load_customer_data() {
include_once './core/customer.class.php';
$customer = new Customer($this->base_object);
// Pass table config to template
$table_data = $customer->list_table_config;
$table_data['list_filter'] = $customer->get_filter();
// Get customer statistics
$stats = $this->get_customer_stats();
$this->layout_object->assign('table_data', $table_data);
$this->layout_object->assign('customer_stats', $stats);
}
/**
* Get customer statistics for dashboard cards
*/
private function get_customer_stats() {
$db = $this->base_object->db;
$stats = array();
// Total customers
$sql = "SELECT COUNT(*) as total FROM customers";
$result = $db->query($sql);
$row = $result->fetch_assoc();
$stats['total'] = $row['total'];
// Active customers (locked = 0 means active)
$sql = "SELECT COUNT(*) as active FROM customers WHERE locked = 0";
$result = $db->query($sql);
$row = $result->fetch_assoc();
$stats['active'] = $row['active'];
// Locked/Disabled customers
$sql = "SELECT COUNT(*) as locked FROM customers WHERE locked = 1";
$result = $db->query($sql);
$row = $result->fetch_assoc();
$stats['locked'] = $row['locked'];
// New customers in last 30 days
$sql = "SELECT COUNT(*) as new_30days FROM customers WHERE registration_date >= DATE_SUB(NOW(), INTERVAL 30 DAY)";
$result = $db->query($sql);
$row = $result->fetch_assoc();
$stats['new_30days'] = $row['new_30days'];
return $stats;
}
/**
* Load customer editor data - WITH INJECTION PROTECTION!
*/
private function load_customer_editor_data() {
include_once './core/customer.class.php';
include_once './core/customeraddress.class.php';
include_once './core/order.class.php';
// SECURITY: Validate and sanitize customer ID
$customer_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($customer_id <= 0) {
$this->layout_object->assign('error', 'Ungültige Kunden-ID');
return;
}
$customer = new Customer($this->base_object);
// Check if customer exists
if (!Customer::has_id($customer_id)) {
$this->layout_object->assign('error', 'Kunde nicht gefunden');
return;
}
// Load customer data - using get_data() for FULL legacy compatibility
// (includes group_name, show_tax via LEFT JOIN customer_groups)
$customer_data = $customer->get_data($customer_id);
// Convert OBJECT to ARRAY for Smarty template compatibility
$customer_data = (array) $customer_data;
// Load customer addresses
$customer_address_object = new CustomerAddress($this->base_object);
$customer_addresses = $customer_address_object->get_data_by_customer_id($customer_id);
// Convert addresses to array if needed
if ($customer_addresses && is_array($customer_addresses)) {
$addresses_array = array();
foreach ($customer_addresses as $addr) {
$addresses_array[] = (array) $addr;
}
$customer_addresses = $addresses_array;
}
// Load customer orders (Bestellungen/Rechnungen)
$orders = OrderHelper::get_all_customer_orders($customer_id);
// Convert orders to array if needed
if ($orders && is_array($orders)) {
$orders_array = array();
foreach ($orders as $order) {
$orders_array[] = (array) $order;
}
$orders = $orders_array;
}
// Get form field configuration from customer class
$form_config = $customer->list_table_config['edit_fields'];
// Load select options for dropdowns
$select_values = array();
foreach ($form_config as $field) {
if (isset($field['values']) && is_string($field['values'])) {
// Call the function to get values (e.g. customer_group_values())
$select_values[$field['db_field']] = $customer->{$field['values']}();
}
}
// Check if save was successful
$save_success = isset($_GET['saved']) && $_GET['saved'] == '1';
// Pass to template
$this->layout_object->assign('customer_id', $customer_id);
$this->layout_object->assign('customer_data', $customer_data);
$this->layout_object->assign('customer_addresses', $customer_addresses);
$this->layout_object->assign('orders', $orders);
$this->layout_object->assign('form_config', $form_config);
$this->layout_object->assign('select_values', $select_values);
$this->layout_object->assign('save_success', $save_success);
}
/**
* Save customer data - WITH INJECTION PROTECTION!
*/
private function save_customer() {
// DEBUG: Write to file
$debug_file = './admin2000_debug.log';
file_put_contents($debug_file, "=== SAVE_CUSTOMER START " . date('Y-m-d H:i:s') . " ===\n", FILE_APPEND);
file_put_contents($debug_file, "POST data: " . print_r($_POST, true) . "\n", FILE_APPEND);
include_once './core/customer.class.php';
// SECURITY: Validate customer ID
$customer_id = isset($_POST['customer_id']) ? intval($_POST['customer_id']) : 0;
file_put_contents($debug_file, "Customer ID: " . $customer_id . "\n", FILE_APPEND);
if ($customer_id <= 0) {
file_put_contents($debug_file, "ERROR: Invalid customer ID\n", FILE_APPEND);
die('Ungültige Kunden-ID');
}
$customer = new Customer($this->base_object);
file_put_contents($debug_file, "Customer object created\n", FILE_APPEND);
// Check if customer exists
if (!Customer::has_id($customer_id)) {
file_put_contents($debug_file, "ERROR: Customer not found\n", FILE_APPEND);
die('Kunde nicht gefunden');
}
file_put_contents($debug_file, "Customer exists check passed\n", FILE_APPEND);
// SECURITY: Sanitize all input data
// Legacy uses 'customer_field' not 'customer_data'!
$customer_data = isset($_POST['customer_field']) ? $_POST['customer_field'] : array();
file_put_contents($debug_file, "customer_field data: " . print_r($customer_data, true) . "\n", FILE_APPEND);
$sanitized_data = array();
foreach ($customer_data as $key => $value) {
// Only allow alphanumeric field names (prevent injection)
if (preg_match('/^[a-zA-Z0-9_]+$/', $key)) {
// CRITICAL: Don't send empty password (would create md5('') hash!)
if ($key === 'pass' && trim($value) === '') {
continue;
}
// Sanitize value based on type
if (is_array($value)) {
$sanitized_data[$key] = array_map('strip_tags', $value);
} else {
$sanitized_data[$key] = strip_tags($value);
}
}
}
// Add customer ID to data
$sanitized_data['id'] = $customer_id;
file_put_contents($debug_file, "Sanitized data: " . print_r($sanitized_data, true) . "\n", FILE_APPEND);
// Save using legacy customer class (has its own security)
file_put_contents($debug_file, "Calling customer->save()\n", FILE_APPEND);
$result = $customer->save($sanitized_data, $customer_id);
file_put_contents($debug_file, "Save result: " . ($result ? 'SUCCESS' : 'FAILED') . "\n", FILE_APPEND);
if ($result) {
// Redirect back to editor with success message
file_put_contents($debug_file, "Redirecting to editor\n", FILE_APPEND);
header('Location: ./index.php?admin_modul=admin2000&section=stammdaten&page=kunden_editor&id=' . $customer_id . '&saved=1');
exit();
} else {
file_put_contents($debug_file, "ERROR: Save failed\n", FILE_APPEND);
die('Fehler beim Speichern der Daten');
}
}
/**
* AJAX handler to get list items
*/
private function get_list_items($section, $page) {
if ($section == 'stammdaten' && $page == 'kunden') {
include_once './core/customer.class.php';
try {
$customer = new Customer($this->base_object);
// Get settings from request
$max_list_items = isset($_GET['max_list_items']) ? (int)$_GET['max_list_items'] : 20;
$actual_page = isset($_GET['actual_page']) ? (int)$_GET['actual_page'] : 1;
$sort_item = isset($_GET['sort_item']) ? $_GET['sort_item'] : 'number';
$sort_direction = isset($_GET['sort_direction']) ? $_GET['sort_direction'] : 'up';
$search_string = isset($_GET['search_string']) ? $_GET['search_string'] : '';
$list_filter = isset($_GET['list_filter']) && is_array($_GET['list_filter']) ? $_GET['list_filter'] : array();
$setting = array(
'max_list_items' => $max_list_items,
'actual_page' => $actual_page,
'sort_item' => $sort_item,
'sort_direction' => $sort_direction,
'search_string' => $search_string,
'list_filter' => $list_filter,
'data_format' => 1
);
$list_data = $customer->get_list_items($setting);
$list_data['list_table_config'] = $customer->list_table_config;
$this->layout_object->assign('list_data', $list_data);
return $this->layout_object->fetch('admin2000_list_items.tpl');
} catch (Exception $e) {
// Error handling
$error_html = '<tr><td colspan="100" style="text-align: center; padding: 40px; color: #e74c3c;">';
$error_html .= '<strong>Fehler beim Laden der Daten</strong><br>';
$error_html .= htmlspecialchars($e->getMessage());
$error_html .= '</td></tr>';
return $error_html;
}
}
return json_encode(array('error' => 'Unknown page'));
}
}
+86
View File
@@ -0,0 +1,86 @@
<?php
/**
* @version $Id: admin_customer_group_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/admin_role.class.php';
class admin_admin_role_editor {
private $base_object;
private $config;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
}
function run() {
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// decide what CRUD method to call and call it in ListAndEdit
// create
$admin_role_object = new Admin_role($this->base_object);
$admin_modules = $admin_role_object->get_all_admin_modules();
$modules = array();
foreach ($admin_modules as $modul) {
if (isset($this->base_object->i18n->shopadmin_translation['admin_interface']['menu'][$modul['name']])) {
$modul['name'] = $this->base_object->i18n->shopadmin_translation['admin_interface']['menu'][$modul['name']];
}
$modules[] = $modul;
}
$this->layout_object->assign('admin_modules', $modules);
if($is_submitted && !$has_id) {
$form_data = $admin_role_object->data_filter($_POST['form_field']);
$form_data['acl_show'] = $admin_role_object->acl_2_string($_POST['acl_show']);
$admin_role_object->create($form_data);
$data = $admin_role_object->get_data();
$this->layout_object->assign('form_data', $data);
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$admin_role_object->id = $_GET['id'];
$data = $admin_role_object->get_data();
$this->layout_object->assign('form_data', $data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$admin_role_object->id = $_POST['id'];
$form_data = $admin_role_object->data_filter($_POST['form_field']);
$form_data['acl_show'] = $admin_role_object->acl_2_string($_POST['acl_show']);
$admin_role_object->update($form_data);
$data = $admin_role_object->get_data();
$this->layout_object->assign('form_data', $data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$admin_role_object->id = $_GET['id'];
$admin_role_object->delete();
}
else {
}
return $this->layout_object->fetch('admin_admin_role_editor.tpl');
}
}
?>
+104
View File
@@ -0,0 +1,104 @@
<?php
/**
* @version $Id: admin_country_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/country.class.php';
include_once './core/shipping_area.class.php';
class admin_country_editor {
private $base_object;
private $config;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->customer_group_object = new Customer_group($base_object);
}
function run() {
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// get shipping areas
$shipping_area_object = new Shipping_area($this->base_object);
$shipping_areas = $shipping_area_object->get_all();
$this->layout_object->assign('shipping_areas', $shipping_areas);
$customer_groups = $this->customer_group_object->get_all();
$this->layout_object->assign('customer_groups', $customer_groups);
// decide what CRUD method to call and call it in ListAndEdit
// create
$country_object = new Country($this->base_object);
if($is_submitted && !$has_id) {
$form_data = $country_object->data_filter($_POST['form_field']);
$country_object->create($form_data);
$save_data = array();
foreach($customer_groups as $customer_group) {
if (isset($_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id']) && $_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id']) {
$save_data[$customer_group->id] = $_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id'];
}
}
$country_object->save_customer_group_shipping_areas($country_object->id, $save_data);
// get country data
$country_data = $country_object->get_data();
$this->layout_object->assign('form_data', $country_data);
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$country_object->id = $_GET['id'];
$country_data = $country_object->get_data();
$this->layout_object->assign('form_data', $country_data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$country_object->id = $_POST['id'];
$form_data = $country_object->data_filter($_POST['form_field']);
$country_object->update($form_data);
$save_data = array();
foreach($customer_groups as $customer_group) {
if (isset($_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id']) && $_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id']) {
$save_data[$customer_group->id] = $_POST['form_field']['customer_group_'.$customer_group->id.'_shipping_area_id'];
}
}
$country_object->save_customer_group_shipping_areas($country_object->id, $save_data);
// get country data
$country_data = $country_object->get_data();
$this->layout_object->assign('form_data', $country_data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$country_object->id = $_GET['id'];
$country_object->delete();
}
else {
}
return $this->layout_object->fetch('admin_country_editor.tpl');
}
}
?>
+131
View File
@@ -0,0 +1,131 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2013 TA-EDV
* @license proprietary
* @author Darius Zylka
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
include_once './core/config.class.php';
class admin_create_dummies {
private $layout_object, $base_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
}
public function run() {
if (isset($_POST['createDummyStructure']) && is_numeric($_POST['createDummyStructure'])) {
$this->_createStructureDummies($_POST['createDummyStructure'], $_POST['l1'], $_POST['l2'], $_POST['l3']);
} else if (isset($_POST['killSubStructure']) && is_numeric($_POST['killSubStructure'])) {
$this->_killStructureSubs($_POST['killSubStructure']);
}
return $this->layout_object->fetch('admin_create_dummies.tpl');
}
private function _createStructureDummies($structure_id, $l1, $l2, $l3) {
$this->_killStructureSubs($structure_id);
for ($i = 1; $i <= $l1; ++$i) {
$nid1 = $this->_insertStructure($structure_id, 1);
for ($j = 1; $j <= $l2; ++$j) {
$nid2 = $this->_insertStructure($nid1, 2);
for ($k = 1; $k <= $l3; ++$k) {
$this->_insertStructure($nid2, 3);
}
}
}
}
private function _insertStructure($parent_id, $level) {
$query = "
INSERT INTO
`structure` (
`parent_id`, `name`, `theme_id`, `active`, `short_uri`, `old_id`, `get_parent_discounts`
)
VALUES (
" . $parent_id . ",
'tmpname',
0,
1,
'tmpsuri',
0,
0
)
";
$this->base_object->db->query($query);
$nid = $this->base_object->db->insert_id;
$name = 'Kind ' . $nid . ' von Papa ' . $parent_id . ' (Sub-Level ' . $level . ')';
$suri = 'Kind_' . $nid . '_von_Papa_' . $parent_id;
$query = "
UPDATE
`structure`
SET
`name` = '" . $name . "',
`short_uri` = '" . $suri . "'
WHERE
`id` = " . $nid . "
";
$this->base_object->db->query($query);
return $nid;
}
private function _getStructureSubs($structure_id) {
$sql = "
SELECT
id
FROM
structure
WHERE
parent_id IN (" . $this->base_object->db->real_escape_string($structure_id) . ")
";
$p = $this->base_object->db->query($sql);
$killId = array();
while ($PO = $p->fetch_object()) {
$killId[] = $PO->id;
}
return $killId;
}
private function _killStructureSubs($structure_id) {
$killId = $this->_getStructureSubs($structure_id);
if (count($killId) > 0) {
$ksql = "
DELETE FROM
structure
WHERE
id IN (" . implode(', ', $killId) . ")
";
$this->base_object->db->query($ksql);
$ksql = "
DELETE FROM
site_content
WHERE
structure_id IN (" . implode(', ', $killId) . ")
";
$this->base_object->db->query($ksql);
$this->_killStructureSubs(implode(',', $killId));
}
}
}
+191
View File
@@ -0,0 +1,191 @@
<?php
/**
* @version $Id: admin_cs_ticket_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/cs_ticket.class.php';
include_once './core/customer.class.php';
include_once './core/cs_ticket_message.class.php';
class admin_cs_ticket_editor {
private $base_object;
private $config;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
}
function run() {
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// decide what CRUD method to call and call it in ListAndEdit
// create new ticket
$ticket_object = new Cs_ticket($this->base_object);
// please deleted this!
$ticket_object->fetch_email();
$customer_object = new Customer($this->base_object);
if ($has_id && isset($_GET['action']) && $_GET['action'] == 'set_ticket_state') {
$this->set_ticket_state($_GET['id']);
}
elseif($is_submitted && !$has_id) {
// get customer email
if ($_POST['form_field']['customer_id']) {
$customer_object->customer_id = $_POST['form_field']['customer_id'];
$customer = $customer_object->get_data();
$_POST['form_field']['m_to'] = $customer->email;
}
// create new ticket
$ticket_id = $ticket_object->create($_POST['form_field']);
$data = $ticket_object->get_data();
if ($data->customer_id) {
$customer_object->customer_id = $data->customer_id;
$data->customer = $customer_object->get_data();
}
$message_number = $data->last_message_number;
$data->selected_message_number = $message_number;
$this->layout_object->assign('form_data', $data);
} // new ticket create form
elseif(!$is_submitted && !$has_id) {
$data = new stdClass();
$data->email_from = $this->base_object->config->shopConfiguration['system_email'];
if (isset($_GET['customer_id'])) {
$customer_object->customer_id = $_GET['customer_id'];
$data->customer = $customer_object->get_data();
}
if (!isset($data->customer)) {
$data->customers = $customer_object->get_all();
}
$this->layout_object->assign('form_data', $data);
}// send response
elseif($has_id && $is_submitted) {
$ticket_object->id = $_GET['id'];
$ticket_object->send_response($_POST['form_field']);
$data = $ticket_object->get_data();
if ($data->customer_id) {
$customer_object->customer_id = $data->customer_id;
$data->customer = $customer_object->get_data();
}
$message_number = $data->last_message_number;
$data->selected_message_number = $message_number;
$this->layout_object->assign('form_data', $data);
}// response
elseif($has_id && !$is_submitted && $_GET['mod'] == 'response') {
// template variable name
$ticket_object->id = $_GET['id'];
$data = $ticket_object->get_data();
$data->email_from = $this->base_object->config->shopConfiguration['system_email'];
if (isset($_GET['message_number']) && $_GET['message_number']) {
$message_number = $_GET['message_number'];
}
else {
$message_number = $data->last_message_number;
}
foreach($data->ticket_messages as $message) {
if($message->message_number == $message_number) {
$data->selected_message = $message;
}
}
if ($data->customer_id) {
$customer_object->customer_id = $data->customer_id;
$data->customer = $customer_object->get_data();
}
$data->response = 1;
$this->layout_object->assign('form_data', $data);
} // get file
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'file_load'){
$ticket_message_object = new Cs_ticket_message($this->base_object);
$file = $ticket_message_object->get_file($_GET['file_id']);
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$file->file_name);
header("Content-Transfer-Encoding: binary");
echo $file->content;
exit();
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$ticket_object->id = $_GET['id'];
$data = $ticket_object->get_data();
if ($data->customer_id) {
$customer_object->customer_id = $data->customer_id;
$data->customer = $customer_object->get_data();
}
if (isset($_GET['message_number']) && $_GET['message_number']) {
$message_number = $_GET['message_number'];
}
else {
$message_number = $data->last_message_number;
}
$data->selected_message_number = $message_number;
$this->layout_object->assign('form_data', $data);
}
else {
}
return $this->layout_object->fetch('admin_cs_ticket_editor.tpl');
}
private function set_ticket_state($id) {
if ($id) {
if (isset($_GET['value'])) {
$value = $_GET['value'];
} elseif (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($value) {
$ticket_object = new Cs_ticket($this->base_object);
$result = $ticket_object->set_ticket_state($value, $id);
if ($result) {
// success
$return = array('status' => 'success', 'message' => 'status set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no value');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
}
?>
+92
View File
@@ -0,0 +1,92 @@
<?php
include_once './core/customer.class.php';
class admin_customer {
private $base_object;
private $config;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$this->default_action();
}
if ($action == 'get_customer_by_string') {
$this->get_customer_by_string();
} elseif ($action == 'get_customer_addresses_by_id') {
$this->get_customer_addresses_by_id();
} else {
$this->default_action();
}
}
private function default_action() {
$return['status'] = 'error';
$return['message'] = "ERROR: Unbekannter Methodenaufruf.";
echo json_encode($return);
}
private function get_customer_by_string() {
if (isset($_GET['data'])) {
$search_string = $_GET['data'];
} else {
$search_string = false;
}
if ($search_string) {
$data = $_GET['data'];
$customer = $this->base_object->customer;
$result = $customer->find_customer_like($data);
if ($result) {
$return = array('status' => 'success', data => $result);
} else {
$return = array('status' => 'success', data => array());
}
} else {
$return = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return);
exit();
}
// deprecated, new version in customer_actions
private function get_customer_addresses_by_id() {
$id = $_GET['id'];
if ($id) {
if (Customer::has_id($id)) {
$customer = $this->base_object->customer;
$customer_name = Customer::get_name_by_id($id, false);
$result = $customer->get_address_by_id($id);
$customer_data = $customer->get_by_id($id);
$return['status'] = 'success';
$return['message'] = "Kunden gefunden.";
$return['data'] = $result;
$return['name'] = $customer_name;
} else {
$return['status'] = 'error';
$return['message'] = 'Id nicht vergeben.';
}
} else {
$return['status'] = 'error';
$return['message'] = "Keine Daten �bergeben.";
}
echo json_encode($return);
}
}
+512
View File
@@ -0,0 +1,512 @@
<?php
/**
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*/
include_once './core/customer.class.php';
include_once './core/customerhelper.class.php';
include_once './core/customergroups.class.php';
include_once './core/customeraddress.class.php';
class admin_customer_actions {
private $base_object;
private $config;
private $layout_object;
private $customer_object;
private $customergroups_object;
private $customer_address_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->layout_object = $layout_object;
$this->customer_object = $base_object->customer;
$this->customergroups_object = new CustomerGroups($base_object);
$this->customer_address_object = new CustomerAddress($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if (isset($_GET['address_id'])) {
$address_id = $_GET['address_id'];
} elseif (isset($_POST['address_id'])) {
$address_id = $_POST['address_id'];
} else {
$address_id = false;
}
if (isset($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
} elseif (isset($_POST['customer_id'])) {
$customer_id = $_POST['customer_id'];
} else {
$customer_id = false;
}
if (isset($_POST['address'])) {
$address = $_POST['address'];
} else {
$address = false;
}
if ($action == 'delete_customer') {
$this->delete_customer($id);
} elseif ($action == 'delete_customers') {
$this->delete_customers();
} elseif ($action == 'get_customers') {
$this->get_customers();
} elseif ($action == 'verify_customer_data') {
$this->verify_customer_data();
} elseif ($action == 'get_customer_by_id') {
$this->get_customer_by_id($id);
} elseif ($action == 'get_customer_addresses_by_id') {
$this->get_customer_addresses_by_id($id);
} elseif ($action == 'set_standard_address') {
$this->set_standard_address();
} elseif ($action == 'delete_address') {
$this->delete_address();
} elseif ($action == 'set_info') {
$this->set_info($id);
} elseif ($action == 'edit_customer_address') {
$this->edit_customer_address($address_id);
} elseif ($action == 'new_customer_address') {
$this->new_customer_address($customer_id);
} elseif ($action == 'update_customer_address') {
$this->update_customer_address($address, $address_id);
} elseif ($action == 'create_customer_address') {
$this->create_customer_address($address, $customer_id);
} elseif ($action == 'ping') {
$this->ping();
}
}
private function verify_customer_data() {
if (isset($_POST['customer_field'])) {
$customer_data = $_POST['customer_field'];
} else {
$customer_data = false;
}
if (isset($_POST['customer_address_field'])) {
$customer_address = $_POST['customer_address_field'];
} else {
$customer_address = array();
}
if ($customer_data) {
$return = CustomerHelper::verify_customer_data($customer_data, $customer_address);
} else {
$return = array('status' => 'error', 'message' => 'no data');
}
echo json_encode($return);
exit();
}
private function delete_customer($id) {
if ($id) {
$result = CustomerHelper::delete_customer($id);
if ($result) {
// deleted
$return = array('status' => 'success', 'message' => 'deleted');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not delete');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function delete_customers() {
if (isset($_GET['ids'])) {
$ids = $_GET['ids'];
} elseif (isset($_POST['ids'])) {
$ids = $_POST['ids'];
} else {
$ids = false;
}
if ($ids) {
$result = CustomerHelper::delete_customers($ids);
if ($result) {
// deleted
$return = array('status' => 'success', 'message' => 'deleted');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not delete');
}
} else {
// no ids
$return = array('status' => 'error', 'message' => 'no ids');
}
echo json_encode($return);
exit();
}
private function get_customers() {
$range = $this->get_range();
if ($range) {
$group = $this->get_group();
$groups = $this->customergroups_object->get_all();
$items = $this->get_items();
$page = $this->get_page();
$pages = $this->customer_object->get_number_of_pages($items, $range, $group);
$pagination = $this->customer_object->get_pagination_array($items, $page, $range, $group);
$sort = $this->get_sort();
$sort_direction = $this->get_sort_direction();
$this->layout_object->assign('items', $items);
$this->layout_object->assign('page', $page);
$this->layout_object->assign('pages', $pages);
$this->layout_object->assign('pagination', $pagination);
$this->layout_object->assign('range', $range);
$this->layout_object->assign('selected_group', $group);
$this->layout_object->assign('groups', $groups);
if ($sort) {
$this->layout_object->assign('sort', $sort);
}
if ($sort_direction) {
$this->layout_object->assign('sort_direction', $sort_direction);
}
$data = $this->base_object->customer->get_all_paginated($items, $page, $range, $sort, $sort_direction, $group);
$this->layout_object->assign('customer_list', $data);
echo $this->layout_object->fetch('table_customer_list.tpl');
} else {
// no range
echo "ERROR: no range";
}
exit();
}
private function get_range() {
if (isset($_GET['range'])) {
$range = $_GET['range'];
} elseif (isset($_POST['range'])) {
$range = $_POST['range'];
} else {
$range = false;
}
return $range;
}
private function get_items() {
if(isset($_GET['items']) && is_numeric($_GET['items'])){
$items = (int)$_GET['items'];
$this->base_object->customer->set_config_item('pagination', $items);
} else {
$items = $this->base_object->customer->get_config_item('pagination');
if(is_numeric($items)) {
$items = (int)$items;
} else {
$items = 10;
}
}
return $items;
} // end get_items
private function get_page() {
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$page = (int)$_GET['page'];
} else {
$page = 1;
}
return $page;
} // end get_page
private function get_group() {
if (isset($_GET['group']) && is_numeric($_GET['group'])) {
$group = (int)$_GET['group'];
} else {
$group = false;
}
return $group;
} // end get_group
private function get_sort() {
if (isset($_GET['sort']) && $_GET['sort']) {
$sort = $_GET['sort'];
} elseif (isset($_POST['sort']) && $_POST['sort']) {
$sort = $_POST['sort'];
} else {
$sort = false;
}
return $sort;
} // end get_sort
private function get_sort_direction() {
if (isset($_GET['sort_direction']) && $_GET['sort_direction']) {
$sort_direction = $_GET['sort_direction'];
} elseif (isset($_POST['sort_direction']) && $_POST['sort_direction']) {
$sort_direction = $_POST['sort_direction'];
} else {
$sort_direction = false;
}
return $sort_direction;
}
private function get_customer_by_id($id) {
if ($id) {
$result = $this->customer_object->get_data($id);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no return data');
}
} else {
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function get_customer_addresses_by_id($id) {
if ($id) {
//$result = $this->customer_address_object->get_data_by_customer_id($id);
$result = $this->customer_object->get_address_by_id_hacked($id);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no return data');
}
} else {
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function set_standard_address() {
if (isset($_GET['address_id'])) {
$address_id = $_GET['address_id'];
} else {
$address_id = false;
}
if (isset($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
} else {
$customer_id = false;
}
if ($address_id) {
if ($customer_id) {
$result = Customer::set_standard_address($customer_id, $address_id);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: no result");
}
} else {
$return = array('status' => 'error', 'message' => "ERROR: no user id");
}
} else {
$return = array('status' => 'error', 'message' => "ERROR: no address id");
}
echo json_encode($return);
exit();
}
private function delete_address() {
if (isset($_GET['address_id'])) {
$address_id = $_GET['address_id'];
} else {
$address_id = false;
}
if (isset($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
} else {
$customer_id = false;
}
if ($address_id) {
if ($customer_id) {
$result = Customer::delete_address($customer_id, $address_id);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: no result");
}
} else {
$return = array('status' => 'error', 'message' => "ERROR: no user id");
}
} else {
$return = array('status' => 'error', 'message' => "ERROR: no address id");
}
echo json_encode($return);
exit();
}
private function set_info($id) {
if ($id) {
$result = $this->customer_object->update(array('info' => $_POST['info']));
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no return data');
}
} else {
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function edit_customer_address($address_id) {
if ($address_id) {
$customer_address_data = $this->customer_address_object->get_data_by_address_id($address_id);
$this->layout_object->assign('action', './index.php?admin_modul=admin_customer_actions&action=update_customer_address&address_id=' . $address_id);
$this->layout_object->assign('address', $customer_address_data);
}
// get countries
$country_object = new Country($this->base_object);
$countries = $country_object->get_all();
$this->layout_object->assign('countries', $countries);
echo $this->layout_object->fetch('admin_address_editor.tpl');
exit();
}
private function new_customer_address($customer_id) {
if (isset($customer_id)) {
$customer_data = $this->customer_object->get_data($customer_id);
$address_defaults = new stdClass();
$address_defaults->customer_id = $customer_id;
$address_defaults->company = $customer_data->company;
$address_defaults->firstname = $customer_data->firstname;
$address_defaults->surname = $customer_data->surname;
$address_defaults->orders = 0;
$this->layout_object->assign('action', './index.php?admin_modul=admin_customer_actions&action=create_customer_address&customer_id=' . $customer_id);
$this->layout_object->assign('address', $address_defaults);
}
// get countries
$country_object = new Country($this->base_object);
$countries = $country_object->get_all();
$this->layout_object->assign('countries', $countries);
echo $this->layout_object->fetch('admin_address_editor.tpl');
exit();
}
private function update_customer_address($data, $address_id) {
if ($data) {
if ($address_id) {
$result = $this->customer_address_object->update($data, $address_id);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$error = $this->customer_address_object->get_error();
if ($error == 'invalid data') {
$return_data = array('status' => 'error', 'message' => $error, 'data' => $this->customer_address_object->get_validation_errors());
} else {
$return_data = array('status' => 'error', 'message' => $error);
}
}
} else {
$return_data = array('status' => 'error', 'message' => 'no address id');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no data');
}
echo json_encode($return_data);
exit();
}
private function create_customer_address($data, $customer_id) {
if ($data) {
if ($customer_id) {
$result = $this->customer_address_object->create($data, $customer_id);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$error = $this->customer_address_object->get_error();
if ($error == 'invalid data') {
$return_data = array('status' => 'error', 'message' => $error, 'data' => $this->customer_address_object->get_validation_errors());
} else {
$return_data = array('status' => 'error', 'message' => $error);
}
}
} else {
$return_data = array('status' => 'error', 'message' => 'no customer id');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no data');
}
echo json_encode($return_data);
exit();
}
private function ping() {
$data = $_GET;
unset($data['admin_modul']);
unset($data['action']);
echo "YOU ARE IN PING<br /><br />";
foreach ($data as $key => $value) {
echo $key . ' : ' . $value . '<br />';
}
exit();
}
}
+202
View File
@@ -0,0 +1,202 @@
<?php
/**
* @version $Id: admin_customer_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/country.class.php';
include_once './core/customer_group.class.php';
include_once './core/customer.class.php';
include_once './core/customeraddress.class.php';
include_once './core/order.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/cs_ticket_message.class.php';
include_once './core/orderstatus.class.php';
include_once './core/admin_role.class.php';
include_once './modules/list_and_edit.class.php';
class admin_customer_editor {
private $base_object;
private $config;
private $layout_object;
private $customer_address_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->customer_address_object = new CustomerAddress($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = false;
}
// get countries
$country_object = new Country($this->base_object);
$countries = $country_object->get_all();
$this->layout_object->assign('countries', $countries);
// get customer groups
$customer_group_object = new Customer_group($this->base_object);
$customer_groups = $customer_group_object->get_all_groups();
$this->layout_object->assign('customer_groups', $customer_groups);
// get all admin roles
$admin_role_object = new Admin_role($this->base_object);
$admin_roles = $admin_role_object->get_all();
$this->layout_object->assign('admin_roles', $admin_roles);
if ($action == 'save') {
return $this->save();
} else {
return $this->default_action($id);
}
} // end run
private function default_action($id) {
if ($id) {
$customer_object = new Customer($this->base_object);
$ticket_object = new Cs_ticket($this->base_object);
$ticket_message_object = new Cs_ticket_message($this->base_object);
$data = $customer_object->get_data($id);
if ($data) {
// get customer groups
$customer_group_object = new Customer_group($this->base_object);
$this->layout_object->assign('customer_group_data', $customer_group_object->get_data($data->group_id));
$orders = OrderHelper::get_all_customer_orders($id);
/*$all_tickets = $ticket_object->get_all_customer_tickets($id);
$tickets = array();
foreach($all_tickets as $ticket) {
// get first message
$ticket->first_message = $ticket_message_object->get_first_message($ticket->id);
$tickets[] = $ticket;
}*/
$customer_address_object = new CustomerAddress($this->base_object);
$customer_address_data = $customer_address_object->get_data_by_customer_id($id);
$this->layout_object->assign('customer_addresses', $customer_address_data);
$this->layout_object->assign('orders', $orders);
$this->layout_object->assign('tickets', $tickets);
$this->layout_object->assign('customer_data', $data);
} else {
$this->layout_object->assign('error_message', "Dieser Kunde existiert nicht.");
}
}
return $this->layout_object->fetch('admin_customer_editor.tpl');
} // end default_action
private function save() {
if (isset($_POST['customer_field'])) {
$data = $_POST['customer_field'];
if ($data['pass1'] != '') {
if ($data['pass1'] == $data['pass2']) {
$data['pass'] = $data['pass1'];
}
}
unset($data['pass1']);
unset($data['pass2']);
} else {
$data = false;
}
if (isset($_POST['customer_address_field'])) {
$address = $_POST['customer_address_field'];
} else {
$address = false;
}
if ($data) {
$unlocked_message = 0;
if ($address) {
$customer_object = new Customer($this->base_object);
$result = $customer_object->create($data);
// customer unlocked email message
if ($data['locked'] == -1) {
$data['locked'] == 0;
$unlocked_message = 1;
}
if ($result) {
$address['customer_id'] = $result;
if ($unlocked_message) {
// send message to customer
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(12, $result, false);
}
$res = $this->customer_address_object->create($address);
// customer new password with email message
if ($_POST['customer_password_action'] == 1) {
$customer_object->new_password($result);
}
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_customer_editor&id=' . $result);
} else {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_customer_editor');
}
} else {
$customer_object = new Customer($this->base_object);
$customer_object->set_id($data['id']);
unset($data['id']);
// customer unlocked email message
if ($data['locked'] == -1) {
$data['locked'] == 0;
$unlocked_message = 1;
}
$result = $customer_object->update($data);
if ($unlocked_message) {
// send message to customer
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(12, $result, false);
}
// customer new password with email message
if ($_POST['customer_password_action'] == 1) {
$customer_object->new_password($result);
}
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_customer_editor&id=' . $result);
}
} else {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_customer_editor');
}
} // end save
} // end admin_customer_editor
+78
View File
@@ -0,0 +1,78 @@
<?php
class admin_customer_editor_actions {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
if ($action == 'set_standard') {
$this->set_standard();
} elseif ($action == "delete") {
$this->delete();
} else {
echo "ERROR: no action.";
exit();
}
}
private function set_standard() {
if (isset($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
} else {
echo json_encode(array('status' => 'error', 'message' => "ERROR: no user id"));
exit();
}
if (isset($_GET['address_id'])) {
$address_id = $_GET['address_id'];
} else {
echo json_encode(array('status' => 'error', 'message' => "ERROR: no address id"));
exit();
}
$result = Customer::set_standard_address($customer_id, $address_id);
echo json_encode(array('status' => 'success', 'data' => $result));
exit();
}
private function delete() {
if (isset($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
} else {
echo json_encode(array('status' => 'error', 'message' => "ERROR: no user id"));
exit();
}
if (isset($_GET['address_id'])) {
$address_id = $_GET['address_id'];
} else {
echo json_encode(array('status' => 'error', 'message' => "ERROR: no address id"));
exit();
}
$result = Customer::delete_address($customer_id, $address_id);
echo json_encode(array('status' => 'success', 'data' => $result));
exit();
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
/**
* @version $Id: admin_statistic.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2010 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/orderhelper.class.php';
include_once './core/order.class.php';
include_once './core/item.class.php';
include_once './core/customer.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/cs_ticket_message.class.php';
include_once './modules/widgets/backordered_items.php';
include_once './modules/widgets/new_customers.php';
include_once './modules/widgets/new_orders.php';
include_once './modules/widgets/warehouse_inventory.php';
include_once './modules/widgets/paypal_money_back.php';
include_once './modules/widgets/new_messages.php';
include_once './modules/widgets/inventory_manager.php';
// TODO: need a new function in customer class
// is_set_config_item return true if key is set and false if not
// and get_config_item returns value if value for key is set and false if value is null
class admin_dashboard {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
if ($action == 'set_data') {
$this->set_data();
} else {
return $this->return_layout();
}
}
function set_data() {
if(isset($_POST['widget_container'])) {
$widget_container = $_POST['widget_container'];
$widget_list = $_POST['widget_list'];
$this->base_object->customer->set_config_item($widget_container, $widget_list);
} else {
echo "ERROR";
}
}
private function get_url() {
if( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ) {
$protocol = "https://";
} else {
$protocol = "http://";
}
return $protocol . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
}
function return_layout() {
//$big_widgets_list = array('backordered_items', '', 'new_messages');
//$big_widgets_list = array('inventory_manager', 'backordered_items');
$big_widgets_list = array('backordered_items');
foreach ($big_widgets_list as $widget) {
$widget_object = new $widget();
$big_widget[] = $widget_object->run();
}
$this->layout_object->assign('big_widgets', $big_widget);
$little_widgets_list = array('new_orders', 'new_customers', 'warehouse_inventory');
foreach ($little_widgets_list as $widget) {
$widget_object = new $widget();
$little_widgets[] = $widget_object->run();
}
$this->layout_object->assign('little_widgets', $little_widgets);
return $this->layout_object->fetch('admin_dashboard.tpl');
}
}
?>
+138
View File
@@ -0,0 +1,138 @@
<?php
/**
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/deliverer.class.php';
include_once './core/countryhelper.class.php';
class admin_deliverer_actions {
private $base_object;
private $layout_object;
private $deliverer_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
$this->deliverer_object = new Deliverer($base_object);
}
function run() {
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif(isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if ($action == "setup_shipping_method_charges") {
$this->setup_shipping_method_charges();
} elseif ($action == 'setup_shipping_methods') {
$this->setup_shipping_methods();
} elseif ($action == 'delete') {
$this->delete($id);
} elseif ($action == "ping") {
$this->ping();
}
}
public function setup_shipping_methods() {
if (isset($_GET['country_id'])) {
$country_id = $_GET['country_id'];
} else {
$country_id = false;
}
if ($country_id) {
$result = DelivererHelper::get_deliverers_by_country($country_id);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$message = DelivererHelper::get_deliverers_by_country_error();
if ($message == '') {
$message = 'no result';
}
$return = array('status' => 'error', 'message' => $message);
}
} else {
$return = array('status' => 'error', 'message' => 'missing arguments');
}
echo json_encode($return);
exit();
}
public function setup_shipping_method_charges() {
if (isset($_GET['deliverer_id'])) {
$deliverer_id = $_GET['deliverer_id'];
} else {
$deliverer_id = false;
}
if (isset($_GET['country_id'])) {
$country_id = $_GET['country_id'];
} else {
$country_id = false;
}
if ($deliverer_id && $country_id) {
$shipping_area_id = CountryHelper::get_shipping_area_by_country_id($country_id);
$deliverer_object = new Deliverer(Registry::get('base'));
$result = $deliverer_object->getAllActive($shipping_area_id);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'missing arguments');
}
echo json_encode($return);
exit();
}
public function delete($id) {
if ($id) {
$result = $this->deliverer_object->delete($id);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$return_data = array('status' => 'error', 'message' => "Kann nicht gel&ouml;schen werden");
}
} else {
$return_data = array('status' => 'error', 'message' => "Keine ID.");
}
echo json_encode($return_data);
exit();
}
private function ping() {
echo "<pre>";
print_r($_GET);
exit();
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>, John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/deliverer.class.php';
class admin_deliverer_editor {
private $base_object;
private $config;
private $layout_object;
private $deliverer_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->deliverer_object = new Deliverer($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if(isset($_GET['id']) && $_GET['id']) {
$id = $_GET['id'];
} else if(isset($_POST['id']) && $_POST['id']) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == 'save') {
$this->save($id);
} else {
return $this->edit($id);
}
}
private function edit($id) {
if ($id) {
// load data for edit
$deliverer_data = $this->deliverer_object->get_data($id);
$this->layout_object->assign('form_data', $deliverer_data);
}
// create
return $this->layout_object->fetch('admin_deliverer_editor.tpl');
} // end edit
private function save($id) {
if ($id) {
// update
$this->deliverer_object->set_id($id);
$form_data = $this->deliverer_object->data_filter($_POST['form_field']);
$data = $this->deliverer_object->update($form_data);
if ($data) {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_deliverer_editor&id=' . $data);
} else {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_deliverer_editor');
}
} else {
// create
$form_data = $this->deliverer_object->data_filter($_POST['form_field']);
$data = $this->deliverer_object->create($form_data);
if ($data) {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_deliverer_editor&id=' . $data);
} else {
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_deliverer_editor');
}
}
exit();
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
/**
* @version $Id: admin_gift_certificate_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rkd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/gift_certificate.class.php';
include_once './core/customer_group.class.php';
include_once './core/structure.class.php';
class admin_gift_certificate_editor {
private $base_object;
private $layout_object;
private $gift_certificate;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->gift_certificate = new Gift_certificate($base_object);
} // end __construct
function run() {
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// get customer groups
$customer_group_object = new Customer_group($this->base_object);
$customer_groups = $customer_group_object->get_all_groups();
$this->layout_object->assign('customer_groups', $customer_groups);
// get all structure tree
$structure_object = new Structure($this->base_object);
$structure_tree = $structure_object->get_all_tree_full_path();
$this->layout_object->assign('structure_tree', $structure_tree);
// create
if($is_submitted && !$has_id) {
$form_data = $this->gift_certificate->data_filter($_POST['form_field']);
$this->gift_certificate->create($form_data);
$data = $this->gift_certificate->get_data();
$this->layout_object->assign('form_data', $data);
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$this->gift_certificate->id = $_GET['id'];
$data = $this->gift_certificate->get_data();
$this->layout_object->assign('form_data', $data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$this->gift_certificate->id = $_POST['id'];
$data = $this->gift_certificate->data_filter($_POST['form_field']);
$this->gift_certificate->update($data);
$data = $this->gift_certificate->get_data();
$this->layout_object->assign('form_data', $data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$this->gift_certificate->id = $_GET['id'];
}
else {
}
return $this->layout_object->fetch('admin_gift_certificate_editor.tpl');
}
} // end admin_manufacturer_editor
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
class admin_help_faq {
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
return $this->layout_object->fetch('admin_help_faq.tpl');
}
}
+220
View File
@@ -0,0 +1,220 @@
<?php
/**
* @version $Id: admin_plugin_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class admin_import_editor {
private $base_object;
private $config;
private $layout_object;
private $import_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
include './core/import.class.php';
$this->import_object = new Import($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == 'save') {
$this->save();
} else if ($action == 'upload_file') {
$this->upload($id);
$this->import_object->id = $id;
$data = $this->import_object->get_data();
$this->layout_object->assign('form_data', $data);
$this->layout_object->assign('error', $this->import_object->error);
return $this->layout_object->fetch('admin_import_editor.tpl');
} else if ($action == 'delete') {
$this->delete($id);
} else if ($action == 'delete_logo') {
$this->delete_logo($id);
}
else {
// get object data
if ($id) {
$this->import_object->id = $id;
$data = $this->import_object->get_data();
$this->layout_object->assign('form_data', $data);
}
$error = isset($this->import_object->error) ? $this->import_object->error : '';
$this->layout_object->assign('error', $error);
return $this->layout_object->fetch('admin_import_editor.tpl');
}
}
private function upload($id) {
$log_object = Logger::get_instance();
if (!$log_object) {
// Fallback, wenn Logger nicht verfügbar ist
$log_object = new class {
public function info($type, $message) { error_log("[$type] $message"); }
public function error($type, $message) { error_log("ERROR[$type] $message"); }
};
}
$log_object->info('fileupload','Starte Upload-Prozess');
header('Content-Type: application/json');
try {
if (!$id) {
throw new Exception('Keine ID angegeben');
}
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file == '') {
throw new Exception('Keine Datei hochgeladen');
}
// Validiere Datei
$file_info = pathinfo($_FILES['Filedata']['name']);
if (strtolower($file_info['extension']) !== 'csv') {
throw new Exception('Nur CSV-Dateien sind erlaubt');
}
if ($_FILES['Filedata']['size'] > 5 * 1024 * 1024) {
throw new Exception('Datei ist zu groß (max. 5MB)');
}
// Speichere die Datei
$result = $this->import_object->save_file($id, $temp_file);
if (!$result) {
throw new Exception('Fehler beim Speichern der Datei');
}
// Hole Import-Konfiguration aus der DB
$sql = "SELECT import_filter, post_process_case FROM import WHERE id = ?";
$stmt = $this->base_object->db->prepare($sql);
$stmt->bind_param('i', $id);
$stmt->execute();
// Initialisiere Variablen
$import_filter = '';
$post_process_case = '';
$stmt->bind_result($import_filter, $post_process_case);
$stmt->fetch();
$stmt->close();
// Sicherheitsprüfung
$allowed_scripts = ['preisupdate.py', 'sdbimport.py'];
if (!in_array($import_filter, $allowed_scripts)) {
throw new Exception("Unbekanntes Importscript!");
}
$python_script = dirname(__FILE__) . '/import/' . $import_filter;
$uploaded_file = './tmp/import/'.basename($_FILES['Filedata']['name']);
$command = "python3 {$python_script} {$uploaded_file} 2>&1";
$output = [];
$return_var = 0;
exec($command, $output, $return_var);
$log_object->info('python_output', implode("\n", $output));
if ($return_var !== 0) {
throw new Exception('Fehler beim Ausführen des Python-Scripts: ' . implode("\n", $output));
}
// Post-Processing
$updated_count = 0;
switch ($post_process_case) {
case 'update_prices':
foreach ($output as $line) {
if (strpos($line, "eindeutige Artikel verarbeitet") !== false) {
if (preg_match('/Insgesamt (\d+) eindeutige/', $line, $matches)) {
$updated_count = intval($matches[1]);
break;
}
}
}
break;
case 'update_sdb_count':
$updated_count = count($output); // oder smarter
break;
default:
$log_object->info('postprocess', "Kein Post-Processing definiert für Fall: $post_process_case");
}
// Aktualisiere Import-Datum und Anzahl
$sql = "UPDATE import SET last_import_date = NOW(), count_imported_items = ? WHERE id = ?";
$stmt = $this->base_object->db->prepare($sql);
$stmt->bind_param('ii', $updated_count, $id);
$stmt->execute();
// Datei löschen
if (file_exists($uploaded_file)) {
unlink($uploaded_file);
}
// Erfolgreiche Antwort
$this->layout_object->assign('info_message', 'CSV-Datei erfolgreich importiert!');
die(json_encode([
'status' => 'success',
'message' => "Import erfolgreich. {$updated_count} Datensätze verarbeitet."
]));
} catch (Exception $e) {
$log_object->error('upload_error', $e->getMessage());
$this->layout_object->assign('error_message', $e->getMessage());
$uploaded_file = './tmp/import/'.basename($_FILES['Filedata']['name']);
if (file_exists($uploaded_file)) {
unlink($uploaded_file);
}
die(json_encode([
'status' => 'error',
'message' => $e->getMessage()
]));
}
}
private function save() {
// Implementierung der save-Methode
// Hier können Sie die Logik zum Speichern der Import-Daten hinzufügen
$this->layout_object->assign('info_message', 'Import-Daten gespeichert.');
return $this->layout_object->fetch('admin_import_editor.tpl');
}
private function delete($id) {
// Implementierung der delete-Methode
$this->import_object->set_object_property('id', $id);
$this->import_object->delete();
$this->layout_object->assign('info_message', 'Import gelöscht.');
return $this->layout_object->fetch('admin_import_editor.tpl');
}
private function delete_logo($id) {
// Implementierung der delete_logo-Methode
$this->import_object->set_object_property('id', $id);
// Hier können Sie die Logik zum Löschen des Logos hinzufügen
$this->layout_object->assign('info_message', 'Logo gelöscht.');
return $this->layout_object->fetch('admin_import_editor.tpl');
}
}
+256
View File
@@ -0,0 +1,256 @@
<?php
/**
* @version $Id: admin_incomming_goods_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rkd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/incomming_goods.class.php';
include_once './core/vendor.class.php';
class admin_incomming_goods_editor {
private $base_object;
private $layout_object;
private $incomming_goods_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->incomming_goods_object = new Incomming_goods($base_object);
} // end __construct
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == "get_tab") {
$this->get_tab($id);
} elseif ($action == "view_stat") {
$this->view_stat($id);
} elseif ($action == "update") {
if (!$id) {
$id = $this->incomming_goods_object->create_new();
}
$this->update($id);
} elseif ($action == "add_item") {
$this->add_item($id);
} elseif ($action == "upload_bill") {
$this->upload_bill($id);
} elseif ($action == "delete_bill_file") {
$this->delete_bill_file($id);
} elseif ($action == "delete_item") {
$this->delete_item($id);
} else {
return $this->setup_list($id);
}
} // end run
private function setup_list($id) {
$today = '';
if ($id) {
$data = $this->incomming_goods_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Dieser Wareneingang existiert nicht.");
}
}
else {
// get today date
$today = date("d.m.Y", time());
}
$this->layout_object->assign('today', $today);
return $this->layout_object->fetch('admin_incomming_goods_editor.tpl');
} // end default_action
private function view_stat($id) {
if ($id) {
$data = $this->incomming_goods_object->get_by_id($id);
$data->item_list = array_reverse($data->item_list);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}
}
elseif(!$id && $_POST['date']) {
$date = substr($_POST['date'],6,4).'-'.substr($_POST['date'],3,2).'-'.substr($_POST['date'],0,2);
$id = $this->incomming_goods_object->get_id_by_date($date);
if(!$id) {
$id = $this->incomming_goods_object->create_new($date);
}
// get data
$data = $this->incomming_goods_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}
}
//$data = $this->incomming_goods_object->get_by_id($id);
// get vendors
$vendor_object = new Vendor($this->base_object);
$data->vendors = $vendor_object->get_all();
if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}
echo $this->layout_object->fetch('admin_incomming_goods_view.tpl');
exit();
}
// only used in ajax, so i terminate with exit
private function update($id) {
$data = array();
$item_amount = $_POST['item_amount'];
$item_price_sum = str_replace(',','.',$_POST['item_price_sum']);
$item_id = $_POST['item_id'];
$data['items'] = array();
for ($i=0;$i < count($item_id);$i++) {
$data['items'][] = array(
'item_id' => $item_id[$i],
'amount' => $item_amount[$i],
'price_sum' => $item_price_sum[$i]
);
}
if (isset($_POST['number'])) {
$data['number'] = $_POST['number'];
$data['vendor_id'] = $_POST['vendor_id'];
$data['date'] = substr($_POST['date'],6,4).'-'.substr($_POST['date'],3,2).'-'.substr($_POST['date'],0,2);
$data['skonto'] = $_POST['skonto'];
$data['eg_nr'] = $_POST['eg_nr'];
$data['cost_sum'] = str_replace(',','.',$_POST['cost_sum']);
$data['import'] = $_POST['import'];
$data['currency'] = $_POST['currency'];
$data['conversion_price'] = str_replace(',','.',$_POST['conversion_price']);
if ($data['id'] == '') {
unset($data['id']);
}
$this->incomming_goods_object->set_id($id);
$result = $this->incomming_goods_object->update($data);
if ($result) {
$return = array('status' => 'success', 'id' => $id);
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
} else {
$return = array('status' => 'error', 'message' => 'no forms data');
}
echo json_encode($return);
exit();
} // end save
private function delete_bill_file($id) {
if ($id) {
if ($this->incomming_goods_object->delete_bill_file($id)) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function upload_bill($id) {
if ($id) {
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file != '') {
$result = $this->incomming_goods_object->save_bill($id, $temp_file);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: can't save", 'data', $result);
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no file');
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no id');
}
echo json_encode($return);
exit();
} // end upload
// only used in ajax, so i terminate with exit
private function add_item($id) {
$data = array();
$this->incomming_goods_object->set_id($id);
$data['item_id'] = $_POST['item_id'];
$data['amount'] = $_POST['amount'];
$data['price_sum'] = str_replace(',','.',$_POST['price_sum']);
$data['inventory_object_id'] = $id;
$result = $this->incomming_goods_object->add_item($data);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
echo json_encode($return);
exit();
} // end save
// only used in ajax, so i terminate with exit
private function delete_item($id) {
$this->incomming_goods_object->set_id($id);
$result = $this->incomming_goods_object->delete_item($_POST['item_id']);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
echo json_encode($return);
exit();
} // end save
} // end
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
class admin_info {
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
return $this->layout_object->fetch('admin_info.tpl');
}
}
+151
View File
@@ -0,0 +1,151 @@
<?php
/**
* @version $Id: admin_init.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Easyshop
* @copyright Copyright (C) 2005 - 2010 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
// PRODUCTION MODE - Keine Warnings im Admin!
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(0);
// including libs
include_once './libs/smarty/libs/Smarty.class.php';
include_once './modules/admin_layout.class.php';
include_once './core/manufacturer.class.php';
$layout_object = new admin_layout();
$layout_object->start($base_object);
Registry::set('layout_object', $layout_object);
// configuration settings
$layout_object->assign('system_configuration', $base_object->config->shopConfiguration);
// start session
@session_start();
// login
if (isset($_POST['shopLogin'])) {
$logindata = $_POST['shopLogin'];
$request = $base_object->customer->login($logindata['user'],$logindata['pass']);
}
// logout
if (isset($_GET['logout'])) {
$base_object->customer->logout();
}
if ($base_object->customer->auth() == 2 || !empty($_FILES)) {
// get default domain config user language
include_once './core/language.class.php';
$language_object = new Language($base_object);
$languages = $language_object->get_all_objects();
$layout_object->assign('content_languages', $languages);
// translation text
$base_object->i18n->get_shopadmin_text($base_object->customer->get_config_item('admin_language'));
$layout_object->assign('translation_text', $base_object->i18n->shopadmin_translation);
// gat admin permissions
$admin_role_data = array();
if ($base_object->customer->admin_role_id) {
$base_object->admin_role->id = $base_object->customer->admin_role_id;
$admin_role_data = $base_object->admin_role->get_data();
}
// get admin menu data
$menudata = $layout_object->get_admin_menu($admin_role_data);
$layout_object->assign('menudata', $menudata);
// if logged in
$maincontent = '';
if (empty($_GET['admin_modul'])) {
$admin_module = 'admin_dashboard';
} else {
$admin_module = $_GET['admin_modul'];
}
// date
$actual_date = array(
'weekday' => date('l'),
'date' => date("Y-m-d")
);
$actual_date['date'] = $base_object->i18n->convert_date($actual_date['date']);
$layout_object->assign('actual_date',$actual_date);
// header stats
include_once './core/stats.class.php';
$header_stats = Stats::get_stats();
$layout_object->assign('header_stats',$header_stats);
// customer data
$layout_object->assign('admin_user', $base_object->customer);
// load modules
if (isset($admin_module) && $admin_module) {
$module_file = 'modules/'.$admin_module.'.php';
if(file_exists($module_file)) {
include_once $module_file;
$modul_object = new $admin_module($base_object, $layout_object);
$maincontent = $modul_object->run();
} else {
$maincontent = $layout_object->fetch('404.tpl');
}
}
$layout_object->assign('maincontent', $maincontent);
$layout_object->assign('URL', MAIN_URL);
if (isset($_GET['m_active'])) {
$_SESSION['easyshop']['m_active'] = $_GET['m_active'];
}
elseif (isset($_SESSION['easyshop']['m_active'])) {
$_GET['m_active'] = $_SESSION['easyshop']['m_active'];
}
else {
$_GET['m_active'] = 0;
}
$layout_object->assign('menu_active', $_GET['m_active']);
$mod = false;
if(isset($_GET['mod'])) {
$mod = $_GET['mod'];
} elseif(isset($_POST['mod'])) {
$mod = $_POST['mod'];
}
if($mod && ($mod == 'ajax')) {
$site = $layout_object->fetch('ajax.tpl');
} elseif($mod && ($mod == 'set_data')) {
$site = $layout_object->fetch('ajax.tpl');
} elseif($mod && ($mod == 'json')) {
// no layout for this
} elseif($admin_module == 'admin2000') {
// Admin2000 runs standalone with its own HTML structure
// No legacy main.tpl wrapper needed
$site = $maincontent;
} else {
$site = $layout_object->fetch('main.tpl');
}
echo $site;
} else {
// if not logged in
// show admin login
echo $layout_object->fetch('admin_login.tpl');
//header("Location: " . MAIN_URL);
}
?>
+204
View File
@@ -0,0 +1,204 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
include_once './core/config.class.php';
class admin_invoice_configuration {
private $invoice;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->invoice = new Invoice();
$this->layout_object = $layout_object;
}
public function run() {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = '';
}
if($action == 'submit') {
$this->save_config_data();
} elseif ($action == 'header_upload') {
$this->header_upload();
} elseif ($action == 'footer_upload') {
$this->footer_upload();
} elseif ($action == 'delete_footer') {
$this->delete_footer();
} elseif ($action == 'delete_header') {
$this->delete_header();
} else {
$this->get_config_data();
return $this->layout_object->fetch('admin_invoice_configuration.tpl');
}
}
private function save_config_data() {
unset($_POST['submit']);
$data = $_POST;
$this->invoice->save($data);
}
private function get_config_data() {
$config_item = $this->invoice->load();
if ($config_item) {
foreach ($config_item as $key => $value) {
$this->layout_object->assign($key, $value);
}
}
}
private function header_upload() {
if ($_FILES['Filedata']['tmp_name'] != '') {
$path = './web/' . SHOP_SYSTEM . '/documents/';
move_uploaded_file($_FILES['Filedata']['tmp_name'], $path . $_FILES['Filedata']['name']);
}
Config::set_key('bill_header_image', $_FILES['Filedata']['name']);
echo 'Header hochgeladen';
}
private function footer_upload() {
if ($_FILES['Filedata']['tmp_name'] != '') {
$path = './web/' . SHOP_SYSTEM . '/documents/';
move_uploaded_file($_FILES['Filedata']['tmp_name'], $path . $_FILES['Filedata']['name']);
}
Config::set_key('bill_footer_image', $_FILES['Filedata']['name']);
echo 'Footer Grafik hochgeladen';
}
private function delete_header() {
Config::set_key('bill_header_image', '');
//Config::set_key('bill_header_height', '');
// TODO: delete image on server
}
private function delete_footer() {
Config::set_key('bill_footer_image', '');
// TODO: delete image on server
}
}
class Invoice {
protected $_db;
public function __construct() {
$this->_db = Registry::get('base')->db;
}
public function load() {
if (Config::has_key('bill_header_text_window')) {
$data['bill_header_text_window'] = Config::get_value('bill_header_text_window');
}
if (Config::has_key('bill_header_text_address')) {
$data['bill_header_text_address'] = Config::get_value('bill_header_text_address');
}
if (Config::has_key('bill_header_alignment_address')) {
$data['bill_header_alignment_address'] = Config::get_value('bill_header_alignment_address');
}
if (Config::has_key('bill_header_image') && Config::is_set('bill_header_image')) {
$data['bill_header_image'] = './web/' . SHOP_SYSTEM . '/documents/' . Config::get_value('bill_header_image');
}
if (Config::has_key('bill_footer_text_margin_bottom')) {
$data['bill_footer_text_margin_bottom'] = Config::get_value('bill_footer_text_margin_bottom');
}
else {
$data['bill_footer_text_margin_bottom'] = -25;
}
if (Config::has_key('bill_footer_alignment_left')) {
$data['bill_footer_alignment_left'] = Config::get_value('bill_footer_alignment_left');
}
if (Config::has_key('bill_footer_text_left')) {
$data['bill_footer_text_left'] = Config::get_value('bill_footer_text_left');
}
if (Config::has_key('bill_footer_alignment_center')) {
$data['bill_footer_alignment_center'] = Config::get_value('bill_footer_alignment_center');
}
if (Config::has_key('bill_footer_text_center')) {
$data['bill_footer_text_center'] = Config::get_value('bill_footer_text_center');
}
if (Config::has_key('bill_footer_alignment_right')) {
$data['bill_footer_alignment_right'] = Config::get_value('bill_footer_alignment_right');
}
if (Config::has_key('bill_footer_text_right')) {
$data['bill_footer_text_right'] = Config::get_value('bill_footer_text_right');
}
if (Config::has_key('bill_footer_image') && Config::is_set('bill_footer_image')) {
$data['bill_footer_image'] = './web/' . SHOP_SYSTEM . '/documents/' . Config::get_value('bill_footer_image');
}
if (isset($data)) {
return $data;
}
return false;
}
public function save($data) {
if (isset($data['bill_header_text_window'])) {
$insert_data['bill_header_text_window'] = $data['bill_header_text_window'];
}
if (isset($data['bill_header_text_address'])) {
$insert_data['bill_header_text_address'] = $data['bill_header_text_address'];
}
if (isset($data['bill_header_alignment_address'])) {
$insert_data['bill_header_alignment_address'] = $data['bill_header_alignment_address'];
}
if (isset($data['bill_header_image']) && $data['bill_header_image'] != '') {
$insert_data['bill_header_image'] = $data['bill_header_image'];
}
if (isset($data['bill_footer_text_margin_bottom']) && $data['bill_footer_text_margin_bottom'] != '') {
$insert_data['bill_footer_text_margin_bottom'] = $data['bill_footer_text_margin_bottom'];
}
if (isset($data['bill_footer_image']) && $data['bill_footer_image'] != '') {
$insert_data['bill_footer_image'] = $data['bill_footer_image'];
}
if (isset($data['bill_footer_alignment_left'])) {
$insert_data['bill_footer_alignment_left'] = $data['bill_footer_alignment_left'];
}
if (isset($data['bill_footer_text_left'])) {
$insert_data['bill_footer_text_left'] = $data['bill_footer_text_left'];
}
if (isset($data['bill_footer_alignment_center'])) {
$insert_data['bill_footer_alignment_center'] = $data['bill_footer_alignment_center'];
}
if (isset($data['bill_footer_text_center'])) {
$insert_data['bill_footer_text_center'] = $data['bill_footer_text_center'];
}
if (isset($data['bill_footer_alignment_right'])) {
$insert_data['bill_footer_alignment_right'] = $data['bill_footer_alignment_right'];
}
if (isset($data['bill_footer_text_right'])) {
$insert_data['bill_footer_text_right'] = $data['bill_footer_text_right'];
}
foreach($insert_data as $key => $value) {
Config::set_key($key, $value);
}
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
include_once './core/item.class.php';
class admin_item {
private $base_object;
private $db;
private $config;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->db = $base_object->db;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$this->default_action();
}
if ($action == 'get_by_string') {
$this->get_by_string();
} else if ($action == 'get_by_id') {
$this->get_by_id();
} else {
$this->default_action();
}
}
private function default_action() {
$return['status'] = 'error';
$return['message'] = "ERROR: Unbekannter Methodenaufruf.";
echo json_encode($return);
}
private function get_by_string() {
if (isset($_GET['data'])) {
$search = $_GET['data'];
} else {
$search = false;
}
if ($search) {
$safe = $this->db->real_escape_string($search);
$sql = "SELECT
i.*,
m.name AS manufacturer
FROM
items i
LEFT JOIN
manufacturers m
ON
m.id = i.manufacturer_id
WHERE
i.number LIKE '%".$safe."%'
OR
i.name LIKE '%".$safe."%'
OR
i.ean_code LIKE '%".$safe."%'
OR
i.vendor_item_number LIKE '%".$safe."%'
OR
i.short_description LIKE '%".$safe."%'
OR
m.name LIKE '%".$safe."%'";
$result = $this->db->query($sql);
$hits = $result->num_rows;
$data = array();
if ($hits) {
$i = 0;
while ($obj = $result->fetch_object()) {
$data[] = $obj;
if ($i++ == 5) {
break;
}
}
}
$return_data = array('status' => 'success', 'data' => $data, 'hits' => $hits);
} else {
$return_data = array('status' => 'no_argument_data', 'message' => 'Keine Daten &Uuml;bergeben.');
}
echo json_encode($return_data);
}
}
+211
View File
@@ -0,0 +1,211 @@
<?php
/**
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/itemhelper.class.php';
include_once './core/item.class.php';
class admin_item_actions {
private $base_object;
private $layout_object;
private $db;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
$this->db = $base_object->db;
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if ($action == "get_variant_price") {
$this->get_variant_price();
} elseif ($action == "ping") {
$this->ping();
} elseif ($action == "get_google_categories") {
$this->get_google_categories($_POST['parent_id']);
} elseif ($action == "update_image") {
$this->update_image();
} elseif ($action == "update_accessory_ordering") {
$this->update_accessory_ordering();
}
}
protected function get_attribute($name) {
if (isset($_POST[$name])) {
return $_POST[$name];
} elseif (isset($_GET[$name])) {
return $_GET[$name];
}
return false;
}
protected function update_accessory_ordering() {
$id = $this->get_attribute('item_id');
$accessories = $this->get_attribute('accessories');
if ($id && $accessories) {
$position = $accessories['position'];
$item_id = $accessories['item_id'];
$len = count($position);
//$this->db->autocommit(false);
for ($i = 0; $i < $len; $i++) {
$sql = 'UPDATE
item_item_assign
SET
position=' . $this->db->real_escape_string($position[$i]) . '
WHERE
item_parent_id=' . $this->db->real_escape_string($id) . '
AND item_child_id=' . $this->db->real_escape_string($item_id[$i]);
echo $sql;
echo "<br />";
//$this->db->query($sql);
}
exit();
//$result = $this->db->commit();
//$this->db->autocommit(true);
}
echo "ok no accessories or no itemmnd?";
exit();
}
private function update_image() {
if (isset($_POST['image_id'])) {
$image_id = $_POST['image_id'];
} else {
$image_id = false;
}
if (isset($_POST['key'])) {
$key = $_POST['key'];
} else {
$key = false;
}
if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($image_id && $key && $value) {
if ($key == 'variant') {
$value = explode('_', $value);
$sql = "UPDATE item_files
SET attribut1='" . $this->db->real_escape_string($value[0]) . "'
, attribut2='" . $this->db->real_escape_string($value[1]) . "'
WHERE id=" . $this->db->real_escape_string($image_id);
} else {
$sql = 'UPDATE item_files
SET ' . $this->db->real_escape_string($key) . "='" . $this->db->real_escape_string($value) . "'
WHERE id=" . $this->db->real_escape_string($image_id);
}
if ($this->db->query($sql)) {
$return_data = array('status' => 'success');
} else {
$return_data = array('status' => 'error');
}
} else {
$return_data = array('status' => 'error');
}
echo json_encode($return_data);
exit();
}
private function get_variant_price() {
if (isset($_GET['id'])) {
$item_id = $_GET['id'];
} else {
$item_id = false;
}
if (isset($_GET['variant1'])) {
$variant1 = $_GET['variant1'];
} else {
$variant1 = false;
}
if (isset($_GET['variant2'])) {
$variant2 = $_GET['variant2'];
} else {
$variant2 = false;
}
if (isset($_GET['group'])) {
$group_id = $_GET['group'];
} else {
$group_id = false;
}
if ($item_id && $variant1 && $variant2 && $group_id) {
$taxrate = ItemHelper::get_item_taxrate($item_id);
if (!$taxrate) {
// TODO: is there a default taxrate somewhere?
$taxrate = 19;
}
$result = ItemHelper::get_item_variant_prices($item_id, $group_id, $taxrate);
if ($result) {
if ($variant2 == 'null') {
$variant2 = '';
}
$return_data = $result[$variant1][$variant2];
$return = array('status' => 'success', 'data' => $return_data);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return);
exit();
}
private function ping() {
$data = $_GET;
unset($data['admin_modul']);
unset($data['action']);
foreach ($data as $key => $value) {
echo $key . ' : ' . $value . '<br />';
}
exit();
}
private function get_google_categories($parent_id) {
$item_object = new Item($this->base_object);
$google_item_categories = $item_object->get_all_google_item_categories($parent_id);
echo json_encode($google_item_categories);
exit();
}
}
+806
View File
@@ -0,0 +1,806 @@
<?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
*
* MODIFIED: PHP 8 Debug Fix - PFC Claude
* Added silent error logging for price update debugging
*/
// DEBUG: Show only real errors, not deprecated spam!
error_reporting(E_ERROR | E_WARNING | E_PARSE);
ini_set('display_errors', 1); // DEBUG: Show errors temporarily!
// FIX PATHS für Testshop
set_include_path(get_include_path() . PATH_SEPARATOR . '/var/www/vhosts/newmail.intelectra.de/httpdocs/');
// Log in erlaubtem Verzeichnis
ini_set('log_errors', 1);
ini_set('error_log', $_SERVER['DOCUMENT_ROOT'] . '/logs/debug_price_update.log');
include_once './core/item.class.php';
include_once './core/manufacturer.class.php';
include_once './core/tax.class.php';
include_once './core/structure.class.php';
include_once './core/customer_group.class.php';
include_once './modules/list_and_edit.class.php';
include_once './core/vendors/edit.class.php';
include_once './core/item_inventory.class.php';
include_once './core/shipping_area.class.php';
class admin_item_editor {
private $base_object;
private $config;
private $layout_object;
private $db;
private $id;
private $item_object;
private $vendor_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->layout_object = $layout_object;
$this->db = $base_object->db;
$this->item_object = new Item($this->base_object,false,0);
$this->list_object = new ListAndEdit($base_object, $layout_object);
$this->vendor_object = new Vendors_Edit($base_object);
}
function run() {
if (isset($_GET['id']) && $_GET['id']) {
$has_id = true;
$id = intval($_GET['id']);
} else if (isset($_POST['id']) && $_POST['id']) {
$has_id = true;
$id = intval($_POST['id']);
} else {
$has_id = false;
$id = false;
}
$this->id = $id;
if (isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
if (isset($_POST['show_price_and_marketing']) && $_POST['show_price_and_marketing']) {
$this->layout_object->assign('show_price_and_marketing', 1);
}
if (isset($_POST['show_attributes']) && $_POST['show_attributes']) {
$this->layout_object->assign('show_attributes', 1);
}
if (isset($_POST['show_versand']) && $_POST['show_versand']) {
$this->layout_object->assign('show_versand', 1);
}
if (isset($_POST['show_seo']) && $_POST['show_seo']) {
$this->layout_object->assign('show_seo', 1);
}
if (isset($_POST['show_lager']) && $_POST['show_lager']) {
$this->layout_object->assign('show_lager', 1);
}
if (isset($_POST['show_price_variants']) && $_POST['show_price_variants']) {
$this->layout_object->assign('show_price_variants', 1);
}
// Lade alle Lieferanten
// $vendors = $this->vendor_object->get_all();
$vendors = $this->vendor_object->get_dropdown_data();
$this->layout_object->assign('vendors', $vendors);
// decide what CRUD method to call and call it in ListAndEdit
if (isset($_POST['mod']) && $_POST['mod'] == 'rename_item_document') {
self::rename_item_document();
} else if (isset($_POST['mod']) && $_POST['mod'] == 'delete_item_document') {
self::delete_item_document();
} else if (isset($_POST['mod']) && $_POST['mod'] == 'add_item_type') {
self::add_item_type();
} else if ($is_submitted && !$has_id) {
// create
self::save_item_types();
// abort if Item Number already exists and reroute to existing item form
$newId = $this->item_object->get_by_number($_POST['form_field']['number']);
if ($newId != false) {
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_item_editor&action=edit&id='.$newId);
return;
} else {
$form_data = $this->item_object->data_filter($_POST['form_field']);
$saved = $this->item_object->create($form_data, $_POST['form_field_prices']);
}
if ($saved) {
self::save_item_types();
// reroute to form with id in saved
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_item_editor&action=edit&id='.$saved);
} else {
// reroute to empty form
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_item_editor&action=add_item');
}
} // copy
else if ($has_id && isset($_GET['mod']) && $_GET['mod'] == 'copy') {
$this->item_object->id = $_GET['id'];
$this->item_object->copy();
if ($this->item_object->id) {
self::save_item_types();
// reroute to form with id in saved
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_item_editor&action=edit&id='.$this->item_object->id);
} else {
// reroute to empty form
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_item_editor&action=add_item');
}
} // delete file
else if ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'delete_file') {
$this->item_object->id = $_POST['id'];
$this->item_object->delete_file($_POST['pic_id']);
} // upload file
else if ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'add_file') {
self::upload_file();
return; // FIX: Stop execution after upload to prevent unnecessary processing
} // upload file
else if ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'get_file_list') {
$this->item_object->id = $_POST['id'];
$file_list = $this->item_object->get_file_list(0);
$this->layout_object->assign('file_list', $file_list);
self::get_item_variants($_POST['id']);
return $this->layout_object->fetch('admin_item_editor_filelist.tpl');
} // sort images
else if ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'sort_image_list') {
$this->item_object->id = $_POST['id'];
$this->item_object->sort_image_list($_POST['pics']);
return;
} // read
else if ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'remove_default_image') {
$this->item_object->id = $_POST['id'];
$this->item_object->remove_default_image();
return;
} // remove default image
else if ($has_id && !$is_submitted && (!isset($_GET['mod']) || $_GET['mod'] != 'delete')) {
// template variable name
$this->item_object->id = $_GET['id'];
$data = $this->item_object->get_data(1, false);
if ($data->variant_price_type == 1) {
$this->layout_object->assign('default_variant_price_type', '1');
} else {
$this->layout_object->assign('default_variant_price_type', '0');
}
if (!empty($data->available_from) && $data->available_from != '0000-00-00') {
$tmp = explode('-', $data->available_from);
$data->available_from = (count($tmp) === 3)
? $tmp[2].'.'.$tmp[1].'.'.$tmp[0]
: '';
} else {
$data->available_from = '';
}
if (!empty($data->available_till) && $data->available_till != '0000-00-00') {
$tmp = explode('-', $data->available_till);
$data->available_till = (count($tmp) === 3)
? $tmp[2].'.'.$tmp[1].'.'.$tmp[0]
: '';
} else {
$data->available_till = '';
}
// Ensure last_change_user is always an object
if (!isset($data->last_change_user) || $data->last_change_user === null) {
$data->last_change_user = new stdClass();
$data->last_change_user->firstname = '';
$data->last_change_user->surname = '';
}
// Clean up files array - remove any false/null entries
if (isset($data->files) && is_array($data->files)) {
$data->files = array_filter($data->files, function($file) {
return $file !== false && $file !== null && is_object($file);
});
// Re-index array to ensure proper iteration
$data->files = array_values($data->files);
} else {
$data->files = array();
}
$this->layout_object->assign('item_data', $data);
$this->layout_object->assign('item_structure_assignment', $this->item_object->getStructureAssignment());
// Load file list for item
$file_list = $this->item_object->get_file_list(0);
if (!$file_list || !is_array($file_list)) {
$file_list = array(); // Fallback to empty array if false or not array
} else {
// Filter out any false/null entries from the array
$file_list = array_filter($file_list, function($file) {
return $file !== false && $file !== null && is_object($file);
});
}
$this->layout_object->assign('file_list', $file_list);
} else if ($has_id && $is_submitted && (!isset($_GET['mod']) || $_GET['mod'] != 'delete')) { // update
self::save_item_types();
self::upload_file();
$this->item_object->id = $_POST['id'];
$form_data = $this->item_object ->data_filter($_POST['form_field']);
// Only set structure_id to 0 for NEW items, not for existing ones
if (!isset($form_data['structure_id']) && !$_POST['id']) {
$form_data['structure_id'] = 0;
}
// DEBUG: Log before price update (silent logging only)
// DISABLED: error_log("DEBUG PRICE UPDATE: Starting update for item ID: " . $this->item_object->id);
// DISABLED: error_log("DEBUG PRICE UPDATE: Form data: " . print_r($form_data, true));
// DISABLED: error_log("DEBUG PRICE UPDATE: Price data: " . print_r($_POST['form_field_prices'], true));
try {
$this->item_object->update($form_data, $_POST['form_field_prices']);
// DISABLED: error_log("DEBUG PRICE UPDATE: Update completed successfully");
// Preserve the active tab if we came from documents tab
$redirect_url = $_SERVER['HTTP_REFERER'];
if (strpos($redirect_url, '#documents') === false && isset($_POST['active_tab']) && $_POST['active_tab'] == 'documents') {
$redirect_url .= '#documents';
}
header('location: '.$redirect_url);
} catch (Exception $e) {
// DISABLED: error_log("DEBUG PRICE UPDATE: FATAL ERROR - " . $e->getMessage());
// DISABLED: error_log("DEBUG PRICE UPDATE: Stack trace: " . $e->getTraceAsString());
// Silent redirect to prevent user seeing error
header('location: '.$_SERVER['HTTP_REFERER']);
}
} else if ($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete') { // delete
$this->item_object ->id = $_GET['id'];
$this->item_object ->delete();
} else {
// new item
$config_object = new Config($this->base_object);
if ($config_object->is_set('variant_price_type')) {
if ($config_object->get_value('variant_price_type') == 'additional_charge') {
$this->layout_object->assign('default_variant_price_type', '1');
}
} else {
$this->layout_object->assign('default_variant_price_type', '0');
}
$this->layout_object->assign('default_shippable', '1');
$this->layout_object->assign('default_price_type', '1');
$this->layout_object->assign('default_state', '1');
// Standardmäßig "Preis zeigen" Sektion bei Neuanlage aktiviert
$this->layout_object->assign('show_price_and_marketing', 1);
}
// set document path
$document_path = str_replace('//', '/', './web/'.SHOP_SYSTEM.'/documents/article/');
$this->layout_object->assign('document_path', $document_path);
// get manufacturer
$manufacturer_object = new Manufacturer($this->base_object);
$manufacturers = $manufacturer_object->get_all();
$this->layout_object->assign('manufacturers', $manufacturers);
// get tax
$tax_object = new Tax($this->base_object);
$taxes = $tax_object->get_all();
$this->layout_object->assign('taxes', $taxes);
// get structure
$structure_object = new Structure($this->base_object);
$structure_tree = $structure_object->get_all_tree_full_path(null, '/');
//echo '<pre style="text-align:left;">';print_r($structure_tree);
$this->layout_object->assign('structure_tree', $structure_tree);
// get schema
$schemas = $this->item_object ->get_all_item_schemas();
$this->layout_object->assign('schemas', $schemas);
// get customer groups
$customerGroups_object = new Customer_group($this->base_object);
$customerGroups = $customerGroups_object->get_all_price_groups();
$groups = array();
foreach ($customerGroups as $group) {
if ($id) {
$group->prices = $this->item_object->getPricesForCustomerGroup($group->id);
} else {
// For new items, create empty prices object
$group->prices = new stdClass();
$group->prices->graduated_prices = false;
// Manually add all price properties with numeric defaults (for calculations)
$group->prices->price_1 = 0; $group->prices->quantity_1 = 1; $group->prices->bargain_price_1 = 0;
$group->prices->price_2 = 0; $group->prices->quantity_2 = 0; $group->prices->bargain_price_2 = 0;
$group->prices->price_3 = 0; $group->prices->quantity_3 = 0; $group->prices->bargain_price_3 = 0;
$group->prices->price_4 = 0; $group->prices->quantity_4 = 0; $group->prices->bargain_price_4 = 0;
$group->prices->price_5 = 0; $group->prices->quantity_5 = 0; $group->prices->bargain_price_5 = 0;
}
$groups[] = $group;
}
$this->layout_object->assign('customerGroups', $groups);
// get accessories
if ($id) {
$item_items = $this->item_object ->get_all_item_items(1, $id, 1);
$this->layout_object->assign('item_items', $item_items);
$item_items2 = $this->item_object ->get_all_item_items(2, $id, 1);
$this->layout_object->assign('item_items2', $item_items2);
$item_items3 = $this->item_object ->get_all_item_items(3, $id, 1);
$this->layout_object->assign('item_items3', $item_items3);
}
// get accessories childs
if ($id) {
$item_items = $this->item_object ->get_all_item_items(1, $id, 0);
$this->layout_object->assign('item_item_child', $item_items);
$item_items2 = $this->item_object ->get_all_item_items(2, $id, 0);
$this->layout_object->assign('item_item_child2', $item_items2);
$item_items3 = $this->item_object ->get_all_item_items(3, $id, 0);
$this->layout_object->assign('item_item_child3', $item_items3);
}
// get shipping areas
$shipping_area_object = new Shipping_area($this->base_object);
$shipping_areas = $shipping_area_object->get_all();
$this->layout_object->assign('shipping_areas', $shipping_areas);
// get google item categories
$google_item_categories1 = $this->item_object ->get_all_google_item_categories();
$this->layout_object->assign('google_item_categories1', $google_item_categories1);
// get item type definitions
$item_type_definitions = self::get_item_type_definitions();
$this->layout_object->assign('item_type_definitions', $item_type_definitions);
// get item types
if ($this->item_object) {
$item_types = $this->item_object->get_item_types();
} else {
$item_types = array(); // For new items
}
$this->layout_object->assign('item_types', $item_types);
// item opinion
if ($id) {
$opinion = $this->item_object->get_opinion_list($id);
$this->layout_object->assign('item_opinion', $opinion);
}
// item inventory
if ($id) {
$inventory_object = new ItemInventory($this->base_object);
$inventory = $inventory_object->get_all_item_inventory($id);
$price_sum_output = 0;
$price_sum_input = 0;
foreach ($inventory as $item_inventory) {
if ($item_inventory->inventory_object_type_id == 2) {
$price_sum_input += $item_inventory->price_sum;
} else {
$price_sum_output += $item_inventory->price_sum;
}
}
$this->layout_object->assign('item_inventory_stats', array('price_sum_input' => $price_sum_input, 'price_sum_output' => $price_sum_output));
$this->layout_object->assign('item_inventory', $inventory);
}
// get variant configuration
include './web/'.SHOP_SYSTEM.'/config/item_variant_schema.inc.php';
$this->layout_object->assign('item_variant_config', $item_fields);
// Ensure item_data is always set (default values for new items)
if (!$this->layout_object->getTemplateVars('item_data')) {
// Create comprehensive default item object with all needed properties
$default_item_data = new stdClass();
$default_item_data->id = '';
$default_item_data->parent_id = 0;
$default_item_data->structure_id = 0;
$default_item_data->schema_id = 0;
$default_item_data->manufacturer_id = 0;
$default_item_data->name = '';
$default_item_data->name_en = '';
$default_item_data->number = '';
$default_item_data->tax_id = 0;
$default_item_data->short_description = '';
$default_item_data->short_description_en = '';
$default_item_data->detail_description = '';
$default_item_data->detail_description_en = '';
$default_item_data->manufacturer_item_number = '';
$default_item_data->default_image_file_name = '';
$default_item_data->seo_title = '';
$default_item_data->seo_description = '';
$default_item_data->seo_keywords = '';
$default_item_data->short_uri = '';
$default_item_data->ean_code = '';
$default_item_data->price_type = '';
$default_item_data->shipping_cost_type = '';
$default_item_data->shipping_item_type = '';
$default_item_data->shipping_weight = '';
$default_item_data->available_from = '';
$default_item_data->available_till = '';
$default_item_data->base_price = '';
$default_item_data->buy_quantity = '';
$default_item_data->google_product_category = '';
$default_item_data->inventory_min = '';
$default_item_data->inventory_number = '';
$default_item_data->inventory_order_quantity = '';
$default_item_data->inventory_rack_number = '';
$default_item_data->min_quantity = '';
$default_item_data->price_je_vpe = '';
$default_prices = new stdClass();
$default_prices->value = 0;
$default_item_data->prices = $default_prices;
$default_item_data->uvp = '';
$default_item_data->uvp_netto = '';
$default_item_data->vpe_amount = '';
$default_item_data->vpe_unit = '';
$default_item_data->youtube_video = '';
$default_item_data->vendor_id = 0;
$default_item_data->vendor_item_number = '';
$default_item_data->price_1 = '';
$default_item_data->has_user_data = 0;
$default_item_data->shippable = 1;
$default_item_data->shippable_inventory = 1;
$default_item_data->bargain_price_type = 0;
// Create empty last_change_user object for new items
$default_last_change_user = new stdClass();
$default_last_change_user->firstname = '';
$default_last_change_user->surname = '';
$default_item_data->last_change_user = $default_last_change_user;
$default_item_data->last_change_date = '';
$default_item_data->schema_data_attributes = array();
$default_item_data->variant_structure = array();
$this->layout_object->assign('item_data', $default_item_data);
}
// Ensure message variables are always set as arrays
if (!$this->layout_object->getTemplateVars('warning_message')) {
$this->layout_object->assign('warning_message', array());
}
if (!$this->layout_object->getTemplateVars('error_message')) {
$this->layout_object->assign('error_message', array());
}
if (!$this->layout_object->getTemplateVars('info_message')) {
$this->layout_object->assign('info_message', array());
}
// Ensure item_structure_assignment is always set
if (!$this->layout_object->getTemplateVars('item_structure_assignment')) {
$this->layout_object->assign('item_structure_assignment', array());
}
// Ensure itemsTax is always set as numeric value for calculations
if (!$this->layout_object->getTemplateVars('itemsTax')) {
$this->layout_object->assign('itemsTax', 0);
}
// Ensure item_types is always set as array
if (!$this->layout_object->getTemplateVars('item_types')) {
$this->layout_object->assign('item_types', array());
}
// Ensure all show_* variables are set as integers for template conditions
$show_vars = ['show_price_and_marketing', 'show_attributes', 'show_versand', 'show_seo', 'show_lager', 'show_price_variants'];
foreach ($show_vars as $var_name) {
if (!$this->layout_object->getTemplateVars($var_name)) {
$this->layout_object->assign($var_name, 0);
}
}
// Ensure base_dir and info object are set for all icon paths
if (!$this->layout_object->getTemplateVars('base_dir')) {
$this->layout_object->assign('base_dir', '.');
}
if (!$this->layout_object->getTemplateVars('info')) {
$info = new stdClass();
$info->base_url = '.';
$this->layout_object->assign('info', $info);
}
return $this->layout_object->fetch('admin_item_editor.tpl');
}
private function save_item_types() {
$this->db->autocommit(false);
self::update_item_types();
self::insert_item_types();
self::delete_item_types();
$result = $this->db->commit();
$this->db->autocommit(true);
} // end save_item_types
private function update_item_types() {
if (!isset($_POST['item_type'])) {
return; // No item_type data to update
}
$data = $_POST['item_type'];
$len = (isset($data['item_type_id']) && is_array($data['item_type_id'])) ? count($data['item_type_id']) : 0;
for ($i = 0; $i < $len; $i++) {
if ($data['item_type_id'][$i] != '') {
if (!$data['item_type_available_from'][$i]) {
$data['item_type_available_from'][$i] = '0000-00-00';
}
if (!$data['item_type_available_until'][$i]) {
$data['item_type_available_until'][$i] = '0000-00-00';
}
$sql = 'UPDATE
item_types
SET
item_type_definition_id='.$this->db->real_escape_string($data['item_type_definition_id'][$i]);
$sql .= " , item_type_text='".$this->db->real_escape_string($data['item_type_text'][$i])."'";
$sql .= " , item_type_available_from='".$this->db->real_escape_string($data['item_type_available_from'][$i])."'";
$sql .= " , item_type_available_until='".$this->db->real_escape_string($data['item_type_available_until'][$i])."'";
$sql .= ' WHERE item_type_id='.$this->db->real_escape_string($data['item_type_id'][$i]);
$sql .= ' AND item_id='.$this->id;
$this->db->query($sql);
}
}
} // end update_item_types
private function insert_item_types() {
if (!isset($_POST['item_type'])) {
return; // No item_type data to insert
}
$data = $_POST['item_type'];
$len = (isset($data['item_type_id']) && is_array($data['item_type_id'])) ? count($data['item_type_id']) : 0;
$sql = 'INSERT INTO item_types (item_id, item_type_definition_id, item_type_text, item_type_available_from, item_type_available_until) VALUES ';
$first = true;
for ($i = 0; $i < $len; $i++) {
if ($data['item_type_id'][$i] == '') {
if ($first) {
$first = false;
} else {
$sql .= ', ';
}
// Fix: Check if array keys exist before accessing them
if (!isset($data['item_type_available_from'][$i]) || !$data['item_type_available_from'][$i]) {
$data['item_type_available_from'][$i] = '0000-00-00';
}
if (!isset($data['item_type_available_until'][$i]) || !$data['item_type_available_until'][$i]) {
$data['item_type_available_until'][$i] = '0000-00-00';
}
$sql .= " ('".
$this->db->real_escape_string($this->id)."', '".
$this->db->real_escape_string($data['item_type_definition_id'][$i])."', '".
$this->db->real_escape_string($data['item_type_text'][$i] ?? '')."', '".
$this->db->real_escape_string($data['item_type_available_from'][$i])."', '".
$this->db->real_escape_string($data['item_type_available_until'][$i])."') ";
}
}
if (!$first) {
$this->db->query($sql);
}
return '';
} // end insert_item_types
private function delete_item_types() {
if (isset($_POST['deletable_item_types'])) {
$data = implode(', ', $_POST['deletable_item_types']);
$sql = 'DELETE FROM
item_types
WHERE
item_type_id IN ('.$data.')
AND
item_id='.$this->id.';';
$this->db->query($sql);
}
} // end delete_item_types
private 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;
}
return $data;
}
return false;
} // end get_item_type_definitions
private function add_item_type() {
$item_type_definitions = self::get_item_type_definitions();
$this->layout_object->assign('item_type_definitions', $item_type_definitions);
// Create empty item_type object for new item type
$item_type = new stdClass();
$item_type->item_type_ordering = '';
$item_type->item_type_id = '';
$item_type->item_type_definition_id = '';
$item_type->item_type_text = '';
$item_type->item_type_definition_type = 0;
$item_type->item_type_available_from = '';
$item_type->item_type_available_until = '';
$this->layout_object->assign('item_type', $item_type);
// Ensure all show_* variables are set for snippet template
$show_vars = ['show_price_and_marketing', 'show_attributes', 'show_versand', 'show_seo', 'show_lager', 'show_price_variants'];
foreach ($show_vars as $var_name) {
if (!$this->layout_object->getTemplateVars($var_name)) {
$this->layout_object->assign($var_name, 0);
}
}
// Ensure base_dir and info object are set for icon paths in snippet template
if (!$this->layout_object->getTemplateVars('base_dir')) {
$this->layout_object->assign('base_dir', '.');
}
if (!$this->layout_object->getTemplateVars('info')) {
$info = new stdClass();
$info->base_url = '.';
$this->layout_object->assign('info', $info);
}
echo $this->layout_object->fetch('snipet_item_type.tpl');
exit();
} // end add_item_type
protected function rename_item_document() {
if (isset($_POST['document_id']) && isset($_POST['new_name'])) {
$document_id = $_POST['document_id'];
$new_name = $_POST['new_name'];
if ($new_name != '') {
if (!stristr('.pdf', $new_name)) {
$new_name.'.pdf';
}
$sql = "UPDATE
item_files
SET
alt='".$this->db->real_escape_string($new_name)."'
WHERE
id=".$this->db->real_escape_string($document_id);
$this->db->query($sql);
}
}
echo " ";
exit();
}
protected function delete_item_document() {
if (isset($_POST['document_id']) && isset($_POST['item_id'])) {
$item_id = $_POST['item_id'];
$document_id = $_POST['document_id'];
$result = $this->item_object->delete_file($document_id, $item_id);
if ($result) {
$return_array = array('status' => 'success');
} else {
$return_array = array('status' => 'error');
}
} else {
$return_array = array('status' => 'error');
}
echo json_encode($return_array);
exit();
}
protected function upload_file() {
// DEBUG: Log upload attempt mit Timestamps
$debug_log = '/var/www/vhosts/intelectra.de/httpdocs/logs/upload_debug.log';
$start = microtime(true);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " === UPLOAD_FILE START ===\n", FILE_APPEND);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " POST submit: " . (isset($_POST['submit']) ? $_POST['submit'] : 'NOT SET') . "\n", FILE_APPEND);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " FILES name: " . (isset($_FILES['Filedata']['name']) ? $_FILES['Filedata']['name'] : 'NOT SET') . "\n", FILE_APPEND);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " FILES size: " . (isset($_FILES['Filedata']['size']) ? $_FILES['Filedata']['size'] : 'NOT SET') . "\n", FILE_APPEND);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " FILES tmp_name: " . (isset($_FILES['Filedata']['tmp_name']) ? $_FILES['Filedata']['tmp_name'] : 'NOT SET') . "\n", FILE_APPEND);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " Item ID: " . (isset($_POST['id']) ? $_POST['id'] : 'NOT SET') . "\n", FILE_APPEND);
$this->item_object->id = $_POST['id'];
if ($_FILES['Filedata']['tmp_name'] != "") { // check if a file has been set
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [1] File found, starting processing...\n", FILE_APPEND);
if (substr($_FILES['Filedata']['name'], -3) == 'pdf') { // check if file is pdf
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [2] PDF detected, calling add_uploaded_pdf\n", FILE_APPEND);
$return_object = $this->item_object ->add_uploaded_pdf($_FILES);
} else {
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [2] Image detected, calling add_uploaded_file\n", FILE_APPEND);
$return_object = $this->item_object ->add_uploaded_file($_FILES, $_POST['watermark_activ']);
}
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [3] Upload function returned: " . ($return_object ? 'SUCCESS' : 'FAILED') . "\n", FILE_APPEND);
if ($return_object) {
$return_data = array('status' => 'success', 'data' => $return_object);
} else {
$return_data = array('status' => 'error');
}
// 🔥 FIX: Bei Datei-Upload sofort Response senden und beenden!
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [4] Checking exit - submit=" . $_POST['submit'] . "\n", FILE_APPEND);
if (isset($_POST['submit']) && $_POST['submit'] == 'Datei hochladen') {
$elapsed = round((microtime(true) - $start) * 1000, 2);
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [5] EXIT - redirecting! (took {$elapsed}ms)\n", FILE_APPEND);
header('Location: ./index.php?admin_modul=admin_item_editor&id=' . $this->item_object->id);
exit();
}
file_put_contents($debug_log, date('Y-m-d H:i:s') . " [5] NO EXIT - continuing to update()!\n", FILE_APPEND);
}
return;
}
private function get_item_variants($item_id) {
$sql = "SELECT
items.*,
item_schema.selectable_attribute_1,
item_schema.selectable_attribute_2
FROM
items
LEFT JOIN
item_schema
ON
items.schema_id = item_schema.id
WHERE
items.id=".$this->db->real_escape_string($item_id);
$request = $this->db->query($sql);
$attributes_array_1 = false;
$attributes_array_2 = false;
$return_array = false;
if ($request->num_rows > 0) {
$data = $request->fetch_object();
if (isset($data->selectable_attribute_1) && $data->selectable_attribute_1 != '0') {
$attributes_array_1 = explode(';', $data->{'attribute_'.$data->selectable_attribute_1});
$this->layout_object->assign('item_variants_1', $attributes_array_1);
}
if (isset($data->selectable_attribute_2) && $data->selectable_attribute_2 != '0') {
$attributes_array_2 = explode(';', $data->{'attribute_'.$data->selectable_attribute_2});
$this->layout_object->assign('item_variants_2', $attributes_array_2);
}
}
} // end get_item_variants
}
?>
+232
View File
@@ -0,0 +1,232 @@
<?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';
class admin_item_editor_ajax {
private $base_object;
private $config;
private $return;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = isset($base_object->config_object) ? $base_object->config_object : null;
$this->layout_object = $layout_object;
}
function run() {
// Start output buffering to catch any debug output
ob_start();
if (isset($_POST['action'])) {
$item_object = new Item($this->base_object);
switch ($_POST['action']) {
case 'prices':
if ($_POST['id']) {
$item_object->id = $_POST['id'];
$customerGroup = ($_POST['customerGroup']) ? $_POST['customerGroup'] : 1;
$this->return['prices'] = $item_object->getPricesForCustomerGroup($customerGroup);
unset($this->return['prices']->item_id);
unset($this->return['prices']->customergroup_id);
//$this->return['variants'] = $item_object->getVariantPricesForCustomerGroup($customerGroup, true, false, 0, 0, false);
} else {
$this->return = array();
}
echo json_encode($this->return);
break;
case 'itemList':
$ret = array();
if (isset($_POST['search']) && $_POST['search']) {
$search = trim($_POST['search']);
if (strlen($search) >= 2) {
// Call Python search script directly!
$python_script = dirname(__FILE__) . '/import/python_search.py';
$command = "python3 " . escapeshellarg($python_script) . " " . escapeshellarg($search);
$output = shell_exec($command);
if ($output) {
$ret = json_decode($output, true);
if (!$ret) {
$ret = array();
}
}
// Fallback to old PHP method if Python fails
if (empty($ret)) {
$ret = $item_object->find_for_ajax($search, 20);
// Convert PHP format to jQuery UI format
$formatted_ret = array();
if (is_array($ret)) {
foreach ($ret as $item) {
$status = ($item->active == 1) ? ' || aktiv' : ' || inaktiv';
$formatted_ret[] = array(
'id' => $item->id,
'value' => $item->number,
'label' => $item->name . ' (' . $item->number . $status . ')',
'number' => $item->number,
'name' => $item->name,
'active' => $item->active
);
}
}
$ret = $formatted_ret;
}
}
}
// Ensure we always return valid JSON
if (!$ret) {
$ret = array();
}
// Clear any debug output that was captured
ob_clean();
header('Content-Type: application/json');
echo json_encode($ret);
break;
case 'get_schema':
$schema_id = ($_POST['schema_id']) ? $_POST['schema_id'] : 0;
$item_object->set_schema_id($schema_id);
$ret = $item_object->get_schema_data();
echo json_encode($ret);
break;
case 'new_variant':
$parent_id = ($_POST['parent_id']) ? $_POST['parent_id'] : 0;
$data = array();
// get parent item data
$item_object->id = $parent_id;
$parent_item_data = $item_object->get_data();
$data['parent_id'] = $parent_id;
// schema data
$data['schema_id'] = $parent_item_data->schema_id;
include_once './core/itemschema.class.php';
$item_schema_object = new ItemSchema($this->base_object);
$schema_data = $item_schema_object->get_data($data['schema_id']);
$data['attribute_'.$schema_data->selectable_attribute_1] = ($_POST['attr1']) ? $_POST['attr1'] : '';
if ($schema_data->selectable_attribute_2) {
$data['attribute_'.$schema_data->selectable_attribute_2] = ($_POST['attr2']) ? $_POST['attr2'] : '';
}
$data['manufacturer_id'] = $parent_item_data->manufacturer_id;
$data['name'] = $parent_item_data->name;
$data['number'] = $parent_item_data->number;
$data['detail_description'] = $parent_item_data->detail_description;
$data['manufacturer_item_number'] = $parent_item_data->manufacturer_item_number;
$data['default_image_file_name'] = $parent_item_data->default_image_file_name;
$data['seo_title'] = $parent_item_data->seo_title;
$data['seo_description'] = $parent_item_data->seo_description;
$data['seo_keywords'] = $parent_item_data->seo_keywords;
$data['ean_code'] = $parent_item_data->ean_code;
$data['price_type'] = $parent_item_data->price_type;
$data['shippable'] = $parent_item_data->shippable;
$data['shippable_inventory'] = $parent_item_data->shippable_inventory;
$data['tax_id'] = $parent_item_data->tax_id;
$item_object->create($data);
//$ret = $item_object->get_schema_data();
echo json_encode($ret);
break;
case 'delete_variant':
$id = ($_POST['id']) ? $_POST['id'] : 0;
$item_object->delete_by_id($id);
echo json_encode($ret);
break;
case 'get_item_variants':
$id = ($_POST['id']) ? $_POST['id'] : 0;
$item_object->id = $id;
$data = $item_object->get_data(1, false);
$ret = array();
$this->layout_object->assign('item_data', $data);
$ret['html'] = $this->layout_object->fetch('admin_item_editor_variant_table.tpl');
echo json_encode($ret);
break;
case 'new_inventory':
$item_id = ($_POST['id']) ? $_POST['id'] : 0;
if (!$item_id) {
$ret = array('status' => 'error', 'message' => 'No item ID provided');
echo json_encode($ret);
break;
}
$data = array();
$data['item_id'] = $item_id;
$data['inventory_object_type_id'] = ($_POST['inventory_type']) ? $_POST['inventory_type'] : '';
$data['amount'] = ($_POST['inventory_amount']) ? $_POST['inventory_amount'] : '';
include_once './core/item_inventory.class.php';
$inventory_object = new ItemInventory();
$result = $inventory_object->add($data);
if ($result === false) {
$ret = array('status' => 'error', 'message' => 'Failed to add inventory: ' . $inventory_object->error);
} else {
$ret = array('status' => 'success', 'result' => $result);
}
echo json_encode($ret);
break;
case 'delete_item_item_assign':
$item_parent_id = $_POST['item_parent_id'];
$item_child_id = $_POST['item_child_id'];
$result = $item_object->delete_item_item_assign($item_parent_id, $item_child_id);
$ret = array('status' => $result ? 'success' : 'error');
echo json_encode($ret);
break;
case 'get_inventory':
$id = ($_POST['id']) ? $_POST['id'] : 0;
$item_object->id = $id;
$data = $item_object->get_data(1, false);
$this->layout_object->assign('item_data', $data);
$ret = array();
// item inventory
if ($id) {
include_once './core/item_inventory.class.php';
$inventory_object = new ItemInventory();
$inventory = $inventory_object->get_all_item_inventory($id);
$this->layout_object->assign('item_inventory', $inventory);
}
//$this->layout_object->assign('item_data', $data);
$ret['html'] = $this->layout_object->fetch('admin_item_editor_inventory_table.tpl');
echo json_encode($ret);
break;
}
}
exit();
return false;
}
}
?>
+125
View File
@@ -0,0 +1,125 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
include_once './core/config.class.php';
class admin_item_image_configuration {
private $ItemImage;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->ItemImage = new ItemImage();
$this->layout_object = $layout_object;
}
public function run() {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = '';
}
if($action == 'submit') {
$this->save_config_data();
} elseif ($action == 'watermark_image_upload') {
$this->watermark_image_upload();
} elseif ($action == 'delete_watermark_image') {
$this->delete_watermark_image();
} else {
$this->get_config_data();
return $this->layout_object->fetch('admin_item_image_configuration.tpl');
}
}
private function save_config_data() {
unset($_POST['submit']);
$data = $_POST;
$this->ItemImage->save($data);
}
private function get_config_data() {
$config_item = $this->ItemImage->load();
if ($config_item) {
foreach ($config_item as $key => $value) {
$this->layout_object->assign($key, $value);
}
}
}
private function watermark_image_upload() {
if ($_FILES['Filedata']['tmp_name'] != '') {
$path = './web/' . SHOP_SYSTEM . '/documents/';
move_uploaded_file($_FILES['Filedata']['tmp_name'], $path . $_FILES['Filedata']['name']);
}
Config::set_key('item_watermark_image', $_FILES['Filedata']['name']);
echo 'Wasserzeichen hochgeladen';
}
private function delete_watermark_image() {
Config::set_key('item_watermark_image', '');
// TODO: delete image on server
}
}
class ItemImage {
protected $_db;
public function __construct() {
$this->_db = Registry::get('base')->db;
}
public function load() {
if (Config::has_key('item_watermark_activ')) {
$data['item_watermark_activ'] = Config::get_value('item_watermark_activ');
}
if (Config::has_key('item_watermark_pos')) {
$data['item_watermark_pos'] = Config::get_value('item_watermark_pos');
}
if (Config::has_key('item_watermark_image') && Config::is_set('item_watermark_image')) {
$data['item_watermark_image'] = './web/' . SHOP_SYSTEM . '/documents/' . Config::get_value('item_watermark_image');
}
if (isset($data)) {
return $data;
}
return false;
}
public function save($data) {
if (isset($data['item_watermark_activ'])) {
$insert_data['item_watermark_activ'] = $data['item_watermark_activ'];
}
if (isset($data['item_watermark_pos'])) {
$insert_data['item_watermark_pos'] = $data['item_watermark_pos'];
}
if (isset($data['item_watermark_image'])) {
$insert_data['item_watermark_image'] = $data['item_watermark_image'];
}
foreach($insert_data as $key => $value) {
Config::set_key($key, $value);
}
}
}
+79
View File
@@ -0,0 +1,79 @@
<?php
/**
* @version $Id: admin_item_schema_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/item.class.php';
include_once './modules/list_and_edit.class.php';
class admin_item_schema_editor {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->list_object = new ListAndEdit($base_object, $layout_object);
}
function run() {
//$this->setup_info();
//var_dump($GLOBALS);
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// decide what CRUD method to call and call it in ListAndEdit
// create
$item_object = new Item($this->base_object);
if($is_submitted && !$has_id) {
$form_data = $item_object->schema_data_filter($_POST['form_field']);
$item_object->create_schema($form_data);
$data = $item_object->get_schema_data();
$this->layout_object->assign('form_data', $data);
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$item_object->set_schema_id($_GET['id']);
$data = $item_object->get_schema_data();
$this->layout_object->assign('form_data', $data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$item_object->set_schema_id($_POST['id']);
$form_data = $item_object->schema_data_filter($_POST['form_field']);
$item_object->update_schema($form_data);
$data = $item_object->get_schema_data();
$this->layout_object->assign('form_data', $data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$item_object->set_schema_id($_GET['id']);
$item_object->delete_schema();
}
else {
}
return $this->layout_object->fetch('admin_item_schema_editor.tpl');
}
}
?>
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* @version $Id: layout.class.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Easyshop
* @copyright Copyright (C) 2005 - 2008 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class admin_layout extends Smarty {
public $currentComGroupPath;
private $base_object;
function start($base_object) {
$this->base_object = $base_object;
// set content charset
header('content-type: text/html; charset=utf-8');
$this->__construct();
$this->compile_id = SHOP_SYSTEM.'_admin';
$this->compile_dir = ROOT_DIR.'/tmp/smarty_compile';
$this->cache_dir = ROOT_DIR.'/tmp/smarty_cache';
$this->template_dir = array(ROOT_DIR.'/themes/admin/templates', ROOT_DIR.'/themes/default/templates');
//$smarty->caching = true;
$this->debugging = false;
$this->assign('servername', $_SERVER['SERVER_NAME']);
$this->assign('THEME_DIR', 'themes/admin');
$this->assign('SHOP_DIR', STANDARD_DIR. 'web/'.SHOP_SYSTEM.'/');
return;
}
function get_admin_menu($admin_role_data) {
// get system registration file
include_once('./core/system_registration.inc.php');
$data = array();
foreach ($admin_modul_registration as $modul) {
if (isset($admin_role_data->acl_show[$modul['modul']]) && $admin_role_data->acl_show[$modul['modul']] == 1) {
$modul['name'] = $this->base_object->i18n->shopadmin_translation['admin_interface']['menu'][$modul['name']];
$data[$modul['position']][] = $modul;
}
}
return $data;
}
function get_base() {
return $this->base_object;
}
}
?>
+167
View File
@@ -0,0 +1,167 @@
<?php
/**
* @version $Id: admin_manufacturer_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jtd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/manufacturer.class.php';
class admin_manufacturer_editor {
private $base_object;
private $layout_object;
private $manufacturer_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->manufacturer_object = new Manufacturer($base_object);
} // end __construct
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == 'save') {
$this->save();
} elseif ($action == 'upload') {
$this->upload($id);
} elseif ($action == 'delete') {
$this->delete($id);
} elseif ($action == 'delete_logo') {
$this->delete_logo($id);
} else {
return $this->default_action($id);
}
} // end run
private function default_action($id) {
if ($id) {
$data = $this->manufacturer_object->get_by_id($id);
if ($data) {
if ($data->logo != '') {
$logo = $this->manufacturer_object->get_image_url() . $data->logo;
$this->layout_object->assign('logo', $logo);
}
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Dieser Hersteller existiert nicht.");
}
}
// implied else, no action taken when you create something new
return $this->layout_object->fetch('admin_manufacturer_editor.tpl');
} // end default_action
private function delete_logo($id) {
if ($id) {
if ($this->manufacturer_object->set_logo($id, '')) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function upload($id) {
$log_object = Logger::get_instance();
$log_object->info('fileupload','jetzt');
if ($id) {
$log_object->info('id',$id);
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file != '') {
$log_object->info('file','datei');
$result = $this->manufacturer_object->save_logo($id, $temp_file);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: can't save", 'data', $result);
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no file');
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no id');
}
echo json_encode($return);
exit();
} // end upload
private function delete($id) {
if ($id) {
$result = $this->manufacturer_object->delete($id);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
// only used in ajax, so i terminate with exit
private function save() {
if (isset($_POST['form_field'])) {
$data = $_POST['form_field'];
if (isset($data['active'])) {
$data['active'] = '1';
} else {
$data['active'] = '0';
}
if ($data['id'] == '') {
unset($data['id']);
}
$result = $this->manufacturer_object->save($data);
if ($result) {
$return = array('status' => 'success', 'id' => $result);
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
} else {
$return = array('status' => 'error', 'message' => 'no forms data');
}
echo json_encode($return);
exit();
} // end save
} // end admin_manufacturer_editor
+87
View File
@@ -0,0 +1,87 @@
<?php
include_once './core/metatag.class.php';
class admin_metatag_editor {
private $base_object;
private $layout_object;
private $metatag_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->metatag_object = new Metatag();
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = false;
}
if ($action == 'save') {
$this->save();
} elseif ($action == 'delete') {
$this->delete($id);
} else {
return $this->default_action($id);
}
}
private function default_action($id) {
if ($id) {
$data = $this->metatag_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Dieser meta tag existiert nicht oder ist nicht freigeschalten.");
}
}
// implied else, no action taken when you create something new
return $this->layout_object->fetch('admin_metatag_editor.tpl');
}
// only used in ajax, so i terminate whith exit
private function save() {
if (isset($_POST['form_field'])) {
$data = $_POST['form_field'];
$result = $this->metatag_object->save($data);
var_dump($result);
} else {
$data = false;
}
//echo json_encode($return);
exit();
}
// only used in ajax, so i terminate whith exit
private function delete($id) {
if (id) {
// delete
if ($this->metatag_object->delete($id)) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => 'database error');
}
} else {
// error
$return = array('status' => 'error', 'message' => 'id error');
}
echo json_encode($return);
exit();
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
class admin_metatags {
private $base_object;
private $layout_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
if ($action == 'some_generic_call') {
} else {
return $this->default_action();
}
}
private function default_action() {
return $this->layout_object->fetch('admin_metatags.tpl');
}
}
+128
View File
@@ -0,0 +1,128 @@
<?php
/**
* @version $Id: admin_object_edit.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class admin_object_edit {
private $base_object;
private $object_name;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
// get vars
foreach (array('action', 'object', 'object_ids', 'form_data', 'object_id', 'email', 'customer_group', 'lang') as $field) {
if (isset($_GET[$field])) {
$this->{$field} = $_GET[$field];
} elseif (isset($_POST[$field])) {
$this->{$field} = $_POST[$field];
} else {
$this->{$field} = false;
}
}
// 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);
// call method
if ($this->action) {
if ($this->{$this->action}()) {
$return = array('status' => 'success', 'message' => 'action already.', 'object_id' => $this->object_id);
}
else {
$return = array('status' => 'error', 'message' => 'action failed');
}
echo json_encode($return);
exit();
} else {
return $this->get_form();
}
}
// get object form
private function get_form() {
// get table funktions (delete, edit, search, filter, sort...) and titlerows:
$this->object->init_edit_fields($this->object_id);
$table_data = $this->object->list_table_config;
$table_data['object_name'] = $this->object_name;
$table_data['object_id'] = $this->object_id;
$table_data['selected_lang'] = $this->lang;
$this->layout_object->assign('table_data', $table_data);
if ($this->object_id) {
$form_data = $this->object->load($this->object_id);
$this->layout_object->assign('form_data', $form_data);
}
echo $this->layout_object->fetch('admin_object_edit.tpl');
exit();
}
// save object
private function save() {
// save data
$result = $this->object->save($this->form_data, $this->object_id);
if ($result && !$this->object_id) {
$this->object_id = $result;
}
return $result;
}
// get object data
private function get_data() {
$form_data = $this->object->load($this->object_id);
echo json_encode($form_data);
exit();
}
// delete object
private function delete_item() {
return $this->object->remove($this->object_id);
}
// delete image file
private function delete_image() {
return $this->object->delete_logo($this->object_id);
}
// add image file
private function upload_image() {
return $this->object->save_logo($this->object_id);
}
// test email
private function test_email() {
return $this->object->test_email($this->object_id, $this->email);
}
// send email
private function send_email() {
return $this->object->send_email($this->object_id, $this->customer_group);
}
// export to shipping
private function export_to_shipping() {
return $this->object->export_to_shipping($this->object_ids, 1);
}
// new customer password
private function new_password() {
return $this->object->new_password($this->object_id);
}
// send email to customer for first activation
private function first_activation() {
return $this->object->first_activation($this->object_id);
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
/**
* @version $Id: admin_standard_messages.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop 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 = 50;
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];
} elseif (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);
$row['price_1'] = number_format($row['price_1'],2,',','.').' EUR';
$row['price_brutto'] = number_format($row['price_brutto'],2,',','.').' EUR';
$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
);
}
}
+707
View File
@@ -0,0 +1,707 @@
<?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/order.class.php';
include_once './core/orderhelper.class.php';
include_once './core/orderstatus.class.php';
include_once './core/delivererhelper.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/customergroups.class.php';
include_once './core/item.class.php';
include_once './core/payment_method.class.php';
include_once './core/shippingareahelper.class.php';
class admin_order_actions {
private $base_object;
private $layout_object;
private $order_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
$this->order_object = new Order($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == "set_payment_status") {
$this->set_payment_status($id);
} else if ($action == "set_payment_method") {
$this->set_payment_method($id);
} else if ($action == "set_order_status") {
$this->set_order_status($id);
} else if ($action == "set_shipping_method") {
$this->set_shipping_method($id);
} else if ($action == "set_order_statuses") {
$this->set_order_statuses();
} else if ($action == "set_payment_statuses") {
$this->set_payment_statuses();
} else if ($action == "get_tab") {
$this->get_tab();
} else if ($action == "get_deliverers_by_country") {
$this->get_deliverers_by_country();
} else if ($action == "get_order_item") {
$this->get_order_item();
} else if ($action == "get_order_invoice_pdf") {
$this->get_order_invoice_pdf();
} else if ($action == "get_order_delivery_note_pdf") {
$this->get_order_delivery_note_pdf();
} else if ($action == "get_payment_data_by_id_and_country") {
$this->get_payment_data_by_id_and_country(); // deprecated can be removed
} else if ($action == "get_payment_method_list") {
$this->get_payment_method_list();
} else if ($action == "setup_payment_methods") {
$this->setup_payment_methods();
} else if ($action == "send_invoice_pdf_by_email") {
$this->send_invoice_pdf_by_email();
} else if ($action == "get_bop_pdf") { // bill of parcels
$this->get_bop_pdf(intval($_GET['order_id']));
} else if ($action == "get_order_pdf") { // bill of parcels
$this->get_order_pdf($_GET['order_id']);
} else if ($action == "get_packing_slip_pdf") {
$this->get_packing_slip_pdf(intval($_GET['order_id']));
} else if ($action == "ping") {
$this->ping();
}
}
private function send_invoice_pdf_by_email() {
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if (isset($_GET['email'])) {
$email = $_GET['email'];
} else {
$email = false;
}
if ($order_id && $email) {
#include_once './core/cs_ticket.class.php';
$ticket_object = new Cs_ticket($this->base_object);
$order = $this->order_object->get_by_id($order_id);
$invoice_pdf = OrderHelper::get_order_invoice_pdf($order_id, 1);
$attachment1 = new stdClass();
$attachment1->file_name = 'rechnung.pdf';
$attachment1->mime_type = 'application/pdf';
$attachment1->content = $invoice_pdf;
$data['attachments'][] = $attachment1;
$ticket_id = $ticket_object->event(11, $order->customer_id, $order_id, $data);
if ($ticket_id) {
$this->order_object->invoice_email_sent($order_id, $email);
$return_data = array('status' => 'success', 'data' => 'Rechnung wurde versendet.');
} else {
$return_data = array('status' => 'error', 'message' => 'no result');
}
} else {
$return_data = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return_data);
exit();
}
private function set_payment_status($id) {
if ($id) {
if (isset($_GET['value'])) {
$value = $_GET['value'];
} else if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($value) {
$result = OrderHelper::set_payment_status($id, $value);
if ($result) {
// success
// send email event if order status is bezahlt and paymentmethod is Vorkasse
$order_data = $this->order_object->get_by_id($id);
if ($value == 2 && $order_data->payment_method == 1) {
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(9, $order_data->customer_id, $order_id);
}
$return = array('status' => 'success', 'message' => 'status set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no value');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function set_payment_method($id) {
if ($id) {
if (isset($_GET['value'])) {
$value = $_GET['value'];
} else if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($value) {
$result = OrderHelper::set_payment_method($id, $value);
if ($result) {
// success
$return = array('status' => 'success', 'message' => 'method set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no value');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function set_order_status($id) {
if ($id) {
if (isset($_GET['value'])) {
$value = $_GET['value'];
} else if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($value) {
$result = OrderHelper::set_order_status($id, $value);
if ($result) {
// success
// change order state event
$this->startTicketEvent($id);
$return = array('status' => 'success', 'message' => 'status set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no value');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function startTicketEvent($id)
{
$order_data = $this->order_object->get_by_id($id);
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(4, $order_data->customer_id, $id);
$event_type = 0;
if ($order_data->order_status == 3) {
$event_type = 5;
} else if ($order_data->order_status == 4) {
$event_type = 6;
} else if ($order_data->order_status == 5) {
$event_type = 7;
} else if ($order_data->order_status == 6) {
$event_type = 8;
}
if ($event_type) {
$ticket_object->event($event_type, $order_data->customer_id, $id);
}
return;
}
private function set_shipping_method($id) {
if ($id) {
if (isset($_GET['value'])) {
$value = $_GET['value'];
} else if (isset($_POST['value'])) {
$value = $_POST['value'];
} else {
$value = false;
}
if ($value) {
$result = OrderHelper::set_shipping_method($id, $value);
if ($result) {
// success
$return = array('status' => 'success', 'message' => 'method set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no value');
}
} else {
// no id
$return = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return);
exit();
}
private function set_payment_statuses() {
if (isset($_GET['seting'])) {
$seting = $_GET['seting'];
} else if (isset($_POST['seting'])) {
$seting = $_POST['seting'];
} else {
$seting = false;
}
if (isset($_GET['ids'])) {
$ids = $_GET['ids'];
} else if (isset($_POST['ids'])) {
$ids = $_POST['ids'];
} else {
$ids = false;
}
if ($seting && $ids) {
$result = OrderHelper::set_payment_statuses($seting, $ids);
if ($result) {
// success
$return = array('status' => 'success', 'message' => 'method set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no values');
}
echo json_encode($return);
exit();
}
private function set_order_statuses() {
if (isset($_GET['seting'])) {
$seting = $_GET['seting'];
} else if (isset($_POST['seting'])) {
$seting = $_POST['seting'];
} else {
$seting = false;
}
if (isset($_GET['ids'])) {
$ids = $_GET['ids'];
} else if (isset($_POST['ids'])) {
$ids = $_POST['ids'];
} else {
$ids = false;
}
if ($seting && $ids) {
$result = OrderHelper::set_order_statuses($seting, $ids);
$idArray=explode(',',$ids);
if (sizeof($idArray) > 0) {
foreach ($idArray As $id) {
if (intval($id)) {
$this->startTicketEvent($id);
}
}
}
if ($result) {
// success
$return = array('status' => 'success', 'message' => 'method set');
} else {
// cant save
$return = array('status' => 'error', 'message' => 'can not save');
}
} else {
// no active marker
$return = array('status' => 'error', 'message' => 'no values');
}
echo json_encode($return);
exit();
}
private function get_tab() {
$order_status = $this->get_order_status();
if ($order_status) {
$items = $this->get_items();
$page = $this->get_page();
$pages = $this->order_object->get_number_of_pages($items, $order_status);
$pagination = $this->order_object->get_pagination_array($items, $page, $order_status);
$sort = $this->get_sort();
$sort_direction = $this->get_sort_direction();
$data = $this->order_object->get_all_paginated($items, $page, $order_status, $sort, $sort_direction);
$order_selector = OrderStatus::get_selector($order_status);
// modernize
$order_status_list = $this->order_object->get_order_status_object();
$this->layout_object->assign('order_status_list', $order_status_list);
$billing_status_list = $this->order_object->get_billing_status_object();
$this->layout_object->assign('billing_status_list', $billing_status_list);
$payment_method_list = $this->order_object->get_payment_method_object();
$this->layout_object->assign('payment_method_list', $payment_method_list);
// end modernize
$this->layout_object->assign('items', $items);
$this->layout_object->assign('page', $page);
$this->layout_object->assign('pages', $pages);
$this->layout_object->assign('pagination', $pagination);
$this->layout_object->assign('range', $range);
$this->layout_object->assign('order_status', $order_status);
$this->layout_object->assign('order_selector', $order_selector);
if ($sort) {
$this->layout_object->assign('sort', $sort);
}
if ($sort_direction) {
$this->layout_object->assign('sort_direction', $sort_direction);
}
$this->layout_object->assign('order_list', $data);
echo $this->layout_object->fetch('table_order_list.tpl');
} else {
// no range
echo "ERROR: no order status";
}
exit();
}
private function get_deliverers_by_country() {
if (isset($_GET['country_id'])) {
$country_id = $_GET['country_id'];
} else {
$country_id = false;
}
if ($country_id) {
$result = DelivererHelper::get_deliverers_by_country($country_id);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'no country id');
}
echo json_encode($return);
exit();
}
private function get_order_status() {
if (isset($_GET['order_status'])) {
$order_status = $_GET['order_status'];
} else if (isset($_POST['order_status'])) {
$order_status = $_POST['order_status'];
} else {
$order_status = false;
}
return $order_status;
}
private function get_items() {
if (isset($_GET['items']) && is_numeric($_GET['items'])) {
$items = (int)$_GET['items'];
$this->base_object->customer->set_config_item('pagination', $items);
} else {
$items = $this->base_object->customer->get_config_item('pagination');
if (is_numeric($items)) {
$items = (int)$items;
} else {
$items = 10;
}
}
return $items;
} // end get_items
private function get_page() {
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
$page = (int)$_GET['page'];
} else {
$page = 1;
}
return $page;
} // end get_page
private function get_sort() {
if (isset($_GET['sort']) && $_GET['sort']) {
$sort = $_GET['sort'];
} else if (isset($_POST['sort']) && $_POST['sort']) {
$sort = $_POST['sort'];
} else {
$sort = false;
}
return $sort;
} // end get_sort
private function get_sort_direction() {
if (isset($_GET['sort_direction']) && $_GET['sort_direction']) {
$sort_direction = $_GET['sort_direction'];
} else if (isset($_POST['sort_direction']) && $_POST['sort_direction']) {
$sort_direction = $_POST['sort_direction'];
} else {
$sort_direction = false;
}
return $sort_direction;
}
private function get_order_item() {
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else {
$id = false;
}
if (isset($_GET['group_id'])) {
$customer_group = $_GET['group_id'];
} else {
$customer_group = 1; // defaults to
}
$customer_group_object = new CustomerGroups();
$show_with_tax = $customer_group_object->get($customer_group)->show_tax;
$this->layout_object->assign('show_with_tax', $show_with_tax);
if ($id) {
$item = new Item($this->base_object, $id);
$data = $item->get_data($customer_group);
$taxes = new Tax($this->base_object);
$this->layout_object->assign('tax_rates', $taxes->get_all());
$this->layout_object->assign('item', $data);
if ($data->combination_item) {
$this->layout_object->assign('stamp', uniqid());
echo $this->layout_object->fetch('table_order_order_combination_list_item.tpl');
} else {
echo $this->layout_object->fetch('table_order_order_list_item.tpl');
}
}
exit();
}
private function get_order_invoice_pdf() {
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($order_id) {
OrderHelper::get_order_invoice_pdf($order_id);
}
exit();
}
private function get_order_delivery_note_pdf() {
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($order_id) {
OrderHelper::get_order_delivery_note_pdf($order_id);
}
exit();
}
private function get_bop_pdf($order_id) {
if (intval($order_id)) {
include_once './core/output/bopPDF.class.php';
$pdf = new bopPDF(intval($order_id));
}
exit();
} // end get_bop_pdf
private function get_order_pdf($order_id) {
if ($order_id) {
include_once './core/output/orderPDF.class.php';
$pdf = new orderPDF($order_id);
}
exit();
} // end get_bop_pdf
private function get_packing_slip_pdf($order_id) {
if (intval($order_id)) {
include_once './core/output/packingslippdf.class.php';
$pdf = new PackingSlipPDF(intval($order_id));
}
exit();
} // end get_packing_slip_pdf
private function ping() {
$data = $_GET;
unset($data['admin_modul']);
unset($data['action']);
foreach ($data as $key => $value) {
echo $key.' : '.$value.'<br />';
}
exit();
}
// TODO: is a duplicate of setup_payment_method_chargesin admin payment method actions? should be get instead of setup?
private function get_payment_data_by_id_and_country() {
if (isset($_GET['method_id'])) {
$method_id = $_GET['method_id'];
} else {
$method_id = false;
}
if (isset($_GET['country_id'])) {
$country_id = $_GET['country_id'];
} else {
$country_id = false;
}
if (isset($_GET['order_items_value'])) {
$order_items_value = $_GET['order_items_value'];
} else {
$order_items_value = false;
}
if ($method_id && $country_id && $order_items_value) {
$default_vat_value = $this->base_object->config->shopConfiguration['default_vat_value'];
$result = PaymentHelper::getPaymentDataByIdAndCountry($method_id, $country_id, $default_vat_value, $order_items_value);
if ($result) {
$return = array('status' => 'success', 'data' => $result, 'arguments' => array('method_id' => $method_id, 'country_id' => $country_id, 'order_items_value' => $order_items_value));
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return);
exit();
}
private function get_payment_method_list() {
if (isset($_GET['countryId'])) {
$countryId = $_GET['countryId'];
} else {
$countryId = false;
}
if (isset($_GET['groupId'])) {
$groupId = $_GET['groupId'];
} else {
$groupId = false;
}
if (isset($_GET['itemsTotal'])) {
$itemsTotal = $_GET['itemsTotal'];
} else {
$itemsTotal = false;
}
if ($countryId && $groupId && $itemsTotal) {
$shippingArea = ShippingAreaHelper::get_shipping_area_by_country_id($countryId,$groupId);
if ($shippingArea) {
$payment_method_object = new Payment_method($this->base_object);
$result = $payment_method_object->getMethodsForGroup($groupId, $itemsTotal, $shippingArea);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => "can't fetch shipping area id");
}
} else {
$return = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return);
exit();
}
public function get_order_talbe($id) {
if ($id) {
$order_data = $this->order_object->get_order_by_id($id);
$header = $order['header'];
$order_items = $order_data['items'];
$footer = $order_data['footer'];
$this->layout_object->assign('order', $header);
$this->layout_object->assign('order_items', $order_items);
$this->layout_object->assign('footer', $footer);
return $this->layout_object->fetch('table_order_order_list.tpl');
}
}
}
?>
+669
View File
@@ -0,0 +1,669 @@
<?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/country.class.php';
include_once './core/order.class.php';
include_once './core/orderhelper.class.php';
include_once './core/itemhelper.class.php';
include_once './core/customer.class.php';
include_once './core/customergroups.class.php';
include_once './core/customerhelper.class.php';
include_once './core/tax.class.php';
include_once './core/payment_method.class.php';
include_once './core/item.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/cs_ticket_message.class.php';
include_once './core/deliverer.class.php';
include_once './core/delivererhelper.class.php';
include_once './core/cstickethelper.php';
include_once './core/cancellationreasons.class.php';
include_once './core/config.class.php';
class admin_order_editor {
protected $layout_object;
protected $base_object;
protected $order_object;
protected $customer_object;
protected $country_object;
protected $customer_group_object;
protected $item_object;
protected $deliverer_object;
protected $cancellation_reasons_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
$this->order_object = new Order($base_object);
$this->customer_object = new Customer($this->base_object);
$this->country_object = new Country($this->base_object);
$this->item_object = new Item($this->base_object);
$this->deliverer_object = new Deliverer($this->base_object);
$this->customer_group_object = new CustomerGroups($this->base_object);
$this->cancellation_reasons_object = new CancellationReasons($base_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = 'add_order';
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == 'submit') {
$this->save($id);
} else {
return $this->edit($id);
}
}
private function edit($id) {
if ($id) {
// get order tickets
$revised_orders_list = OrderHelper::get_revision_history_for_order($id);
$ticket_object = new Cs_ticket($this->base_object);
$ticket_message_object = new Cs_ticket_message($this->base_object);
$all_tickets = CSTicketHelper::get_tickets_by_ids($revised_orders_list);
$tickets = array();
foreach ($all_tickets as $ticket) {
// get first message
$ticket->first_message = $ticket_message_object->get_first_message($ticket->id);
$tickets[] = $ticket;
}
$this->layout_object->assign('tickets', $tickets);
try {
$order = $this->order_object->get_order_by_id($id);
$customer_id = $order['header']->customer_id;
if (OrderHelper::order_has_revision($id)) {
$order_revisions = OrderHelper::get_all_orders_by_order_number($order['header']->order_number);
$this->layout_object->assign('order_history', $order_revisions);
}
$this->customer_group_object->get_by_user($customer_group_id);
$order_data = $order['header'];
$customer_group_id = CustomerHelper::get_customer_group_id_by_customer_id($customer_id);
$customer_email = CustomerHelper::get_customer_email($customer_id);
$group_data = $this->customer_group_object->get($customer_group_id);
$order_data->group_id = $group_data->id;
$order_data->group_name = $group_data->name;
$order_data->group_show_tax = $group_data->show_tax;
$order_data->customer_email = $customer_email;
$order_items = array_reverse($order['items']);
$order_footer = $order['footer'];
// deliverers
$deliverers = DelivererHelper::get_deliverers_with_prices_by_country($order_data->shipping_country);
$this->layout_object->assign('deliverers', $deliverers);
// payment method
$payment_method = PaymentHelper::getActivePaymentMethodsByCountry($order['header']->shipping_country);
$this->layout_object->assign('payment_method_list', $payment_method);
// cancellation reasons
$cancellation_reasons = $this->cancellation_reasons_object->get_all('active');
$this->layout_object->assign('cancellation_reasons', $cancellation_reasons);
$this->layout_object->assign('addresses', $this->customer_object->get_address_by_customer_id($customer_id));
$shipping_charge_taxes = ($order_footer->shipping_charges / 119.0) * 19;
$payment_method_charge_taxes = ($order_footer->payment_method_charges / 119.0) * 19;
$additional_chrges = $shipping_charge_taxes + $payment_method_charge_taxes;
if (isset($order_footer->taxes['19.00'])) {
$order_footer->taxes['19.00'] += $shipping_charge_taxes + $payment_method_charge_taxes;
} else {
if ($additional_chrges > 0) {
$order_footer->taxes['19.00'] = $shipping_charge_taxes + $payment_method_charge_taxes;
}
}
$this->layout_object->assign('order', $order_data);
$this->layout_object->assign('order_items', $order_items);
$this->layout_object->assign('footer', $order_footer);
} catch (Exception $e) {
$this->layout_object->assign('error_message', $e->getMessage());
}
} else {
if ($_GET['customer_id']) {
$this->customer_object->set_id($_GET['customer_id']);
$customer_data = $this->customer_object->get_data();
$customer_group_data = $this->customer_group_object->get($customer_data->group_id);
$temp = new stdClass();
$temp->customer_id = $customer_data->id;
$temp->group_id = $customer_data->group_id;
$temp->customer_number = $customer_data->number;
$temp->customer_name = $customer_data->firstname.' '.$customer_data->surname;
$temp->group_show_tax = $customer_group_data->show_tax;
$temp->group_name = $customer_group_data->name;
$this->layout_object->assign('order', $temp);
$this->layout_object->assign('addresses', $this->customer_object->get_address_by_customer_id($_GET['customer_id']));
//doesn't work hmm, besides i would still need to insert the fields in the template
$this->layout_object->assign('use_default_address', true);
$default_address_country_id = CustomerHelper::get_default_address_country($customer_data->id);
if ($default_address_country_id) {
// deliverers
$deliverers = DelivererHelper::get_deliverers_with_prices_by_country($default_address_country_id);
$this->layout_object->assign('deliverers', $deliverers);
// payment method
$payment_method = PaymentHelper::getActivePaymentMethodsByCountry($default_address_country_id);
$this->layout_object->assign('payment_method_list', $payment_method);
}
}
}
if (Config::has_key('invoice_number_manual')) {
$invoice_number_manual = Config::get_value('invoice_number_manual');
} else {
$invoice_number_manual = false;
}
$this->layout_object->assign('invoice_number_manual', $invoice_number_manual);
if (Config::has_key('shipping_list_number_manual')) {
$shipping_list_number_manual = Config::get_value('shipping_list_number_manual');
} else {
$shipping_list_number_manual = false;
}
$this->layout_object->assign('shipping_list_number_manual', $shipping_list_number_manual);
// get countries
$countries = $this->country_object->get_all();
$this->layout_object->assign('countries', $countries);
// payment methods
$order_status = $this->order_object->get_order_status_object();
$this->layout_object->assign('order_status_list', $order_status);
// billing status
$billing_status = $this->order_object->get_billing_status_object();
$this->layout_object->assign('billing_status_list', $billing_status);
// taxes
$taxes = new Tax($this->base_object);
$this->layout_object->assign('tax_rates', $taxes->get_all());
$this->layout_object->assign('order_list', $this->layout_object->fetch('table_order_order_list.tpl'));
if (isset($_GET['action']) && $_GET['action'] == 'order_print') {
echo $this->layout_object->fetch('admin_order_print.tpl');
exit();
}
else {
return $this->layout_object->fetch('admin_order_editor.tpl');
}
}
private function save($id) {
$data = new stdClass();
$show_taxes = $_POST['show_taxes'];
unset($_POST['show_taxes']);
if (isset($_POST['order'])) {
$order = $_POST['order'];
if (isset($order['is_eu_order'])) {
$data->is_eu_order = $order['is_eu_order'] == 'on' ? 1 : 0;
} else {
$data->is_eu_order = 0;
}
if (isset($order['customer_vat_reg_num'])) {
$data->customer_vat_reg_num = $order['customer_vat_reg_num'];
}
}
if (isset($_POST['export_to_shipping'])) {
$data->export_to_shipping = $_POST['export_to_shipping'];
}
if (isset($_POST['paymorrow'])) {
$paymorrow = $_POST['paymorrow'];
if (isset($paymorrow['paymorrow_request_id'])) {
$data->paymorrow_request_id = $paymorrow['paymorrow_request_id'];
}
if (isset($paymorrow['paymorrow_transaction_id'])) {
$data->paymorrow_transaction_id = $paymorrow['paymorrow_transaction_id'];
}
if (isset($paymorrow['paymorrow_response_result_code'])) {
$data->paymorrow_response_result_code = $paymorrow['paymorrow_response_result_code'];
}
if (isset($paymorrow['paymorrow_response_status_code'])) {
$data->paymorrow_response_status_code = $paymorrow['paymorrow_response_status_code'];
}
if (isset($paymorrow['paymorrow_response_timestamp'])) {
$data->paymorrow_response_timestamp = $paymorrow['paymorrow_response_timestamp'];
}
if (isset($paymorrow['paymorrow_bic'])) {
$data->paymorrow_bic = $paymorrow['paymorrow_bic'];
}
if (isset($paymorrow['paymorrow_iban'])) {
$data->paymorrow_iban = $paymorrow['paymorrow_iban'];
}
if (isset($paymorrow['paymorrow_national_bank_code'])) {
$data->paymorrow_national_bank_code = $paymorrow['paymorrow_national_bank_code'];
}
if (isset($paymorrow['paymorrow_national_bank_account_number'])) {
$data->paymorrow_national_bank_account_number = $paymorrow['paymorrow_national_bank_account_number'];
}
if (isset($paymorrow['paymorrow_payment_reference'])) {
$data->paymorrow_payment_reference = $paymorrow['paymorrow_payment_reference'];
}
}
if (isset($_POST['klarna'])) {
$klarna = $_POST['klarna'];
if (isset($klarna['klarna_invoice_number'])) {
$data->klarna_invoice_number = $klarna['klarna_invoice_number'];
}
}
if (isset($_POST['orderInfo'])) {
$orderInfo = $_POST['orderInfo'];
if (isset($orderInfo['order_number'])) {
$data->order_number = $orderInfo['order_number'];
}
if (isset($orderInfo['order_revision'])) {
$data->order_revision = $orderInfo['order_revision'];
}
if (isset($orderInfo['order_addendum'])) {
$data->order_addendum = $orderInfo['order_addendum'];
}
}
if (isset($_POST['inventory_management'])) {
$inventory_management = $_POST['inventory_management'];
if (isset($inventory_management['inventory_decremented'])) {
$data->inventory_decremented = $inventory_management['inventory_decremented'];
}
if (isset($inventory_management['inventory_decremented_date'])) {
$data->inventory_decremented_date = $inventory_management['inventory_decremented_date'];
}
if (isset($inventory_management['inventory_incremented'])) {
$data->inventory_incremented = $inventory_management['inventory_incremented'];
}
if (isset($inventory_management['inventory_incremented_date'])) {
$data->inventory_incremented_date = $inventory_management['inventory_incremented_date'];
}
}
if (isset($_POST['invoice_email'])) {
$invoice_email = $_POST['invoice_email'];
if (isset($invoice_email['invoice_email_sent'])) {
$data->invoice_email_sent = $invoice_email['invoice_email_sent'];
}
if (isset($invoice_email['invoice_email_date'])) {
$data->invoice_email_date = $invoice_email['invoice_email_date'];
}
if (isset($invoice_email['invoice_email_recipient'])) {
$data->invoice_email_recipient = $invoice_email['invoice_email_recipient'];
}
}
// cancellation
if (isset($_POST['cancellationData'])) {
if (isset($_POST['cancellationData']['cancellation_date'])) {
$data->cancellation_date = $_POST['cancellationData']['cancellation_date'];
}
if (isset($_POST['cancellationData']['cancellation_status'])) {
$data->cancellation_status = $_POST['cancellationData']['cancellation_status'];
}
if (isset($_POST['cancellationData']['cancellation_reason_id']) && $_POST['cancellationData']['cancellation_reason_id'] != '-') {
$data->cancellation_reason_id = $_POST['cancellationData']['cancellation_reason_id'];
}
if (isset($_POST['cancellationData']['cancellation_info'])) {
$data->cancellation_info = $_POST['cancellationData']['cancellation_info'];
}
}
if (isset($_POST['without_shipping_charges']) && $_POST['without_shipping_charges'] == 'yes') {
$data->without_shipping_charges = 1;
} else {
$data->without_shipping_charges = 0;
}
if (isset($_POST['giftCertificate'])) {
$data->giftCertificateCode = $_POST['giftCertificate']['gift_certificate_code'];
}
if (isset($_POST['dateOptions'])) {
$dates = $_POST['dateOptions'];
if ($dates['order_date']) {
$data->order_date = $dates['order_date'];
}
if ($dates['billing_date']) {
$data->billing_date = $dates['billing_date'];
}
if ($dates['payment_date']) {
$data->payment_date = $dates['payment_date'];
}
}
$data->paypal = $_POST['paypal'];
if (isset($_POST['orderNotice'])) {
$notices = $_POST['orderNotice'];
if ($notices['customer_info']) {
$data->customer_info = $notices['customer_info'];
}
if ($notices['invoice_info']) {
$data->invoice_info = $notices['invoice_info'];
}
if ($notices['internal_info']) {
$data->internal_info = $notices['internal_info'];
}
if ($notices['delivery_note_info']) {
$data->delivery_note_info = $notices['delivery_note_info'];
}
}
if (isset($_POST['group_id'])) {
$group_id = $_POST['group_id'];
}
$data->revisor_id = $this->base_object->customer->id;
$orderData = $_POST['orderOptions'];
if (isset($_POST['customer'])) {
$data->customer = (object) $_POST['customer'];
}
if (isset($_POST['billingAddress'])) {
$data->billingAddress = (object) $_POST['billingAddress'];
}
if (isset($_POST['shippingAddress'])) {
$data->shippingAddress = (object) $_POST['shippingAddress'];
}
$break_order_apart = false;
$not_delierable = false;
if (isset($_POST['order_item'])) {
$items = $this->make_items_array($_POST['order_item']);
if (isset($_POST['child_item'])) {
$children = $this->make_child_items_array($_POST['child_item']);
$items = array_merge($items, $children);
}
foreach ($items as $order_item) {
$this->item_object->id = $order_item->item_id;
$item = $this->item_object->get_data($group_id, false);
$prices = $this->item_object->calculate_prices($item, $order_item->quantity, $order_item->variant_1, $order_item->variant_2, $order_item->price, $data->customer->customer_id);
$data->items[] = array(
'itemId' => $order_item->item_id,
'variant1' => $order_item->variant_1,
'variant2' => $order_item->variant_2,
'quantity' => $order_item->quantity,
'prices' => $prices,
'mainItemNumber' => $item->number,
'variantItemNumber' => $item->variant_data[$order_item->variant_1][$order_item->variant_2]['item_number'],
'vatId' => $item->tax_id,
'vatRate' => $item->tax,
'vatValue' => $prices['itemPriceGross'] - $prices['itemPriceNet'],
'name' => $item->name,
'item_status' => $order_item->item_status,
'item_status_text' => $order_item->item_status_text,
'delivery_date' => $order_item->delivery_date,
'backorder_quantity' => $order_item->backorder_quantity,
'userData' => $order_item->user_data,
'parentItemId' => $order_item->parent_item_id,
'stamp' => $order_item->stamp
);
++$data->itemsQuantity;
$data->itemsOverallQuantity += $itemDataSet->quantity;
$data->itemSumNet += $prices['itemPriceNet'] * $order_item->quantity;
$data->itemSumGross += $prices['itemPriceGross'] * $order_item->quantity;
$data->itemSumVat['id'][$item->tax_id] += ($prices['itemPriceGross'] - $prices['itemPriceNet']) * $order_item->quantity;
$data->itemSumVat['rate'][$item->tax] += ($prices['itemPriceGross'] - $prices['itemPriceNet']) * $order_item->quantity;
}
}
//tracking code
$data->trackingcode = $orderData['trackingcode'];
$customer_group_id = $group_id;
// Payment
$data->payment = PaymentHelper::getPaymentDataByIdAndCountry(
$orderData['payment_method'],
$data->shippingAddress->country,
$this->base_object->config->shopConfiguration['default_vat_value'],
$data->itemSumGross,
$customer_group_id
);
$data->payment->status = $orderData['payment_status'];
// Deliverer
// TODO: delivery method can't be defined in backend order editor
$data->shipping = DelivererHelper::getDeliveryDataByIdAndCountry(
$orderData['delivery_method'],
$data->shippingAddress->country,
$this->base_object->config->shopConfiguration['default_vat_value'],
$customer_group_id
);
if ($orderData['invoice_number'] != '') {
$data->invoice_number = $orderData['invoice_number'];
}
$data->order_status = $orderData['order_status'];
if (isset($_POST['generate_invoice_number']) && $_POST['generate_invoice_number'] == 'yes') {
$invoice_number = true;
} else {
$invoice_number = false;
}
if (isset($_POST['generate_shipping_list_number']) && $_POST['generate_shipping_list_number'] == 'yes') {
$shipping_list_number = true;
} else {
$shipping_list_number = false;
}
if (isset($_POST['manual_shipping_charges']) && $_POST['manual_shipping_charges'] != '') {
$data->manual_shipping_charges = $_POST['manual_shipping_charges'];
}
$data->set_inventory = (isset($_POST['set_inventory'])) ? $_POST['set_inventory'] : 0;
$status_has_chagned = false;
if ($id) {
//echo "update"; exit();
$status_has_chagned = $this->has_order_changed($data->order_status, $id);
$data->old_order_id = $id;
$return = $this->order_object->update($data, $invoice_number, $shipping_list_number, $show_taxes);
} else {
//echo "create"; exit();
$return = $this->order_object->create($data, $invoice_number, $shipping_list_number, $show_taxes);
}
if ($return) {
if ($status_has_chagned) {
// emails on status change
$this->checkorderStatus($data->order_status,$return,$data->customer->customer_id);
}
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_order_editor&id='.$return);
} else {
header('location: http://'.$_SERVER["SERVER_NAME"].'/index.php?admin_modul=admin_order_editor');
}
}
private function checkorderStatus($orderStatus_id,$order_id,$customer_id) {
if ($orderStatus_id == 3) {
$event_type = 5;
} else if ($orderStatus_id == 4) {
$event_type = 6;
} else if ($orderStatus_id == 5) {
$event_type = 7;
} else if ($orderStatus_id == 6) {
$event_type = 8;
}
if ($event_type) {
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event($event_type, $customer_id, $order_id);
}
return;
}
private function has_order_changed($order_status_id, $order_id) {
$event_type = 0;
$db = $this->base_object->db;
$sql = "SELECT * FROM orders
WHERE id = ".$order_id." AND order_status != ".$order_status_id;
$result = $db->query($sql);
return $result->num_rows > 0;
}
private function make_items_array($data) {
$len = count($data['item_id']);
for ($i = 0; $i < $len; $i++) {
$tmp = new stdClass();
$tmp->quantity = $data['amount'][$i];
$tmp->item_id = $data['item_id'][$i];
$tmp->variant_1 = $data['variant1'][$i];
$tmp->variant_2 = $data['variant2'][$i];
$tmp->taxes = $data['taxes'][$i];
$tmp->price = $data['price'][$i];
$tmp->item_status = $data['item_status'][$i];
$tmp->item_status_text = $data['item_status_text'][$i];
$tmp->delivery_date = $data['delivery_date'][$i];
$tmp->backorder_quantity = $data['backorder_quantity'][$i];
// NEW for holzeisstock
$tmp->user_data = $data['user_data'][$i];
$tmp->parent_item_id = $data['parent_item_id'][$i];
$tmp->stamp = $data['stamp'][$i];
$return[] = $tmp;
}
return $return;
}
private function make_child_items_array($data) {
$len = count($data['is_selected']);
$return = array();
for ($i = 0; $i < $len; $i++) {
if ($data['is_selected'][$i] == 1) {
$tmp = new stdClass();
$tmp->quantity = $data['amount'][$i];
$tmp->item_id = $data['item_id'][$i];
$tmp->variant_1 = $data['variant1'][$i];
$tmp->variant_2 = $data['variant2'][$i];
$tmp->taxes = $data['taxes'][$i];
$tmp->price = $data['price'][$i];
// not set / editable
$tmp->item_status = 0;
$tmp->backorder_quantity = 0;
$tmp->delivery_date = '';
$tmp->item_status_text = '';
// NEW for holzeisstock
$tmp->user_data = $data['user_data'][$i];
$tmp->parent_item_id = $data['parent_item_id'][$i];
$tmp->stamp = $data['stamp'][$i];
$return[] = $tmp;
}
}
return $return;
}
}
?>
+97
View File
@@ -0,0 +1,97 @@
<?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_order_editor_actions {
private $base_object;
private $layout_object;
private $db;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
$this->db = $base_object->db;
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == "get_variant_price") {
$this->get_variant_price();
} else if ($action == "ping") {
$this->ping();
}
exit();
}
private function get_variant_price() {
echo "TODO THIS IS A WORK IN PROGRESS";
exit();
}
private function find_item() {
if (isset($_GET['data'])) {
$data = $_GET['data'];
} else {
$data = false;
}
if ($data) {
"SELECT
i.*,
m.name AS manufacturer
FROM
items i
LEFT JOIN
manufacturers m
ON
m.id = i.manufacturer_id
WHERE
i.number LIKE '%Schuh%'
OR
i.name LIKE '%Schuh%'
OR
i.short_description LIKE '%Schuh%'
OR
m.name LIKE '%Schuh%'";
$item = new Item($this->base_object);
$hits = $item->hits_by_string($data);
$result = $item->find_by_sitemap_cron.phpstring($data);
$return['status'] = 'success';
//$return['message'] = '';
$return['data'] = $result;
$return['hits'] = $hits;
} else {
$return['status'] = 'no_argument_data';
$return['message'] = "Keine Daten �bergeben.";
}
echo json_encode($return);
}
}
?>
+41
View File
@@ -0,0 +1,41 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web shop system
*/
include_once './core/payment_method.class.php';
class admin_order_payment_method {
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
}
function run() {
$payment_method = new Payment_method($this->base_object);
if (isset($_GET['method_id'])) {
$payment_method_id = $_GET['method_id'];
$payment_method_name = $payment_method->get_by_id($payment_method_id)->module;
} elseif (isset($_GET['method_name'])) {
$payment_method_name = $_GET['method_name'];
} else {
$payment_method_name = false;
}
if ($payment_method_name) {
$order_id = $_GET['id'];
return $this->layout_object->fetch('payment_method_' . $payment_method_name . '.tpl');
} else {
echo "ERROR";
}
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
/**
* @package Easyshop Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/paymenthelper.class.php';
class admin_payment_method_actions {
private $base_object;
private $layout_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if ($action == "get_payment_data_by_id_and_country") {
$this->get_payment_data_by_id_and_country();
} elseif ($action == 'setup_payment_methods') {
$this->setup_payment_methods();
}elseif ($action == "ping") {
$this->ping();
}
}
private function get_payment_data_by_id_and_country() {
if (isset($_GET['method_id'])) {
$method_id = $_GET['method_id'];
} else {
$method_id = false;
}
if (isset($_GET['country_id'])) {
$country_id = $_GET['country_id'];
} else {
$country_id = false;
}
if (isset($_GET['order_items_value'])) {
$order_items_value = $_GET['order_items_value'];
} else {
$order_items_value = false;
}
if ($method_id && $country_id) {
if ($order_items_value !== false) {
$default_vat_value = $this->base_object->config->shopConfiguration['default_vat_value'];
$result = PaymentHelper::getPaymentDataByIdAndCountry($method_id, $country_id, $default_vat_value, $order_items_value);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'no order items total');
}
} else {
if (!$method_id) {
$return = array('status' => 'error', 'message' => 'no method id');
} elseif (!$country_id) {
$return = array('status' => 'error', 'message' => 'no country id');
}
}
echo json_encode($return);
exit();
}
private function setup_payment_methods() {
if (isset($_GET['countryId'])) {
$countryId = $_GET['countryId'];
} else {
$countryId = false;
}
if ($countryId) {
$result = PaymentHelper::getActivePaymentMethodsByCountry($countryId);
if ($result) {
$return = array('status' => 'success', 'data' => $result);
} else {
$return = array('status' => 'error', 'message' => 'no result');
}
} else {
$return = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return);
exit();
}
private function ping() {
echo "<pre>";
print_r($_GET);
exit();
}
}
+110
View File
@@ -0,0 +1,110 @@
<?php
/**
* @version $Id: admin_payment_method_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/payment_method.class.php';
include_once './modules/list_and_edit.class.php';
class admin_payment_method_editor {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->layout_object = $layout_object;
$this->list_object = new ListAndEdit($base_object, $layout_object);
}
function run() {
//$this->setup_info();
//var_dump($GLOBALS);
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// decide what CRUD method to call and call it in ListAndEdit
// create
$payment_method_object = new Payment_method($this->base_object);
if($is_submitted && !$has_id) {
$form_data = $payment_method_object->data_filter($_POST['form_field']);
if (isset($form_data['active'])) {
$form_data['active'] = '1';
} else {
$form_data['active'] = '0';
}
$payment_method_object->create($form_data);
$payment_method_data = $payment_method_object->get_data();
$this->layout_object->assign('form_data', $payment_method_data);
// configuration data
if ($payment_method_data->configuration_group_id) {
$config_data = $this->config->get_config_elements($payment_method_data->configuration_group_id);
$this->layout_object->assign('config_data', $config_data);
}
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$payment_method_object->id = $_GET['id'];
$payment_method_data = $payment_method_object->get_data();
$this->layout_object->assign('form_data', $payment_method_data);
// configuration data
if ($payment_method_data->configuration_group_id) {
$config_data = $this->config->get_config_elements($payment_method_data->configuration_group_id);
$this->layout_object->assign('config_data', $config_data);
}
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$payment_method_object->id = $_POST['id'];
$form_data = $payment_method_object->data_filter($_POST['form_field']);
if (isset($form_data['active'])) {
$form_data['active'] = '1';
} else {
$form_data['active'] = '0';
}
$payment_method_object->update($form_data);
// payment method data
$payment_method_data = $payment_method_object->get_data();
$this->layout_object->assign('form_data', $payment_method_data);
// configuration data
if ($payment_method_data->configuration_group_id) {
$config_data = $this->config->get_config_elements($payment_method_data->configuration_group_id);
$this->layout_object->assign('config_data', $config_data);
}
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$payment_method_object->id = $_GET['id'];
$payment_method_object->delete();
}
else {
}
return $this->layout_object->fetch('admin_payment_method_editor.tpl');
}
}
?>
+163
View File
@@ -0,0 +1,163 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John Daly <jd@ta-edv.de>
* Easyway Shop is a web shop system
*/
include_once './core/paypal/transaction.class.php';
include_once './core/order.class.php';
include_once './core/orderhelper.class.php';
include_once './core/paypalrefund.class.php';
include_once './modules/admin_order_actions.php';
class admin_paypal_transaction {
private $base_object;
private $layout_object;
private $order_object;
private $transaction_object;
private $paypal_refund_object;
private $order_actions_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->order_object = new Order($base_object);
$this->transaction_object = new Transaction();
$this->paypal_refund_object = new PaypalRefund($base_object);
$this->order_actions_object = new admin_order_actions($base_object, $layout_object);
}
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($action == 'submit') {
$this->save($id);
} else {
return $this->edit($order_id);
}
}
private function edit($order_id) {
if ($order_id) {
$this->layout_object->assign('this_order', $this->order_actions_object->get_order_talbe($order_id));
// get the order in question
$this->order_object->set_id($order_id);
$order_data = $this->order_object->get_data();
// get the sum of the items that can't be delivered
$order_data->item_refund = OrderHelper::get_money_back($order_id);
// get the previous order
$this->order_object->set_id($order_data->revised_order_id);
$order_data->prev_order = $this->order_object->get_data();
$this->layout_object->assign('old_order', $this->order_actions_object->get_order_talbe($order_data->revised_order_id));
// assign the order data
$this->layout_object->assign('order_data', $order_data);
// get the data from paypal
$transaction_data = $this->transaction_object->get_transaction_details($order_id);
if ($transaction_data) {
$this->layout_object->assign('transaction_data', $transaction_data);
} else {
$this->layout_object->assign('no_transaction_data', true);
}
} else {
$this->layout_object->assign('no_order_id', true);
}
return $this->layout_object->fetch('admin_paypal_transaction.tpl');
}
private function save() {
$data = $this->clean_data($_POST);
$is_valid = $this->validate($data);
$refund_id = ($this->paypal_refund_object->create($data));
$transaction_data = $this->transaction_object->refund_transaction($return);
echo "<pre>";
print_r($transaction_data);
exit();
/*
if ($is_valid) {
$refund_id = ($this->paypal_refund_object->create($data));
if ($refund_id) {
$transaction_data = $this->transaction_object->refund_transaction($return);
if ($transaction_data) {
$this->paypal_refund_object->update($transaction_data, $id);
header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul');
} else {
echo "no transaction data";
//header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_paypal_transaction&order_id=' . $data['order_id']);
}
} else {
echo "no refund id";
//header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_paypal_transaction&order_id=' . $data['order_id']);
}
} else {
echo "data is not valid";
//header('location: http://' . $_SERVER["SERVER_NAME"] . '/index.php?admin_modul=admin_paypal_transaction&order_id=' . $data['order_id']);
}
*/
exit();
}
private function clean_data($data) {
if (isset($data['order_total'])) {
$data['order_total'] = $this->parse_number($data['order_total']);
}
if (isset($data['item_refund'])) {
$data['item_refund'] = $this->parse_number($data['item_refund']);
}
if (isset($data['shipping_charges'])) {
$data['shipping_charges'] = $this->parse_number($data['shipping_charges']);
}
if (isset($data['refund_amount'])) {
$data['refund_amount'] = $this->parse_number($data['refund_amount']);
}
return $data;
}
private function parse_number($num) {
$num = str_replace(',', '.', $num);
$num = str_replace(' ', '', $num);
return $num;
}
private function validate($data) {
if ($data['refund_type'] == '1') {
return true;
}
return is_numeric($data['refund_amount']);
}
}
@@ -0,0 +1,79 @@
<?php
/**
* @version $Id: admin_price_search_engine_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/export.class.php';
include_once './core/structure.class.php';
include_once './core/customer_group.class.php';
include_once './modules/list_and_edit.class.php';
class admin_price_search_engine_editor {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->list_object = new ListAndEdit($base_object, $layout_object);
}
function run() {
//$this->setup_info();
//var_dump($GLOBALS);
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// get customer groups
$customer_group_object = new Customer_group($this->base_object);
$customer_groups = $customer_group_object->get_all_groups();
$this->layout_object->assign('customer_groups', $customer_groups);
// get all structure tree
$structure_object = new Structure($this->base_object);
$structure_tree = $structure_object->get_all_tree_full_path();
$this->layout_object->assign('structure_tree', $structure_tree);
// decide what CRUD method to call and call it in ListAndEdit
// create
$export_object = new Export($this->base_object);
if($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$export_object->id = $_GET['id'];
$data = $export_object->get_data();
$this->layout_object->assign('form_data', $data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$export_object->id = $_POST['id'];
$form_data = $export_object->data_filter($_POST['form_field']);
$export_object->update($form_data);
$export_object->update_selected_structure($_POST['structure_ids']);
$data = $export_object->get_data();
$this->layout_object->assign('form_data', $data);
}
return $this->layout_object->fetch('admin_price_search_engine_editor.tpl');
}
}
?>
+198
View File
@@ -0,0 +1,198 @@
<?php
/**
* @version $Id: admin_retail_sale_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/retail_sale.class.php';
class admin_retail_sale_editor {
private $base_object;
private $layout_object;
private $retail_sale_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->retail_sale_object = new Retail_sale($base_object);
} // end __construct
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == "get_tab") {
$this->get_tab($id);
} elseif ($action == "view_stat") {
$this->view_stat($id);
} elseif ($action == "update") {
$this->update($id);
} elseif ($action == "add_item") {
$this->add_item($id);
} elseif ($action == "delete_item") {
$this->delete_item($id);
} else {
return $this->setup_list($id);
}
} // end run
private function setup_list($id) {
$today = '';
if ($id) {
$data = $this->retail_sale_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Diese Statistik existiert nicht.");
}
}
else {
// get today date
$today = date("d.m.Y", time());
}
$this->layout_object->assign('today', $today);
return $this->layout_object->fetch('admin_retail_sale_editor.tpl');
} // end default_action
private function view_stat($id) {
if ($id) {
$data = $this->retail_sale_object->get_by_id($id);
$data->item_list = array_reverse($data->item_list);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}
}
elseif(!$id && $_POST['date']) {
$date = substr($_POST['date'],6,4).'-'.substr($_POST['date'],3,2).'-'.substr($_POST['date'],0,2);
$id = $this->retail_sale_object->get_id_by_date($date);
if(!$id) {
$id = $this->retail_sale_object->create_new($date);
}
// get data
$data = $this->retail_sale_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
$today = substr($data->date,8,2).'.'.substr($data->date,5,2).'.'.substr($data->date,0,4);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}
}
//$data = $this->retail_sale_object->get_by_id($id);
/*if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Es ist ein Fehler aufgetreten.");
}*/
echo $this->layout_object->fetch('admin_retail_sale_view.tpl');
exit();
}
// only used in ajax, so i terminate with exit
private function update($id) {
$data = array();
$item_amount = $_POST['item_amount'];
$item_price_sum = str_replace(',','.',$_POST['item_price_sum']);
$item_id = $_POST['item_id'];
$data['items'] = array();
for ($i=0;$i < count($item_id);$i++) {
$data['items'][] = array(
'item_id' => $item_id[$i],
'amount' => $item_amount[$i],
'price_sum' => $item_price_sum[$i]
);
}
if (isset($_POST['ec_sum'])) {
$data['ec_sum'] = str_replace(',','.',$_POST['ec_sum']);
if ($data['id'] == '') {
unset($data['id']);
}
$this->retail_sale_object->set_id($id);
$result = $this->retail_sale_object->update($data);
if ($result) {
$return = array('status' => 'success', 'id' => $result);
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
} else {
$return = array('status' => 'error', 'message' => 'no forms data');
}
echo json_encode($return);
exit();
} // end save
// only used in ajax, so i terminate with exit
private function add_item($id) {
$data = array();
$this->retail_sale_object->set_id($id);
$data['item_id'] = $_POST['item_id'];
$data['amount'] = $_POST['amount'];
$data['price_sum'] = str_replace(',','.',$_POST['price_sum']);
$data['inventory_object_id'] = $id;
//$data['create_time'] = '2011-03-25 00:00:00';
$result = $this->retail_sale_object->add_item($data);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
echo json_encode($return);
exit();
} // end save
// only used in ajax, so i terminate with exit
private function delete_item($id) {
$this->retail_sale_object->set_id($id);
$result = $this->retail_sale_object->delete_item($_POST['item_id']);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
echo json_encode($return);
exit();
} // end save
} // end
+133
View File
@@ -0,0 +1,133 @@
<?php
/**
* Carteasy – Admin: Widerrufsliste
*
* Simple Liste aller Widerrufs-Datensätze mit Filter + Action "processed".
* Zugriff: /index.php?admin_modul=admin_revocation_list
*
* @copyright Wlanium / Thomas Bartelt
* @since 2026-04-19
*/
include_once './core/revocation.class.php';
class admin_revocation_list {
private $base_object;
private $layout_object;
private $revocation;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->revocation = new Revocation($base_object);
}
public function run() {
// Action: als bearbeitet markieren
if ($_SERVER['REQUEST_METHOD'] === 'POST'
&& isset($_POST['action'])
&& $_POST['action'] === 'mark_processed'
&& !empty($_POST['id'])
) {
$this->revocation->mark_processed(
(int)$_POST['id'],
(string)($_POST['note'] ?? '')
);
// PRG
header('Location: /index.php?admin_modul=admin_revocation_list&done=1');
exit;
}
$filter_status = isset($_GET['status']) ? (string)$_GET['status'] : '';
$rows = $this->revocation->list_all($filter_status ?: null, 500);
return $this->render($rows, $filter_status, !empty($_GET['done']));
}
private function render($rows, $filter, $just_done) {
$h = function($s) { return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); };
$html = '<div style="padding:20px;font-family:Arial,sans-serif;">';
$html .= '<h1 style="color:#c00;">Widerrufsliste</h1>';
$html .= '<p style="color:#666;">Elektronische Widerrufe nach EU-RL 2026/2673. '
. 'Alle B2C-Bestellungen seit Aktivierung des Features.</p>';
if ($just_done) {
$html .= '<div style="background:#e7f7e7;border-left:4px solid #2a7;'
. 'padding:10px 14px;margin:12px 0;">Als bearbeitet markiert.</div>';
}
// Filter
$html .= '<form method="get" style="margin:16px 0;">'
. '<input type="hidden" name="admin_modul" value="admin_revocation_list">'
. '<label>Status: '
. '<select name="status" onchange="this.form.submit()">'
. '<option value="">alle</option>';
foreach (['pending','submitted','processed','expired','revoked_by_admin'] as $st) {
$sel = ($st === $filter) ? ' selected' : '';
$html .= '<option value="'.$st.'"'.$sel.'>'.$st.'</option>';
}
$html .= '</select></label></form>';
if (empty($rows)) {
$html .= '<p><em>Keine Einträge gefunden.</em></p></div>';
return $html;
}
$html .= '<table style="width:100%;border-collapse:collapse;font-size:.9em;">'
. '<thead><tr style="background:#f0f0f0;text-align:left;">'
. '<th style="padding:8px;">ID</th>'
. '<th style="padding:8px;">Bestellnr.</th>'
. '<th style="padding:8px;">Kunde (E-Mail)</th>'
. '<th style="padding:8px;">Status</th>'
. '<th style="padding:8px;">Bestelldatum</th>'
. '<th style="padding:8px;">Widerruf am</th>'
. '<th style="padding:8px;">Owner-Mail</th>'
. '<th style="padding:8px;">Aktion</th>'
. '</tr></thead><tbody>';
foreach ($rows as $r) {
$badge_color = [
'pending' => '#999',
'submitted' => '#c00',
'processed' => '#2a7',
'expired' => '#888',
'revoked_by_admin'=> '#555',
][$r->status] ?? '#555';
$html .= '<tr style="border-bottom:1px solid #eee;">'
. '<td style="padding:8px;">'.(int)$r->id.'</td>'
. '<td style="padding:8px;">'.$h($r->order_number ?: '#'.$r->order_id).'</td>'
. '<td style="padding:8px;">'.$h($r->customer_email).'</td>'
. '<td style="padding:8px;"><span style="background:'.$badge_color
. ';color:#fff;padding:2px 8px;border-radius:3px;font-size:.85em;">'
. $h($r->status).'</span></td>'
. '<td style="padding:8px;">'.$h($r->order_date).'</td>'
. '<td style="padding:8px;">'.$h($r->submitted_at ?? '–').'</td>'
. '<td style="padding:8px;">'.$h($r->owner_notified_at ? '✓' : '–').'</td>'
. '<td style="padding:8px;">';
if ($r->status === 'submitted') {
$html .= '<form method="post" style="display:inline;" '
. 'onsubmit="return confirm(\'Als bearbeitet markieren?\')">'
. '<input type="hidden" name="admin_modul" value="admin_revocation_list">'
. '<input type="hidden" name="action" value="mark_processed">'
. '<input type="hidden" name="id" value="'.(int)$r->id.'">'
. '<button type="submit" style="background:#2a7;color:#fff;'
. 'border:0;padding:6px 12px;border-radius:3px;cursor:pointer;">'
. 'processed</button></form>';
} elseif ($r->status === 'processed') {
$html .= '<span style="color:#2a7;">abgeschlossen</span>';
} else {
$html .= '–';
}
$html .= '</td></tr>';
}
$html .= '</tbody></table></div>';
return $html;
}
}
+36
View File
@@ -0,0 +1,36 @@
<?php
include_once './core/search.class.php';
class admin_search {
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
}
function run() {
$search = $_GET['search'];
$customers = Search::customers($search);
$this->layout_object->assign('customer_hits', $customers['hits']);
$this->layout_object->assign('customer_search', $customers['results']);
$orders = Search::orders($search);
$this->layout_object->assign('order_hits', $orders['hits']);
$this->layout_object->assign('order_search', $orders['results']);
$items = Search::items($search);
$this->layout_object->assign('item_hits', $items['hits']);
$this->layout_object->assign('item_search', $items['results']);
$manufacturers = Search::manufacturers($search);
$this->layout_object->assign('manufacturer_hits', $manufacturers['hits']);
$this->layout_object->assign('manufacturer_search', $manufacturers['results']);
echo $this->layout_object->fetch('admin_search.tpl');
}
}
+133
View File
@@ -0,0 +1,133 @@
<?php
/**
* @version $Id: admin_seo.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/metatag.class.php';
class admin_seo {
private $base_object;
private $layout_object;
private $manufacturer_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
} // end __construct
function run() {
if (isset($_POST['action']) && $_POST['action'] == 'save_analytics_code') {
$this->save_analytics_code();
}
else if (isset($_GET['action']) && $_GET['action'] == 'save_metatags') {
$this->save_metatags();
}
else {
return $this->default_action();
}
}
private function default_action() {
// get default metatags
$metatag_object = new Metatag(false, $this->base_object);
$metatags = $metatag_object->get_all_metatags_by_group('DEFAULT');
$this->layout_object->assign('metatags', $metatags);
$item_structure_metatags = $metatag_object->get_all_metatags_by_group('MENU');
$this->layout_object->assign('item_structure_metatags', $item_structure_metatags);
$item_structure_metatags = $metatag_object->get_all_metatags_by_group('MENU1');
$this->layout_object->assign('item_structure_metatags1', $item_structure_metatags);
$item_structure_metatags = $metatag_object->get_all_metatags_by_group('MENU2');
$this->layout_object->assign('item_structure_metatags2', $item_structure_metatags);
$item_structure_metatags = $metatag_object->get_all_metatags_by_group('MENU3');
$this->layout_object->assign('item_structure_metatags3', $item_structure_metatags);
$item_structure_metatags = $metatag_object->get_all_metatags_by_group('MENU4');
$this->layout_object->assign('item_structure_metatags4', $item_structure_metatags);
$item_details_metatags = $metatag_object->get_all_metatags_by_group('ARTIKEL');
$this->layout_object->assign('item_details_metatags', $item_details_metatags);
return $this->layout_object->fetch('admin_seo.tpl');
}
private function save_analytics_code() {
if (isset($_POST['google_analytics_code'])) {
$this->base_object->config->update_config_element('google_analytics_code', $_POST['google_analytics_code']);
$return['status'] = 'success';
$return['message'] = 'Google Analytics Code gespeichert!';
} else {
$return['status'] = 'error';
$return['message'] = 'Kein Argument übergeben.';
}
echo json_encode($return);
}
private function save_metatags() {
if (isset($_POST['metatag_field'])) {
$metatag_object = new Metatag(false, $this->base_object);
$default_data = array();
$item_details_data = array();
$structure_data = array();
$structure_data1 = array();
$structure_data2 = array();
$structure_data3 = array();
$structure_data4 = array();
foreach($_POST['metatag_field'] as $key => $value) {
if (substr($key, 0, 10) == 'structure_') {
$structure_data[substr($key,10)] = $value;
}
elseif (substr($key, 0, 11) == 'structure1_') {
$structure_data1[substr($key,11)] = $value;
}
elseif (substr($key, 0, 11) == 'structure2_') {
$structure_data2[substr($key,11)] = $value;
}
elseif (substr($key, 0, 11) == 'structure3_') {
$structure_data3[substr($key,11)] = $value;
}
elseif (substr($key, 0, 11) == 'structure4_') {
$structure_data4[substr($key,11)] = $value;
}
elseif(substr($key, 0, 13) == 'item__detail_') {
$item_details_data[substr($key,13)] = $value;
}
else {
$default_data[$key] = $value;
}
}
$metatags = $metatag_object->save_metatags('DEFAULT', $default_data);
$metatags = $metatag_object->save_metatags('ARTIKEL', $item_details_data);
$metatags = $metatag_object->save_metatags('MENU', $structure_data);
$metatags = $metatag_object->save_metatags('MENU1', $structure_data1);
$metatags = $metatag_object->save_metatags('MENU2', $structure_data2);
$metatags = $metatag_object->save_metatags('MENU3', $structure_data3);
$metatags = $metatag_object->save_metatags('MENU4', $structure_data4);
$return['status'] = 'success';
$return['message'] = 'Metatags gespeichert!!';
} else {
$return['status'] = 'error';
$return['message'] = 'Kein Argument übergeben.';
}
echo json_encode($return);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
class admin_setting_editor {
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
if(isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = '';
}
if($action == 'submit' && isset($_POST['form_data'])) {
$form_data = $_POST['form_data'];
$this->base_object->customer->set_config_item('admin_language', $form_data['language']);
header('Location: '.$_SERVER['REQUEST_URI']);
exit();
}
$this->layout_object->assign('admin_language', $this->base_object->customer->get_config_item('admin_language'));
$this->layout_object->assign('language_selection', $this->base_object->i18n->admin_language_code_iso639);
return $this->layout_object->fetch('admin_setting_editor.tpl');
}
}
+373
View File
@@ -0,0 +1,373 @@
<?php
/**
* @version $Id: admin_shipping_area_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/shipping_area.class.php';
include_once './core/deliverer.class.php';
include_once './core/customer_group.class.php';
include_once './core/customergrouppmconf.class.php';
class admin_shipping_area_editor {
private $base_object;
private $config;
private $layout_object;
private $customer_group_object;
private $customer_group_data;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->customer_group_object = new Customer_group($base_object);
$this->customer_group_data = $this->customer_group_object->get_all();
}
function run() {
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
$id = $_GET['id'];
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
$id = $_POST['id'];
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
$customer_groups = $this->customer_group_object->get_all();
$this->layout_object->assign('groups', $customer_groups);
// get deliverer
$deliverer_object = new Deliverer($this->base_object);
$deliverers = $deliverer_object->get_all();
$this->layout_object->assign('deliverers', $deliverers);
// decide what CRUD method to call and call it in ListAndEdit
// create
$shipping_area_object = new Shipping_area($this->base_object);
if($is_submitted && !$has_id) {
$form_data = $shipping_area_object->data_filter($_POST['form_field']);
$shipping_area_object->create($form_data);
$shipping_area_data = $shipping_area_object->get_data();
// MUST BE saved first
// $this->load_payment_method_setings($shipping_area_data);
// $this->save_payment_method_setings();
$this->layout_object->assign('form_data', $shipping_area_data);
}// read
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$shipping_area_object->id = $_GET['id'];
$shipping_area_data = $shipping_area_object->get_data();
$this->load_payment_method_setings($shipping_area_data);
$this->layout_object->assign('form_data', $shipping_area_data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$shipping_area_object->id = $_POST['id'];
$form_data = $shipping_area_object->data_filter($_POST['form_field']);
$shipping_area_object->update($form_data);
$this->save_payment_method_setings($id);
$shipping_area_data = $shipping_area_object->get_data();
$this->load_payment_method_setings($shipping_area_data);
$this->layout_object->assign('form_data', $shipping_area_data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$shipping_area_object->id = $_GET['id'];
$shipping_area_object->delete();
}
else {
}
return $this->layout_object->fetch('admin_shipping_area_editor.tpl');
}
private function save_payment_method_setings($id) {
if (isset($_POST['form_field'])) {
$pm = $_POST['form_field'];
}
// Vorauskasse
if (isset($pm['active_vk']) && $pm['active_vk'] == 2) {
$prepayment = $_POST['prepayment'];
$data = $this->make_save_array($prepayment);
$pm_id = 1;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Nachnahme
if (isset($pm['active_nn']) && $pm['active_nn'] == 2) {
$collect_on_delivery = $_POST['collect_on_delivery'];
$data = $this->make_save_array($collect_on_delivery);
$pm_id = 2;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Paypal
if (isset($pm['active_pp']) && $pm['active_pp'] == 2) {
$paypal = $_POST['paypal'];
$data = $this->make_save_array($paypal);
$pm_id = 4;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Rechnung
if (isset($pm['active_r']) && $pm['active_r'] == 2) {
$invoice = $_POST['invoice'];
$data = $this->make_save_array($invoice);
$pm_id = 3;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Bankeinzug
if (isset($pm['active_be']) && $pm['active_be'] == 2) {
$direct_debit = $_POST['direct_debit'];
$data = $this->make_save_array($direct_debit);
$pm_id = 6;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Barverkauf
if (isset($pm['active_bar']) && $pm['active_bar'] == 2) {
$cash = $_POST['cash'];
$data = $this->make_save_array($cash);
$pm_id = 7;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Klarna Rechnung
if (isset($pm['active_klarna_rechnung']) && $pm['active_klarna_rechnung'] == 2) {
$klarna_re = $_POST['klarna_re'];
$data = $this->make_save_array($klarna_re);
$pm_id = 8;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// Klarna Raten
if (isset($pm['active_klarna_raten']) && $pm['active_klarna_raten'] == 2) {
$klarna_ra = $_POST['klarna_ra'];
$data = $this->make_save_array($klarna_ra);
$pm_id = 9;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// paymorrow Rechnung
if (isset($pm['active_paymorrow_rechnung']) && $pm['active_paymorrow_rechnung'] == 2) {
$paymorrow_re = $_POST['paymorrow_re'];
$data = $this->make_save_array($paymorrow_re);
$pm_id = 10;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// paymorrow Raten
if (isset($pm['active_paymorrow_raten']) && $pm['active_paymorrow_raten'] == 2) {
$paymorrow_ra = $_POST['paymorrow_ra'];
$data = $this->make_save_array($paymorrow_ra);
$pm_id = 11;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// billpay invoice
if (isset($pm['active_billpay_invoice']) && $pm['active_billpay_invoice'] == 2) {
$billpay_invoice = $_POST['billpay_invoice'];
$data = $this->make_save_array($billpay_invoice);
$pm_id = 12;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// computop creditcard
if (isset($pm['active_computop_creditcard']) && $pm['active_computop_creditcard'] == 2) {
$computop_creditcard = $_POST['computop_creditcard'];
$data = $this->make_save_array($computop_creditcard);
$pm_id = 13;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
// customized
if (isset($pm['active_customized']) && $pm['active_customized'] == 2) {
$customized = $_POST['customized'];
$data = $this->make_save_array($customized);
$pm_id = 14;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$prepayment_conf->save_array($data);
}
}
private function make_save_array($data) {
foreach($this->customer_group_data as $customer_group) {
if (isset($data[$customer_group->id])) {
$tmp['group'] = $customer_group->id;
$tmp['active'] = '1';
$return[] = $tmp;
} else {
$tmp['group'] = $customer_group->id;
$tmp['active'] = '0';
$return[] = $tmp;
}
}
return $return;
}
private function load_payment_method_setings($data) {
$id = $data->id;
// Vorauskasse
if ($data->active_vk == '2') {
$pm_id = 1;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('prepayment', $mydata);
}
// Nachnahme
if ($data->active_nn == '2') {
$pm_id = 2;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('collect_on_delivery', $mydata);
}
// Paypal
if ($data->active_pp == '2') {
$pm_id = 4;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('paypal', $mydata);
}
// Rechnung
if ($data->active_r == '2') {
$pm_id = 3;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('invoice', $mydata);
}
// Bankeinzug
if ($data->active_be == '2') {
$pm_id = 6;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('direct_debit', $mydata);
}
// Barverkauf
if ($data->active_bar == '2') {
$pm_id = 7;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('cash', $mydata);
}
// Klarna Rechnung
if ($data->active_klarna_rechnung == '2') {
$pm_id = 8;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('klarna_re', $mydata);
}
// Klarna Raten
if ($data->active_klarna_raten == '2') {
$pm_id = 9;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('klarna_ra', $mydata);
}
// paymorrow Rechnung
if ($data->active_paymorrow_rechnung == '2') {
$pm_id = 10;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('paymorrow_re', $mydata);
}
// paymorrow Raten
if ($data->active_paymorrow_raten == '2') {
$pm_id = 11;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('paymorrow_ra', $mydata);
}
// billpay invoice
if ($data->active_billpay_invoice == '2') {
$pm_id = 12;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('billpay_invoice', $mydata);
}
// computop creditcard
if ($data->active_computop_creditcard == '2') {
$pm_id = 13;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('computop_creditcard', $mydata);
}
// customized
if ($data->active_customized == '2') {
$pm_id = 14;
$prepayment_conf = new CustomerGroupPMConf($pm_id, $id);
$mydata = $prepayment_conf->get_all();
$this->layout_object->assign('customized', $mydata);
}
}
}
?>
+128
View File
@@ -0,0 +1,128 @@
<?php
include_once './core/structure.class.php';
include_once './core/site_content.class.php';
class admin_site_designer{
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$structure = new Structure($this->base_object);
$siteContent = new SiteContent($this->base_object);
if (isset($_GET['id'])) {
$id = (int)$_GET['id'];
if ($structure->is_set($id)){
$config = $siteContent->get_by_structure_id($id);
if($config == false) {
$this->layout_object->assign('info_message', 'Diese Seite wurde noch nicht konfiguriert.');
$this->layout_object->assign('textbox_num', '1');
$this->layout_object->assign('textbox_activ', 0);
$this->layout_object->assign('slider_num', '2');
$this->layout_object->assign('slider_activ', 0);
$this->layout_object->assign('article_list_num', '3');
$this->layout_object->assign('article_list_activ', 0);
$this->layout_object->assign('featured_num', '4');
$this->layout_object->assign('featured_activ', 0);
$this->layout_object->assign('manufacturers_num', '5');
$this->layout_object->assign('manufacturers_activ', 0);
} else {
foreach($config as $obj) {
if($obj->type == 'textbox') {
$this->layout_object->assign('textbox_num', $obj->position);
$this->layout_object->assign('textbox_activ', (int)$obj->activ);
$this->layout_object->assign('textbox_content', $obj->content);
} elseif($obj->type == 'slider') {
$this->layout_object->assign('slider_num', $obj->position);
$this->layout_object->assign('slider_activ', (int)$obj->activ);
$this->layout_object->assign('slider_content', $obj->content);
} elseif($obj->type == 'article_list') {
$this->layout_object->assign('article_list_num', $obj->position);
$this->layout_object->assign('article_list_activ', (int)$obj->activ);
$this->layout_object->assign('article_list_content', $obj->content);
} elseif($obj->type == 'featured') {
$this->layout_object->assign('featured_num', $obj->position);
$this->layout_object->assign('featured_activ', (int)$obj->activ);
$this->layout_object->assign('featured_content', $obj->content);
} elseif($obj->type == 'manufacturers') {
$this->layout_object->assign('manufacturers_num', $obj->position);
$this->layout_object->assign('manufacturers_activ', (int)$obj->activ);
}
}
}
$this->layout_object->assign('id', $id);
$this->layout_object->assign('item_cats', $structure->get_all_item_categories());
$this->layout_object->assign('site_info', true);
} else {
$this->layout_object->assign('error_message', 'Die von ihnen angegebenen Seiten ID ist im System nicht vorhanden.');
}
return $this->get_layout();
} else {
if (isset($_GET['mod']) && $_GET['mod'] == 'ajax') {
if (isset($_GET['set']) && $_GET['set'] == 'widgets') {
$id = $_POST['id'];
$textbox = 'textbox';
$textbox_activ = $_POST['content_box_textbox'] ? 1 : 0;
$textbox_num = $_POST['textbox_num'];
$textbox_content = $_POST['content_box_textbox_body'] ? $_POST['content_box_textbox_body'] : '';
$slider = 'slider';
$slider_activ = $_POST['content_box_slider'] ? 1 : 0;
$slider_num =$_POST['slider_num'];
$slider_content = $_POST['cat_id'] ? $_POST['cat_id'] : '';
$article_list = 'article_list';
$article_list_activ = $_POST['content_box_article_list'] ? 1 : 0;
$article_list_num = $_POST['article_list_num'];
$article_list_content = $_POST['article_list_style'] ? $_POST['article_list_style'] : '0';
$featured = 'featured';
$featured_activ = $_POST['content_box_featured'] ? 1 : 0;
$featured_num = $_POST['featured_num'];
$featured_content = $_POST['item_id'] ? $_POST['item_id'] : '0';
$banner = 'banner';
$banner_activ = $_POST['content_box_banner'] ? 1 : 0;
$banner_num = $_POST['banner_num'];
$banner_content = $_POST['banner_link'] ? $_POST['banner_link'] : '0';
$manufacturers = 'manufacturers';
$manufacturers_activ = $_POST['content_box_manufacturers'] ? 1 : 0;
$manufacturers_num = $_POST['manufacturers_num'];
if ($siteContent->get_by_structure_id($id) == false) {
$siteContent->insert_by_structure_id($id, $textbox, $textbox_num, $textbox_activ, $textbox_content);
$siteContent->insert_by_structure_id($id, $slider, $slider_num, $slider_activ, $slider_content);
$siteContent->insert_by_structure_id($id, $article_list, $article_list_num, $article_list_activ, $article_list_content);
$siteContent->insert_by_structure_id($id, $featured, $featured_num, $featured_activ, $featured_content);
$siteContent->insert_by_structure_id($id, $banner, $banner_num, $banner_activ, $banner_content);
$siteContent->insert_by_structure_id($id, $manufacturers, $manufacturers_num, $manufacturers_activ, '');
} else {
$siteContent->update_by_structure_id($id, $textbox, $textbox_num, $textbox_activ, $textbox_content);
$siteContent->update_by_structure_id($id, $slider, $slider_num, $slider_activ, $slider_content);
$siteContent->update_by_structure_id($id, $article_list, $article_list_num, $article_list_activ, $article_list_content);
$siteContent->update_by_structure_id($id, $featured, $featured_num, $featured_activ, $featured_content);
$siteContent->update_by_structure_id($id, $banner, $banner_num, $banner_activ, $banner_content);
$siteContent->update_by_structure_id($id, $manufacturers, $manufacturers_num, $manufacturers_activ, '');
}
} else {
echo 'FEHLER';
}
} else {
$this->layout_object->assign('site_list', $structure->get_all_item_categories());
return $this->get_layout();
}
}
}
function get_layout() {
return $this->layout_object->fetch('admin_site_designer.tpl');
}
}
+115
View File
@@ -0,0 +1,115 @@
<?php
/**
* @version $Id: admin_standard_message_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/standard_message.class.php';
include_once './modules/list_and_edit.class.php';
class admin_standard_message_editor {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config_object;
$this->layout_object = $layout_object;
$this->list_object = new ListAndEdit($base_object, $layout_object);
}
function run() {
//$this->setup_info();
//var_dump($GLOBALS);
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// get customer groups
$customer_group_object = new Customer_group($this->base_object);
$customer_groups = $customer_group_object->get_all_groups();
$this->layout_object->assign('customer_groups', $customer_groups);
// decide what CRUD method to call and call it in ListAndEdit
// create
$standard_message_object = new Standard_message($this->base_object);
$this->layout_object->assign('events', $standard_message_object->events);
if($is_submitted && !$has_id) {
$form_data = $standard_message_object->data_filter($_POST['form_field']);
$standard_message_object->create($form_data);
$standard_data = $standard_message_object->get_data();
$this->layout_object->assign('form_data', $standard_data);
}// read
// delete file
elseif ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'delete_file') {
$standard_message_object->id = $_POST['id'];
$standard_message_object->delete_file($_POST['file_id']);
$file_list = $standard_message_object->get_file_list();
$this->layout_object->assign('file_list', $file_list);
return $this->layout_object->fetch('admin_standard_message_editor_filelist.tpl');
} // upload file
elseif ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'add_file') {
$standard_message_object->id = $_POST['id'];
$standard_message_object->add_uploaded_file($_FILES);
} // get file list
elseif ($has_id && isset($_POST['mod']) && $_POST['mod'] == 'get_file_list') {
$standard_message_object->id = $_POST['id'];
$file_list = $standard_message_object->get_file_list();
$this->layout_object->assign('file_list', $file_list);
return $this->layout_object->fetch('admin_standard_message_editor_filelist.tpl');
} // get file
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'file_load'){
$file = $standard_message_object->get_file($_GET['file_id']);
$mime_type = $file->mime_type;
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: $mime_type");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=".$file->file_name);
header("Content-Transfer-Encoding: binary");
echo $file->content;
exit();
}
elseif($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$standard_message_object->id = $_GET['id'];
$standard_data = $standard_message_object->get_data();
$this->layout_object->assign('form_data', $standard_data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$standard_message_object->id = $_POST['id'];
$form_data = $standard_message_object->data_filter($_POST['form_field']);
$standard_message_object->update($form_data);
$standard_data = $standard_message_object->get_data();
$this->layout_object->assign('form_data', $standard_data);
} // delete
elseif($has_id && isset($_GET['mod']) && $_GET['mod'] == 'delete'){
$standard_message_object->id = $_GET['id'];
$standard_message_object->delete();
}
else {
}
return $this->layout_object->fetch('admin_standard_messages_editor.tpl');
}
}
?>
+282
View File
@@ -0,0 +1,282 @@
<?php
/**
* @version $Id: admin_shoptheme_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rkd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/statistic.class.php';
class admin_statistic_editor {
private $base_object;
private $layout_object;
private $statistic_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->statistic_object = new Statistic($base_object);
} // end __construct
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == "get_tab") {
$this->get_tab($id);
} elseif ($action == "view_stat") {
$this->view_stat($id);
} elseif ($action == "get_csv") {
$this->get_csv($id);
} else {
return $this->setup_list($id);
}
} // end run
private function setup_list($id) {
if ($id) {
$data = $this->statistic_object->get_by_id($id);
if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Diese Statistik existiert nicht.");
}
}
// implied else, no action taken when you create something new
$tabs = array (
'year' => 'Jahr',
'month' => 'Monat',
/*'week' => 'Woche',*/
'day' => 'Tag'
);
$stat_tabs = array();
foreach ($tabs as $tab_key => $tab_value) {
$temp['name'] = $tab_value;
$temp['id'] = $tab_key;
$temp['selector'] = $tab_key;
$stat_tabs[] = $temp;
}
$this->layout_object->assign('tabs', $stat_tabs);
return $this->layout_object->fetch('admin_statistic_editor.tpl');
} // end default_action
private function get_tab($id) {
$data = array();
if ($id) {
$data = $this->statistic_object->get_by_id($id);
// get today date
$today = getdate();
$this->layout_object->assign('today', $today);
// set years
$years = array();
for ($y=0;$y<5;$y++) {
$years[] = $today['year'] - $y;
}
$this->layout_object->assign('years', $years);
$this->layout_object->assign('tab_id', $_GET['tab_id']);
if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Diese Statistik existiert nicht.");
}
}
$this->layout_object->assign('statistic_data', $data);
echo $this->layout_object->fetch('admin_statistic_filter.tpl');
exit();
}
private function view_stat($id) {
$data = array();
if ($id) {
$tab_id = $_GET['tab_id'];
$filter = array('period' => $tab_id);
if ($tab_id == 'year') {
$year = $_POST['year'];
$filter['date_start'] = $year.'-01-01';
$filter['date_end'] = $year.'-12-31';
}
else if ($tab_id == 'month') {
$year = $_POST['year'];
$month = $_POST['month'];
$filter['date_start'] = $year.'-'.$month.'-01';
$monat = mktime(0, 0, 0, $month, 1, $year);
$max_days_of_month = date("t", $monat);
$filter['date_end'] = $year.'-'.$month.'-'.$max_days_of_month;
}
else if ($tab_id == 'week') {
$filter['date_start'] = '2012-01-01';
$filter['date_end'] = '2012-12-31';
}
else if ($tab_id == 'day') {
$year = substr($_POST['date'],6,4);
$month = substr($_POST['date'],3,2);
$day = substr($_POST['date'],0,2);
$filter['date_start'] = $year.'-'.$month.'-'.$day;
$filter['date_end'] = $year.'-'.$month.'-'.$day;
}
else {
echo "No date selected!";
exit();
}
$data = $this->statistic_object->get_by_id($id);
$this->layout_object->assign('filter', $filter);
if ($data) {
$this->layout_object->assign('form_data', $data);
} else {
$this->layout_object->assign('error_message', "Diese Statistik existiert nicht.");
}
}
// get today date
$today = getdate();
$this->layout_object->assign('today', $today);
// load modules
$module_file = 'core/statistics/'.$data->modul.'.inc.php';
$stat_modul = $data->modul;
if(file_exists($module_file)) {
include_once $module_file;
$modul_object = new $stat_modul($this->base_object);
$data->statistic_data = $modul_object->run($filter);
} else {
echo "Statistic modul not found!";
exit();
}
// Generate modern Plotly charts
$plotly_chart_bar = $this->generate_plotly_chart($data->statistic_data, $filter, 'bar');
$plotly_chart_line = $this->generate_plotly_chart($data->statistic_data, $filter, 'line');
$this->layout_object->assign('plotly_chart_bar', $plotly_chart_bar);
$this->layout_object->assign('plotly_chart_line', $plotly_chart_line);
$this->layout_object->assign('statistic_data', $data);
echo $this->layout_object->fetch('admin_statistic_view.tpl');
exit();
}
private function generate_plotly_chart($statistic_data, $filter, $chart_type = 'bar') {
// Prepare data for Python chart service
$chart_config = array(
'type' => $chart_type,
'title' => ($chart_type == 'bar' ? 'Säulendiagramm' : 'Liniendiagramm'),
'period' => $filter['period']
);
$input_data = array(
'data' => $statistic_data,
'config' => $chart_config
);
$json_input = json_encode($input_data);
// Call Python chart service
$python_script = ROOT_DIR . 'modules/import/chart_service.py';
$command = "echo " . escapeshellarg($json_input) . " | python3 " . escapeshellarg($python_script) . " 2>&1";
$output = shell_exec($command);
if (empty($output)) {
return '<div style="padding: 20px; background: #fee; border: 1px solid #fcc;">Chart-Generierung fehlgeschlagen</div>';
}
return $output;
}
private function get_csv($id) {
if ($id) {
$tab_id = $_GET['tab_id'];
$filter = array('period' => $tab_id);
$filter['date_start'] = $_GET['date_start'];
$filter['date_end'] = $_GET['date_end'];
$data = $this->statistic_object->get_by_id($id);
}
// load modules
$module_file = 'core/statistics/'.$data->modul.'.inc.php';
$stat_modul = $data->modul;
if(file_exists($module_file)) {
include_once $module_file;
$modul_object = new $stat_modul($this->base_object);
$data->statistic_data = $modul_object->run($filter);
} else {
echo "Statistic modul not found!";
exit();
}
$csv = '';
foreach ($data->statistic_data as $row) {
$csv .= implode(";",$row)."\r\n";
}
$csv = utf8_decode($csv);
echo $csv;
$application="text/csv";
header( "Content-Type: $application" );
header( "Content-Disposition: attachment; filename=statistik.csv");
header( "Content-Description: csv File" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
exit();
}
// only used in ajax, so i terminate with exit
private function save() {
if (isset($_POST['form_field'])) {
$data = $_POST['form_field'];
if ($data['id'] == '') {
unset($data['id']);
}
$result = $this->statistic_object->save($data);
if ($result) {
$return = array('status' => 'success', 'id' => $result);
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
} else {
$return = array('status' => 'error', 'message' => 'no forms data');
}
echo json_encode($return);
exit();
} // end save
} // end
+679
View File
@@ -0,0 +1,679 @@
<?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 './modules/list_and_edit.class.php';
include_once './core/structure.class.php';
include_once './core/site_content.class.php';
include_once './core/manufacturer.class.php';
include_once './core/customer_group.class.php';
include_once './core/shop_theme.class.php';
class admin_structure {
private $base_object;
private $layout_object;
private $config;
private $structure_object;
private $site_content_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->config = $base_object->config_object;
$this->structure_object = new Structure($base_object);
$this->site_content_object = new SiteContent($base_object);
$this->customer_group_object = new Customer_group($base_object);
}
function run() {
if (isset($_GET['id'])) {
$id = $_GET['id'];
} else if (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else if (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if ($action == 'delete') {
$this->del($id);
} else if ($action == 'save_site') {
$this->save_site($id);
} else if ($action == 'save_discount') {
$this->save_discount($id);
} else if ($action == 'get_discount') {
$this->get_discount($id, $_POST['customerGroup']);
} else if ($action == 'save_layout') {
$this->save_layout($id);
} else if ($action == 'get_sub_structure') {
$this->get_sub_structure($id);
} else if ($action == 'upload_banner') {
$this->upload_banner($id);
} else if ($action == 'upload_textbox_image') {
$this->upload_textbox_image($id);
} else if ($action == 'get_banner') {
$this->get_banner($id);
} else if ($action == 'delete_banner') {
$this->delete_banner($id, $_GET['banner_image']);
} else if ($action == 'delete_textbox_image') {
$this->delete_textbox_image($id);
} else if ($action == 'set_configuration_type') {
$this->set_configuration_type($id);
} else if ($action == 'copy') {
return $this->edit($id, true);
} else if ($action == 'upload') {
$this->upload($id);
} else if ($action == 'delete_image') {
$this->delete_image($id);
} else if ($action == 'upload_header_image') {
$this->upload_header_image($id);
} else if ($action == 'delete_header_image') {
$this->delete_header_image($id);
} else {
return $this->edit($id);
}
}
private function delete_image($id) {
if ($id) {
if ($this->structure_object->set_image($id, '')) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function delete_header_image($id) {
if ($id) {
if ($this->structure_object->set_header_image($id, '')) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function upload_header_image($id) {
if ($id) {
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file != '') {
$result = $this->structure_object->save_header_image($id, $temp_file);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: can't save", 'data', $result);
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no file');
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no id');
}
echo json_encode($return);
exit();
} // end upload
private function upload($id) {
if ($id) {
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file != '') {
$result = $this->structure_object->save_image($id, $temp_file);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: can't save", 'data', $result);
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no file');
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no id');
}
echo json_encode($return);
exit();
} // end upload
private function save_discount($id) {
if (isset($_POST)) {
$form_data = $_POST['form_field'];
} else {
$form_data = false;
}
if ($form_data) {
if ($id) {
// todo save discounts
$form_data['structure_id'] = $id;
$manufacturer_object = new Manufacturer($this->base_object);
$manufacturer_list = $manufacturer_object->get_all_active();
$save_request = $this->structure_object->save_discounts($form_data, $manufacturer_list);
if (!isset($save_request['error'])) {
$return_data = array('status' => 'success', 'data' => true);
} else {
$message_text = $save_request['error'];
$return_data = array('status' => 'error', 'message' => $message_text, 'save_errors' => $save_errors);
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no data');
}
echo json_encode($return_data);
exit();
}
private function get_discount($structure_id, $customer_group_id) {
$discounts = $this->structure_object->get_discounts($structure_id, $customer_group_id);
// get manufacturer
$manufacturer_object = new Manufacturer($this->base_object);
$manufacturer_list = $manufacturer_object->get_all_active();
$data = array();
foreach ($manufacturer_list as $obj) {
$data[$obj->id] = (isset($discounts[$obj->id]))? $discounts[$obj->id] : 0;
}
$return_data = array('status' => 'success', 'message' => '', 'discounts' => $data);
echo json_encode($return_data);
exit();
}
// needs some more work
private function upload_banner($id) {
$result = $this->site_content_object->add_banner($_FILES, $id);
if ($result) {
$return_array = array('status' => 'success', 'path' => '/web/'.SHOP_SYSTEM.'/images/site/', 'image' => $result);
} else {
$return_array = array('status' => 'error', 'message' => 'no result');
}
echo json_encode($return_array);
exit();
}
// needs some more work
private function upload_textbox_image($id) {
$result = $this->site_content_object->add_textbox_image($_FILES, $id);
if ($result) {
$return_array = array('status' => 'success', 'path' => '/web/'.SHOP_SYSTEM.'/images/site/', 'image' => $result);
} else {
$return_array = array('status' => 'error', 'message' => 'no result');
}
echo json_encode($return_array);
exit();
}
// needs some more work
private function get_banner($id) {
echo "TODO";
exit();
}
private function delete_banner($id, $image_name) {
if ($id) {
$result = $this->site_content_object->delete_banner($id, $image_name);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$return_data = array('status' => 'error', 'message' => 'no result');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return_data);
exit();
}
private function delete_textbox_image($id) {
if ($id) {
$result = $this->site_content_object->delete_textbox_image($id);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$return_data = array('status' => 'error', 'message' => 'no result');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return_data);
exit();
}
private function set_configuration_type($id) {
if (isset($_GET['checked'])) {
$is_checked = $_GET['checked'];
} else {
$is_checked = false;
}
if ($id) {
if ($is_checked !== false) {
$this->structure_object->structure_id = $id;
$result = $this->structure_object->set_site_configuration_type($is_checked);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$return_data = array('status' => 'error', 'message' => 'no result with '.$is_checked.' this argument');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no data');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return_data);
exit();
}
private function del($id) {
if ($id) {
$result = $this->structure_object->delete($id);
if ($result) {
$return_data = array('status' => 'success', 'data' => $result);
} else {
$return_data = array('status' => 'error', 'message' => 'not implemented');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
echo json_encode($return_data);
exit();
}
private function save_site($id) {
if ($id) {
// save logo
$temp_file = $_FILES['logo_image']['tmp_name'];
if ($temp_file != '') {
$result = $this->structure_object->save_image($id, $temp_file);
}
// save header
$temp_file = $_FILES['header_image']['tmp_name'];
if ($temp_file != '') {
$result = $this->structure_object->save_header_image($id, $temp_file);
}
$form_data = $this->structure_object->data_filter($_POST['form_field']);
$this->structure_object->structure_id = $id;
$return = $this->structure_object->update($form_data);
$sort_item_ids = $_POST['sort_item_id'];
$sort_item_pos = $_POST['sort_item_pos'];
$this->structure_object->update_sort($sort_item_ids, $sort_item_pos);
if ($return) {
header('location: http://'.$_SERVER['SERVER_NAME'].'/index.php?admin_modul=admin_structure&id='.$id);
exit();
}
} else {
$form_data = $this->structure_object->data_filter($_POST['form_field']);
$return_id = $this->structure_object->create($form_data);
$sort_item_ids = $_POST['sort_item_id'];
$sort_item_pos = $_POST['sort_item_pos'];
$this->structure_object->update_sort($sort_item_ids, $sort_item_pos);
if ($return_id) {
header('location: http://'.$_SERVER['SERVER_NAME'].'/index.php?admin_modul=admin_structure&id='.$return_id);
exit();
}
}
header('location: '.$_SERVER["HTTP_REFERER"]);
exit();
}
private function save_layout($id) {
if (isset($_POST)) {
$form_data = $_POST;
} else {
$form_data = false;
}
if ($form_data) {
if ($id) {
$textbox = 'textbox';
$textbox_activ = $form_data['content_box_textbox'] ? 1 : 0;
$textbox_num = $form_data['textbox_num'];
$textbox_title = $form_data['content_box_textbox_title'];
$textbox_title_style = $form_data['content_box_textbox_title_style'];
$textbox_title_en = $form_data['content_box_textbox_title_en'];
$textbox_content = $form_data['content_box_textbox_body'] ? $form_data['content_box_textbox_body'] : '';
$textbox_content_en = $form_data['content_box_textbox_body_en'] ? $form_data['content_box_textbox_body_en'] : '';
$textbox_image = array('image_name' => $form_data['textbox_image_name'],'image_position' => $form_data['textbox_image_position'], 'image_link' => $form_data['textbox_image_link']);
$slider = 'slider';
$slider_activ = $form_data['content_box_slider'] ? 1 : 0;
$slider_num = $form_data['slider_num'];
$slider_title = $form_data['content_box_slider_title'];
$slider_title_style = $form_data['content_box_slider_title_style'];
$slider_title_en = $form_data['content_box_slider_title_en'];
$slider_content = $form_data['cat_id'] ? $form_data['cat_id'] : '';
$article_list = 'article_list';
$article_list_activ = $form_data['content_box_article_list'] ? 1 : 0;
$article_list_num = $form_data['article_list_num'];
$article_list_title_style = $form_data['content_box_article_list_title_style'];
$article_list_content = $form_data['article_list_style'] ? $form_data['article_list_style'] : '0';
$banner = 'banner';
$banner_activ = $form_data['content_box_banner'] ? 1 : 0;
$banner_num = $form_data['banner_num'];
// formated banner configuration
$banner_content = array();
foreach ($form_data['banner_link'] as $key => $value) {
$banner_content[] = array(
'image_name' => $key,
'image_link' => $value,
'image_link_target' => $form_data['image_link_target'][$key]
);
}
$manufacturers = 'manufacturers';
$manufacturers_activ = $form_data['content_box_manufacturers'] ? 1 : 0;
$manufacturers_num = $form_data['manufacturers_num'];
$popular = 'popular';
$popular_num = $form_data['popular_num'];
$popular_active = $form_data['content_box_popular'] ? 1 : 0;
$popular_content = $form_data['popular_cat_id'] ? $form_data['popular_cat_id'] : '';
$substructure = 'substructure';
$substructure_num = $form_data['substructure_num'];
$substructure_title = $form_data['content_box_substructure_title'];
$substructure_title_style = $form_data['content_box_substructure_title_style'];
$substructure_title_en = $form_data['content_box_substructure_title_en'];
$substructure_active = $form_data['content_box_substructure'] ? 1 : 0;
$substructure_cat_id = $form_data['substructure_cat_id'] ? $form_data['substructure_cat_id'] : '';
$substructure_ebenen = $form_data['substructure_ebenen'] ? $form_data['substructure_ebenen'] : '';
$save_errors = false;
$textbox_result = $this->site_content_object->save_by_structure_id($id, $textbox, $textbox_num, $textbox_activ, $textbox_content, $textbox_title, $textbox_image, $textbox_content_en, $textbox_title_en, $textbox_title_style);
if (!$textbox_result) $save_errors = true;
$slider_result = $this->site_content_object->save_by_structure_id($id, $slider, $slider_num, $slider_activ, $slider_content, $slider_title, '', '', $slider_title_en, $slider_title_style);
if (!$slider_result) $save_errors = true;
$article_result = $this->site_content_object->save_by_structure_id($id, $article_list, $article_list_num, $article_list_activ, $article_list_content, '', '', '', '',$article_list_title_style);
if (!$article_result) $save_errors = true;
$banner_result = $this->site_content_object->save_by_structure_id($id, $banner, $banner_num, $banner_activ, $banner_content);
if (!$banner_result) $save_errors = true;
$manufacturer_result = $this->site_content_object->save_by_structure_id($id, $manufacturers, $manufacturers_num, $manufacturers_activ, '');
if (!$manufacturer_result) $save_errors = true;
$popular_result = $this->site_content_object->save_by_structure_id($id, $popular, $popular_num, $popular_active, $popular_content);
if (!$popular_result) $save_errors = true;
$substructure_result = $this->site_content_object->save_by_structure_id($id, $substructure, $substructure_num, $substructure_active, array('cat_id' => $substructure_cat_id,'ebenen' => $substructure_ebenen), $substructure_title, '', '', $substructure_title_en, $substructure_title_style);
if (!$substructure_result) $save_errors = true;
if (!$save_errors) {
$return_data = array('status' => 'success', 'data' => true);
} else {
$message_text = '';
if (!$textbox_result) $message_text .= " can't save textbox ";
if (!$slider_result) $message_text .= " can't save slider ";
if (!$article_result) $message_text .= " can't save article ";
if (!$banner_result) $message_text .= " can't save banner ";
if (!$manufacturer_result) $message_text .= " can't save manufacturer ";
if (!$popular_result) $message_text .= " can't save popular ";
if (!$substructure_result) $message_text .= " can't save substructure ";
$return_data = array('status' => 'error', 'message' => $message_text, 'save_errors' => $save_errors);
}
} else {
$return_data = array('status' => 'error', 'message' => 'no id');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no data');
}
echo json_encode($return_data);
exit();
}
private function get_sub_structure() {
if (isset($_GET['parent_id'])) {
$parent_id = $_GET['parent_id'];
} else {
$parent_id = false;
}
if ($parent_id) {
$structure_tree = $this->structure_object->get_all_tree_full_path();
echo "Structure Tree 2";
var_dump($structure_tree);
if ($id) {
$structure_data = $this->structure_object->get_data($id);
$this->layout_object->assign('structure_data', $structure_data);
}
$this->layout_object->assign('structure_tree', $structure_tree);
$this->layout_object->assign('parent_id', $parent_id);
echo $this->layout_object->fetch('admin_sub_structure.tpl');
}
exit();
}
private function edit($id, $copy = false) {
if ($id) {
$is_set = $this->structure_object->is_set($id);
if ($is_set) {
$structure_data = $this->structure_object->get_data($id);
if ($structure_data->image != '') {
$image = $this->structure_object->get_image_url().$structure_data->image;
$this->layout_object->assign('image', $image);
}
if ($structure_data->header_image != '') {
$image = $this->structure_object->get_header_image_url().$structure_data->header_image;
$this->layout_object->assign('header_image', $image);
}
// get themes
$shop_theme_object = new Shop_theme($this->base_object);
$this->layout_object->assign('shop_themes', $shop_theme_object->get_all());
// get item types
include_once './core/itemtype.class.php';
$item_type_oject = new ItemType($this->base_object);
$this->layout_object->assign('item_types',$item_type_oject->get_all_objects());
// get customer groups
include_once './core/customer_group.class.php';
$customer_group_oject = new Customer_group($this->base_object);
$this->layout_object->assign('customer_groups',$customer_group_oject->get_all_objects());
if ($copy) {
unset($structure_data->id);
}
$this->layout_object->assign('form_data', $structure_data);
$config = $this->site_content_object->get_by_structure_id($id);
if ($config == false) {
$i = 1;
$this->layout_object->assign('textbox_num', $i++);
$this->layout_object->assign('textbox_activ', 0);
$this->layout_object->assign('slider_num', $i++);
$this->layout_object->assign('slider_activ', 0);
$this->layout_object->assign('article_list_num', $i++);
$this->layout_object->assign('article_list_activ', 0);
$this->layout_object->assign('banner_num', $i++);
$this->layout_object->assign('banner_activ', 0);
$this->layout_object->assign('manufacturers_num', $i++);
$this->layout_object->assign('manufacturers_activ', 0);
$this->layout_object->assign('popular_num', $i++);
$this->layout_object->assign('popular_active', 0);
$this->layout_object->assign('substructure_num', $i++);
$this->layout_object->assign('substructure_active', 0);
}
else {
$show_item_discount = 0;
foreach ($config as $obj) {
if ($obj->type == 'textbox') {
$this->layout_object->assign('textbox_num', $obj->position);
$this->layout_object->assign('textbox_activ', (int)$obj->activ);
$this->layout_object->assign('textbox_title', $obj->title);
$this->layout_object->assign('textbox_title_style', $obj->style);
$this->layout_object->assign('textbox_title_en', $obj->title_en);
$this->layout_object->assign('textbox_content', $obj->content);
$this->layout_object->assign('textbox_content_en', $obj->content_en);
$config = array();
eval($obj->configuration);
$this->layout_object->assign('textbox_configuration', $config);
$this->layout_object->assign('textbox_id', $obj->id);
} else if ($obj->type == 'slider') {
$this->layout_object->assign('slider_num', $obj->position);
$this->layout_object->assign('slider_title', $obj->title);
$this->layout_object->assign('slider_title_style', $obj->style);
$this->layout_object->assign('slider_title_en', $obj->title_en);
$this->layout_object->assign('slider_activ', (int)$obj->activ);
$this->layout_object->assign('slider_content', $obj->content);
} else if ($obj->type == 'article_list') {
$this->layout_object->assign('article_list_num', $obj->position);
$this->layout_object->assign('article_list_activ', (int)$obj->activ);
$this->layout_object->assign('article_list_title_style', $obj->style);
$this->layout_object->assign('article_list_content', $obj->content);
if ($obj->activ == 1) {
$show_item_discount = 1;
}
} else if ($obj->type == 'featured') {
$this->layout_object->assign('featured_num', $obj->position);
$this->layout_object->assign('featured_activ', (int)$obj->activ);
$this->layout_object->assign('featured_content', $obj->content);
} else if ($obj->type == 'banner') {
$this->layout_object->assign('banner_num', $obj->position);
$this->layout_object->assign('banner_activ', (int)$obj->activ);
$this->layout_object->assign('banner_content', $obj->content);
$config = array();
eval($obj->configuration);
$this->layout_object->assign('banner_configuration', $config);
$this->layout_object->assign('banner_id', $obj->id);
} else if ($obj->type == 'manufacturers') {
$this->layout_object->assign('manufacturers_num', $obj->position);
$this->layout_object->assign('manufacturers_activ', (int)$obj->activ);
} else if ($obj->type == 'popular') {
$this->layout_object->assign('popular_num', $obj->position);
$this->layout_object->assign('popular_activ', (int)$obj->activ);
$this->layout_object->assign('popular_content', $obj->content);
} else if ($obj->type == 'substructure') {
$config = array();
eval($obj->configuration);
$this->layout_object->assign('substructure_configuration', $config);
$this->layout_object->assign('substructure_num', $obj->position);
$this->layout_object->assign('substructure_title', $obj->title);
$this->layout_object->assign('substructure_title_style', $obj->style);
$this->layout_object->assign('substructure_title_en', $obj->title_en);
$this->layout_object->assign('substructure_activ', (int)$obj->activ);
$config = array();
eval($obj->configuration);
$this->layout_object->assign('substructure_configuration', $config);
$this->layout_object->assign('substructure_ebenen', $config);
}
}
if ($show_item_discount) {
// get customer groups
$customer_groups = $this->customer_group_object->get_all_groups();
$this->layout_object->assign('customer_groups', $customer_groups);
// get group discounts for first customergroup
$first_customer_group = $customer_groups[100];
$discounts = $this->structure_object->get_discounts($id, $first_customer_group->id);
// get manufacturer
$manufacturer_object = new Manufacturer($this->base_object);
$manufacturer_list = $manufacturer_object->get_all_active();
$manufacturers = array();
foreach ($manufacturer_list as $obj) {
$obj->discount = (isset($discounts[$obj->id]))? $discounts[$obj->id] : 0;
$manufacturers[] = $obj;
}
$this->layout_object->assign('manufacturer_list', $manufacturers);
}
}
$this->layout_object->assign('item_cats', $this->structure_object->get_all_item_categories());
$this->layout_object->assign('site_info', true);
} else {
$this->layout_object->assign('error_message', 'Die von ihnen angegebenen Seiten ID ist im System nicht vorhanden.');
}
}
// get structure tree
$structure_tree = $this->structure_object->get_all_tree_full_path();
/*echo "Structure Tree 1:<br>";
var_dump($structure_tree);*/
$this->layout_object->assign('structure_tree', $structure_tree);
// get structure tree html
$structure_tree_html = $this->structure_object->get_tree_html('./index.php?admin_modul=admin_structure&id=');
$this->layout_object->assign('structure_tree_html', $structure_tree_html);
return $this->layout_object->fetch('admin_structure.tpl');
}
}
?>
+65
View File
@@ -0,0 +1,65 @@
<?php
/**
* @version $Id: admin_system_config_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './modules/list_and_edit.class.php';
class admin_system_config_editor {
private $base_object;
private $config;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->config = $base_object->config;
$this->layout_object = $layout_object;
$this->list_object = new ListAndEdit($base_object, $layout_object);
}
function run() {
//$this->setup_info();
//var_dump($GLOBALS);
if(isset($_GET['id']) && $_GET['id']) {
$has_id = true;
} else if(isset($_POST['id']) && $_POST['id']) {
$has_id = true;
} else {
$has_id = false;
}
if(isset($_POST['submit'])) {
$is_submitted = true;
} else {
$is_submitted = false;
}
// decide what CRUD method to call and call it in ListAndEdit
if($has_id && !$is_submitted && $_GET['mod'] != 'delete') {
// template variable name
$config_data['elemente'] = $this->config->get_config_elements($_GET['id']);
$config_data['id'] = $_GET['id'];
$this->layout_object->assign('form_data', $config_data);
} // update
elseif($has_id && $is_submitted && $_GET['mod'] != 'delete') {
$this->config->update($_GET['id'], $_POST['form_field']);
$config_data['elemente'] = $this->config->get_config_elements($_GET['id']);
$config_data['id'] = $_GET['id'];
$this->layout_object->assign('form_data', $config_data);
}
else {
}
return $this->layout_object->fetch('admin_system_config_editor.tpl');
}
}
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
*
* Program Description:
* Easyway Shop is an e-commerce system with many features.
*
* File Description:
*
*/
class admin_system_log {
private $layout_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
$log = $this->base_object->logger->get_last_log();
$this->layout_object->assign('log', $log);
return $this->layout_object->fetch('admin_system_log.tpl');
}
}
+187
View File
@@ -0,0 +1,187 @@
<?php
/**
* @version $Id: admin_vendor_editor.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* Easyshop is a web shop system
*/
include_once './core/vendors/edit.class.php';
class admin_vendor_editor {
private $base_object;
private $layout_object;
private $vendor_object;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->vendor_object = new Vendors_Edit($base_object);
} // end __construct
function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if (isset($_GET['object_id'])) {
$id = $_GET['object_id'];
} elseif (isset($_POST['id'])) {
$id = $_POST['id'];
} else {
$id = false;
}
if ($action == 'save') {
$this->save();
} elseif ($action == 'upload') {
$this->upload($id);
} elseif ($action == 'delete') {
$this->delete($id);
} elseif ($action == 'delete_logo') {
$this->delete_logo($id);
} else {
return $this->default_action($id);
}
} // end run
private function default_action($id) {
// Debug-Ausgabe
error_log("Vendor Editor - default_action mit ID: " . print_r($id, true));
if ($id) {
$data = $this->vendor_object->get_data($id);
// Debug-Ausgabe
error_log("Vendor Data: " . print_r($data, true));
if ($data) {
// Stelle sicher, dass alle notwendigen Felder vorhanden sind
$form_data = new stdClass();
$form_data->id = $data->id;
$form_data->name = $data->hersteller_name;
$form_data->marke_name = $data->marke_name;
$form_data->strasse = $data->strasse;
$form_data->strasse2 = $data->strasse2;
$form_data->PLZ = $data->PLZ;
$form_data->ort = $data->ort;
$form_data->land = $data->land;
$form_data->email = $data->email;
$form_data->homepage = $data->homepage;
if (isset($data->logo) && $data->logo != '') {
$logo = $this->vendor_object->get_image_url() . $data->logo;
$this->layout_object->assign('logo', $logo);
}
$this->layout_object->assign('form_data', $form_data);
$this->layout_object->assign('is_edit', true);
} else {
$this->layout_object->assign('error_message', "Dieser Lieferant existiert nicht.");
}
} else {
// Neuer Lieferant
$this->layout_object->assign('is_edit', false);
}
return $this->layout_object->fetch('admin_vendor_editor.tpl');
} // end default_action
private function delete_logo($id) {
if ($id) {
if ($this->vendor_object->set_logo($id, '')) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function upload($id) {
$log_object = Logger::get_instance();
$log_object->info('fileupload','jetzt');
if ($id) {
$log_object->info('id',$id);
$temp_file = $_FILES['Filedata']['tmp_name'];
if ($temp_file != '') {
$log_object->info('file','datei');
$result = $this->vendor_object->save_logo($id, $temp_file);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error', 'message' => "ERROR: can't save", 'data', $result);
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no file');
}
} else {
$return = array('status' => 'error', 'message' => 'ERROR: no id');
}
echo json_encode($return);
exit();
} // end upload
private function delete($id) {
if ($id) {
$result = $this->vendor_object->delete($id);
if ($result) {
$return = array('status' => 'success');
} else {
$return = array('status' => 'error');
}
} else {
$return = array('status' => 'error');
}
echo json_encode($return);
exit();
}
private function save() {
if (isset($_POST['form_field'])) {
$data = $_POST['form_field'];
if (isset($data['active'])) {
$data['active'] = '1';
} else {
$data['active'] = '0';
}
if ($data['id'] == '') {
unset($data['id']);
}
$result = $this->vendor_object->save($data);
if ($result) {
$return = array('status' => 'success', 'id' => $result);
} else {
$return = array('status' => 'error', 'message' => 'save failed');
}
} else {
$return = array('status' => 'error', 'message' => 'no forms data');
}
echo json_encode($return);
exit();
} // end save
} // end admin_vendor_editor
+20
View File
@@ -0,0 +1,20 @@
<?php
/**
* @version $Id: admin_xmlsitemap.php 10381 2008-06-01 03:35:53Z pasamio $
* @package Easyshop
* @copyright Copyright (C) 2005 - 2010 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class admin_xml_sitemap {
function __construct($layout_object) {
$this->layout_object = $layout_object;
}
function run() {
return $this->layout_object->fetch('admin_xml_sitemap.tpl');
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
function smarty_function_create_match($creatematch)
{
$sql = "SELECT im.navisionid,im.id,im.vertreiber,im.bestellcode,i.attribute_7,i.number,i.krempl_id FROM krempl_passendwie im INNER JOIN items i ON i.attribute_7 = im.navisionid WHERE im.navisionid = ".$this->id;
$result = $this->db->query($sql);
while ($row = $result->fetch_object()) {
$obj->match[] = $row;
}
if ($obj->krempl_id) {
$sql = "SELECT im.navisionid,im.id,im.vertreiber,im.bestellcode,i.attribute_7,i.number,i.krempl_id FROM krempl_passendwie im INNER JOIN items i ON i.attribute_7 = im.navisionid WHERE im.id = ".$this->db->real_escape_string($obj->krempl_id);
$result = $this->db->query($sql);
}
}
function smarty_function_load_match($html2, &$smarty)
{
$result = smarty_function_create_match($html2['creatematch']);
$smarty->assign($html2['assign'], $result);
}
$html2 = "";
foreach ($obj->match as $m) {
$html2 .= '<div id="itemMatch"><strong>'.$m->vertreiber.'</strong><br>'.$m->bestellcode.'</div>';
}
/*var_dump($html2);
$obj->geraetematch = $html2; */
/*$table_data = array();
foreach ($obj->geraetematch as $geraet) {
$nr1 = str_replace('#', '', $geraet->nr);
$nr1 = str_replace('_', ' ', $nr1);
$nr2 = str_replace('#', '', $geraet->vertreiber);
$nr2 = str_replace('_', ' ', $nr2);
$nr3 = str_replace('#', '', $geraet->bestellcode);
$nr3 = str_replace('_', ' ', $nr3);
//$table_data[$einkaufsmoeglichkeitencached][$bezeichnungoriginal][] = array($nr1, $nr2,$nr3);
}
//$html = '<table border="0" cellpadding="2" cellspacing="0">';
foreach ($table_data as $key => $marken) {
$y = 0;
$html .= '<tr class="intelectra_item_table_header"><td colspan="3"><h4><b>'.$obj->name.' passend zu '.$key.' '.$parent_warengruppe.'</b></h4></tr>';
$html .= '<tr class="intelectra_item_table_header"><td>Ger&auml;te-/Modellbezeichnung</td><td>E-, Service-, Produktions- oder Hauptnummer</td><td>Zusatz-, F- oder Seriennummer oder Fertigungsdatum</td></tr>';
foreach ($marken as $geraet => $nummern) {
$color = 'intelectra_table_row1';
if ($y % 2 == 1) {
$color = 'intelectra_table_row2';
}
$z = 0;
foreach ($nummern as $nummer) {
if ($z == 0) {
$html .= '<tr class="'.$color.'"><td>'.$geraet.'</td><td>'.$nummer[0].'</td><td>'.$nummer[1].''.$nummer[2].'</td></tr>';
} else {
$html .= '<tr class="'.$color.'"><td>&nbsp;</td><td>'.$nummer[0].'</td><td>'.$nummer[1].''.$nummer[2].'</td></tr>';
}
$z++;
}
$y++;
}
}*/
//$html .= '</table>';
+233
View File
@@ -0,0 +1,233 @@
#!/usr/bin/env python3
"""
Chart Generation Service with Plotly
Generates modern, interactive charts from statistical data
"""
import json
import sys
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.colors as pc
def generate_chart(data, chart_config):
"""
Generate Plotly chart from statistical data
Args:
data: List of lists - first row is headers, rest is data
chart_config: Dict with chart configuration (title, type, etc.)
Returns:
HTML string with embedded Plotly chart
"""
if not data or len(data) < 2:
return "<div>Keine Daten verfügbar</div>"
headers = data[0]
rows = data[1:]
# Extract x-axis labels (first column)
x_labels = [str(row[0]) for row in rows]
# Prepare traces for each data series
fig = go.Figure()
# Color palette - modern and professional
colors = pc.qualitative.Plotly
# Create a trace for each column (except first which is x-axis)
for i in range(1, len(headers)):
y_values = [row[i] if i < len(row) else 0 for row in rows]
fig.add_trace(go.Bar(
name=headers[i],
x=x_labels,
y=y_values,
marker_color=colors[i % len(colors)],
hovertemplate='<b>%{x}</b><br>%{fullData.name}: %{y}<extra></extra>'
))
# Update layout with modern styling
fig.update_layout(
title={
'text': chart_config.get('title', 'Statistik'),
'x': 0.5,
'xanchor': 'center',
'font': {'size': 20, 'color': '#333'}
},
barmode='group',
plot_bgcolor='rgba(240, 240, 240, 0.5)',
paper_bgcolor='white',
font={'family': 'Arial, sans-serif', 'size': 12, 'color': '#333'},
hovermode='x unified',
legend={
'orientation': 'h',
'yanchor': 'bottom',
'y': -0.2,
'xanchor': 'center',
'x': 0.5,
'bgcolor': 'rgba(255, 255, 255, 0.8)',
'bordercolor': '#ccc',
'borderwidth': 1
},
xaxis={
'title': headers[0] if headers else '',
'showgrid': False,
'showline': True,
'linecolor': '#ccc'
},
yaxis={
'title': 'Anzahl',
'showgrid': True,
'gridcolor': 'rgba(200, 200, 200, 0.3)',
'showline': True,
'linecolor': '#ccc'
},
margin={'l': 60, 'r': 40, 't': 80, 'b': 100},
height=500
)
# Generate HTML with Plotly CDN
html = fig.to_html(
include_plotlyjs='cdn',
div_id='plotly-chart',
config={
'displayModeBar': True,
'displaylogo': False,
'modeBarButtonsToRemove': ['pan2d', 'lasso2d', 'select2d'],
'responsive': True
}
)
return html
def generate_line_chart(data, chart_config):
"""
Generate Plotly line chart for time series data
"""
if not data or len(data) < 2:
return "<div>Keine Daten verfügbar</div>"
headers = data[0]
rows = data[1:]
x_labels = [str(row[0]) for row in rows]
fig = go.Figure()
colors = pc.qualitative.Plotly
# Create line traces
for i in range(1, len(headers)):
y_values = [row[i] if i < len(row) else 0 for row in rows]
fig.add_trace(go.Scatter(
name=headers[i],
x=x_labels,
y=y_values,
mode='lines+markers',
line={'color': colors[i % len(colors)], 'width': 3},
marker={'size': 8},
hovertemplate='<b>%{x}</b><br>%{fullData.name}: %{y}<extra></extra>'
))
# Update layout - NO fixed y-axis minimum for line charts
fig.update_layout(
title={
'text': chart_config.get('title', 'Statistik Verlauf'),
'x': 0.5,
'xanchor': 'center',
'font': {'size': 20, 'color': '#333'}
},
plot_bgcolor='rgba(240, 240, 240, 0.5)',
paper_bgcolor='white',
font={'family': 'Arial, sans-serif', 'size': 12, 'color': '#333'},
hovermode='x unified',
legend={
'orientation': 'h',
'yanchor': 'bottom',
'y': -0.2,
'xanchor': 'center',
'x': 0.5,
'bgcolor': 'rgba(255, 255, 255, 0.8)',
'bordercolor': '#ccc',
'borderwidth': 1
},
xaxis={
'title': headers[0] if headers else '',
'showgrid': False,
'showline': True,
'linecolor': '#ccc'
},
yaxis={
'title': 'Anzahl',
'showgrid': True,
'gridcolor': 'rgba(200, 200, 200, 0.3)',
'showline': True,
'linecolor': '#ccc',
'rangemode': 'normal', # Auto-scale, don't force to 0
'autorange': True
},
margin={'l': 60, 'r': 40, 't': 80, 'b': 100},
height=500
)
html = fig.to_html(
include_plotlyjs='cdn',
div_id='plotly-line-chart',
config={
'displayModeBar': True,
'displaylogo': False,
'modeBarButtonsToRemove': ['pan2d', 'lasso2d', 'select2d'],
'responsive': True
}
)
return html
def main():
"""
Main entry point - expects JSON input via stdin
Expected format:
{
"data": [[headers], [row1], [row2], ...],
"config": {
"title": "Chart Title",
"type": "bar" or "line",
"period": "year", "month", or "day"
}
}
"""
try:
# Read JSON from stdin
input_data = json.load(sys.stdin)
data = input_data.get('data', [])
config = input_data.get('config', {})
# Generate chart based on type
chart_type = config.get('type', 'bar')
if chart_type == 'line':
html = generate_line_chart(data, config)
else:
html = generate_chart(data, config)
# Output HTML
print(html)
except Exception as e:
error_html = f"""
<div style="padding: 20px; background: #fee; border: 1px solid #fcc; border-radius: 4px;">
<h3 style="color: #c33; margin: 0 0 10px 0;">Chart-Generierung fehlgeschlagen</h3>
<p style="margin: 0; color: #666;">Fehler: {str(e)}</p>
</div>
"""
print(error_html)
sys.exit(1)
if __name__ == '__main__':
main()
+6
View File
@@ -0,0 +1,6 @@
[database]
host = localhost
user = tbapy
password = 9%%0H32ryj_N9%%0H32ryj
database = webshop-sql
autocommit = true
+150
View File
@@ -0,0 +1,150 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Image Processing Service für Intelectra WebShop
EINFACH & SCHNELL - erstellt nur Thumbnails!
Kompatibel mit Legacy PHP item.class.php
"""
import json
import sys
import os
from PIL import Image
import logging
# Logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('/var/www/vhosts/intelectra.de/httpdocs/logs/image_processing.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger('image_processing')
class ImageProcessingService:
"""Einfacher Thumbnail-Generator - keine DB, keine Komplexität!"""
def __init__(self, config):
"""
config = {
'source_file': '/full/path/to/original.jpg',
'watermark': 0 oder 1,
'shop_system': 'intelectra_shop',
'document_root': '/var/www/...',
'image_sizes': [['thumb_', 90], ['overview_', 150], ...] # Von PHP übergeben!
}
"""
self.source_file = config.get('source_file')
self.watermark_enabled = config.get('watermark', 0) == 1
self.document_root = config.get('document_root', '')
# Bildgrößen von PHP übernehmen (aus DB-Konfiguration!)
# PHP übergibt: [['overview_', 150], ['thumb_', 90], ['details_', 330], ['detaildefault_', 600]]
php_image_sizes = config.get('image_sizes', [])
# In Python-Format konvertieren: [('prefix', size), ...]
self.image_sizes = []
# Original resized (falls konfiguriert)
self.image_sizes.append(('', 800))
# Thumbnails von PHP config
for img_config in php_image_sizes:
if isinstance(img_config, (list, tuple)) and len(img_config) >= 2:
prefix = img_config[0]
size = int(img_config[1])
self.image_sizes.append((prefix, size))
logger.info(f"Service initialized for: {self.source_file}")
logger.info(f"Image sizes: {self.image_sizes}")
def process(self):
"""Hauptfunktion: Erstellt alle Thumbnails"""
try:
if not os.path.exists(self.source_file):
logger.error(f"Source file not found: {self.source_file}")
return False
# Original-Bild öffnen
with Image.open(self.source_file) as img:
# Original Format beibehalten (JPG/PNG/GIF)
img_format = img.format
# Alle Größen generieren
for prefix, size in self.image_sizes:
self.create_thumbnail(img, prefix, size, img_format)
logger.info(f"✅ Successfully processed: {self.source_file}")
return True
except Exception as e:
logger.error(f"❌ Error processing {self.source_file}: {str(e)}")
return False
def create_thumbnail(self, img, prefix, max_size, img_format):
"""Erstellt ein Thumbnail mit gegebener Größe"""
try:
# Dateiname mit Präfix
source_dir = os.path.dirname(self.source_file)
source_filename = os.path.basename(self.source_file)
target_filename = f"{prefix}{source_filename}"
target_path = os.path.join(source_dir, target_filename)
# Kopie erstellen für Resize
thumb = img.copy()
# Proportional auf max_size verkleinern (behält Aspect Ratio!)
thumb.thumbnail((max_size, max_size), Image.Resampling.LANCZOS)
# Speichern im Original-Format
if img_format == 'JPEG':
thumb.save(target_path, 'JPEG', quality=85, optimize=True)
elif img_format == 'PNG':
thumb.save(target_path, 'PNG', optimize=True)
elif img_format == 'GIF':
thumb.save(target_path, 'GIF')
else:
thumb.save(target_path)
logger.debug(f"Created: {target_filename} ({max_size}px)")
except Exception as e:
logger.warning(f"Could not create {prefix} thumbnail: {str(e)}")
def main():
"""Entry Point - wird von PHP aufgerufen"""
try:
if len(sys.argv) < 2:
logger.error("No config provided!")
sys.exit(1)
# JSON Config von PHP
config_json = sys.argv[1]
config = json.loads(config_json)
logger.info("=" * 60)
logger.info("🚀 Image Processing Service STARTED")
logger.info(f"Source: {config.get('source_file', 'unknown')}")
# Service starten
service = ImageProcessingService(config)
success = service.process()
if success:
logger.info("✅ Processing completed successfully")
sys.exit(0)
else:
logger.error("❌ Processing failed")
sys.exit(1)
except Exception as e:
logger.error(f"FATAL ERROR: {str(e)}")
sys.exit(1)
if __name__ == "__main__":
main()
+433
View File
@@ -0,0 +1,433 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Import-Skript für Intelectra Webshop
Dieses Skript wird remote per SSH von der GUI aufgerufen.
Es erwartet eine CSV-Datei als erstes Argument.
Mit --passendwie wird die krempl_passendwie Tabelle aktualisiert.
"""
import csv
import pymysql
import os
import sys
import argparse
from datetime import datetime
from configparser import ConfigParser
CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'db_config.ini')
REQUIRED_COLUMNS = {
'id', 'altenr', 'originalnummer', 'navisionid', 'zolltarifnummer',
'marke', 'ersatzteilvertreiber', 'ean', 'ersatzteilvorwaerts',
'ersatzteilvorwaertsnavisionid'
}
REQUIRED_COLUMNS_PASSENDWIE = {
'id', 'navisionid', 'vertreiberid', 'vertreiber', 'bestellcode'
}
REQUIRED_COLUMNS_GERAETE = {
'id', 'nr', 'marke', 'typ', 'zusatzNummer', 'modellBezeichnung', 'produktionsstart', 'produktionsende',
'wgtext1', 'wgtext2', 'zusatz', 'bezeichnungoriginal', 'typDE', 'typFR'
}
REQUIRED_COLUMNS_MAPPING = {
'ersatzteil', 'geraet'
}
def load_db_config():
parser = ConfigParser()
parser.read(CONFIG_PATH)
config = parser['database']
return {
'host': config.get('host', 'localhost'),
'user': config.get('user'),
'password': config.get('password', ''),
'database': config.get('database', 'webshop-sql'),
'autocommit': True
}
def connect_to_db():
return pymysql.connect(**load_db_config())
def validate_headers(headers):
return REQUIRED_COLUMNS.issubset(set(headers))
def validate_geraete_headers(headers):
return REQUIRED_COLUMNS_GERAETE.issubset(set(headers))
def validate_mapping_headers(headers):
return REQUIRED_COLUMNS_MAPPING.issubset(set(headers))
def run_import(csv_path):
if not os.path.exists(csv_path):
print(f"[ERROR] Datei nicht gefunden: {csv_path}")
return
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f, delimiter=';')
if not validate_headers(reader.fieldnames):
print(f"[ERROR] CSV-Header ungültig: {reader.fieldnames}")
return
conn = connect_to_db()
cursor = conn.cursor()
backup_table(cursor)
cursor.execute("TRUNCATE TABLE krempl_art_22")
insert_sql = """
INSERT INTO krempl_art_22
(id, altenr, originalnummer, navisionid, zolltarifnummer, marke,
ersatzteilvertreiber, ean, ersatzteilvorwaerts, ersatzteilvorwaertsnavisionid)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
"""
total = 0
batch = []
for row in reader:
try:
values = (
int(row['id']) if row['id'] else None,
row['altenr'],
row['originalnummer'],
int(row['navisionid']) if row['navisionid'] else None,
row['zolltarifnummer'],
row['marke'],
row['ersatzteilvertreiber'],
row['ean'],
row['ersatzteilvorwaerts'],
int(row['ersatzteilvorwaertsnavisionid']) if row['ersatzteilvorwaertsnavisionid'] else None
)
batch.append(values)
if len(batch) >= 500:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
batch.clear()
except Exception as e:
print(f"[WARN] Zeile übersprungen wegen Fehler: {e}")
continue
if batch:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
print(f"[OK] Import abgeschlossen. {total} Datensätze importiert.")
# Tabellen-Statistiken aktualisieren für bessere Query-Performance
print("[INFO] Aktualisiere Tabellen-Statistiken...")
cursor.execute("ANALYZE TABLE krempl_art_22")
print("[OK] Statistiken aktualisiert.")
cursor.close()
conn.close()
def backup_table(cursor):
name = f"krempl_art_22_backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
try:
cursor.execute(f"CREATE TABLE {name} AS SELECT * FROM krempl_art_22")
print(f"[INFO] Backup-Tabelle erstellt: {name}")
except Exception as e:
print(f"[WARN] Backup fehlgeschlagen: {e}")
def run_passendwie_import(csv_path):
if not os.path.exists(csv_path):
print(f"[ERROR] Datei nicht gefunden: {csv_path}")
return
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f, delimiter=';')
if not REQUIRED_COLUMNS_PASSENDWIE.issubset(set(reader.fieldnames)):
print(f"[ERROR] CSV-Header ungültig: {reader.fieldnames}")
return
conn = connect_to_db()
cursor = conn.cursor()
backup_passendwie_table(cursor)
insert_sql = """
INSERT INTO krempl_passendwie
(id, navisionid, vertreiberid, vertreiber, bestellcode)
VALUES (%s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
navisionid = VALUES(navisionid),
vertreiberid = VALUES(vertreiberid),
vertreiber = VALUES(vertreiber),
bestellcode = VALUES(bestellcode)
"""
total = 0
batch = []
for row in reader:
try:
values = (
int(row['id']) if row['id'] else None,
int(row['navisionid']) if row['navisionid'] else None,
row['vertreiberid'],
row['vertreiber'],
row['bestellcode']
)
batch.append(values)
if len(batch) >= 500:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
batch.clear()
except Exception as e:
print(f"[WARN] Zeile übersprungen wegen Fehler: {e}")
continue
if batch:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
print(f"[OK] PassendWie-Import abgeschlossen. {total} Datensätze importiert.")
# Tabellen-Statistiken aktualisieren für bessere Query-Performance
print("[INFO] Aktualisiere Tabellen-Statistiken...")
cursor.execute("ANALYZE TABLE krempl_passendwie")
print("[OK] Statistiken aktualisiert.")
cursor.close()
conn.close()
def backup_passendwie_table(cursor):
# 1. Alle bisherigen Backups suchen
cursor.execute("SHOW TABLES LIKE 'krempl_passendwie_backup_%'")
backups = [row[0] for row in cursor.fetchall()]
# 2. Nach Datum sortieren (Tabellenname enthält Zeitstempel)
backups.sort()
# 3. Wenn mehr als 2 Backups existieren, die ältesten löschen
while len(backups) >= 3:
to_delete = backups.pop(0)
try:
cursor.execute(f"DROP TABLE `{to_delete}`")
print(f"[INFO] Altes Backup gelöscht: {to_delete}")
except Exception as e:
print(f"[WARN] Konnte Backup nicht löschen: {e}")
# 4. Neues Backup anlegen
name = f"krempl_passendwie_backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
try:
cursor.execute(f"CREATE TABLE `{name}` AS SELECT * FROM krempl_passendwie")
print(f"[INFO] Backup-Tabelle erstellt: {name}")
except Exception as e:
print(f"[WARN] Backup fehlgeschlagen: {e}")
def run_geraete_import(csv_path):
if not os.path.exists(csv_path):
print(f"[ERROR] Datei nicht gefunden: {csv_path}")
return
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f, delimiter=';')
if not validate_geraete_headers(reader.fieldnames):
print(f"[ERROR] CSV-Header ungültig: {reader.fieldnames}")
return
conn = connect_to_db()
cursor = conn.cursor()
backup_geraete_table(cursor)
insert_sql = """
INSERT INTO krempl_geraete_22
(id, nr, marke, typ, zusatZNummer, modellBezeichnung, produktionsstart, produktionsende, wgtext1, wgtext2, zusatz, bezeichnungoriginal, typDE, typFR)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
nr = VALUES(nr),
marke = VALUES(marke),
typ = VALUES(typ),
zusatZNummer = VALUES(zusatZNummer),
modellBezeichnung = VALUES(modellBezeichnung),
produktionsstart = VALUES(produktionsstart),
produktionsende = VALUES(produktionsende),
wgtext1 = VALUES(wgtext1),
wgtext2 = VALUES(wgtext2),
zusatz = VALUES(zusatz),
bezeichnungoriginal = VALUES(bezeichnungoriginal),
typDE = VALUES(typDE),
typFR = VALUES(typFR)
"""
total = 0
batch = []
for row in reader:
try:
values = (
int(row['id']) if row['id'] else None,
row['nr'],
row['marke'],
row['typ'],
row['zusatzNummer'],
row['modellBezeichnung'],
row['produktionsstart'],
row['produktionsende'],
row['wgtext1'],
row['wgtext2'],
row['zusatz'],
row['bezeichnungoriginal'],
row['typDE'],
row['typFR']
)
batch.append(values)
if len(batch) >= 500:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
batch.clear()
except Exception as e:
print(f"[WARN] Zeile übersprungen wegen Fehler: {e}")
continue
if batch:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
print(f"[OK] ZusatzDatenOriginalteil-Import abgeschlossen. {total} Datensätze importiert.")
# Tabellen-Statistiken aktualisieren für bessere Query-Performance
print("[INFO] Aktualisiere Tabellen-Statistiken...")
cursor.execute("ANALYZE TABLE krempl_geraete_22")
print("[OK] Statistiken aktualisiert.")
cursor.close()
conn.close()
def backup_geraete_table(cursor):
# 1. Alle bisherigen Backups suchen
cursor.execute("SHOW TABLES LIKE 'krempl_geraete_22_backup_%'")
backups = [row[0] for row in cursor.fetchall()]
# 2. Nach Datum sortieren (Tabellenname enthält Zeitstempel)
backups.sort()
# 3. Wenn mehr als 2 Backups existieren, die ältesten löschen
while len(backups) >= 3:
to_delete = backups.pop(0)
try:
cursor.execute(f"DROP TABLE `{to_delete}`")
print(f"[INFO] Altes Backup gelöscht: {to_delete}")
except Exception as e:
print(f"[WARN] Konnte Backup nicht löschen: {e}")
# 4. Neues Backup anlegen
name = f"krempl_geraete_22_backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
try:
cursor.execute(f"CREATE TABLE `{name}` AS SELECT * FROM krempl_geraete_22")
print(f"[INFO] Backup-Tabelle erstellt: {name}")
except Exception as e:
print(f"[WARN] Backup fehlgeschlagen: {e}")
def run_mapping_import(csv_path):
if not os.path.exists(csv_path):
print(f"[ERROR] Datei nicht gefunden: {csv_path}")
return
with open(csv_path, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f, delimiter=';')
if not validate_mapping_headers(reader.fieldnames):
print(f"[ERROR] CSV-Header ungültig: {reader.fieldnames}")
return
conn = connect_to_db()
cursor = conn.cursor()
backup_mapping_table(cursor)
insert_sql = """
INSERT INTO krempl_artikelgeraet_22
(ersatzteil, geraet)
VALUES (%s, %s)
ON DUPLICATE KEY UPDATE
geraet = VALUES(geraet)
"""
total = 0
batch = []
for row in reader:
try:
values = (
int(row['ersatzteil']) if row['ersatzteil'] else None,
int(row['geraet']) if row['geraet'] else None
)
batch.append(values)
if len(batch) >= 500:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
batch.clear()
except Exception as e:
print(f"[WARN] Zeile übersprungen wegen Fehler: {e}")
continue
if batch:
cursor.executemany(insert_sql, batch)
conn.commit()
total += len(batch)
print(f"[OK] KremplMapping-Import abgeschlossen. {total} Datensätze importiert.")
# Tabellen-Statistiken aktualisieren für bessere Query-Performance
print("[INFO] Aktualisiere Tabellen-Statistiken...")
cursor.execute("ANALYZE TABLE krempl_artikelgeraet_22")
print("[OK] Statistiken aktualisiert.")
cursor.close()
conn.close()
def backup_mapping_table(cursor):
# 1. Alle bisherigen Backups suchen
cursor.execute("SHOW TABLES LIKE 'krempl_artikelgeraet_22_backup_%'")
backups = [row[0] for row in cursor.fetchall()]
# 2. Nach Datum sortieren (Tabellenname enthält Zeitstempel)
backups.sort()
# 3. Wenn mehr als 2 Backups existieren, die ältesten löschen
while len(backups) >= 3:
to_delete = backups.pop(0)
try:
cursor.execute(f"DROP TABLE `{to_delete}`")
print(f"[INFO] Altes Backup gelöscht: {to_delete}")
except Exception as e:
print(f"[WARN] Konnte Backup nicht löschen: {e}")
# 4. Neues Backup anlegen
name = f"krempl_artikelgeraet_22_backup_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
try:
cursor.execute(f"CREATE TABLE `{name}` AS SELECT * FROM krempl_artikelgeraet_22")
print(f"[INFO] Backup-Tabelle erstellt: {name}")
except Exception as e:
print(f"[WARN] Backup fehlgeschlagen: {e}")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Import-Skript für Intelectra Webshop')
parser.add_argument('csv_file', help='Pfad zur CSV-Datei')
parser.add_argument('--passendwie', action='store_true', help='Import in krempl_passendwie Tabelle')
parser.add_argument('--geraete', action='store_true', help='Import in krempl_geraete_22 Tabelle')
parser.add_argument('--mapping', action='store_true', help='Import in krempl_artikelgeraet_22 Tabelle')
args = parser.parse_args()
print(f"[INFO] Starte Import für Datei: {args.csv_file}")
if args.mapping:
run_mapping_import(args.csv_file)
elif args.geraete:
run_geraete_import(args.csv_file)
elif args.passendwie:
run_passendwie_import(args.csv_file)
else:
run_import(args.csv_file)
+258
View File
@@ -0,0 +1,258 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Smart Save Service für Intelectra WebShop
Speichert nur echte Änderungen - keine DELETE * mehr!
"""
import json
import sys
import pymysql
import logging
from configparser import ConfigParser
import os
from datetime import datetime
# Logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('/var/www/vhosts/intelectra.de/httpdocs/logs/item_save_service.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger('item_save_service')
class ItemSaveService:
"""Intelligenter Save-Service mit Change Detection"""
def __init__(self):
self.conn = self._connect_db()
self.cursor = self.conn.cursor(pymysql.cursors.DictCursor)
def _connect_db(self):
"""DB-Connection aus config.ini"""
config_file = os.path.join(os.path.dirname(__file__), 'db_config.ini')
config = ConfigParser()
config.read(config_file)
return pymysql.connect(
host=config.get('database', 'host', fallback='localhost'),
user=config.get('database', 'user', fallback='tbapy'),
password=config.get('database', 'password', fallback='9%%0H32ryj_N9%%0H32ryj'),
database=config.get('database', 'database', fallback='webshop-sql'),
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
def save_alternative_items(self, item_id, new_items):
"""
Speichert Alternativartikel - NUR Änderungen!
Type 3 = Alternativartikel
"""
try:
# 1. Aktuelle Items laden
self.cursor.execute(
"SELECT item_child_id FROM item_item_assign WHERE item_parent_id = %s AND type = 3 ORDER BY position",
(item_id,)
)
current_items = [row['item_child_id'] for row in self.cursor.fetchall()]
# 2. Änderungen erkennen
new_items = [int(x) for x in new_items if x] # Clean input
to_delete = set(current_items) - set(new_items)
to_add = set(new_items) - set(current_items)
# Reihenfolge geändert?
order_changed = (current_items != new_items) and not to_delete and not to_add
changes_made = False
# 3. Nur löschen was weg muss
if to_delete:
placeholders = ','.join(['%s'] * len(to_delete))
self.cursor.execute(
f"DELETE FROM item_item_assign WHERE item_parent_id = %s AND item_child_id IN ({placeholders}) AND type = 3",
[item_id] + list(to_delete)
)
logger.info(f"Deleted {len(to_delete)} alternative items from item {item_id}")
changes_made = True
# 4. Nur hinzufügen was neu ist
if to_add:
# Position berechnen - bei erster Zuweisung start bei 1
if not current_items:
start_pos = 1
else:
start_pos = len(current_items) - len(to_delete) + 1
values = []
for idx, child_id in enumerate(to_add):
values.append((item_id, child_id, 3, start_pos + idx))
self.cursor.executemany(
"INSERT INTO item_item_assign (item_parent_id, item_child_id, type, position) VALUES (%s, %s, %s, %s)",
values
)
logger.info(f"Added {len(to_add)} alternative items to item {item_id}")
changes_made = True
# 5. Reihenfolge updaten wenn nötig
if order_changed or to_add or to_delete:
for idx, child_id in enumerate(new_items):
self.cursor.execute(
"UPDATE item_item_assign SET position = %s WHERE item_parent_id = %s AND item_child_id = %s AND type = 3",
(idx + 1, item_id, child_id)
)
logger.info(f"Updated positions for item {item_id}")
changes_made = True
self.conn.commit()
return {
'success': True,
'changes': {
'deleted': len(to_delete),
'added': len(to_add),
'reordered': order_changed
},
'message': 'Changes saved' if changes_made else 'No changes detected'
}
except Exception as e:
self.conn.rollback()
logger.error(f"Error saving alternative items: {str(e)}")
return {
'success': False,
'error': str(e)
}
def save_accessory_items(self, item_id, new_items):
"""Type 1 = Zubehör - gleiche Logik"""
return self._save_related_items(item_id, new_items, 1)
def save_spare_parts(self, item_id, new_items):
"""Type 2 = Ersatzteile - gleiche Logik"""
return self._save_related_items(item_id, new_items, 2)
def _save_related_items(self, item_id, new_items, item_type):
"""Generische Methode für alle Verknüpfungstypen"""
type_names = {1: 'accessory', 2: 'spare_part', 3: 'alternative'}
try:
# Gleiche Logik wie save_alternative_items
self.cursor.execute(
"SELECT item_child_id FROM item_item_assign WHERE item_parent_id = %s AND type = %s ORDER BY position",
(item_id, item_type)
)
current_items = [row['item_child_id'] for row in self.cursor.fetchall()]
new_items = [int(x) for x in new_items if x]
to_delete = set(current_items) - set(new_items)
to_add = set(new_items) - set(current_items)
if to_delete:
placeholders = ','.join(['%s'] * len(to_delete))
self.cursor.execute(
f"DELETE FROM item_item_assign WHERE item_parent_id = %s AND item_child_id IN ({placeholders}) AND type = %s",
[item_id] + list(to_delete) + [item_type]
)
if to_add:
# Position berechnen - bei erster Zuweisung start bei 1
if not current_items:
start_pos = 1
else:
start_pos = len(current_items) - len(to_delete) + 1
values = [(item_id, child_id, item_type, start_pos + idx)
for idx, child_id in enumerate(to_add)]
self.cursor.executemany(
"INSERT INTO item_item_assign (item_parent_id, item_child_id, type, position) VALUES (%s, %s, %s, %s)",
values
)
# Update positions
for idx, child_id in enumerate(new_items):
self.cursor.execute(
"UPDATE item_item_assign SET position = %s WHERE item_parent_id = %s AND item_child_id = %s AND type = %s",
(idx + 1, item_id, child_id, item_type)
)
self.conn.commit()
logger.info(f"Saved {type_names[item_type]} items: {len(to_delete)} deleted, {len(to_add)} added")
return {
'success': True,
'type': type_names[item_type],
'changes': {
'deleted': len(to_delete),
'added': len(to_add)
}
}
except Exception as e:
self.conn.rollback()
logger.error(f"Error saving {type_names[item_type]} items: {str(e)}")
return {'success': False, 'error': str(e)}
def close(self):
"""Cleanup"""
if self.cursor:
self.cursor.close()
if self.conn:
self.conn.close()
def main():
"""CLI Entry Point für PHP shell_exec()"""
if len(sys.argv) < 2:
print(json.dumps({'error': 'No data provided'}))
sys.exit(1)
try:
# Parse input
data = json.loads(sys.argv[1])
item_id = data.get('item_id')
action = data.get('action', 'save_all')
service = ItemSaveService()
if action == 'save_alternatives':
items = data.get('items', [])
result = service.save_alternative_items(item_id, items)
elif action == 'save_accessories':
items = data.get('items', [])
result = service.save_accessory_items(item_id, items)
elif action == 'save_spare_parts':
items = data.get('items', [])
result = service.save_spare_parts(item_id, items)
elif action == 'save_all':
# Alle 3 Typen speichern
results = {}
if 'alternatives' in data:
results['alternatives'] = service.save_alternative_items(item_id, data['alternatives'])
if 'accessories' in data:
results['accessories'] = service.save_accessory_items(item_id, data['accessories'])
if 'spare_parts' in data:
results['spare_parts'] = service.save_spare_parts(item_id, data['spare_parts'])
result = {'success': True, 'results': results}
else:
result = {'error': f'Unknown action: {action}'}
service.close()
# Return JSON
print(json.dumps(result))
except Exception as e:
logger.error(f"Main error: {str(e)}")
print(json.dumps({'error': str(e)}))
sys.exit(1)
if __name__ == '__main__':
main()
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
KremplImport GUI - Desktop CSV Import Tool für Intelectra
Version: Full-Tunnel-Mode™
"""
import tkinter as tk
from tkinter import filedialog, messagebox, scrolledtext
import csv
import os
from dotenv import load_dotenv
from datetime import datetime
import paramiko
from scp import SCPClient
import threading
load_dotenv()
# DB-Konfiguration aus .env-Datei
DB_CONFIG = {
'host': os.getenv('DB_HOST', 'localhost'),
'port': int(os.getenv('DB_PORT', 3306)),
'user': os.getenv('DB_USER', 'root'),
'password': os.getenv('DB_PASSWORD', ''),
'database': os.getenv('DB_NAME', 'webshop-sql'),
'autocommit': True
}
SSH_CONFIG = {
'ssh_host': os.getenv('SSH_HOST', 'remotehost'),
'ssh_user': os.getenv('SSH_USER', 'user'),
'ssh_password': os.getenv('SSH_PASSWORD', 'password'),
'remote_path': os.getenv('REMOTE_PATH', '/tmp/artikel_Export.csv'),
'remote_script': os.getenv('REMOTE_SCRIPT', '/opt/import/import_script.py')
}
REQUIRED_COLUMNS = {
'id', 'altenr', 'originalnummer', 'navisionid', 'zolltarifnummer',
'marke', 'ersatzteilvertreiber', 'ean', 'ersatzteilvorwaerts',
'ersatzteilvorwaertsnavisionid'
}
class KremplImporterApp:
def __init__(self, master):
self.master = master
self.master.title("KremplImport GUI (Full-Tunnel-Mode™)")
self.master.geometry("700x550")
self.csv_path = tk.StringVar()
tk.Label(master, text="1. CSV-Datei auswählen:").pack(pady=(10, 0))
tk.Entry(master, textvariable=self.csv_path, width=80).pack(padx=10)
tk.Button(master, text="Durchsuchen", command=self.select_file).pack(pady=5)
tk.Button(master, text="CSV validieren", command=self.validate_csv).pack(pady=10)
tk.Button(master, text="Hochladen & Import starten (Remote)", command=self.upload_and_import).pack(pady=5)
tk.Label(master, text="Protokoll:").pack(pady=(10, 0))
self.log_output = scrolledtext.ScrolledText(master, height=20)
self.log_output.pack(padx=10, fill='both', expand=True)
def log(self, msg):
self.log_output.insert(tk.END, msg + '\n')
self.log_output.see(tk.END)
def select_file(self):
file_path = filedialog.askopenfilename(filetypes=[("CSV files", "*.csv")])
if file_path:
self.csv_path.set(file_path)
self.log(f"Datei ausgewählt: {file_path}")
def validate_csv(self):
path = self.csv_path.get()
if not os.path.exists(path):
messagebox.showerror("Fehler", "Datei nicht gefunden!")
return False
try:
with open(path, 'r', encoding='utf-8') as f:
reader = csv.reader(f, delimiter=';')
headers = next(reader)
missing = REQUIRED_COLUMNS - set(headers)
if missing:
self.log(f"FEHLENDE SPALTEN: {', '.join(missing)}")
messagebox.showerror("CSV ungültig", "Spalten fehlen!")
return False
self.log(f"CSV validiert. Spalten ok: {', '.join(headers)}")
return True
except Exception as e:
self.log(f"Fehler beim Validieren: {e}")
return False
def upload_and_import(self):
if not self.validate_csv():
return
self.log("[🔄] Starte Tunnel-Upload-Prozess...")
threading.Thread(target=self.run_remote_process).start()
def run_remote_process(self):
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(
hostname=SSH_CONFIG['ssh_host'],
username=SSH_CONFIG['ssh_user'],
password=SSH_CONFIG['ssh_password']
)
with SCPClient(ssh.get_transport()) as scp:
scp.put(self.csv_path.get(), SSH_CONFIG['remote_path'])
self.log(f"[📤] Datei hochgeladen nach {SSH_CONFIG['remote_path']}")
cmd = f"python3 {SSH_CONFIG['remote_script']} {SSH_CONFIG['remote_path']}"
self.log(f"[🚀] Starte Remote-Skript: {cmd}")
stdin, stdout, stderr = ssh.exec_command(cmd)
output = stdout.read().decode()
error = stderr.read().decode()
if output:
self.log(f"[✅ OUTPUT]:\n{output}")
if error:
self.log(f"[⚠️ ERROR]:\n{error}")
ssh.close()
except Exception as e:
self.log(f"[❌] Fehler beim Remote-Vorgang: {e}")
messagebox.showerror("Fehler", str(e))
if __name__ == '__main__':
root = tk.Tk()
app = KremplImporterApp(root)
root.mainloop()
+318
View File
@@ -0,0 +1,318 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Preisupdate-Skript für Intelectra Webshop
Dieses Skript importiert Preisdaten aus einer CSV-Datei in die Datenbank.
Es erstellt automatisch Backups der bestehenden Preisdaten vor dem Update.
Verwendung:
python3 preisupdate.py /pfad/zur/csv_datei.csv
CSV-Format:
Artikelnummer;VK1;VK3;VK100;VK_Endkunde
Beispiel: 12345;10,50;9,50;8,50;11,50
"""
import csv
import pymysql
import datetime
import os
import sys
import logging
from configparser import ConfigParser
# Logging-Konfiguration
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('preisupdate.log')
]
)
logger = logging.getLogger('preisupdate')
def load_config():
"""
Lädt die Konfiguration aus einer INI-Datei oder Umgebungsvariablen.
Falls keine Konfigurationsdatei gefunden wird, werden Standardwerte verwendet.
"""
config = {
'host': 'localhost',
'user': 'tbapy',
'password': '9%%0H32ryj_N9%%0H32ryj',
'database': 'webshop-sql',
'autocommit': True
}
# Versuche, Konfiguration aus Datei zu laden
config_file = os.path.join(os.path.dirname(__file__), 'db_config.ini')
if os.path.exists(config_file):
parser = ConfigParser()
parser.read(config_file)
if 'database' in parser:
config.update(parser['database'])
logger.info("Konfiguration aus Datei geladen")
# Umgebungsvariablen haben Vorrang
if 'DB_HOST' in os.environ:
config['host'] = os.environ['DB_HOST']
if 'DB_USER' in os.environ:
config['user'] = os.environ['DB_USER']
if 'DB_PASSWORD' in os.environ:
config['password'] = os.environ['DB_PASSWORD']
if 'DB_NAME' in os.environ:
config['database'] = os.environ['DB_NAME']
return config
def connect_db():
"""
Stellt eine Verbindung zur Datenbank her.
Returns:
pymysql.Connection: Die Datenbankverbindung
"""
config = load_config()
try:
conn = pymysql.connect(
host=config['host'],
user=config['user'],
password=config['password'],
database=config['database'],
autocommit=config['autocommit']
)
logger.info(f"Verbindung zur Datenbank {config['database']} hergestellt")
return conn
except Exception as e:
logger.error(f"Fehler beim Verbinden zur Datenbank: {e}")
raise
def cleanup_old_backups(cursor, keep_count=3):
"""
Löscht alte Backup-Tabellen, behält aber die neuesten 'keep_count' Backups.
Args:
cursor: Der Datenbank-Cursor
keep_count: Anzahl der zu behaltenden Backups
"""
try:
# Finde alle Backup-Tabellen
cursor.execute("""
SELECT table_name
FROM information_schema.tables
WHERE table_name LIKE 'item_prices_backup_%'
ORDER BY table_name DESC
""")
backups = cursor.fetchall()
# Wenn mehr als keep_count Backups existieren, lösche die ältesten
if len(backups) > keep_count:
for backup in backups[keep_count:]:
logger.info(f"Lösche altes Backup: {backup[0]}")
cursor.execute(f"DROP TABLE {backup[0]}")
logger.info(f"Backup-Bereinigung abgeschlossen. {len(backups)-keep_count} alte Backups entfernt.")
except Exception as e:
logger.error(f"Fehler bei der Backup-Bereinigung: {e}")
raise
def backup_and_clear_table(cursor):
"""
Erstellt ein Backup der aktuellen Preisdaten und leert die Update-Tabelle.
Args:
cursor: Der Datenbank-Cursor
"""
try:
# Erstelle ein Backup mit aktuellem Datum
backup_table_name = f"item_prices_backup_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}"
logger.info(f"Backup-Tabelle: {backup_table_name}")
cursor.execute(f"CREATE TABLE {backup_table_name} AS SELECT * FROM item_prices;")
logger.info("Backup der Echtpreise erstellt.")
# Bereinige alte Backups
cleanup_old_backups(cursor)
# Truncate der item_preise_update-Tabelle
cursor.execute("TRUNCATE TABLE item_preise_update;")
logger.info("item_preise_update geleert.")
except Exception as e:
logger.error(f"Fehler beim Backup und Leeren der Tabelle: {e}")
raise
def get_item_id(cursor, article_number):
"""
Ermittelt die ID eines Artikels anhand seiner Artikelnummer.
Args:
cursor: Der Datenbank-Cursor
article_number: Die Artikelnummer
Returns:
int: Die Artikel-ID oder None, wenn nicht gefunden
"""
try:
cursor.execute("SELECT id FROM items WHERE number = %s", (article_number,))
result = cursor.fetchone()
return result[0] if result else None
except Exception as e:
logger.error(f"Fehler beim Abrufen der Artikel-ID für {article_number}: {e}")
return None
def update_item_prices(cursor):
"""
Aktualisiert die Haupttabelle item_prices mit den Daten aus item_preise_update.
Args:
cursor: Der Datenbank-Cursor
Returns:
int: Anzahl der aktualisierten Datensätze
"""
try:
logger.info("Aktualisiere item_prices aus item_preise_update...")
cursor.execute("""
UPDATE item_prices ip
JOIN item_preise_update ipu
ON ip.item_id = ipu.item_id
AND ip.customergroup_id = ipu.customergroup_id
SET
ip.quantity_1 = ipu.quantity_1,
ip.price_1 = ipu.price_1,
ip.quantity_2 = ipu.quantity_2,
ip.price_2 = ipu.price_2,
ip.quantity_3 = ipu.quantity_3,
ip.price_3 = ipu.price_3;
""")
# Hole die Anzahl der aktualisierten Zeilen
rows_affected = cursor.rowcount
logger.info(f"Aktualisierte Datensätze: {rows_affected}")
logger.info("Update von item_prices abgeschlossen.")
return rows_affected
except Exception as e:
logger.error(f"Fehler beim Aktualisieren der Preise: {e}")
raise
def import_csv_to_db(csv_file):
"""
Importiert Preisdaten aus einer CSV-Datei in die Datenbank.
Args:
csv_file: Pfad zur CSV-Datei
Returns:
tuple: (Anzahl der verarbeiteten Artikel, Anzahl der aktualisierten Datensätze)
"""
conn = connect_db()
cursor = conn.cursor()
updated_count = 0
processed_items = set() # Für die Zählung eindeutiger Artikel
try:
# Backup & Truncate durchführen
backup_and_clear_table(cursor)
# Prüfe, ob die Datei existiert
if not os.path.exists(csv_file):
raise FileNotFoundError(f"Die Datei {csv_file} wurde nicht gefunden")
# Prüfe, ob die Datei leer ist
if os.path.getsize(csv_file) == 0:
raise ValueError(f"Die Datei {csv_file} ist leer")
with open(csv_file, "r", encoding="utf-8") as file:
reader = csv.reader(file, delimiter=';')
# Prüfe, ob die Datei eine Kopfzeile hat
try:
header = next(reader)
if len(header) < 5:
raise ValueError(f"Ungültiges CSV-Format: Erwartet mindestens 5 Spalten, gefunden {len(header)}")
logger.info(f"CSV-Header: {header}")
except StopIteration:
raise ValueError(f"Die Datei {csv_file} enthält keine Daten")
for row_num, row in enumerate(reader, start=2): # Start bei 2, da Zeile 1 der Header ist
# Prüfe, ob die Zeile genügend Spalten hat
if len(row) < 5:
logger.warning(f"Zeile {row_num}: Ungültiges Format, überspringe Zeile")
continue
article_number, vk1, vk3, vk100, vk_endkunde = row[:5]
# Überspringe leere Zeilen
if not article_number.strip():
continue
item_id = get_item_id(cursor, article_number)
# Ersetze Komma durch Punkt für float-Umwandlung
try:
vk1 = float(vk1.replace(",", "."))
vk3 = float(vk3.replace(",", "."))
vk100 = float(vk100.replace(",", "."))
vk_endkunde = float(vk_endkunde.replace(",", "."))
except ValueError as e:
logger.warning(f"Zeile {row_num}: Ungültiger Preiswert, überspringe Zeile: {e}")
continue
if item_id:
processed_items.add(item_id) # Merke uns den Artikel
# Sicherstellen, dass beide Einträge für customergroup_id 101 und 1 vorhanden sind
cursor.execute("""
INSERT INTO item_preise_update (item_id, customergroup_id, quantity_1, price_1)
VALUES (%s, 101, 1, %s)
ON DUPLICATE KEY UPDATE price_1 = VALUES(price_1)
""", (item_id, vk1))
cursor.execute("""
INSERT INTO item_preise_update (item_id, customergroup_id, quantity_1, price_1)
VALUES (%s, 1, 1, %s)
ON DUPLICATE KEY UPDATE price_1 = VALUES(price_1)
""", (item_id, vk_endkunde))
# VK3 nur wenn > 0 für customergroup_id 101
if vk3 > 0:
cursor.execute("""
UPDATE item_preise_update SET quantity_2 = 3, price_2 = %s
WHERE item_id = %s AND customergroup_id = 101
""", (vk3, item_id))
# VK100 nur wenn > 0 für customergroup_id 101
if vk100 > 0:
cursor.execute("""
UPDATE item_preise_update SET quantity_3 = 100, price_3 = %s
WHERE item_id = %s AND customergroup_id = 101
""", (vk100, item_id))
else:
logger.warning(f"Artikelnummer {article_number} nicht gefunden!")
# Update der Haupttabelle item_prices
updated_count = update_item_prices(cursor)
logger.info(f"Insgesamt {len(processed_items)} eindeutige Artikel verarbeitet")
return len(processed_items), updated_count
except Exception as e:
logger.error(f"Fehler beim Import: {e}")
raise
finally:
cursor.close()
conn.close()
logger.info("CSV-Import und Datenabgleich abgeschlossen!")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Bitte CSV-Datei als Parameter angeben!")
print("Verwendung: python3 preisupdate.py /pfad/zur/csv_datei.csv")
sys.exit(1)
try:
processed_count, updated_count = import_csv_to_db(sys.argv[1])
print(f"Insgesamt {processed_count} eindeutige Artikel verarbeitet")
print(f"Insgesamt {updated_count} Datensätze aktualisiert")
except Exception as e:
logger.error(f"Fehler: {e}")
sys.exit(1)
+252
View File
@@ -0,0 +1,252 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Smart Price Update Service für Intelectra WebShop
Verhindert 50+ REPLACE INTO Abfragen pro Preisänderung!
"""
import json
import sys
import pymysql
import logging
from configparser import ConfigParser
import os
from datetime import datetime
from decimal import Decimal
# Logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler('/var/www/vhosts/intelectra.de/httpdocs/logs/price_update_service.log'),
logging.StreamHandler()
]
)
logger = logging.getLogger('price_update_service')
class PriceUpdateService:
"""Intelligenter Price-Update Service mit Change Detection"""
def __init__(self):
self.conn = self._connect_db()
self.cursor = self.conn.cursor(pymysql.cursors.DictCursor)
def _connect_db(self):
"""DB-Connection aus config.ini"""
config_file = os.path.join(os.path.dirname(__file__), 'db_config.ini')
config = ConfigParser()
config.read(config_file)
return pymysql.connect(
host=config.get('database', 'host', fallback='localhost'),
user=config.get('database', 'user', fallback='tbapy'),
password=config.get('database', 'password', fallback='9%%0H32ryj_N9%%0H32ryj'),
database=config.get('database', 'database', fallback='webshop-sql'),
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor
)
def update_prices_smart(self, item_id, price_data):
"""
Smart Price Update - NUR Änderungen!
Verhindert 50+ REPLACE INTO Abfragen
"""
try:
changes_made = False
total_changes = 0
# 1. Aktuelle Preise laden
self.cursor.execute(
"SELECT customergroup_id, price_1, price_2, price_3, quantity_2, quantity_3, bargain_price_1, bargain_price_2, bargain_price_3 FROM item_prices WHERE item_id = %s",
(item_id,)
)
current_prices = {row['customergroup_id']: row for row in self.cursor.fetchall()}
logger.info(f"Loaded {len(current_prices)} existing price records for item {item_id}")
# 2. Preisänderungen verarbeiten
for group_id, group_prices in price_data.items():
if not group_id.startswith('group_'):
continue
customer_group_id = int(group_id.replace('group_', ''))
current_price = current_prices.get(customer_group_id, {})
# 3. Change Detection für diese Kundengruppe
needs_update = self._price_changed(current_price, group_prices)
if needs_update:
if current_price:
# UPDATE bestehenden Record
self._update_existing_price(item_id, customer_group_id, group_prices)
logger.info(f"Updated prices for group {customer_group_id}")
else:
# INSERT neuen Record
self._insert_new_price(item_id, customer_group_id, group_prices)
logger.info(f"Inserted new prices for group {customer_group_id}")
changes_made = True
total_changes += 1
else:
logger.debug(f"No price changes for group {customer_group_id}")
self.conn.commit()
return {
'success': True,
'item_id': item_id,
'changes_made': changes_made,
'groups_updated': total_changes,
'message': f'Updated {total_changes} price groups' if changes_made else 'No price changes detected'
}
except Exception as e:
self.conn.rollback()
logger.error(f"Error updating prices for item {item_id}: {str(e)}")
return {
'success': False,
'error': str(e),
'item_id': item_id
}
def _safe_float(self, value):
"""Konvertiert Wert sicher zu float - behandelt leere Strings und None"""
if value is None or value == '' or value == 'null':
return 0.0
try:
return float(value)
except (ValueError, TypeError):
return 0.0
def _price_changed(self, current_price, new_prices):
"""Erkennt ob sich Preise geändert haben"""
if not current_price: # Neue Kundengruppe
return True
# Alle relevanten Preisfelder prüfen
price_fields = [
'price_1', 'price_2', 'price_3',
'quantity_2', 'quantity_3',
'bargain_price_1', 'bargain_price_2', 'bargain_price_3'
]
for field in price_fields:
if field in new_prices:
current_val = self._safe_float(current_price.get(field, 0))
new_val = self._safe_float(new_prices[field])
# Dezimal-Vergleich mit Toleranz (0.01)
if abs(current_val - new_val) > 0.001:
logger.debug(f"Price change detected in {field}: {current_val} -> {new_val}")
return True
return False
def _update_existing_price(self, item_id, customer_group_id, group_prices):
"""Update bestehenden Preis-Record"""
set_clauses = []
values = []
price_fields = [
'price_1', 'price_2', 'price_3',
'quantity_2', 'quantity_3',
'bargain_price_1', 'bargain_price_2', 'bargain_price_3'
]
for field in price_fields:
if field in group_prices:
set_clauses.append(f"{field} = %s")
values.append(self._safe_float(group_prices[field]))
if set_clauses:
values.extend([item_id, customer_group_id])
sql = f"UPDATE item_prices SET {', '.join(set_clauses)} WHERE item_id = %s AND customergroup_id = %s"
self.cursor.execute(sql, values)
def _insert_new_price(self, item_id, customer_group_id, group_prices):
"""Insert neuen Preis-Record"""
fields = ['item_id', 'customergroup_id']
values = [item_id, customer_group_id]
price_fields = [
'price_1', 'price_2', 'price_3',
'quantity_2', 'quantity_3',
'bargain_price_1', 'bargain_price_2', 'bargain_price_3'
]
for field in price_fields:
if field in group_prices:
fields.append(field)
values.append(self._safe_float(group_prices[field]))
placeholders = ', '.join(['%s'] * len(values))
sql = f"INSERT INTO item_prices ({', '.join(fields)}) VALUES ({placeholders})"
self.cursor.execute(sql, values)
def get_price_statistics(self, item_id):
"""Debug: Preisstatistiken für ein Item"""
try:
self.cursor.execute("""
SELECT
COUNT(*) as total_groups,
MIN(price_1) as min_price,
MAX(price_1) as max_price,
AVG(price_1) as avg_price
FROM item_prices
WHERE item_id = %s AND price_1 > 0
""", (item_id,))
stats = self.cursor.fetchone()
return {
'success': True,
'item_id': item_id,
'statistics': stats
}
except Exception as e:
return {
'success': False,
'error': str(e)
}
def close(self):
"""Cleanup"""
if self.cursor:
self.cursor.close()
if self.conn:
self.conn.close()
def main():
"""CLI Entry Point für PHP shell_exec()"""
if len(sys.argv) < 2:
print(json.dumps({'error': 'No data provided'}))
sys.exit(1)
try:
# Parse input
data = json.loads(sys.argv[1])
item_id = data.get('item_id')
action = data.get('action', 'update_prices')
service = PriceUpdateService()
if action == 'update_prices':
price_data = data.get('prices', {})
result = service.update_prices_smart(item_id, price_data)
elif action == 'get_statistics':
result = service.get_price_statistics(item_id)
else:
result = {'error': f'Unknown action: {action}'}
service.close()
# Return JSON
print(json.dumps(result))
except Exception as e:
logger.error(f"Main error: {str(e)}")
print(json.dumps({'error': str(e)}))
sys.exit(1)
if __name__ == '__main__':
main()
+116
View File
@@ -0,0 +1,116 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Command-line search script - called by PHP
Usage: python3 python_search.py "search_term"
Output: JSON array of items
"""
import json
import sys
import pymysql
import os
from configparser import ConfigParser
CONFIG_PATH = os.path.join(os.path.dirname(__file__), 'db_config.ini')
def load_db_config():
"""Load database config from ini file"""
parser = ConfigParser()
parser.read(CONFIG_PATH)
config = parser['database']
return {
'host': config.get('host', 'localhost'),
'user': config.get('user'),
'password': config.get('password'),
'database': config.get('database'),
'charset': 'utf8mb4',
'autocommit': True
}
def search_items(query):
"""Search items in database"""
print(f"# DEBUG: search_items called with '{query}'", file=sys.stderr)
if len(query.strip()) < 2:
print("# DEBUG: Query too short", file=sys.stderr)
return []
try:
print("# DEBUG: Loading config...", file=sys.stderr)
config = load_db_config()
print(f"# DEBUG: Connecting to DB: {config['host']}", file=sys.stderr)
conn = pymysql.connect(**config)
cursor = conn.cursor(pymysql.cursors.DictCursor)
print("# DEBUG: Connected successfully", file=sys.stderr)
sql = """
SELECT id, number, name, active
FROM items
WHERE (number LIKE %s OR name LIKE %s)
AND active = 1
ORDER BY
CASE
WHEN number LIKE %s THEN 1
WHEN name LIKE %s THEN 2
ELSE 3
END,
name ASC, number ASC
LIMIT 20
"""
search_param = f"%{query}%"
search_param_start = f"{query}%"
print(f"# DEBUG: SQL params: {search_param}", file=sys.stderr)
cursor.execute(sql, (search_param, search_param, search_param_start, search_param_start))
results = cursor.fetchall()
print(f"# DEBUG: Raw SQL results: {len(results)} rows", file=sys.stderr)
# Test: try without active filter
test_sql = "SELECT COUNT(*) as total FROM items WHERE (number LIKE %s OR name LIKE %s)"
cursor.execute(test_sql, (search_param, search_param))
total = cursor.fetchone()
print(f"# DEBUG: Total matches (any active): {total}", file=sys.stderr)
items = []
for row in results:
status = ' || aktiv' if row['active'] else ' || inaktiv'
items.append({
'id': row['id'],
'value': row['number'],
'label': f"{row['name']} ({row['number']}{status})",
'number': row['number'],
'name': row['name'],
'active': row['active']
})
cursor.close()
conn.close()
return items
except Exception as e:
# Return empty array on error - let PHP fallback handle it
return []
if __name__ == '__main__':
print("# DEBUG: Script started", file=sys.stderr)
print(f"# DEBUG: Args: {sys.argv}", file=sys.stderr)
if len(sys.argv) != 2:
print("# DEBUG: Wrong number of args", file=sys.stderr)
print("[]")
sys.exit(1)
search_query = sys.argv[1]
print(f"# DEBUG: Searching for '{search_query}'", file=sys.stderr)
try:
results = search_items(search_query)
print(f"# DEBUG: Got results: {results}", file=sys.stderr)
print(json.dumps(results))
except Exception as e:
print(f"# DEBUG: Exception: {e}", file=sys.stderr)
import traceback
traceback.print_exc(file=sys.stderr)
print("[]")
+246
View File
@@ -0,0 +1,246 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Sicherheitsdaten-Import-Skript für Intelectra Webshop
Dieses Skript importiert Sicherheitsdaten aus einer CSV-Datei in die Datenbank.
Verwendung:
python3 sdbimport.py /pfad/zur/csv_datei.csv
CSV-Format:
article_id;navision_id;warning_ids;Bedienungsanleitung;EU_Datenblatt;Energielabel;Produktdatenblatt;Sicherheitsdatenblatt;Zertifikat;null_feld
Beispiel: 12345;67890;1;2;3;http://example.com/ba.pdf;http://example.com/eu.pdf;http://example.com/el.pdf;http://example.com/pd.pdf;http://example.com/sdb.pdf;http://example.com/cert.pdf;
"""
import csv
import pymysql
import sys
import os
import logging
from configparser import ConfigParser
# Logging-Konfiguration
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('sdbimport.log')
]
)
logger = logging.getLogger('sdbimport')
def load_config():
"""
Lädt die Konfiguration aus einer INI-Datei oder Umgebungsvariablen.
Falls keine Konfigurationsdatei gefunden wird, werden Standardwerte verwendet.
"""
config = {
'host': 'localhost',
'user': 'tbapy',
'password': '9%%0H32ryj_N9%%0H32ryj',
'database': 'webshop-sql',
'autocommit': True
}
# Versuche, Konfiguration aus Datei zu laden
config_file = os.path.join(os.path.dirname(__file__), 'db_config.ini')
if os.path.exists(config_file):
parser = ConfigParser()
parser.read(config_file)
if 'database' in parser:
config.update(parser['database'])
logger.info("Konfiguration aus Datei geladen")
# Umgebungsvariablen haben Vorrang
if 'DB_HOST' in os.environ:
config['host'] = os.environ['DB_HOST']
if 'DB_USER' in os.environ:
config['user'] = os.environ['DB_USER']
if 'DB_PASSWORD' in os.environ:
config['password'] = os.environ['DB_PASSWORD']
if 'DB_NAME' in os.environ:
config['database'] = os.environ['DB_NAME']
return config
def connect_db():
"""
Stellt eine Verbindung zur Datenbank her.
Returns:
pymysql.Connection: Die Datenbankverbindung
"""
config = load_config()
try:
conn = pymysql.connect(
host=config['host'],
user=config['user'],
password=config['password'],
database=config['database'],
autocommit=config['autocommit']
)
logger.info(f"Verbindung zur Datenbank {config['database']} hergestellt")
return conn
except Exception as e:
logger.error(f"Fehler beim Verbinden zur Datenbank: {e}")
raise
def get_item_id(cursor, article_id, navision_id):
"""
Ermittelt die item_id basierend auf verschiedenen Kriterien.
Args:
cursor: Datenbankverbindung
article_id: Die Artikel-ID aus der CSV
navision_id: Die Navision-ID aus der CSV
Returns:
int: Die gefundene item_id oder None wenn nicht gefunden
"""
# Versuche zuerst über navision_id und attribute_7 zu finden
if navision_id:
sql = """
SELECT id
FROM items
WHERE navision_id = %s
AND attribute_7 IS NOT NULL
LIMIT 1
"""
cursor.execute(sql, (navision_id,))
result = cursor.fetchone()
if result:
return result[0]
# Wenn nicht gefunden, versuche über items.number = article_id
sql = """
SELECT id
FROM items
WHERE number = %s
LIMIT 1
"""
cursor.execute(sql, (article_id,))
result = cursor.fetchone()
return result[0] if result else None
def import_sicherheitsdaten(csv_file):
"""
Importiert Sicherheitsdaten aus einer CSV-Datei in die Datenbank.
Args:
csv_file: Pfad zur CSV-Datei
Returns:
int: Anzahl der verarbeiteten Artikel
"""
conn = connect_db()
cursor = conn.cursor()
processed_items = 0
skipped_items = 0
try:
# Prüfe, ob die Datei existiert
if not os.path.exists(csv_file):
raise FileNotFoundError(f"Die Datei {csv_file} wurde nicht gefunden")
# Prüfe, ob die Datei leer ist
if os.path.getsize(csv_file) == 0:
raise ValueError(f"Die Datei {csv_file} ist leer")
with open(csv_file, newline='', encoding='utf-8') as f:
reader = csv.DictReader(f, delimiter=';')
# Prüfe, ob die Datei die erforderlichen Spalten enthält
required_fields = ['article_id', 'warning_ids']
missing_fields = [field for field in required_fields if field not in reader.fieldnames]
if missing_fields:
raise ValueError(f"Die CSV-Datei fehlt die erforderlichen Spalten: {', '.join(missing_fields)}")
logger.info(f"CSV-Header: {reader.fieldnames}")
for row_num, row in enumerate(reader, start=2):
try:
article_id = row['article_id']
navision_id = row.get('navision_id')
if not article_id:
logger.warning(f"Zeile {row_num}: Keine article_id angegeben, überspringe Zeile")
skipped_items += 1
continue
# Ermittle item_id basierend auf den Kriterien
item_id = get_item_id(cursor, article_id, navision_id)
if not item_id:
logger.warning(f"Zeile {row_num}: Kein passender Artikel gefunden für article_id={article_id}, navision_id={navision_id}")
skipped_items += 1
continue
warning_ids = row.get('warning_ids') or ''
ba = row.get('Bedienungsanleitung') or ''
eu = row.get('EU_Datenblatt') or ''
el = row.get('Energielabel') or ''
pd = row.get('Produktdatenblatt') or ''
sdb = row.get('Sicherheitsdatenblatt') or ''
cert = row.get('Zertifikat') or ''
null_feld = row.get('null_feld') or ''
sql = """
INSERT INTO sicherheitshinweis_item
(article_id, navision_id, warning_ids, Bedienungsanleitung, EU_Datenblatt, Energielabel,
Produktdatenblatt, Sicherheitsdatenblatt, Zertifikat, null_feld)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
ON DUPLICATE KEY UPDATE
navision_id = VALUES(navision_id),
warning_ids = VALUES(warning_ids),
Bedienungsanleitung = VALUES(Bedienungsanleitung),
EU_Datenblatt = VALUES(EU_Datenblatt),
Energielabel = VALUES(Energielabel),
Produktdatenblatt = VALUES(Produktdatenblatt),
Sicherheitsdatenblatt = VALUES(Sicherheitsdatenblatt),
Zertifikat = VALUES(Zertifikat),
null_feld = VALUES(null_feld)
"""
cursor.execute(sql, (
item_id, # Verwende die gefundene item_id statt article_id
navision_id,
warning_ids,
ba, eu, el, pd, sdb, cert, null_feld
))
processed_items += 1
# Logge Fortschritt alle 100 Einträge
if processed_items % 100 == 0:
logger.info(f"{processed_items} Artikel verarbeitet")
except Exception as e:
logger.error(f"Fehler bei Zeile {row_num} (article_id: {article_id}): {e}")
skipped_items += 1
continue
logger.info(f"Import abgeschlossen: {processed_items} Artikel verarbeitet, {skipped_items} übersprungen")
return processed_items
except Exception as e:
logger.error(f"Fehler beim Sicherheitsdaten-Import: {e}")
raise
finally:
cursor.close()
conn.close()
logger.info("Sicherheitsdaten-Import abgeschlossen")
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Bitte CSV-Datei als Parameter angeben!")
print("Verwendung: python3 sdbimport.py /pfad/zur/csv_datei.csv")
sys.exit(1)
try:
processed_count = import_sicherheitsdaten(sys.argv[1])
print(f"Insgesamt {processed_count} eindeutige Artikel verarbeitet")
except Exception as e:
logger.error(f"Fehler: {e}")
sys.exit(1)
+559
View File
@@ -0,0 +1,559 @@
<?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
if (isset($_GET['admin_modul'])) {
// including libs
include_once './libs/smarty/libs/Smarty.class.php';
include_once './modules/admin_layout.class.php';
include_once './core/manufacturer.class.php';
$layout_object = new admin_layout();
$layout_object->start($base_object);
Registry::set('layout_object', $layout_object);
// configuration settings
$layout_object->assign('system_configuration', $base_object->config->shopConfiguration);
// start session
@session_start();
// login
if (isset($_POST['shopLogin'])) {
$logindata = $_POST['shopLogin'];
$request = $base_object->customer->login($logindata['user'],$logindata['pass']);
}
// logout
if (isset($_GET['logout'])) {
$base_object->customer->logout();
}
if ($base_object->customer->auth() == 2 || !empty($_FILES)) {
// get default domain config user language
include_once './core/language.class.php';
$language_object = new Language($base_object);
$languages = $language_object->get_all_objects();
$layout_object->assign('content_languages', $languages);
// translation text
$base_object->i18n->get_shopadmin_text($base_object->customer->get_config_item('admin_language'));
$layout_object->assign('translation_text', $base_object->i18n->shopadmin_translation);
// gat admin permissions
$admin_role_data = array();
if ($base_object->customer->admin_role_id) {
$base_object->admin_role->id = $base_object->customer->admin_role_id;
$admin_role_data = $base_object->admin_role->get_data();
}
// get admin menu data
$menudata = $layout_object->get_admin_menu($admin_role_data);
$layout_object->assign('menudata', $menudata);
// if logged in
$maincontent = '';
if (empty($_GET['admin_modul'])) {
$admin_module = 'admin_dashboard';
} else {
$admin_module = $_GET['admin_modul'];
}
// date
$actual_date = array(
'weekday' => date('l'),
'date' => date("Y-m-d")
);
$actual_date['date'] = $base_object->i18n->convert_date($actual_date['date']);
$layout_object->assign('actual_date',$actual_date);
// header stats
include_once './core/stats.class.php';
$header_stats = Stats::get_stats();
$layout_object->assign('header_stats',$header_stats);
// customer data
$layout_object->assign('admin_user', $base_object->customer);
// load modules
if (isset($admin_module) && $admin_module) {
$module_file = 'modules/'.$admin_module.'.php';
if (file_exists($module_file)) {
include_once $module_file;
$modul_object = new $admin_module($base_object, $layout_object);
$maincontent = $modul_object->run();
} else {
$maincontent = $layout_object->fetch('404.tpl');
}
}
$layout_object->assign('maincontent', $maincontent);
$layout_object->assign('URL', MAIN_URL);
if (isset($_GET['m_active'])) {
$_SESSION['easyshop']['m_active'] = $_GET['m_active'];
} else if (isset($_SESSION['easyshop']['m_active'])) {
$_GET['m_active'] = $_SESSION['easyshop']['m_active'];
} else {
$_GET['m_active'] = 0;
}
$layout_object->assign('menu_active', $_GET['m_active']);
$mod = false;
if (isset($_GET['mod'])) {
$mod = $_GET['mod'];
} else if (isset($_POST['mod'])) {
$mod = $_POST['mod'];
}
if ($mod && ($mod == 'ajax')) {
$site = $layout_object->fetch('ajax.tpl');
} else if ($mod && ($mod == 'set_data')) {
$site = $layout_object->fetch('ajax.tpl');
} else if ($mod && ($mod == 'json')) {
// no layout for this
} else {
$site = $layout_object->fetch('main.tpl');
}
echo $site;
} else {
// if not logged in show admin login
echo $layout_object->fetch('admin_login.tpl');
}
} else {
// show website
include_once './libs/smarty/libs/Smarty.class.php';
include_once './core/layout.class.php';
include_once './core/website.class.php';
include_once './core/structure.class.php';
include_once './core/metatag.class.php';
include_once './core/item.class.php';
include_once './core/shop_theme.class.php';
$layout_menu_id = false;
// start session
if (!isset($_REQUEST['nosess'])) {
session_start();
}
// language selection
if (isset($_GET['lang'])) {
$_SESSION['user_lang'] = $_GET['lang'];
}
// layout object
$layout_object = new layout();
$layout_object->start($base_object);
Registry::set('layout_object', $layout_object);
// website object
$website_object = new website($base_object);
$update_cart = 0;
// login
if (isset($_POST['shopLogin'])) {
$logindata = $_POST['shopLogin'];
$login_save_session = false;
if (isset($_POST['login_save_session']) && $_POST['login_save_session'] == 1) {
$login_save_session = true;
}
$request = $base_object->customer->login($logindata['user'], $logindata['pass'], $login_save_session);
if ($request == 1 && $base_object->config->shopConfiguration['save_customer_shoppingcart'] == 1) {
$update_cart = 1;
}
$layout_object->assign('login_state', $request);
//header('Location: '.$_SERVER['REQUEST_URI']);
}
// logout
else if (isset($_GET['logout'])) {
$base_object->customer->logout();
header('Location: '.STANDARD_DIR);
}
// Create metatag object
$layout_object->metaTagObject = new Metatag($layout_object, $base_object);
$layout_object->metaTagObject->get_by_group('DEFAULT');
// customer authentification
if ($base_object->customer->auth() > 0) {
$customer_data = $base_object->customer->get_data();
$layout_object->assign('customer', $customer_data);
}
if ($update_cart == 1) {
include_once './core/shoppingcart.class.php';
$shopping_cart_object = New Shoppingcart($base_object);
$shopping_cart_object->update_customer_cart();
}
// get customer group
if (isset($base_object->customer->group_id)) {
$base_object->customer_group->id = $base_object->customer->group_id;
} else {
$base_object->customer_group->id = 100;
}
$base_object->customer_group->load_data();
$show_prices_before_login = $base_object->config->shopConfiguration['show_prices_before_login'];
$no_prices = false;
if ($show_prices_before_login != '1') {
if (!$base_object->is_customer_logged_in()) {
$no_prices = true;
}
}
$layout_object->assign('no_prices', $no_prices);
$structure_id = '';
//include_once(ROOT_DIR.'core/website.class.php');
$website_object = new website($base_object);
// frontend ajax
if (!empty($_GET['website_modul'])) {
$website_modul = $_GET['website_modul'];
$module_file = 'modules/'.$website_modul.'.php';
if (file_exists($module_file)) {
include_once $module_file;
$modul_object = new $website_modul($base_object, $layout_object);
if (property_exists($modul_object, 'website_object')) {
$modul_object->website_object = $website_object;
}
if (isset($_POST['param_1'])) {
$website_content = $modul_object->run($_POST['param_1']);
} else {
$website_content = $modul_object->run();
}
echo $website_content;
} else {
$maincontent = $layout_object->_fetch('404.tpl');
}
exit();
}
// Domainhandling
if (isset($base_object->config->shopConfiguration['has_multiple_domains']) && is_array($base_object->config->shopConfiguration['has_multiple_domains'])) {
foreach ($base_object->config->shopConfiguration['has_multiple_domains'] as $domain_arr) {
if ($domain_arr['domain'] == str_replace('www.', '', $_SERVER['HTTP_HOST'])) {
$domain_dependend_layout = true;
$layout_menu_id = $domain_arr['menu_id'];
$_GET['menu_id'] = (is_numeric($_GET['menu_id'])) ? $_GET['menu_id'] : $layout_menu_id;
}
}
}
// start breadcrumb
$breadcrumb = array();
// item search redirect
if (isset($_POST['search_item']) && $_POST['search_item']) {
if (isset($_POST['search_item_categories']) && $_POST['search_item_categories'] > 0) {
header('Location: /index.php?search_item='.$_POST['search_item'].'&item_category='.$_POST['search_item_categories']);
} else if (is_array($_POST['search_item'])) {
$querystring = http_build_query($_POST['search_item']);
header('Location: /index.php?'.$querystring);
} else {
header('Location: /index.php?search_item='.$_POST['search_item']);
}
} else if (isset($_GET['search_item']) && $_GET['search_item']) { // item search per get
$breadcrumb[] = array('name' => 'Artikelsuche', 'short_uri' => '');
$search = array('search_item' => $_GET['search_item']);
if (isset($_GET['item_category']) && $_GET['item_category'] > 0) {
$search['item_category'] = $_GET['item_category'];
}
if (isset($_GET['search_item2']) && $_GET['search_item2']) {
$search['search_item2'] = $_GET['search_item2'];
}
if (isset($_GET['search_item3']) && $_GET['search_item3']) {
$search['search_item3'] = $_GET['search_item3'];
}
include_once(ROOT_DIR.'modules/website_item_search.php');
$content_object = new website_item_search($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($search);
} else if (isset($_POST['manufacturer_id']) && $_POST['manufacturer_id']) { // manufacturer item list
$breadcrumb[] = array('name' => 'Hersteller', 'short_uri' => '/manufacturers/');
$search = array('manufacturer_id' => $_POST['manufacturer_id']);
include_once(ROOT_DIR.'modules/website_item_search.php');
$content_object = new website_item_search($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($search);
} else if (isset($_GET['seo_manufacturer_suri']) && $_GET['seo_manufacturer_suri']) { // manufacturer details
$breadcrumb[] = array('name' => 'Hersteller', 'short_uri' => '/manufacturers/');
if (isset($_GET['structureSuri']) && $_GET['structureSuri']) {
include_once(ROOT_DIR.'modules/website_manufacturers_structure_details.php');
$content_object = new website_manufacturers_structure_details($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($_GET['seo_manufacturer_suri'], $_GET['structureSuri']);
} else {
include_once(ROOT_DIR.'modules/website_manufacturers_details.php');
$content_object = new website_manufacturers_details($base_object, $layout_object, $metatag_object);
$layout_object->maincontent = $content_object->run($_GET['seo_manufacturer_suri']);
}
} else if (isset($_GET['item_id']) && $_GET['item_id'] && $_GET['action'] != 'delete') { // item details
$layout_object->assign('site_type', 'full_width');
$item_id = $_GET['item_id'];
include_once(ROOT_DIR.'modules/website_item.php');
$content_object = new website_item($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($item_id);
// set last customer interesting groups
$group_id = ($_GET['menu_id']) ? $_GET['menu_id'] : $content_object->item_data->structure_id;
$base_object->customer->set_last_interesting_item_groups($group_id);
$layout_object->assign('menu_id', $_GET['menu_id']);
// Meta tags
$layout_object->metaTagObject->get_by_group('ARTIKEL');
$layout_object->metaTagObject->overwriteVar('Bezeichnung', $content_object->item_data->name);
$hersteller = Manufacturer::get_name_by_id_static($content_object->item_data->manufacturer_id);
$layout_object->metaTagObject->overwriteVar('VonHersteller', 'von '.$hersteller);
$layout_object->metaTagObject->overwriteVar('Hersteller', $hersteller);
$layout_object->metaTagObject->overwriteVar('ArtikelAttribut6', str_replace(';',',',$content_object->item_data->attribute_6));
$structure_id = ($_GET['menu_id']) ? $_GET['menu_id'] : $content_object->structure_data[0]->id;
$structure_object = new Structure($base_object);
$tree_ids = array_reverse($structure_object->get_all_tree_ids($structure_id));
$z = 0;
foreach ($tree_ids as $sid) {
$z++;
$layout_object->metaTagObject->overwriteVar('Struktur'.$z, Structure::get_name_by_id_static($sid));
}
$layout_object->metaTagObject->overwriteVar('Warengruppe', Structure::get_name_by_id_static($structure_id));
// multi domain handling
if (isset($base_object->config->shopConfiguration['multi_domain']) && $base_object->config->shopConfiguration['multi_domain']) {
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
// is domain found..
if (isset($base_object->config->shopConfiguration['multi_domain'][$domain])) {
// check domain with structure id
foreach ($base_object->config->shopConfiguration['multi_domain'] as $domain_name => $domain_structure_id) {
if (in_array($domain_structure_id, $tree_ids) && $domain != $domain_name) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$domain_name.$_SERVER['REQUEST_URI']);
}
}
}
}
$layout_object->metaTagObject->overwriteMetas(array(
'title' => $content_object->item_data->seo_title,
'keywords' => $content_object->item_data->seo_keywords,
'description' => $content_object->item_data->seo_description
));
} else { // load main modules
if (isset($_GET['menu_id']) && $_GET['menu_id']) {
$structure_id = $_GET['menu_id'];
$layout_object->assign('current_menu_id', $structure_id);
} else {
if (is_numeric($layout_menu_id)) {
$structure_id = $layout_menu_id;
} else {
$structure_id = 6;
$layout_object->assign('entrypage', true);
}
}
// get site configuration
$structure_object = new Structure($base_object);
$structure_object->structure_id = $structure_id;
$structure_data = $structure_object->get_data();
if ($structure_data->active == 2 && $structure_data->customer_group != $base_object->customer_group->id) {
$structure_id = 6;
$structure_object->structure_id = $structure_id;
$structure_data = $structure_object->get_data();
}
$breadcrumb[] = array('name' => $structure_data->name, 'short_uri' => $structure_data->short_uri, 'object' => $structure_data);
$layout_object->assign('structureData', $structure_data);
$manufacturers = Manufacturer::get_names_by_structure_id($structure_id);
$layout_object->assign('manufacturersOfCurrentStructureId', $manufacturers);
$content_modul = $structure_object->get_type_modul($structure_data->type);
// get maincontent
include_once(ROOT_DIR.'modules/'.$content_modul.'.php');
$content_object = new $content_modul($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($structure_id);
// multi layout with redirect to correct domain
if (isset($base_object->config->shopConfiguration['multi_domain']) && $base_object->config->shopConfiguration['multi_domain']) {
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
// is domain found..
if (isset($base_object->config->shopConfiguration['multi_domain'][$domain])) {
$structure_object = new Structure($base_object);
$tree_ids = $structure_object->get_all_tree_ids($content_object->item_data->structure_id);
// check domain with structure id
foreach ($base_object->config->shopConfiguration['multi_domain'] as $domain_name => $domain_structure_id) {
if (in_array($domain_structure_id, $tree_ids) && $domain != $domain_name) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$domain_name.$_SERVER['REQUEST_URI']);
}
}
}
}
// Meta tags
$structure_level = $structure_object->get_level($structure_data->id, 0);
if ($structure_level > 0 && $structure_level < 5) {
$layout_object->metaTagObject->get_by_group('MENU'.$structure_level);
} else {
$layout_object->metaTagObject->get_by_group('MENU');
}
$layout_object->metaTagObject->overwriteVar('Warengruppe', $structure_data->name);
$tree_ids = array_reverse($structure_object->get_all_tree_ids($structure_data->id));
$z = 0;
foreach ($tree_ids as $sid) {
$z++;
$layout_object->metaTagObject->overwriteVar('Struktur'.$z, Structure::get_name_by_id_static($sid));
}
$usedManus = array();
if ($manufacturers) {
$layout_object->metaTagObject->overwriteVar('Hersteller', implode(', ', $manufacturers));
foreach ($manufacturers as $manuName) {
$usedManus[] = $structure_data->name.' '.$manuName;
}
}
$usedSubs = $structure_object->get_subcategories($structure_id);
if ($usedSubs) {
$layout_object->metaTagObject->overwriteVar('Unterwarengruppen', implode(', ', $usedSubs));
}
$layout_object->metaTagObject->overwriteMetas(array(
'title' => $structure_data->seo_title,
'keywords' => ($structure_data->seo_keywords) ? $structure_data->seo_keywords : implode(', ', $usedManus),
'description' => $structure_data->seo_description
));
}
$layout_object->assign('layout_menu_id', $layout_menu_id);
$base_object->structure_id = $structure_id;
// get main widgets
include '.'.$layout_object->theme_dir.'/theme_widget.inc.php';
$base_object->config->shopConfiguration['widget_regions'] = $widget_regions;
if (isset($widget_regions)) {
$base_object->config->shopConfiguration['widget_regions'] = $widget_regions;
foreach ($widget_regions as $region) {
$base_object->config->shopConfiguration['default_widget_list_'.$region] = ${'default_widget_list_'.$region};
}
}
if (is_array($base_object->config->shopConfiguration['widget_regions'])) {
foreach ($base_object->config->shopConfiguration['widget_regions'] as $region) {
if ($base_object->config->shopConfiguration['has_frontend_widget_config']) {
${$region.'_widget_list'} = $base_object->config->shopConfiguration['widget_'.$region.'_column'];
} else {
${$region.'_widget_list'} = $base_object->config->shopConfiguration['default_widget_list_'.$region];
}
${$region.'_bar'} = '';
if (gettype(${$region.'_widget_list'}) == 'array') {
foreach (${$region.'_widget_list'} as $widget) {
$widget_data = '';
if ($widget['widget']) {
$widget_data = $website_object->{$widget['widget']}(($widget['config']) ? $widget['config'] : false);
}
$layout_object->assign($widget['widget'], $widget_data);
${$region.'_bar'}[] = $layout_object->_fetch($widget['template']);
}
}
$layout_object->assign($region.'_widgets', ${$region.'_bar'});
}
}
$main_theme_id = $structure_data->theme_id;
$header_image = $structure_data->header_image;
$header_link = $structure_data->header_image_link;
// full path breadcrump
if (isset($website_object->activated_structures) && $website_object->activated_structures) {
$breadcrumb = array();
foreach ($website_object->activated_structures as $structure_obj) {
$breadcrumb[] = array('name' => $structure_obj->name, 'short_uri' => $structure_obj->full_short_uri, 'object' => $structure_obj);
// get theme configuration from parent structures
if ($structure_obj->theme_id) {
$main_theme_id = $structure_obj->theme_id;
}
// get header image from parent structures
if ($structure_obj->header_image) {
$header_image = $structure_obj->header_image;
$header_link = $structure_obj->header_image_link;
}
}
}
// get dynamic theme data
$theme_data = new stdClass();
if ($main_theme_id) {
$shop_theme_object = new ShopTheme($base_object);
$theme_data = $shop_theme_object->get_data($main_theme_id);
}
$theme_data->header_image = $header_image;
$theme_data->header_image_link = $header_link;
$layout_object->assign('theme_data', $theme_data);
if ($layout_menu_id) {
$layout_object->assign('menu_items_allsubs', Structure::getLayoutMenu($layout_menu_id));
}
// multi layout with redirect to correct domain
if (isset($base_object->config->shopConfiguration['multi_layout']) && $base_object->config->shopConfiguration['multi_layout']) {
if (!isset($_SESSION['layout_id'])) {
$layout_id = $base_object->config->shopConfiguration['multi_layout_default'];
} else {
$layout_id = $_SESSION['layout_id'];
}
foreach ($base_object->config->shopConfiguration['multi_layout'] as $structure_id => $l_id) {
if (in_array($structure_id, $_GET['parent_ids'])) {
$layout_id = $l_id;
}
}
$_SESSION['layout_id'] = $layout_id;
$layout_object->assign('layout_id', $layout_id);
}
// assign meta tags to template / layout object
$layout_object->metaTagObject->assign();
// show breadcrumb
$layout_object->assign('breadcrumb', $breadcrumb);
// read main template
$layout_object->show_site();
}
?>
+155
View File
@@ -0,0 +1,155 @@
<?php
/**
* @version $Id: list_and_edit.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jtd@ta-edv.de>
* Easyshop is a web shop system
*/
class ListAndEdit {
private $layout_object;
private $base_object;
function __construct($base_object, $layout_object) {
$this->layout_object = $layout_object;
$this->base_object = $base_object;
}
function create() {
$temp = $this->get_POST();
//var_dump($temp);
$temp = $this->core_class_obj->set_row($this->get_POST());
// let set_row return the id and load page with read?
} // end create
function read($var_name) {
$temp = $this->get_GET();
$data = $this->core_class_obj->get_by_id($temp['id']);
$this->layout_object->assign($var_name, $data);
} // end read
function update($fields) {
$data = $this->get_POST();
$id = $this->get_id();
if(isset($data['id'])) {
$data = $this->strip_id($data);
}
$data = $this->make_booleans($data, $fields);
//var_dump($data);
$temp = $this->core_class_obj->set_by_id($data, $id);
//var_dump($temp);
} // end update
function delete() {
$data = $this->get_GET();
$id = $data['id'];
$this->core_class_obj->delete_by_id($id);
} // end delete
/**
* Get all vars given in POST, removes module name, submit from submit button
* and empty values.
*/
private function get_POST() {
$data = $_POST;
if(isset($data['modul'])) {
unset($data['modul']);
}
if(isset($data['submit'])) {
unset($data['submit']);
}
foreach($data as $key => $value) {
if($data[$key] == ""){
unset($data[$key]);
}
}
return $data;
} // end get_POST
private function get_GET() {
return $_GET;
} // end get_GET
private function strip_id($data) {
if(isset($data['id'])) {
unset($data['id']);
return $data;
}
return $data;
} // end strip_id
protected function get_id() {
if(isset($_GET['id'])) return $_GET['id'];
if(isset($_POST['id'])) return $_POST['id'];
return false;
} // end get_id
protected function get_submitted() {
if(isset($_POST['submit'])) {
return true;
}
return false;
}
private function make_booleans($data, $fields) {
//var_dump($fields);
//var_dump('<br />');
foreach($fields as $field) {
//var_dump($data[$field]);
if(isset($data[$field])) {
$data[$field] = 1;
} else {
$data[$field] = 0;
}
//var_dump($data[$field]);
//var_dump('<br />');
}
return $data;
} // end make_booleans
function get_items() {
if(isset($_GET['items']) && is_numeric($_GET['items'])){
$items = (int)$_GET['items'];
$this->base_object->customer->set_config_item('pagination', $items);
} else {
$items = $this->base_object->customer->get_config_item('pagination');
if(is_numeric($items)) {
$items = (int)$items;
} else {
$items = 10;
}
}
return $items;
} // end get_items
function get_page() {
if(isset($_GET['page']) && is_numeric($_GET['page'])){
$page = (int)$_GET['page'];
} else {
$page = 1;
}
return $page;
} // end get_page
function get_tab() {
if(isset($_GET['tab'])) {
$tab = $_GET['tab'];
} else {
$tab = 'all';
}
return $tab;
}
} // end ListAndEdit
+81
View File
@@ -0,0 +1,81 @@
<div class="main_widget_account_wrapper">
<div class="widget_menu_trennlinie1"></div>
<div class="widget_icon"></div>
<div class="widget_title">
<span class="button_name">{$template_text.default.my_account}</span>
<span class="button_text">
{if isset($customer) && ($customer->id != $system_configuration.guest_order_customer_id)}
{if isset($customer->company) && $customer->company != ''}
{$customer->company}
{else}
{$customer->firstname} {$customer->surname}
{/if}
{else}
{$template_text.main_widget_login.please_login}
{/if}
</span>
</div>
<div class="widget_menu_arrow"></div>
<div class="widget_menu_trennlinie"></div>
</div>
<div id="account_kontext" class="{if isset($customer)}account_kontext_active{else}inactive{/if}">
{if isset($customer) && ($customer->id != $system_configuration.guest_order_customer_id)}
<!-- Loggedin -->
<div class="account_kontext_menu_wrapper account_kontext_databox" style="height:170px;">
<div class="title">{$template_text.main_widget_login.logedin}</div>
<a href="/Kundencenter/" class="menu_item" title="Kundencenter">
<span></span>
{if isset($customer->company) && $customer->company != ''}
{$customer->company}
{else}
{$customer->firstname} {$customer->surname}
{/if}
</a>
{if $customer->default_address_street}
<div class="default_address">
{$customer->default_address_street} {$customer->default_address_house_number}<br />
{$customer->default_address_zip_code} {$customer->default_address_city}<br />
</div>
{/if}
</div>
<br />
<div class="account_kontext_menu_wrapper account_kontext_menubox">
<div class="title">{$template_text.main_widget_login.title_customer_center}</div>
<a href="/Kundencenter/" class="menu_item" title="Bestellungen"><span></span>{$template_text.main_widget_login.link_my_orders}</a>
<a href="/Kundencenter/" class="menu_item" title="Adresse"><span></span>{$template_text.main_widget_login.link_edit_address}</a>
<a href="/Kundencenter/" class="menu_item" title="Konto"><span></span>{$template_text.main_widget_login.link_change_account}</a>
<a href="/Merkliste/" class="menu_item" title="Merkliste"><span></span>{$template_text.main_widget_login.link_memory_items}</a>
</div>
<div class="account_button_wrapper" style="position:absolute;bottom:0px;">
{if isset($customer) && $customer->admin_role_id}<a href="{$SUB_DIR}index.php?admin_modul=admin_dashboard" target="_blank" id="account_button_admin" title="Verwaltung">{$template_text.main_widget_login.button_admin}</a>{/if}
<a href="/LogOff/" id="account_button_logout" title="Logout">{$template_text.default.logout}</a>
</div>
{else}
<div class="account_kontext_menu_wrapper account_kontext_loginbox">
<div class="title">{$template_text.main_widget_login.login_widget_already_login}</div>
<div class="subtitle">{$template_text.main_widget_login.login_widget_already_login_info}</div>
<div class="login_form">
<form method="post" action="./">
<input class="login_field login_name" type="text" name="shopLogin[user]" data-defaultv="{$template_text.default.email_address}" value="{$template_text.default.email_address}" />
<input class="login_field login_password" type="password" name="shopLogin[pass]" data-defaultv="{$template_text.default.password}" value="{$template_text.default.password}" />
<input type="hidden" name="shopAction" value="try_login" />
<input type="hidden" name="login_save_session" id="field_login_save_session" value="0" />
<button class="login_button" type="submit">
{$template_text.default.login}
</button>
</form>
</div>
<a href="/Passwort-Vergessen/" class="menu_item_password_forgotten" title="Passwort vergessen">{$template_text.main_widget_login.link_password_forgotten}</a>
<a href="#save_session" id="login_save_session" class="login_save_session_inactive" title="save login">{$template_text.main_widget_login.save_login}</a>
</div>
<br />
<div class="account_kontext_menu_wrapper account_kontext_registrationbox">
<div class="title">{$template_text.main_widget_login.title_new_customer}</div>
<div class="reg_text">{$template_text.main_widget_login.customer_registration_text}</div>
<a href="/Kundenregistrierung/" class="menu_item" title="Kundenregistrierung">{$template_text.main_widget_login.link_customer_registration}</a>
</div>
{/if}
</div>
+74
View File
@@ -0,0 +1,74 @@
<?php
include_once './core/registry.class.php';
include_once './core/paypalexpresscheckout.class.php';
include_once './core/orderstatus.class.php';
function pay_order($base_object, $layout_object, $order_id) {
$order_id = $_GET['order_id'];
$menu_id = $_GET['menu_id'];
$return_url = 'http://' . $_SERVER['SERVER_NAME'] . '/index.php?menu_id=' . $menu_id;
$cancel_url = $return_url . '&cancel=true';
$order_id = $_GET['order_id'];
$order = new Order(Registry::get('base'));
$paypal = new PayPalExpressCheckout($return_url, $cancel_url, $order->get_order_total_by_id($order_id));
// payment_cancelled
// payment_open
// payment_confirm
// payment_confirmed
// payment_error
if (isset($_GET['confirm'])) {
$token = $_GET['token'];
$payer_id = $_GET['PayerId'];
if ($paypal->do_express_checkout_payment($token, $payer_id)) {
$order->set_order_status(OrderStatus::open(), $id);
$call = 'payment_confirmed';
} else {
$layout_object->assign('message', 'Beim Bezahlabschluss ist ein Fehler aufgetreten. ');
$call = 'payment_error';
}
} elseif (isset($_GET['cancel'])) {
$call = 'payment_cancelled';
$order->set_order_status(OrderStatus::cancel(), $order_id);
} else {
$token = $_GET['token'];
$payer_id = $_GET['PayerId'];
if (isset($_GET['token'])) {
if ($paypal->get_express_checkout_details($token)) {
$confirm_url = 'http://' . $_SERVER['SERVER_NAME'] . '/index.php?menu_id=' . $menu_id . '&step=5&order_id=' . $order_id . '&token=' . $token . '&PayerId=' . $payer_id . '&confirm=' . true;
$layout_object->assign('confirm_url', $confirm_url);
$call = 'payment_confirm';
} else {
$layout_object->assign('message', 'Bei der PayPal rückfrage ist ein Fehler aufgetreten.');
$call = 'payment_error';
}
} else {
if ($paypal->set_express_checkout()) {
$layout_object->assign('paypal_link', $paypal->get_link());
$token = $paypal->get_token();
$order->set_order_paypal_token($token, $order_id);
$call = 'payment_open';
} else {
$layout_object->assign('message', 'Beim Initialisieren von PayPal ist ein Fehler aufgetreten.');
$call = 'payment_error';
}
}
}
$layout_object->assign('call', $call);
return $layout_object->fetch('payment_method_paypal.tpl');
}
+16
View File
@@ -0,0 +1,16 @@
<?php
include_once './core/registry.class.php';
include_once './core/paymentmethod.class.php';
function pay_order($base_object, $layout_object, $order_id) {
$order_id = $_GET['order_id'];
$order = new Order(Registry::get('base'));
$order->set_order_status(OrderStatus::open(), $order_id);
$layout_object->assign('order_text', PaymentMethod::get_order_text($order->payment_method));
return $layout_object->fetch('payment_method_vorkasse.tpl');
}
?>
+873
View File
@@ -0,0 +1,873 @@
<?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/country.class.php');
include_once('./core/customer.class.php');
include_once('./core/customeraddress.class.php');
include_once('./core/shoppingcart.class.php');
include_once('./core/payment_method.class.php');
include_once('./core/deliverer.class.php'); // should be called shipping methods
include_once('./core/order.class.php');
include_once('./core/cs_ticket.class.php');
include_once('./core/orderhelper.class.php');
include_once('./core/giftcertificatehelper.class.php');
class website_cashdesk {
private $base_object;
private $layout_object;
private $errors;
private $personal_data;
private $countries;
private $customer_data;
private $customer_addresses;
private $shipping_address;
private $billing_address;
private $shoppingcart_data;
private $shipping_area_id;
private $payment_methods;
private $payment_method_id;
private $shipping_methods;
private $shipping_method_id;
private $has_gift_certificate;
private $gift_certificate_code;
private $gift_certificate_is_valid;
private $gift_certificate;
private $gift_certificate_value;
private $order_number;
private $order_id;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->errors = array();
}
// end __construct
public function run() {
// SUCCESS-Seite nach REDIRECT - verhindert Doppel-Bestellungen
if (isset($_GET['success']) && $_GET['success'] == '1') {
// Bestellnummer aus URL für Template verfügbar machen
if (isset($_GET['order'])) {
$this->layout_object->assign('order_number', $_GET['order']);
}
// Success-Template anzeigen - auch bei Reload!
return $this->layout_object->_fetch('content_cash_desk/completed.tpl');
}
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
// guest order
$this->base_object->customer->customer_id = $this->base_object->config->shopConfiguration['guest_order_customer_id'];
$this->layout_object->assign('guest_order', 1);
}
$action = '';
if ($this->base_object->customer->customer_id) {
if (isset($_POST['cashdesk_action'])) {
$action = $_POST['cashdesk_action'];
} else if (isset($_POST['save_address'])) {
$action = 'save_address';
} else if (isset($_GET['token'])) {
$action = 'change_order';
$param = 'paypal';
}
$this->personal_data = $_POST;
if ($action == 'ready2fly') {
// MAKE ORDER
$this->setup_countries();
$this->setup_customer_data();
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->manage_guest_order_address();
} else {
$this->manage_address();
}
$this->manage_shoppingcart();
$this->manage_payment_method();
$this->manage_shipping_method();
$this->manage_gift_certificate();
$this->managa_conditions();
$this->before_saving_order();
if (count($this->errors) == 0) {
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->setup_customer_data();
// check customer already exists by email
$customer_id = 0;//$this->base_object->customer->check_email($_POST['billing']['email']);
if (!$customer_id) {
// create new customer for guest order
$customer_data = array (
'honorific' => $_POST['billing']['honorific'],
'company' => $_POST['billing']['company'],
'firstname' => $_POST['billing']['firstname'],
'surname' => $_POST['billing']['surname'],
'phone' => $_POST['billing']['phone'],
'group_id' => $this->base_object->config->shopConfiguration['guest_order_customer_group'],
'email' => $_POST['billing']['email']
);
$result = $this->base_object->customer->create($customer_data);
} else {
$result = $customer_id;
}
if ($result) {
$this->customer_data->id = $customer_id = $this->base_object->customer->customer_id = $result;
include_once './core/customeraddress.class.php';
$customer_address_object = new CustomerAddress($this->base_object);
$billing_address = array (
'honorific' => $_POST['billing']['honorific'],
'company' => $_POST['billing']['company'],
'firstname' => $_POST['billing']['firstname'],
'surname' => $_POST['billing']['surname'],
'street' => $_POST['billing']['street'],
'house_number' => $_POST['billing']['house_number'],
'city' => $_POST['billing']['city'],
'zip_code' => $_POST['billing']['zip_code'],
'country' => $_POST['billing']['country'],
'customer_id' => $customer_id
);
$res = $customer_address_object->create($billing_address);
$this->billing_address['address'] = $res;
$shipping_address = array (
'honorific' => $_POST['shipping']['honorific'],
'company' => $_POST['shipping']['company'],
'firstname' => $_POST['shipping']['firstname'],
'surname' => $_POST['shipping']['surname'],
'street' => $_POST['shipping']['street'],
'house_number' => $_POST['shipping']['house_number'],
'city' => $_POST['shipping']['city'],
'zip_code' => $_POST['shipping']['zip_code'],
'country' => $_POST['shipping']['country'],
'customer_id' => $customer_id
);
$res = $customer_address_object->create($shipping_address);
$this->shipping_address['address'] = $res;
}
}
if (isset($_POST['billing']['email'])) {
$data = array(
'id' => $this->base_object->customer->customer_id,
'email' => $_POST['billing']['email']
);
$this->base_object->customer->save($data);
}
$is_saved = $this->save_order();
if ($is_saved) {
return $this->after_saving_order();
}
}
} else if ($action == 'change_order') {
return $this->change_order($param);
} else if ($action == 'save_address') {
// SAVE ADDRESS
$this->setup_customer_data();
$this->save_address();
} else {
// SHOW ORDER
$this->setup_countries();
$this->setup_customer_data();
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->manage_guest_order_address();
} else {
$this->manage_address();
}
$this->manage_shoppingcart();
$this->manage_payment_method();
$this->manage_shipping_method();
$this->manage_gift_certificate();
$this->managa_conditions();
}
//echo var_dump($this->personal_data);
$this->manage_errors();
$this->manage_data_persistence();
// customer info
if (isset($_SESSION['customer_info']) && $_SESSION['customer_info']) {
$this->layout_object->assign('customer_info', $_SESSION['customer_info']);
}
if (!$this->base_object->config->shopConfiguration['menu_in_cashdesk']) {
$this->layout_object->assign('site_type', 'full_width');
}
return $this->layout_object->_fetch('content_cash_desk.tpl');
} else if ($_GET['token']) {
return $this->change_order('paypal');
} else {
// login
$_SESSION['easyshop']['shopAction'] = 'cash_desk_customer_registration';
$this->layout_object->assign('go_to_cash_desk', 1);
return $this->layout_object->_fetch('content_login.tpl');
}
}
// end run
private function setup_countries() {
$country_object = new Country($this->base_object);
$this->countries = $country_object->get_all();
$this->layout_object->assign('countries', $this->countries);
}
// end setup_countries
private function setup_customer_data() {
$customer_id = $this->base_object->customer->customer_id;
$customer_object = new Customer($this->base_object);
$this->customer_data = $customer_object->get_by_id($customer_id);
// customer data is assigned in manage_address to take care of potential missing default address data
$this->layout_object->assign('shoppingcartVATUsage', $this->base_object->customer_group->show_tax);
$this->layout_object->assign('show_tax', $this->base_object->customer_group->show_tax);
$this->layout_object->assign('customer_data', $this->customer_data);
}
// end setup_customer_data
private function manage_guest_order_address() {
$address_object = new CustomerAddress($this->base_object);
$address_object->set_customer_id($this->customer_data->id);
$this->customer_addresses = $address_object->get_all();
if (!isset($this->customer_addresses[$this->customer_data->default_address])) {
$new_default = current($this->customer_addresses);
$this->customer_data->default_address_country_id = $new_default->country;
$this->customer_data->default_address_countryname = $this->countries[$new_default->country]->name;
}
if (isset($_POST['shipping']) && $_POST['shipping']['address'] == -1) {
$this->shipping_address = $_POST['billing'];
$_POST['shipping'] = $_POST['billing'];
} else if (isset($_POST['shipping'])) {
if (!$this->shipping_address['country']) {
$_POST['shipping']['country'] = $this->customer_data->default_address_country_id;
$this->layout_object->assign('default_address_country_id', $this->customer_data->default_address_country_id);
}
$this->shipping_address = $_POST['shipping'];
} else {
$this->shipping_address['country'] = $this->customer_data->default_address_country_id;
}
$this->layout_object->assign('shipping_address', $this->shipping_address);
if (isset($_POST['billing'])) {
$this->billing_address = $_POST['billing'];
} else {
$this->billing_address['country'] = $this->customer_data->default_address_country_id;
}
$this->layout_object->assign('billing_address', $this->billing_address);
$this->layout_object->assign('customer', $this->customer_data);
$shipping_country_id = $this->shipping_address['country'];
$this->shipping_area_id = Country::getShippingAreaById($shipping_country_id, $this->customer_data->group_id);
$this->layout_object->assign('addresses', $this->customer_addresses);
} // end manage_address
private function manage_address() {
$address_object = new CustomerAddress($this->base_object);
$address_object->set_customer_id($this->customer_data->id);
$this->customer_addresses = $address_object->get_all();
// hack for missing default address
if (is_array($this->customer_addresses) && !isset($this->customer_addresses[$this->customer_data->default_address])) {
$new_default = current($this->customer_addresses);
$this->customer_data->default_address = $new_default->id;
$this->customer_data->default_address_company = $new_default->company;
$this->customer_data->default_address_honorific = $new_default->honorific;
$this->customer_data->default_address_firstname = $new_default->firstname;
$this->customer_data->default_address_surname = $new_default->surname;
$this->customer_data->default_address_street = $new_default->street;
$this->customer_data->default_address_house_number = $new_default->house_number;
$this->customer_data->default_address_zip_code = $new_default->zip_code;
$this->customer_data->default_address_city = $new_default->city;
$this->customer_data->default_address_country_id = $new_default->country;
$this->customer_data->default_address_countryname = $this->countries[$new_default->country]->name;
}
if (isset($_POST['shipping']['address']) && $_POST['shipping']['address'] == -1) {
$this->shipping_address = $_POST['billing'];
} else if (isset($_POST['shipping'])) {
$this->shipping_address = $_POST['shipping'];
} else {
$this->shipping_address['address'] = $this->customer_data->default_address;
$this->shipping_address['honorific'] = $this->customer_data->default_address_honorific;
$this->shipping_address['firstname'] = $this->customer_data->default_address_firstname;
$this->shipping_address['surname'] = $this->customer_data->default_address_surname;
$this->shipping_address['company'] = $this->customer_data->default_address_company;
$this->shipping_address['street'] = $this->customer_data->default_address_street;
$this->shipping_address['house_number'] = $this->customer_data->default_address_house_number;
$this->shipping_address['zip_code'] = $this->customer_data->default_address_zip_code;
$this->shipping_address['city'] = $this->customer_data->default_address_city;
$this->shipping_address['country'] = $this->customer_data->default_address_country_id;
}
if (isset($_POST['billing'])) {
$this->billing_address = $_POST['billing'];
} else {
$this->billing_address['address'] = $this->customer_data->default_address;
$this->billing_address['honorific'] = $this->customer_data->default_address_honorific;
$this->billing_address['firstname'] = $this->customer_data->default_address_firstname;
$this->billing_address['surname'] = $this->customer_data->default_address_surname;
$this->billing_address['company'] = $this->customer_data->default_address_company;
$this->billing_address['street'] = $this->customer_data->default_address_street;
$this->billing_address['house_number'] = $this->customer_data->default_address_house_number;
$this->billing_address['zip_code'] = $this->customer_data->default_address_zip_code;
$this->billing_address['city'] = $this->customer_data->default_address_city;
$this->billing_address['country'] = $this->customer_data->default_address_country_id;
}
$billing_country_id = $this->billing_address['country'];
$this->layout_object->assign('customer', $this->customer_data);
$shipping_country_id = $this->shipping_address['country'];
$this->shipping_area_id = Country::getShippingAreaById($shipping_country_id, $this->customer_data->group_id);
$this->layout_object->assign('addresses', $this->customer_addresses);
}
// end manage_address
private function manage_shoppingcart() {
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
// can't show shoppingcart data here, gift certificates can change the data
}
// end manage_shoppingcart
private function manage_payment_method() {
$payment_method_object = new Payment_method($this->base_object);
$this->payment_methods = $payment_method_object->getMethodsForGroup($this->customer_data->group_id, $this->shoppingcart_data['price_sum_gross'], $this->shipping_area_id);
if (isset($_POST['payment_method']) && $_POST['payment_method'] > 0) {
$this->payment_method_id = $_POST['payment_method'];
} else {
//$this->personal_data['payment_method'] = $this->payment_method_id = current($this->payment_methods)->id;
foreach ($this->payment_methods as $pm) {
if ($pm->activeType > 0) {
$this->personal_data['payment_method'] = $this->payment_method_id = $pm->id;
break;
}
}
}
$this->layout_object->assign('payment_methods', $this->payment_methods);
}
// end manage_payment_method
private function manage_shipping_method() {
$shipping_method_object = new Deliverer($this->base_object);
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
$this->shipping_methods = $shipping_method_object->getAllActive(
$this->shipping_area_id, $this->shoppingcart_data['standard_shipping_items'], $this->shoppingcart_data['bulk_goods'], $this->shoppingcart_data['item_weight'], $this->shoppingcart_data['price_sum_gross']
);
if (isset($_POST['shipping_method']) && $_POST['shipping_method'] > 0) {
foreach ($this->shipping_methods as $sm) {
if ($sm->id == $_POST['shipping_method']) {
$this->shipping_method_id = $_POST['shipping_method'];
}
}
}
if (!$this->shipping_method_id) {
$methods = $this->shipping_methods;
$method = array_shift($methods);
$this->personal_data['shipping_method'] = $this->shipping_method_id = $method->id;
}
$this->layout_object->assign('deliverers', $this->shipping_methods);
}
// end manage_shipping_method
private function manage_gift_certificate() {
$this->shoppingcart_data['order_total'] = $this->shoppingcart_data['price_sum_gross'] + $this->payment_methods[$this->payment_method_id]->paymentAdd + $this->shipping_methods[$this->shipping_method_id]->price_add;
$this->shoppingcart_data['payment_method_vat'] = $this->payment_methods[$this->payment_method_id]->paymentAddVat;
$this->shoppingcart_data['shipping_method_vat'] = $this->shipping_methods[$this->shipping_method_id]->price_add_vat;
if (isset($_POST['giftcertificate']['gift_certificat_code']) && $_POST['giftcertificate']['gift_certificat_code'] != '') {
$this->has_gift_certificate = true;
$this->gift_certificate_code = $_POST['giftcertificate']['gift_certificat_code'];
$this->layout_object->assign('giftcode', $this->gift_certificate_code);
$this->gift_certificate_is_valid = GiftCertificateHelper::code_is_valide($this->customer_data->id, $this->gift_certificate_code, $this->shoppingcart_data['price_sum_gross']);
if ($this->gift_certificate_is_valid) {
$this->shoppingcart_data['gift_certificate_code'] = $this->gift_certificate_code;
$this->gift_certificate = GiftCertificateHelper::get_certificate_by_code($this->gift_certificate_code);
$this->gift_certificate_value = GiftCertificateHelper::get_certificate_value($this->gift_certificate_code, $this->shoppingcart_data['price_sum_gross'], $this->customer_data->group_id);
$this->layout_object->assign('giftcertificatevalue', $this->gift_certificate_value->with_vat);
$this->layout_object->assign('giftcertificatmessage', "Code akzeptiert.");
// calculate the part of the gift certificate for each tax rate
$part = $this->gift_certificate_value->with_vat / $this->shoppingcart_data['price_sum_gross'];
} else {
$this->gift_certificate_error = GiftCertificateHelper::get_error_text();
$this->layout_object->assign('gftcertificateerrormessage', $this->gift_certificate_error);
$this->layout_object->assign('giftcertificatmessage', 'Code wird nicht akzeptiert.');
}
} else {
$this->has_gift_certificate = false;
}
foreach ($this->shoppingcart_data['tax_values'] as $key => $value) {
$this->shoppingcart_data['tax_values'][$key]['gift']['percent'] = $percent = round(($value['gross'] / $this->shoppingcart_data['price_sum_gross'] * 100), 2);
$this->shoppingcart_data['tax_values'][$key]['gift']['gross'] = $new_gross = $this->shoppingcart_data['price_sum_gross'] / 100 * $percent;
$this->shoppingcart_data['tax_values'][$key]['gift']['net'] = $new_net = $new_gross / (100 + $key) * 100;
$this->shoppingcart_data['tax_values'][$key]['gift']['vat'] = $new_gross - $new_net;
if ($this->base_object->customer_group->show_tax) {
$this->shoppingcart_data['tax_values'][$key]['gift']['show'] = $new_gross;
} else {
$this->shoppingcart_data['tax_values'][$key]['gift']['show'] = $new_net;
}
}
// TODO: HACK, generalize this
if (isset($this->payment_methods[9])) {
if ((isset($this->base_object->config->shopConfiguration['klarna_eid']) &&
$this->base_object->config->shopConfiguration['klarna_eid'] != '') &&
(isset($this->base_object->config->shopConfiguration['klarna_secret']) &&
$this->base_object->config->shopConfiguration['klarna_secret'] != '')) {
include_once('./core/shop_klarna.class.php');
// klarna installments
$klarna_object = new Shop_klarna($this->base_object);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$klarna_installments = $klarna_object->get_installments($this->shoppingcart_data['order_total'] - $this->gift_certificate_value->with_vat);
} else {
$klarna_installments = $klarna_object->get_installments($this->shoppingcart_data['order_total']);
}
$this->layout_object->assign('klarna_installments', $klarna_installments);
}
}
// since the gift certificate can change the cart data this must be done here
$this->layout_object->assign('shoppingcart', $this->shoppingcart_data);
}
// end manage_gift_certificate
private function managa_conditions() {
$site_content_object = new SiteContent($this->base_object);
$agb_data = array();
$agb_data['datenschutz'] = $site_content_object->get_textbox_data_by_id(55);
$agb_data['agbs'] = $site_content_object->get_textbox_data_by_id(56);
$agb_data['agbs_b2b'] = $site_content_object->get_textbox_data_by_id(10632);
$agb_data['widerruf'] = $site_content_object->get_textbox_data_by_id(60);
$this->layout_object->assign('agb_data', $agb_data);
}
// end manage_conditions
private function manage_errors() {
$this->layout_object->assign('error_message', $this->errors);
}
// end manage_errors
private function manage_data_persistence() {
// ugly hack for data persistence
$this->layout_object->assign('personal_data', $this->personal_data);
}
// end manage_data_persistence
private function save_address() {
$address = $_POST;
unset($address['save_address']);
$address_id = false;
if ($address['address'] != '') {
$address_id = $address['address'];
}
unset($address['address']);
$address['customer_id'] = $this->customer_data->id;
$customer_address_object = new CustomerAddress($this->base_object);
$ret = array();
if ($customer_address_object->validate($address)) {
if ($address_id) {
$customer_address_object->update($address, $address_id);
} else {
$address_id = $customer_address_object->create($address);
}
$ret['id'] = $address_id;
$ret['stat'] = 'OK';
} else {
$ret['stat'] = 'ERR';
$ret['data'] = $customer_address_object->get_validation_errors();
}
echo json_encode($ret);
exit();
}
// end save_address
private function before_saving_order() {
// check order
if (!isset($_GET['guest_order']) || $_GET['guest_order'] != 1) {
if (!is_numeric($_POST['billing']['address'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Rechnungsadresse';
}
if (!is_numeric($_POST['shipping']['address'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Lieferadresse';
}
}
if (!is_numeric($_POST['payment_method'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Zahlungsart';
} else {
$payment_method_id = $_POST['payment_method'];
if ($this->payment_methods[$payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id]);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
if ($this->payment_methods[$payment_method_id]->argument != '') {
$return = $payment_method_module->before_order($this->payment_methods[$payment_method_id]->argument);
} else {
$return = $payment_method_module->before_order();
}
if ($return) {
$this->errors[] = $return;
}
}
}
}
if (!is_numeric($_POST['shipping_method'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Versandart';
}
if (!is_numeric($_POST['agreements_accepted'])) {
$this->errors[] = 'Bitte akzeptieren Sie unsere Bedingungen';
}
}
// end before_saving_order
private function save_order() {
// 🚀 FIX 1: Verhindere Doppel-Bestellungen (PayPal Return Flow + Neuanlage)
// Prüfe SOWOHL Customer-ID ALS AUCH Session (wichtig bei Neuanlage!)
$customer_id = intval($this->base_object->customer->customer_id);
$session_id = session_id();
// Prüfe ob bereits eine Order in den letzten 5 Minuten angelegt wurde
// ENTWEDER von dieser Customer-ID ODER von dieser Session (für Neukunden!)
$sql = "SELECT id, order_number, order_total, order_date, customer_id
FROM orders
WHERE (customer_id = " . $this->base_object->db->real_escape_string($customer_id) . "
OR customer_id IN (
SELECT id FROM customers
WHERE email = '" . $this->base_object->db->real_escape_string($this->customer_data->email ?? '') . "'
AND registration_date >= DATE_SUB(NOW(), INTERVAL 10 MINUTE)
))
AND order_date >= DATE_SUB(NOW(), INTERVAL 5 MINUTE)
ORDER BY id DESC LIMIT 1";
$result = $this->base_object->db->query($sql);
if ($result && $result->num_rows > 0) {
$existing_order = $result->fetch_object();
error_log("ORDER PREVENTED: Duplicate order detected - " .
"Customer: " . $customer_id .
" (Email: " . ($this->customer_data->email ?? 'unknown') . "), " .
"Existing Order: " . $existing_order->order_number .
" (ID: " . $existing_order->id . ") from " . $existing_order->order_date .
", Context: " . (isset($_GET['token']) ? 'PayPal Return' : 'Direct'));
// Setze Order-Daten für Success-Seite
$this->order_id = $existing_order->id;
$this->order_number = $existing_order->order_number;
return true; // Gib vor, dass Order erfolgreich war (ist sie ja!)
}
// 🚀 FIX 2: Verhindere 0€ Bestellungen ohne Items (Race Condition / Session Loss)
if (empty($this->shoppingcart_data) ||
!isset($this->shoppingcart_data['items']) ||
empty($this->shoppingcart_data['items']) ||
!isset($this->shoppingcart_data['amount_sum']) ||
intval($this->shoppingcart_data['amount_sum']) <= 0) {
error_log("ORDER PREVENTED: Empty cart or 0€ order attempted - Customer: " .
($this->customer_data->id ?? 'unknown') .
", Cart Items: " . (count($this->shoppingcart_data['items'] ?? [])) .
", Amount Sum: " . ($this->shoppingcart_data['amount_sum'] ?? '0'));
$this->errors[] = 'Ihr Warenkorb ist leer. Bitte fügen Sie Artikel hinzu.';
return false;
}
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$orderDataObject = OrderHelper::createOrderObject(array(
'customerId' => $this->customer_data->id,
'cartId' => session_id(),
'billingAddressId' => $this->billing_address['address'],
'shippingAddressId' => $this->shipping_address['address'],
'paymentMethodId' => $this->payment_method_id,
'shippingMethodId' => $this->shipping_method_id,
'giftCertificate' => $this->gift_certificate_code
), $this->base_object);
} else {
$orderDataObject = OrderHelper::createOrderObject(array(
'customerId' => $this->base_object->customer->customer_id,
'cartId' => session_id(),
'billingAddressId' => $this->billing_address['address'],
'shippingAddressId' => $this->shipping_address['address'],
'paymentMethodId' => $this->payment_method_id,
'shippingMethodId' => $this->shipping_method_id
), $this->base_object);
}
// TODO : HACK
// fix up paymemt method with ALL the data
$orderDataObject->payment->methodId = $this->payment_method_id;
$orderDataObject->payment->areaId = $this->shipping_area_id;
$orderDataObject->payment->priceGross = $this->payment_methods[$this->payment_method_id]->paymentAdd;
$orderDataObject->payment->priceNet = $this->payment_methods[$this->payment_method_id]->paymentAddNet;
$orderDataObject->payment->priceVat = $this->payment_methods[$this->payment_method_id]->paymentAddVat;
$orderDataObject->payment->vatRate = '19.00';
// TODO : HACK
// fix up shipping method with ALL the data
$orderDataObject->shipping->methodId = $this->shipping_method_id;
$orderDataObject->shipping->areaId = $this->shipping_area_id;
$orderDataObject->shipping->priceGross = $this->shipping_methods[$this->shipping_method_id]->price_add;
$orderDataObject->shipping->priceNet = $this->shipping_methods[$this->shipping_method_id]->price_add_net;
$orderDataObject->shipping->priceVat = $this->shipping_methods[$this->shipping_method_id]->price_add_vat;
$orderDataObject->shipping->vatRate = '19.00';
if (isset($_POST['customer_info']) && $_POST['customer_info'] != '') {
$orderDataObject->customer_info = $_POST['customer_info'];
}
if ($this->payment_methods[$this->payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$this->payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id]);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
if ($this->payment_methods[$this->payment_method_id]->argument != '') {
$return = $payment_method_module->during_order($this->payment_methods[$this->payment_method_id]->argument);
} else {
$return = $payment_method_module->during_order();
}
if ($return) {
foreach ($return as $key => $value) {
$orderDataObject->$key = $value;
}
}
}
}
$order_object = new Order($this->base_object);
$this->order_id = $order_object->create($orderDataObject);
$this->order_number = OrderHelper::get_order_number($this->order_id);
unset($_SESSION['customer_info']);
if ($this->order_id) {
// send email
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(3, $this->customer_data->id, $this->order_id);
// EU-RL 2026/2673: elektronischer Widerruf (B2C) – silent solange Flag aus
try {
include_once './core/revocation.class.php';
$revocation_obj = new Revocation($this->base_object);
$revocation_obj->create_for_order($this->order_id);
} catch (Throwable $e) {
error_log('Revocation hook failed for order '.$this->order_id.': '.$e->getMessage());
}
if ($this->order_number) {
return true;
}
}
return false;
}
// end save_order
private function after_saving_order() {
$this->layout_object->assign('order_number', $this->order_number);
$this->layout_object->assign('order_amount', $this->shoppingcart_data['order_total']);
// get trusted shop payment id
$trusted_shop_payment = 'OTHER';
if ($this->payment_method_id == 1) {
$trusted_shop_payment = 'PREPAYMENT';
} else if ($this->payment_method_id == 2) {
$trusted_shop_payment = 'CASH_ON_DELIVERY';
} else if ($this->payment_method_id == 3) {
$trusted_shop_payment = 'INVOICE';
} else if ($this->payment_method_id == 4) {
$trusted_shop_payment = 'PAYPAL';
} else if ($this->payment_method_id == 6) {
$trusted_shop_payment = 'DIRECT_DEBIT';
}
$this->layout_object->assign('trusted_shop_payment', $trusted_shop_payment);
$shoppingcart_object = new Shoppingcart($this->base_object);
$shoppingcart_object->clear(1);
if ($this->payment_methods[$this->payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$this->payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id], $this->order_id);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
return $payment_method_module->after_order($this->shoppingcart_data['order_total']);
}
}
// REDIRECT statt Template - verhindert Doppel-Bestellungen bei F5
$order_num = $this->order_number ? $this->order_number : 'unbekannt';
header('Location: /Kasse/?success=1&order=' . urlencode($order_num));
exit;
}
// end after_saving_order
private function change_order($param) {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($param).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
return $payment_method_module->change_order();
}
}
// end change_order
private function manage_guest_payment_method() {
$payment_method_object = new Payment_method($this->base_object);
/* temp: */ $this->shipping_area_id = 1;
$this->payment_methods = $payment_method_object->getMethodsForGroup($this->base_object->config->shopConfiguration['guest_order_customer_group'], $this->shoppingcart_data['price_sum_gross'], $this->shipping_area_id);
if (isset($_POST['payment_method']) && $_POST['payment_method'] > 0) {
$this->payment_method_id = $_POST['payment_method'];
} else {
$this->personal_data['payment_method'] = $this->payment_method_id = current($this->payment_methods)->id;
}
$this->layout_object->assign('payment_methods', $this->payment_methods);
}
// end manage_payment_method
private function manage_guest_shipping_method() {
$shipping_method_object = new Deliverer($this->base_object);
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
$this->shipping_methods = $shipping_method_object->getAllActive(
$this->shipping_area_id, $this->shoppingcart_data['standard_shipping_items'], $this->shoppingcart_data['bulk_goods'], $this->shoppingcart_data['item_weight']
);
if (isset($_POST['shipping_method']) && $_POST['shipping_method'] > 0) {
$this->shipping_method_id = $_POST['shipping_method'];
} else {
$this->personal_data['shipping_method'] = $this->shipping_method_id = current($this->shipping_methods)->id;
}
$this->layout_object->assign('deliverers', $this->shipping_methods);
}
// end manage_shipping_method
}
// end website_cashdesk
?>
+799
View File
@@ -0,0 +1,799 @@
<?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/country.class.php');
include_once('./core/customer.class.php');
include_once('./core/customeraddress.class.php');
include_once('./core/shoppingcart.class.php');
include_once('./core/payment_method.class.php');
include_once('./core/deliverer.class.php'); // should be called shipping methods
include_once('./core/order.class.php');
include_once('./core/cs_ticket.class.php');
include_once('./core/orderhelper.class.php');
include_once('./core/giftcertificatehelper.class.php');
class website_cashdesk {
private $base_object;
private $layout_object;
private $errors;
private $personal_data;
private $countries;
private $customer_data;
private $customer_addresses;
private $shipping_address;
private $billing_address;
private $shoppingcart_data;
private $shipping_area_id;
private $payment_methods;
private $payment_method_id;
private $shipping_methods;
private $shipping_method_id;
private $has_gift_certificate;
private $gift_certificate_code;
private $gift_certificate_is_valid;
private $gift_certificate;
private $gift_certificate_value;
private $order_number;
private $order_id;
function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->errors = array();
}
// end __construct
public function run() {
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
// guest order
$this->base_object->customer->customer_id = $this->base_object->config->shopConfiguration['guest_order_customer_id'];
$this->layout_object->assign('guest_order', 1);
}
$action = '';
if ($this->base_object->customer->customer_id) {
if (isset($_POST['cashdesk_action'])) {
$action = $_POST['cashdesk_action'];
} else if (isset($_POST['save_address'])) {
$action = 'save_address';
} else if (isset($_GET['token'])) {
$action = 'change_order';
$param = 'paypal';
}
$this->personal_data = $_POST;
if ($action == 'ready2fly') {
// MAKE ORDER
$this->setup_countries();
$this->setup_customer_data();
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->manage_guest_order_address();
} else {
$this->manage_address();
}
$this->manage_shoppingcart();
$this->manage_payment_method();
$this->manage_shipping_method();
$this->manage_gift_certificate();
$this->managa_conditions();
$this->before_saving_order();
if (count($this->errors) == 0) {
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->setup_customer_data();
// check customer already exists by email
$customer_id = 0;//$this->base_object->customer->check_email($_POST['billing']['email']);
if (!$customer_id) {
// create new customer for guest order
$customer_data = array (
'honorific' => $_POST['billing']['honorific'],
'company' => $_POST['billing']['company'],
'firstname' => $_POST['billing']['firstname'],
'surname' => $_POST['billing']['surname'],
'phone' => $_POST['billing']['phone'],
'group_id' => $this->base_object->config->shopConfiguration['guest_order_customer_group'],
'email' => $_POST['billing']['email']
);
$result = $this->base_object->customer->create($customer_data);
} else {
$result = $customer_id;
}
if ($result) {
$this->customer_data->id = $customer_id = $this->base_object->customer->customer_id = $result;
include_once './core/customeraddress.class.php';
$customer_address_object = new CustomerAddress($this->base_object);
$billing_address = array (
'honorific' => $_POST['billing']['honorific'],
'company' => $_POST['billing']['company'],
'firstname' => $_POST['billing']['firstname'],
'surname' => $_POST['billing']['surname'],
'street' => $_POST['billing']['street'],
'house_number' => $_POST['billing']['house_number'],
'city' => $_POST['billing']['city'],
'zip_code' => $_POST['billing']['zip_code'],
'country' => $_POST['billing']['country'],
'customer_id' => $customer_id
);
$res = $customer_address_object->create($billing_address);
$this->billing_address['address'] = $res;
$shipping_address = array (
'honorific' => $_POST['shipping']['honorific'],
'company' => $_POST['shipping']['company'],
'firstname' => $_POST['shipping']['firstname'],
'surname' => $_POST['shipping']['surname'],
'street' => $_POST['shipping']['street'],
'house_number' => $_POST['shipping']['house_number'],
'city' => $_POST['shipping']['city'],
'zip_code' => $_POST['shipping']['zip_code'],
'country' => $_POST['shipping']['country'],
'customer_id' => $customer_id
);
$res = $customer_address_object->create($shipping_address);
$this->shipping_address['address'] = $res;
}
}
if (isset($_POST['billing']['email'])) {
$data = array(
'id' => $this->base_object->customer->customer_id,
'email' => $_POST['billing']['email']
);
$this->base_object->customer->save($data);
}
$is_saved = $this->save_order();
if ($is_saved) {
return $this->after_saving_order();
}
}
} else if ($action == 'change_order') {
return $this->change_order($param);
} else if ($action == 'save_address') {
// SAVE ADDRESS
$this->setup_customer_data();
$this->save_address();
} else {
// SHOW ORDER
$this->setup_countries();
$this->setup_customer_data();
if (isset($_GET['guest_order']) && $_GET['guest_order'] == 1) {
$this->manage_guest_order_address();
} else {
$this->manage_address();
}
$this->manage_shoppingcart();
$this->manage_payment_method();
$this->manage_shipping_method();
$this->manage_gift_certificate();
$this->managa_conditions();
}
//echo var_dump($this->personal_data);
$this->manage_errors();
$this->manage_data_persistence();
// customer info
if (isset($_SESSION['customer_info']) && $_SESSION['customer_info']) {
$this->layout_object->assign('customer_info', $_SESSION['customer_info']);
}
if (!$this->base_object->config->shopConfiguration['menu_in_cashdesk']) {
$this->layout_object->assign('site_type', 'full_width');
}
return $this->layout_object->_fetch('content_cash_desk.tpl');
} else if ($_GET['token']) {
return $this->change_order('paypal');
} else {
// login
$_SESSION['easyshop']['shopAction'] = 'cash_desk_customer_registration';
$this->layout_object->assign('go_to_cash_desk', 1);
return $this->layout_object->_fetch('content_login.tpl');
}
}
// end run
private function setup_countries() {
$country_object = new Country($this->base_object);
$this->countries = $country_object->get_all();
$this->layout_object->assign('countries', $this->countries);
}
// end setup_countries
private function setup_customer_data() {
$customer_id = $this->base_object->customer->customer_id;
$customer_object = new Customer($this->base_object);
$this->customer_data = $customer_object->get_by_id($customer_id);
// customer data is assigned in manage_address to take care of potential missing default address data
$this->layout_object->assign('shoppingcartVATUsage', $this->base_object->customer_group->show_tax);
$this->layout_object->assign('show_tax', $this->base_object->customer_group->show_tax);
$this->layout_object->assign('customer_data', $this->customer_data);
}
// end setup_customer_data
private function manage_guest_order_address() {
$address_object = new CustomerAddress($this->base_object);
$address_object->set_customer_id($this->customer_data->id);
$this->customer_addresses = $address_object->get_all();
if (!isset($this->customer_addresses[$this->customer_data->default_address])) {
$new_default = current($this->customer_addresses);
$this->customer_data->default_address_country_id = $new_default->country;
$this->customer_data->default_address_countryname = $this->countries[$new_default->country]->name;
}
if (isset($_POST['shipping']) && $_POST['shipping']['address'] == -1) {
$this->shipping_address = $_POST['billing'];
$_POST['shipping'] = $_POST['billing'];
} else if (isset($_POST['shipping'])) {
if (!$this->shipping_address['country']) {
$_POST['shipping']['country'] = $this->customer_data->default_address_country_id;
$this->layout_object->assign('default_address_country_id', $this->customer_data->default_address_country_id);
}
$this->shipping_address = $_POST['shipping'];
} else {
$this->shipping_address['country'] = $this->customer_data->default_address_country_id;
}
$this->layout_object->assign('shipping_address', $this->shipping_address);
if (isset($_POST['billing'])) {
$this->billing_address = $_POST['billing'];
} else {
$this->billing_address['country'] = $this->customer_data->default_address_country_id;
}
$this->layout_object->assign('billing_address', $this->billing_address);
$this->layout_object->assign('customer', $this->customer_data);
$shipping_country_id = $this->shipping_address['country'];
$this->shipping_area_id = Country::getShippingAreaById($shipping_country_id, $this->customer_data->group_id);
$this->layout_object->assign('addresses', $this->customer_addresses);
} // end manage_address
private function manage_address() {
$address_object = new CustomerAddress($this->base_object);
$address_object->set_customer_id($this->customer_data->id);
$this->customer_addresses = $address_object->get_all();
// hack for missing default address
if (is_array($this->customer_addresses) && !isset($this->customer_addresses[$this->customer_data->default_address])) {
$new_default = current($this->customer_addresses);
$this->customer_data->default_address = $new_default->id;
$this->customer_data->default_address_company = $new_default->company;
$this->customer_data->default_address_honorific = $new_default->honorific;
$this->customer_data->default_address_firstname = $new_default->firstname;
$this->customer_data->default_address_surname = $new_default->surname;
$this->customer_data->default_address_street = $new_default->street;
$this->customer_data->default_address_house_number = $new_default->house_number;
$this->customer_data->default_address_zip_code = $new_default->zip_code;
$this->customer_data->default_address_city = $new_default->city;
$this->customer_data->default_address_country_id = $new_default->country;
$this->customer_data->default_address_countryname = $this->countries[$new_default->country]->name;
}
if ($_POST['shipping']['address'] == -1) {
$this->shipping_address = $_POST['billing'];
} else if (isset($_POST['shipping'])) {
$this->shipping_address = $_POST['shipping'];
} else {
$this->shipping_address['address'] = $this->customer_data->default_address;
$this->shipping_address['honorific'] = $this->customer_data->default_address_honorific;
$this->shipping_address['firstname'] = $this->customer_data->default_address_firstname;
$this->shipping_address['surname'] = $this->customer_data->default_address_surname;
$this->shipping_address['company'] = $this->customer_data->default_address_company;
$this->shipping_address['street'] = $this->customer_data->default_address_street;
$this->shipping_address['house_number'] = $this->customer_data->default_address_house_number;
$this->shipping_address['zip_code'] = $this->customer_data->default_address_zip_code;
$this->shipping_address['city'] = $this->customer_data->default_address_city;
$this->shipping_address['country'] = $this->customer_data->default_address_country_id;
}
if (isset($_POST['billing'])) {
$this->billing_address = $_POST['billing'];
} else {
$this->billing_address['address'] = $this->customer_data->default_address;
$this->billing_address['honorific'] = $this->customer_data->default_address_honorific;
$this->billing_address['firstname'] = $this->customer_data->default_address_firstname;
$this->billing_address['surname'] = $this->customer_data->default_address_surname;
$this->billing_address['company'] = $this->customer_data->default_address_company;
$this->billing_address['street'] = $this->customer_data->default_address_street;
$this->billing_address['house_number'] = $this->customer_data->default_address_house_number;
$this->billing_address['zip_code'] = $this->customer_data->default_address_zip_code;
$this->billing_address['city'] = $this->customer_data->default_address_city;
$this->billing_address['country'] = $this->customer_data->default_address_country_id;
}
$billing_country_id = $this->billing_address['country'];
$this->layout_object->assign('customer', $this->customer_data);
$shipping_country_id = $this->shipping_address['country'];
$this->shipping_area_id = Country::getShippingAreaById($shipping_country_id, $this->customer_data->group_id);
$this->layout_object->assign('addresses', $this->customer_addresses);
}
// end manage_address
private function manage_shoppingcart() {
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
// can't show shoppingcart data here, gift certificates can change the data
}
// end manage_shoppingcart
private function manage_payment_method() {
$payment_method_object = new Payment_method($this->base_object);
$this->payment_methods = $payment_method_object->getMethodsForGroup($this->customer_data->group_id, $this->shoppingcart_data['price_sum_gross'], $this->shipping_area_id);
if (isset($_POST['payment_method']) && $_POST['payment_method'] > 0) {
$this->payment_method_id = $_POST['payment_method'];
} else {
//$this->personal_data['payment_method'] = $this->payment_method_id = current($this->payment_methods)->id;
foreach ($this->payment_methods as $pm) {
if ($pm->activeType > 0) {
$this->personal_data['payment_method'] = $this->payment_method_id = $pm->id;
break;
}
}
}
$this->layout_object->assign('payment_methods', $this->payment_methods);
}
// end manage_payment_method
private function manage_shipping_method() {
$shipping_method_object = new Deliverer($this->base_object);
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
$this->shipping_methods = $shipping_method_object->getAllActive(
$this->shipping_area_id, $this->shoppingcart_data['standard_shipping_items'], $this->shoppingcart_data['bulk_goods'], $this->shoppingcart_data['item_weight'], $this->shoppingcart_data['price_sum_gross']
);
if (isset($_POST['shipping_method']) && $_POST['shipping_method'] > 0) {
foreach ($this->shipping_methods as $sm) {
if ($sm->id == $_POST['shipping_method']) {
$this->shipping_method_id = $_POST['shipping_method'];
}
}
}
if (!$this->shipping_method_id) {
$methods = $this->shipping_methods;
$method = array_shift($methods);
$this->personal_data['shipping_method'] = $this->shipping_method_id = $method->id;
}
$this->layout_object->assign('deliverers', $this->shipping_methods);
}
// end manage_shipping_method
private function manage_gift_certificate() {
$this->shoppingcart_data['order_total'] = $this->shoppingcart_data['price_sum_gross'] + $this->payment_methods[$this->payment_method_id]->paymentAdd + $this->shipping_methods[$this->shipping_method_id]->price_add;
$this->shoppingcart_data['payment_method_vat'] = $this->payment_methods[$this->payment_method_id]->paymentAddVat;
$this->shoppingcart_data['shipping_method_vat'] = $this->shipping_methods[$this->shipping_method_id]->price_add_vat;
if (isset($_POST['giftcertificate']['gift_certificat_code']) && $_POST['giftcertificate']['gift_certificat_code'] != '') {
$this->has_gift_certificate = true;
$this->gift_certificate_code = $_POST['giftcertificate']['gift_certificat_code'];
$this->layout_object->assign('giftcode', $this->gift_certificate_code);
$this->gift_certificate_is_valid = GiftCertificateHelper::code_is_valide($this->customer_data->id, $this->gift_certificate_code, $this->shoppingcart_data['price_sum_gross']);
if ($this->gift_certificate_is_valid) {
$this->shoppingcart_data['gift_certificate_code'] = $this->gift_certificate_code;
$this->gift_certificate = GiftCertificateHelper::get_certificate_by_code($this->gift_certificate_code);
$this->gift_certificate_value = GiftCertificateHelper::get_certificate_value($this->gift_certificate_code, $this->shoppingcart_data['price_sum_gross'], $this->customer_data->group_id);
$this->layout_object->assign('giftcertificatevalue', $this->gift_certificate_value->with_vat);
$this->layout_object->assign('giftcertificatmessage', "Code akzeptiert.");
// calculate the part of the gift certificate for each tax rate
$part = $this->gift_certificate_value->with_vat / $this->shoppingcart_data['price_sum_gross'];
} else {
$this->gift_certificate_error = GiftCertificateHelper::get_error_text();
$this->layout_object->assign('gftcertificateerrormessage', $this->gift_certificate_error);
$this->layout_object->assign('giftcertificatmessage', 'Code wird nicht akzeptiert.');
}
} else {
$this->has_gift_certificate = false;
}
foreach ($this->shoppingcart_data['tax_values'] as $key => $value) {
$this->shoppingcart_data['tax_values'][$key]['gift']['percent'] = $percent = round(($value['gross'] / $this->shoppingcart_data['price_sum_gross'] * 100), 2);
$this->shoppingcart_data['tax_values'][$key]['gift']['gross'] = $new_gross = $this->shoppingcart_data['price_sum_gross'] / 100 * $percent;
$this->shoppingcart_data['tax_values'][$key]['gift']['net'] = $new_net = $new_gross / (100 + $key) * 100;
$this->shoppingcart_data['tax_values'][$key]['gift']['vat'] = $new_gross - $new_net;
if ($this->base_object->customer_group->show_tax) {
$this->shoppingcart_data['tax_values'][$key]['gift']['show'] = $new_gross;
} else {
$this->shoppingcart_data['tax_values'][$key]['gift']['show'] = $new_net;
}
}
// TODO: HACK, generalize this
if (isset($this->payment_methods[9])) {
if ((isset($this->base_object->config->shopConfiguration['klarna_eid']) &&
$this->base_object->config->shopConfiguration['klarna_eid'] != '') &&
(isset($this->base_object->config->shopConfiguration['klarna_secret']) &&
$this->base_object->config->shopConfiguration['klarna_secret'] != '')) {
include_once('./core/shop_klarna.class.php');
// klarna installments
$klarna_object = new Shop_klarna($this->base_object);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$klarna_installments = $klarna_object->get_installments($this->shoppingcart_data['order_total'] - $this->gift_certificate_value->with_vat);
} else {
$klarna_installments = $klarna_object->get_installments($this->shoppingcart_data['order_total']);
}
$this->layout_object->assign('klarna_installments', $klarna_installments);
}
}
// since the gift certificate can change the cart data this must be done here
$this->layout_object->assign('shoppingcart', $this->shoppingcart_data);
}
// end manage_gift_certificate
private function managa_conditions() {
$site_content_object = new SiteContent($this->base_object);
$agb_data = array();
$agb_data['datenschutz'] = $site_content_object->get_textbox_data_by_id(55);
$agb_data['agbs'] = $site_content_object->get_textbox_data_by_id(56);
$agb_data['agbs_b2b'] = $site_content_object->get_textbox_data_by_id(10632);
$agb_data['widerruf'] = $site_content_object->get_textbox_data_by_id(60);
$this->layout_object->assign('agb_data', $agb_data);
}
// end manage_conditions
private function manage_errors() {
$this->layout_object->assign('error_message', $this->errors);
}
// end manage_errors
private function manage_data_persistence() {
// ugly hack for data persistence
$this->layout_object->assign('personal_data', $this->personal_data);
}
// end manage_data_persistence
private function save_address() {
$address = $_POST;
unset($address['save_address']);
$address_id = false;
if ($address['address'] != '') {
$address_id = $address['address'];
}
unset($address['address']);
$address['customer_id'] = $this->customer_data->id;
$customer_address_object = new CustomerAddress($this->base_object);
$ret = array();
if ($customer_address_object->validate($address)) {
if ($address_id) {
$customer_address_object->update($address, $address_id);
} else {
$address_id = $customer_address_object->create($address);
}
$ret['id'] = $address_id;
$ret['stat'] = 'OK';
} else {
$ret['stat'] = 'ERR';
$ret['data'] = $customer_address_object->get_validation_errors();
}
echo json_encode($ret);
exit();
}
// end save_address
private function before_saving_order() {
// check order
if (!isset($_GET['guest_order']) || $_GET['guest_order'] != 1) {
if (!is_numeric($_POST['billing']['address'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Rechnungsadresse';
}
if (!is_numeric($_POST['shipping']['address'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Lieferadresse';
}
}
if (!is_numeric($_POST['payment_method'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Zahlungsart';
} else {
$payment_method_id = $_POST['payment_method'];
if ($this->payment_methods[$payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id]);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
if ($this->payment_methods[$payment_method_id]->argument != '') {
$return = $payment_method_module->before_order($this->payment_methods[$payment_method_id]->argument);
} else {
$return = $payment_method_module->before_order();
}
if ($return) {
$this->errors[] = $return;
}
}
}
}
if (!is_numeric($_POST['shipping_method'])) {
$this->errors[] = 'Bitte w&auml;hlen Sie eine Versandart';
}
if (!is_numeric($_POST['agreements_accepted'])) {
$this->errors[] = 'Bitte akzeptieren Sie unsere Bedingungen';
}
}
// end before_saving_order
private function save_order() {
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$orderDataObject = OrderHelper::createOrderObject(array(
'customerId' => $this->customer_data->id,
'cartId' => session_id(),
'billingAddressId' => $this->billing_address['address'],
'shippingAddressId' => $this->shipping_address['address'],
'paymentMethodId' => $this->payment_method_id,
'shippingMethodId' => $this->shipping_method_id,
'giftCertificate' => $this->gift_certificate_code
), $this->base_object);
} else {
$orderDataObject = OrderHelper::createOrderObject(array(
'customerId' => $this->base_object->customer->customer_id,
'cartId' => session_id(),
'billingAddressId' => $this->billing_address['address'],
'shippingAddressId' => $this->shipping_address['address'],
'paymentMethodId' => $this->payment_method_id,
'shippingMethodId' => $this->shipping_method_id
), $this->base_object);
}
// TODO : HACK
// fix up paymemt method with ALL the data
$orderDataObject->payment->methodId = $this->payment_method_id;
$orderDataObject->payment->areaId = $this->shipping_area_id;
$orderDataObject->payment->priceGross = $this->payment_methods[$this->payment_method_id]->paymentAdd;
$orderDataObject->payment->priceNet = $this->payment_methods[$this->payment_method_id]->paymentAddNet;
$orderDataObject->payment->priceVat = $this->payment_methods[$this->payment_method_id]->paymentAddVat;
$orderDataObject->payment->vatRate = '19.00';
// TODO : HACK
// fix up shipping method with ALL the data
$orderDataObject->shipping->methodId = $this->shipping_method_id;
$orderDataObject->shipping->areaId = $this->shipping_area_id;
$orderDataObject->shipping->priceGross = $this->shipping_methods[$this->shipping_method_id]->price_add;
$orderDataObject->shipping->priceNet = $this->shipping_methods[$this->shipping_method_id]->price_add_net;
$orderDataObject->shipping->priceVat = $this->shipping_methods[$this->shipping_method_id]->price_add_vat;
$orderDataObject->shipping->vatRate = '19.00';
if (isset($_POST['customer_info']) && $_POST['customer_info'] != '') {
$orderDataObject->customer_info = $_POST['customer_info'];
}
if ($this->payment_methods[$this->payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$this->payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id]);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
if ($this->payment_methods[$this->payment_method_id]->argument != '') {
$return = $payment_method_module->during_order($this->payment_methods[$this->payment_method_id]->argument);
} else {
$return = $payment_method_module->during_order();
}
if ($return) {
foreach ($return as $key => $value) {
$orderDataObject->$key = $value;
}
}
}
}
$order_object = new Order($this->base_object);
$this->order_id = $order_object->create($orderDataObject);
$this->order_number = OrderHelper::get_order_number($this->order_id);
unset($_SESSION['customer_info']);
if ($this->order_id) {
// send email
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(3, $this->customer_data->id, $this->order_id);
if ($this->order_number) {
return true;
}
}
return false;
}
// end save_order
private function after_saving_order() {
$this->layout_object->assign('order_number', $this->order_number);
$this->layout_object->assign('order_amount', $this->shoppingcart_data['order_total']);
// get trusted shop payment id
$trusted_shop_payment = 'OTHER';
if ($this->payment_method_id == 1) {
$trusted_shop_payment = 'PREPAYMENT';
} else if ($this->payment_method_id == 2) {
$trusted_shop_payment = 'CASH_ON_DELIVERY';
} else if ($this->payment_method_id == 3) {
$trusted_shop_payment = 'INVOICE';
} else if ($this->payment_method_id == 4) {
$trusted_shop_payment = 'PAYPAL';
} else if ($this->payment_method_id == 6) {
$trusted_shop_payment = 'DIRECT_DEBIT';
}
$this->layout_object->assign('trusted_shop_payment', $trusted_shop_payment);
$shoppingcart_object = new Shoppingcart($this->base_object);
$shoppingcart_object->clear(1);
if ($this->payment_methods[$this->payment_method_id]->module != '') {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($this->payment_methods[$this->payment_method_id]->module).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
$payment_method_module->set_data($this->customer_data, $this->shipping_address, $this->billing_address, $this->shoppingcart_data, $this->shipping_methods[$this->shipping_method_id], $this->payment_methods[$this->payment_method_id], $this->order_id);
if ($this->has_gift_certificate && $this->gift_certificate_is_valid) {
$payment_method_module->set_gift_certificate($this->gift_certificate_value);
}
return $payment_method_module->after_order($this->shoppingcart_data['order_total']);
}
}
return $this->layout_object->_fetch('content_cash_desk/completed.tpl');
}
// end after_saving_order
private function change_order($param) {
$path = $_SERVER['DOCUMENT_ROOT'].'/core/paymentmethods/';
$module_name = ucfirst($param).'PaymentMethod';
$file_name = strtolower($module_name).'.class.php';
if (file_exists($path.$file_name)) {
include_once('./core/paymentmethods/'.$file_name);
$payment_method_module = new $module_name($this->base_object, $this->layout_object);
return $payment_method_module->change_order();
}
}
// end change_order
private function manage_guest_payment_method() {
$payment_method_object = new Payment_method($this->base_object);
/* temp: */ $this->shipping_area_id = 1;
$this->payment_methods = $payment_method_object->getMethodsForGroup($this->base_object->config->shopConfiguration['guest_order_customer_group'], $this->shoppingcart_data['price_sum_gross'], $this->shipping_area_id);
if (isset($_POST['payment_method']) && $_POST['payment_method'] > 0) {
$this->payment_method_id = $_POST['payment_method'];
} else {
$this->personal_data['payment_method'] = $this->payment_method_id = current($this->payment_methods)->id;
}
$this->layout_object->assign('payment_methods', $this->payment_methods);
}
// end manage_payment_method
private function manage_guest_shipping_method() {
$shipping_method_object = new Deliverer($this->base_object);
$shoppingcart_object = new Shoppingcart($this->base_object);
$this->shoppingcart_data = $shoppingcart_object->get_data();
$this->shipping_methods = $shipping_method_object->getAllActive(
$this->shipping_area_id, $this->shoppingcart_data['standard_shipping_items'], $this->shoppingcart_data['bulk_goods'], $this->shoppingcart_data['item_weight']
);
if (isset($_POST['shipping_method']) && $_POST['shipping_method'] > 0) {
$this->shipping_method_id = $_POST['shipping_method'];
} else {
$this->personal_data['shipping_method'] = $this->shipping_method_id = current($this->shipping_methods)->id;
}
$this->layout_object->assign('deliverers', $this->shipping_methods);
}
// end manage_shipping_method
}
// end website_cashdesk
?>
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* @version $Id: website_contact.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_contact {
private $base_object;
private $layout_object;
private $mandatoryfields = array('forename', 'surname', 'e_mail', 'call_number_private');
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
if ($_POST['account_contact'] == 'ready_to_fly') {
$this->layout_object->assign('contactdata', $_POST['contact']);
$json = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=6LfR26UZAAAAACn88_M7nYay62q7NZL6v0oh4lK3&response='.$_POST['g-recaptcha-response']);
$data_check = json_decode($json);
if ($data_check->success && $this->check_mandatory($_POST['contact'])) {
// include './core/mail.class.php';
$mailer = new mail_tools($this->base_object);
$message = $this->layout_object->_fetch('content_contact_mail.tpl');
$subject = 'Kontakt Website';
if (isset($_POST['contact']['callback']) && $_POST['contact']['callback']) {
$_POST['contact']['callback'] = preg_replace("@[^0-9\.]@si", '', $_POST['contact']['callback']);
$subject .= ' (Rückruf: ' . $_POST['contact']['callback'] . ')';
}
$sent = $mailer->send_mail($subject, $message, $this->base_object->config->shopConfiguration['mailRecipients'], 'intern');
if ($sent) {
$this->layout_object->assign('contactSTATUS', 1);
} else {
$this->layout_object->assign('contactSTATUS', 2);
}
} else {
$this->layout_object->assign('contactSTATUS', 3);
}
}
return $this->layout_object->_fetch('content_contact.tpl');
}
public function check_mandatory(&$data) {
if (is_array($this->mandatoryfields)) {
$checked = true;
foreach ($this->mandatoryfields as $field) {
$input = trim($data[$field]);
$checked &=!empty($input);
$data[$field] = $input;
}
return $checked;
} else {
return true;
}
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
class website_customer_login {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$customer_id = $this->base_object->customer->customer_id;
if ($customer_id) {
return $this->layout_object->_fetch('content_already_logged_in.tpl');
}
return $this->layout_object->_fetch('content_login.tpl');
}
}
+268
View File
@@ -0,0 +1,268 @@
<?php
/**
* @version $Id: website_customer_registration.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/country.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/site_content.class.php';
class website_customer_registration {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$data = array(
'state' => 0
);
$error_message = array();
if (isset($_POST['customer_field'])) {
//$form_data = $this->base_object->customer->data_filter($_POST['customer_field']);
$form_data = $_POST['customer_field'];
$group_id = 1;
$json = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=6LfR26UZAAAAACn88_M7nYay62q7NZL6v0oh4lK3&response='.$_POST['g-recaptcha-response']);
$data_check = json_decode($json);
//var_dump($data_check->success);
if (
(
($data_check->success && $form_data['honorific'] == 2) &&
$form_data['company'] &&
$form_data['street'] &&
$form_data['house_number'] &&
$form_data['zip_code'] &&
$form_data['city'] &&
$form_data['email'] &&
$_POST['agreements_accepted'] &&
$form_data['password1']
) || (
($form_data['honorific'] == '0' || $form_data['honorific'] == '1') && $data_check->success &&
$form_data['firstname'] &&
$form_data['surname'] &&
$form_data['street'] &&
$form_data['house_number'] &&
$form_data['zip_code'] &&
$form_data['city'] &&
$form_data['email'] &&
$_POST['agreements_accepted'] &&
$form_data['password1']
)
) {
$customer_data = $form_data;
if (isset($form_data['company'])) {
$address_data['company'] = $form_data['company'];
}
if (isset($form_data['honorific'])) {
$address_data['honorific'] = $form_data['honorific'];
}
if (isset($form_data['firstname'])) {
$address_data['firstname'] = $form_data['firstname'];
}
if (isset($form_data['surname'])) {
$address_data['surname'] = $form_data['surname'];
}
if (isset($form_data['street'])) {
$address_data['street'] = $form_data['street'];
unset($customer_data['street']);
}
if (isset($form_data['house_number'])) {
$address_data['house_number'] = $form_data['house_number'];
unset($customer_data['house_number']);
}
if (isset($form_data['zip_code'])) {
$address_data['zip_code'] = $form_data['zip_code'];
unset($customer_data['zip_code']);
}
if (isset($form_data['city'])) {
$address_data['city'] = $form_data['city'];
unset($customer_data['city']);
}
if (isset($form_data['country'])) {
$address_data['country'] = $form_data['country'];
unset($customer_data['country']);
}
if ($form_data['password1'] == $form_data['password2']) {
$customer_data['pass'] = $form_data['password1'];
unset($customer_data['password1']);
unset($customer_data['password2']);
unset($form_data['password1']);
unset($form_data['password2']);
} else {
unset($form_data['password1']);
unset($form_data['password2']);
$data['state'] = 4;
$error_message[] = 'Die Passwörter stimmen nicht überein!';
$data['form_data'] = $form_data;
$this->layout_object->assign('data', $data);
// error message
$this->layout_object->assign('error_message', $error_message);
// get countries
$country_object = new Country($this->base_object);
$countries = $country_object->get_all(array(
'isset_shipping_area' => 1
));
$this->layout_object->assign('countries', $countries);
return $this->layout_object->_fetch('content_customer_registration.tpl');
}
$birthdate = $_POST['birthdate'];
if ($birthdate['day'] != 0 && $birthdate['month'] != 0 && $birthdate['year'] != 0) {
// there is a typo in the database
$burth_date = $birthdate['year'] . '-' . $birthdate['month'] . '-' . $birthdate['day'];
$customer_data['burth_date'] = $burth_date;
}
if (isset($form_data['merchant'])) {
$customer_data['merchant'] = 1;
} else {
$customer_data['merchant'] = 0;
}
// new customer registration default customer group
if ($this->base_object->config->shopConfiguration['customer_registration_group_id']) {
$customer_data['group_id'] = $this->base_object->config->shopConfiguration['customer_registration_group_id'];
}
else {
$customer_data['group_id'] = 100;
}
// get customer group
$this->base_object->customer_group->id = $customer_data['group_id'];
$customer_group_data = $this->base_object->customer_group->get_data();
if ($customer_group_data->state_after_registration) {
$customer_data['locked'] = 0;
}
else {
$customer_data['locked'] = 1;
}
$result = $this->base_object->customer->create($customer_data);
if ($result) {
$address_data['customer_id'] = $result;
$address_id = $this->base_object->customer->add_address($address_data);
// Adresse als standard definieren
Customer::set_standard_address($address_data['customer_id'], $address_id);
// ticket event new customer registration
$ticket_object = new Cs_ticket($this->base_object);
if ($form_data['honorific'] == 2) {
$ticket_object->event(13, $result, false); // company
}
else {
$ticket_object->event(2, $result, false); // person
}
// auto login
if ($customer_group_data->state_after_registration == 2) {
$_SESSION['easyshop']['login']['id'] = $result;
}
}
$data['state'] = 1;
if ($result) {
if ($_SESSION['easyshop']['shopAction'] == 'cash_desk_customer_registration') {
header('Location: /Kasse/');
}
else {
header('Location: /Kundenregistrierung_abschluss/');
}
} else {
$error = $this->base_object->customer->get_error();
if ($error == 'email exisitiert bereits') {
$data['state'] = 3;
$error_message[] = 'Es ist bereits ein Kunde mit dieser E-Mail Adresse registriert!';
$data['form_data'] = $form_data;
} else {
$data['state'] = 5;
$data['form_data'] = $form_data;
$error_message[] = 'Es ist ein Fehler Aufgetreten, bitte wenden Sie sich direkt an den Shopbetreiber!';
}
}
}
else {
$data['state'] = 2;
$error_message[] = 'Bitte füllen Sie alle Pflichtfelder aus und bestätigen Sie unsere AGB!';
$data['form_data'] = $form_data;
}
}
else {
if (isset($_POST['shopAction']) && $_POST['shopAction'] == 'cash_desk_customer_registration') {
$_SESSION['easyshop']['shopAction'] = 'cash_desk_customer_registration';
}
else {
$_SESSION['easyshop']['shopAction'] = '';
}
}
// information_privacy_statement
$site_content_object = new SiteContent($this->base_object);
$agb_data = array();
$agb_data['datenschutz'] = $site_content_object->get_textbox_data_by_id(55);
$agb_data['agbs'] = $site_content_object->get_textbox_data_by_id(56);
$agb_data['widerruf'] = $site_content_object->get_textbox_data_by_id(60);
$this->layout_object->assign('agb_data', $agb_data);
// get countries
$country_object = new Country($this->base_object);
$countries = $country_object->get_all(array('isset_shipping_area' => 1));
$this->layout_object->assign('countries', $countries);
// error message
$this->layout_object->assign('error_message', $error_message);
// days
$days = array();
for($i=1;$i<32;$i++) {
$days[] = $i;
}
$this->layout_object->assign('days', $days);
// months
$months = array();
for($i=1;$i<13;$i++) {
$months[] = $i;
}
$this->layout_object->assign('months', $months);
// years
$years = array();
for($i=1944;$i<2012;$i++) {
$years[] = $i;
}
$this->layout_object->assign('years', $years);
$this->layout_object->assign('data', $data);
return $this->layout_object->_fetch('content_customer_registration.tpl');
}
}
+362
View File
@@ -0,0 +1,362 @@
<?php
/**
* @version $Id: website_customercenter.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>, John T. Daly <jd@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/customer.class.php';
include_once './core/country.class.php';
include_once './core/orderstatus.class.php';
include_once './core/order.class.php';
include_once './core/orderhelper.class.php';
include_once './core/customeraddress.class.php';
include_once './core/export.class.php';
class website_customercenter {
private $base_object;
private $layout_object;
private $customer_address_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->customer_address_object = new CustomerAddress($base_object);
$freetextfield_functions = './web/' . SHOP_SYSTEM . '/code/freetextfield_functions.php';
if (file_exists($freetextfield_functions)) {
include $freetextfield_functions;
}
}
function run() {
$customer_id = $this->base_object->customer->customer_id;
if ($customer_id) {
if(isset($_POST['action'])) {
$action = $_POST['action'];
} elseif(isset($_GET['action'])) {
$action = $_GET['action'];
}
if ($action == 'add_address') {
$this->add_address($customer_id);
} elseif ($action == 'edit_base_data') {
$this->edit_base_data($customer_id);
} elseif ($action == 'edit_payment_data') {
$this->edit_payment_data($customer_id);
} elseif ($action == 'set_standard') {
$this->set_standard($customer_id);
} elseif ($action == 'delete_address') {
$this->delete_address($customer_id);
} elseif ($action == 'get_invoice_pdf') {
return $this->get_invoice_pdf();
} elseif ($action == 'get_address') {
$this->get_address();
} elseif ($action == 'freetextfield_action') {
$this->freetextfield_action($customer_id);
} elseif ($action == 'get_item_export') {
$this->get_item_export($customer_id);
} else {
return $this->default_action($customer_id);
}
} else {
return $this->layout_object->_fetch('content_login.tpl');
}
}
private function get_item_export($customer_id) {
$customer_object = $this->base_object->customer;
$customer_data = $customer_object->get_data($customer_id);
$export_object = new Export($this->base_object);
$export_object->set_customer_number($customer_data->number);
if (isset($_GET['rf_special']) && $_GET['rf_special'] == 1) {
$export_object->set_seperator('|');
$csv_data = $export_object->get_export_csv('customer_rf_special');
}
else {
$export_object->set_seperator(';');
$csv_data = $export_object->get_export_csv('customer');
}
header( "Content-Type: text/csv" );
header( "Content-Disposition: attachment; filename=items.csv");
header( "Content-Description: csv File" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
echo utf8_decode($csv_data);
exit();
} // end get_item_export
private function get_address() {
if (isset($_GET['id'])) {
$address_id = $_GET['id'];
} else {
$address_id = false;
}
if ($address_id) {
$address_data = CustomerHelper::get_customer_address($address_id);
if ($address_data) {
$result = array('status' => 'success', 'data' => $address_data);
} else {
$result = array('status' => 'error');
}
} else {
$result = array('status' => 'error');
}
echo json_encode($result);
exit();
}
private function default_action($customer_id) {
$country = new Country($this->base_object);
$order = new Order($this->base_object);
$this->layout_object->assign('this_url', $this->get_this_url());
$customer_object = $this->base_object->customer;
$customer_data = $customer_object->get_by_id($customer_id);
$this->layout_object->assign('customer', $customer_data);
$customer_name = Customer::get_name_by_id($customer_id);
$this->layout_object->assign('customer_name', $customer_name);
$customer_addresses = Customer::get_address_by_id($customer_id);
$this->layout_object->assign('customer_addresses', $customer_addresses);
$this->layout_object->assign('default_country', 27);
$this->layout_object->assign('countries', $country->get_all());
$this->layout_object->assign('orderstatus', OrderStatus::get_all());
$this->layout_object->assign('orderitems', $order->get_all_order_items_by_customer_id($customer_id));
$this->layout_object->assign('orders', OrderHelper::get_all_customer_orders($customer_id));
if ($customer_data->has_item_export) {
$this->layout_object->assign('item_export', true);
}
$this->freetextfield_setup($customer_id);
return $this->layout_object->_fetch('content_customer_center.tpl');
} // end default_action
private function freetextfield_setup($customer_id) {
if (function_exists("freetextfield1_setup")) {
freetextfield1_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
if (function_exists("freetextfield2_setup")) {
freetextfield2_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
if (function_exists("freetextfield3_setup")) {
freetextfield3_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
if (function_exists("freetextfield4_setup")) {
freetextfield4_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
if (function_exists("freetextfield5_setup")) {
freetextfield5_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
if (function_exists("freetextfield6_setup")) {
freetextfield6_setup($this->base_object->db, $this->layout_object ,$customer_id);
}
} // end freetextfield_functions
private function freetextfield_action($customer_id) {
if (isset($_POST['freetextfield'])) {
$freetextfield = $_POST['freetextfield'];
} elseif (isset($_GET['freetextfield'])) {
$freetextfield = $_GET['freetextfield'];
} else {
$freetextfield = false;
}
if($freetextfield) {
if ($freetextfield == '1') {
if (function_exists("freetextfield1_action")) {
freetextfield1_action($this->base_object->db, $this->layout_object ,$customer_id);
}
} elseif ($freetextfield == '2') {
if (function_exists("freetextfield2_action")) {
freetextfield2_action($this->base_object->db, $this->layout_object ,$customer_id);
}
} elseif ($freetextfield == '3') {
if (function_exists("freetextfield3_action")) {
freetextfield3_action($this->base_object->db, $this->layout_object ,$customer_id);
}
} elseif ($freetextfield == '4') {
if (function_exists("freetextfield4_action")) {
freetextfield4_action($this->base_object->db, $this->layout_object ,$customer_id);
}
} elseif ($freetextfield == '5') {
if (function_exists("freetextfield5_action")) {
freetextfield5_action($this->base_object->db, $this->layout_object ,$customer_id);
}
} elseif ($freetextfield == '6') {
if (function_exists("freetextfield6_action")) {
freetextfield6_action($this->base_object->db, $this->layout_object ,$customer_id);
}
}
}
exit();
} // end freetextfield_action
private function add_address($customer_id) {
unset($_POST['action']);
$data = $_POST;
$data['customer_id'] = $customer_id;
if ($data['id'] == '') {
unset($data['id']);
}
$data['orders'] = 0;
if (isset($data['id'])) {
$id = $data['id'];
unset($data['id']);
$diff = $this->customer_address_object->check_data_diff($data, $id);
$this->customer_address_object->update($data, $id);
if ($diff) {
$html_table = $this->customer_address_object->make_diff_table($diff);
include_once('./core/cs_ticket.class.php');
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(15, $customer_id, false, array('customer_data_diff' => $html_table));
}
} else {
$this->customer_address_object->create($data);
include_once('./core/cs_ticket.class.php');
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(15, $customer_id, false, array('customer_data_diff' => 'Kunde hat eine neue Adresse hinzugefügt.'));
}
header('location: ' . $_SERVER["HTTP_REFERER"]);
}
private function edit_base_data($customer_id) {
$customer = $this->base_object->customer;
unset($_POST['action']);
$pass1 = $_POST['pass1'];
unset($_POST['pass1']);
$pass2 = $_POST['pass2'];
unset($_POST['pass2']);
$data = $_POST;
if ($pass1 != '') {
if ($pass1 == $pass2) {
$data['pass'] = $pass1;
}
}
$diff = $customer->check_data_diff($customer_id, $data);
$result = $customer->update($data);
// email notification
if ($diff && !(count($diff) == 1 && isset($diff['pass']))) {
$html_table = $customer->make_diff_table($diff);
include_once('./core/cs_ticket.class.php');
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(15, $customer_id, false, array('customer_data_diff' => $html_table));
}
header('location: ' . $_SERVER["HTTP_REFERER"]);
}
private function edit_payment_data($customer_id) {
$customer = $this->base_object->customer;
unset($_POST['action']);
$result = $customer->update($_POST);
$result = $customer->update($data);
// email notification
include_once('./core/cs_ticket.class.php');
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(15, $customer_id);
header('location: ' . $_SERVER["HTTP_REFERER"]);
}
private function set_standard($customer_id) {
$address_id = $_GET['id'];
$result = Customer::set_standard_address($customer_id, $address_id);
// event notification
include_once('./core/cs_ticket.class.php');
$ticket_object = new Cs_ticket($this->base_object);
$ticket_object->event(15, $customer_id, false, array('customer_data_diff' => 'Der Kunde hat seine Standardadresse geändert.'));
echo json_encode(array('success' => $result));
exit();
}
private function delete_address($customer_id) {
$address_id = $_GET['id'];
$result = Customer::delete_address($customer_id, $address_id);
echo json_encode(array('success' => $result));
exit();
}
private function get_this_url() {
$base_url = 'https://' . $_SERVER["SERVER_NAME"];
if($_SERVER['SERVER_PORT'] != '80') {
$base_url .= ':' . $_SERVER['SERVER_PORT'];
}
return $base_url . '/index.php?menu_id=' . $_GET['menu_id'] . '&parent_id=' . $_GET['parent_id'];
}
private function get_invoice_pdf() {
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($order_id) {
if ($this->show_invoice($order_id)) {
OrderHelper::get_order_invoice_pdf($order_id);
} else {
return $this->layout_object->_fetch('error_404.tpl');
}
} else {
return $this->layout_object->_fetch('error_404.tpl');
}
}
// TODO: check if you can even show this order
private function show_invoice($order_id) {
// has invoce date?
// belongs to logged in customer
return true;
}
}
+441
View File
@@ -0,0 +1,441 @@
<?php
/**
* @version $Id: website_dyncontent.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/item.class.php';
include_once './core/site_content.class.php';
include_once './core/structure.class.php';
include_once './core/manufacturer.class.php';
include_once './core/config.class.php';
include_once './core/itemhelper.class.php';
include_once './core/manufacturerhelper.class.php';
class website_dyncontent {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run($structure_id) {
$maincontent = '';
if ($structure_id) {
$site_content_object = new SiteContent($this->base_object);
$structure_object = new Structure($this->base_object);
$this->layout_object->assign('structure_id', $structure_id);
$site_content = $site_content_object->get_by_structure_id($structure_id);
$structure_content = $structure_object->get_by_id($structure_id);
if (isset($this->base_object->config->shopConfiguration['full_shop_name'])) {
$shop_name = $this->base_object->config->shopConfiguration['full_shop_name'];
} else {
$shop_name = SHOP_SYSTEM;
}
$need_left_column = 0;
// load content blocks
if ($site_content) {
foreach ($site_content as $block) {
if ($block->activ == 1) {
$need_left_column = 1;
if ($block->type == 'article_list') {
$maincontent .= $this->item_list($structure_id, $block);
$need_left_column = 1;
}
elseif ($block->type == 'textbox') {
$maincontent .= $this->textbox($structure_id, $block);
$need_left_column = 1;
}
elseif ($block->type == 'slider') {
$maincontent .= $this->slider($structure_id, $block);
}
elseif ($block->type == 'banner') {
$maincontent .= $this->banner($structure_id, $block);
}
elseif ($block->type == 'manufacturers') {
$maincontent .= $this->manufacturers($structure_id, $block);
}
elseif ($block->type == 'popular') {
if (isset($this->base_object->config->shopConfiguration['popular_content_feature']) && $this->base_object->config->shopConfiguration['popular_content_feature'] == 2) {
$maincontent .= $this->popular2($structure_id, $block);
} else {
$maincontent .= $this->popular($structure_id, $block);
}
}
elseif ($block->type == 'substructure') {
$maincontent .= $this->substructure($structure_id, $block);
}
}
}
}
}
if (!$need_left_column) {
$this->layout_object->assign('site_type', 'full_width');
}
return $maincontent;
}
private function popular($structure_id, $block) {
$popular_items = ItemHelper::get_best_selling_items(3, $block->content);
$popular_brands = ManufacturerHelper::get_best_selling_manufacturers(3, $block->content);
$this->layout_object->assign('popular_items', $popular_items);
$this->layout_object->assign('popular_manufacturers', $popular_brands);
return $this->layout_object->_fetch('content_box_popular.tpl');
}
private function popular2($structure_id, $block) {
$popular_items = ItemHelper::get_best_selling_items(3, $block->content);
$popular_brands = ManufacturerHelper::get_best_selling_manufacturers(10, $block->content);
$this->layout_object->assign('popular_items', $popular_items);
$this->layout_object->assign('popular_manufacturers', $popular_brands);
return $this->layout_object->_fetch('content_box_popular2.tpl');
}
private function substructure($structure_id, $block) {
// Set configuration
$config = array();
eval($block->configuration);
$block->configuration = $config;
if (isset($block->configuration['cat_id']) && is_numeric($block->configuration['cat_id'])) {
$structure_id = $block->configuration['cat_id'];
}
// get substructures
$structure_object = new Structure($this->base_object);
if (isset($block->configuration['ebenen']) && is_numeric($block->configuration['ebenen']) && $block->configuration['ebenen'] > 1) {
$substructures = $structure_object->get_structure_family($structure_id);
$tpl = 'content_box_substructure_family.tpl';
} else {
$substructures = $structure_object->get_subcategory_objects($structure_id);
$tpl = 'content_box_substructure.tpl';
}
$this->layout_object->assign('block', $block);
$this->layout_object->assign('substructures', $substructures);
$output = $this->layout_object->_fetch($tpl);
return $output;
}
private function item_list($structure_id, $block) {
$item_object = new Item($this->base_object);
// Structure change
if (!isset($_SESSION['lastStructureId']) || $_SESSION['lastStructureId'] != $structure_id) {
unset($_SESSION['itemsPerPage']);
unset($_SESSION['currentPage']);
unset($_SESSION['currentManufacturer']);
unset($_SESSION['listStyleType']);
}
$_SESSION['lastStructureId'] = $structure_id;
// Manufacturer change
if (isset($_POST['manufacturerSelector']) && $_POST['manufacturerSelector']) {
if (is_numeric($_POST['manufacturerSelector'])) {
$_SESSION['currentManufacturer'] = $_POST['manufacturerSelector'];
} else {
unset($_SESSION['currentManufacturer']);
}
unset($_SESSION['currentPage']);
}
// Per page change
if (isset($_POST['pagingSelector']) && $_POST['pagingSelector']) {
$possibilities = array(12, 24, 48, '9999');
if (in_array($_POST['pagingSelector'], $possibilities)) {
$_SESSION['itemsPerPage'] = $_POST['pagingSelector'];
$_SESSION['currentPage'] = 1;
}
}
if (!isset($_SESSION['itemsPerPage']) || !$_SESSION['itemsPerPage']) {
$_SESSION['itemsPerPage'] = 24;
}
// list style
if (isset($_POST['listStyleSelector']) && $_POST['listStyleSelector']) {
$possibilities = array(1, 2, 3);
if (in_array($_POST['listStyleSelector'], $possibilities)) {
$_SESSION['listStyleType'] = $_POST['listStyleSelector'];
}
}
if (!isset($_SESSION['listStyleType']) || !$_SESSION['listStyleType']) {
if ($block->content) {
$_SESSION['listStyleType'] = $block->content;
}
else {
$_SESSION['listStyleType'] = 1;
}
}
// list sort by
if (isset($_POST['sort_by']) && $_POST['sort_by']) {
$_SESSION['sort_by'] = $_POST['sort_by'];
}
if (!isset($_SESSION['sort_by']) || !$_SESSION['sort_by']) {
if ($this->base_object->config->shopConfiguration['sort_item_list_by']) {
$_SESSION['sort_by'] = $this->base_object->config->shopConfiguration['sort_item_list_by'];
}
else {
$_SESSION['sort_by'] = 'number_up';
}
}
// Page change
if(isset($_POST['page'])) {
$_GET['page'] = $_POST['page'];
}
if (isset($_GET['page']) && $_GET['page'] && is_numeric($_GET['page'])) {
$_SESSION['currentPage'] = $_GET['page'];
}
if (!isset($_SESSION['currentPage']) || !$_SESSION['currentPage']) {
$_SESSION['currentPage'] = 1;
}
if(!isset($_SESSION['currentManufacturer'])) {
$_SESSION['currentManufacturer'] = '';
}
// Infinite scrolling?
$useInfinityScroll = false;
if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && isset($_GET['loadstep']) && is_numeric($_GET['loadstep']) && $_SESSION['itemsPerPage'] == '9999') {
$_SESSION['currentPage'] = ($_GET['loadstep'] > 0) ? $_GET['loadstep'] : 1;
$useInfinityScroll = true;
} else if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && $_SESSION['itemsPerPage'] == '9999') {
$_SESSION['currentPage'] = 1;
$useInfinityScroll = true;
}
// Load items
$article_list = $item_object->get_item_list_new(
$structure_id,
$_SESSION['itemsPerPage'],
$_SESSION['currentPage'],
true,
$_SESSION['currentManufacturer'],
$_SESSION['sort_by'],
$useInfinityScroll
);
// Still necessary?
if (isset($_GET['page']) && ($_GET['page'] > ceil($item_object->itemCount / $_SESSION['itemsPerPage']))) {
$_SESSION['currentPage'] = $_GET['page'] = ceil($item_object->itemCount / $_SESSION['itemsPerPage']);
$article_list = $item_object->get_item_list_new(
$structure_id,
$_SESSION['itemsPerPage'],
$_SESSION['currentPage'],
true,
$_SESSION['currentManufacturer'],
$_SESSION['sort_by'],
$useInfinityScroll
);
}
// Show the (first) item, if only one item exists in current category
if ($this->base_object->config->shopConfiguration['show_details_by_one_item_in_structure'] == 1 && count($article_list) == 1) {
$currentItem = current($article_list);
if ($currentItem->short_uri) {
header('Location: ./' . $currentItem->short_uri . '.html');
} else {
header('Location: /index.php?item_id=' . $currentItem->id);
}
exit();
}
$this->layout_object->assign('shopArticles', $article_list);
// Show only the items for infinite scrolling
if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && isset($_GET['loadstep']) && is_numeric($_GET['loadstep'])) {
$data = array(
'template' => $this->layout_object->fetch('item_box_loop.tpl'),
'counter' => count($article_list)
);
echo json_encode($data);
exit();
// Show default item list
} else {
$this->layout_object->assign('block', $block);
$this->layout_object->assign('itemsPerPage', $_SESSION['itemsPerPage']);
$this->layout_object->assign('listStyleType', $_SESSION['listStyleType']);
$this->layout_object->assign('sort_by', $_SESSION['sort_by']);
$this->layout_object->assign('itemsFound', $item_object->itemCount);
$this->layout_object->assign('found_pages', ceil($item_object->itemCount / $_SESSION['itemsPerPage']));
$this->layout_object->assign('found_showing_page', $_SESSION['currentPage']);
$this->layout_object->assign('currentManufacturer', $_SESSION['currentManufacturer']);
$this->layout_object->assign('useInfinityScroll', $useInfinityScroll);
return $this->layout_object->_fetch('content_box_item_list.tpl');
}
}
private function item_list_old($structure_id, $block) {
$item_object = new Item($this->base_object);
// Structure change
if ($_SESSION['lastStructureId'] != $structure_id) {
unset($_SESSION['itemsPerPage']);
unset($_SESSION['currentPage']);
unset($_SESSION['currentManufacturer']);
}
$_SESSION['lastStructureId'] = $structure_id;
// Manufacturer change
if ($_POST['manufacturerSelector']) {
if (is_numeric($_POST['manufacturerSelector'])) {
$_SESSION['currentManufacturer'] = $_POST['manufacturerSelector'];
} else {
unset($_SESSION['currentManufacturer']);
}
unset($_SESSION['currentPage']);
}
// Per page change
if ($_POST['pagingSelector']) {
$possibilities = array(12, 24, 48, 'all');
if (in_array($_POST['pagingSelector'], $possibilities)) {
$_SESSION['itemsPerPage'] = $_POST['pagingSelector'];
$_SESSION['currentPage'] = 1;
}
}
if (!$_SESSION['itemsPerPage']) {
$_SESSION['itemsPerPage'] = 24;
}
// Page change
if ($_GET['page'] && is_numeric($_GET['page'])) {
$_SESSION['currentPage'] = $_GET['page'];
}
if (!$_SESSION['currentPage']) {
$_SESSION['currentPage'] = 1;
}
$article_list = $item_object->get_item_list($structure_id, $_SESSION['itemsPerPage'], $_SESSION['currentPage'], true, $_SESSION['currentManufacturer']);
if ($_GET['page'] > ceil($item_object->itemCount / $_SESSION['itemsPerPage'])) {
$_SESSION['currentPage'] = $_GET['page'] = ceil($item_object->itemCount / $_SESSION['itemsPerPage']);
$article_list = $item_object->get_item_list($structure_id, $_SESSION['itemsPerPage'], $_SESSION['currentPage'], true, $_SESSION['currentManufacturer']);
}
// Show the (first) item, if only one item exists in current category
if ($this->base_object->config->shopConfiguration['show_details_by_one_item_in_structure'] == 1 && count($article_list) == 1) {
$currentItem = current($article_list);
if ($currentItem->short_uri) {
header('Location: /' . $currentItem->short_uri . '.html');
} else {
header('Location: /index.php?item_id=' . $currentItem->id);
}
exit();
}
$this->layout_object->assign('shopArticles', $article_list);
$this->layout_object->assign('shopView', $shopView);
$this->layout_object->assign('block', $block);
$this->layout_object->assign('itemsPerPage', $_SESSION['itemsPerPage']);
$this->layout_object->assign('itemsFound', $item_object->itemCount);
$this->layout_object->assign('found_pages', ceil($item_object->itemCount / $_SESSION['itemsPerPage']));
$this->layout_object->assign('found_showing_page', $_SESSION['currentPage']);
$this->layout_object->assign('currentManufacturer', $_SESSION['currentManufacturer']);
return $this->layout_object->_fetch('content_box_item_list.tpl');
}
private function textbox($structure_id, $block) {
$config = array();
eval($block->configuration);
// replace meta script
$var_data = array();
$var_data['[#HIDDEN_TEXT_START]'] = '<span class="text_box_hidden_text">';
$var_data['[#HIDDEN_TEXT_END]'] = ' </span> <a class="text_box_link_show_text" href="#">mehr&gt;&gt;</a><a class="text_box_link_hide_text" href="#">&lt;&lt;weniger</a>';
$block->content = strtr($block->content, $var_data);
$block->configuration = $config;
$this->layout_object->assign('block', $block);
return $this->layout_object->_fetch('content_box_textbox.tpl');
}
private function banner($structure_id, $block) {
$config = array();
eval($block->configuration);
$block->configuration = $config;
$this->layout_object->assign('block', $block);
return $this->layout_object->_fetch('content_box_banner.tpl');
}
private function slider($structure_id, $block) {
// get config
$quantity = (Config::has_key('slider_items') && Config::is_set('slider_items')) ? Config::get_value('slider_items') : 10;
$sort = ($this->base_object->config->shopConfiguration['sort_item_list_by']) ? $this->base_object->config->shopConfiguration['sort_item_list_by'] : 'number_up';
$structure_object = new Structure($this->base_object);
$structure_content = $structure_object->get_by_id($block->content);
$item_object = new Item($this->base_object);
if ($structure_content->item_type) {
$article_list = $item_object->get_item_list_by_type($block->content, $quantity, 1, true, false, $sort);
} else {
$article_list = $item_object->get_item_list_new($block->content, $quantity,1, true, false, $sort);
}
//echo '<pre>';print_r($article_list);exit();
$this->layout_object->assign('shopArticles', $article_list);
$this->layout_object->assign('block', $block);
return $this->layout_object->_fetch('content_box_slider.tpl');
}
private function manufacturers($structure_id, $block) {
$this->layout_object->assign('manufacturers', Manufacturer::get_all_active_static());
return $this->layout_object->_fetch('content_box_manufacturers.tpl');
}
}
+27
View File
@@ -0,0 +1,27 @@
<?php
/**
* @version $Id: website_contact.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_error_404 {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
return $this->layout_object->_fetch('error_404.tpl');
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
include_once './core/export.class.php';
class website_export {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$modul_id = $_GET['id'];
$export_object = new Export($this->base_object);
$export_data = $export_object->get_export_csv($modul_id);
return $export_data;
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
class website_external_link {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run() {
echo "<h1>todo</h1>";
exit();
}
}
+26
View File
@@ -0,0 +1,26 @@
<?php
include_once './core/sitemap.class.php';
include_once './core/structure.class.php';
class website_google_map {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$geo_arr = split(',', $this->base_object->config->shopConfiguration['google_map_geo_coordinates']);
$geo_data['geo_lat'] = trim($geo_arr[0]);
$geo_data['geo_lon'] = trim($geo_arr[1]);
$this->layout_object->assign('geo_data', $geo_data);
return $this->layout_object->_fetch('content_google_map.tpl');
}
}
+473
View File
@@ -0,0 +1,473 @@
<?php
/*
* @version $Id: index.php 10381 2008-06-01 03:35:53Z $
* @package Carteasy
* @copyright Copyright (C) 2005 - 2011 Wlanium
* @license proprietary
* @author Thomas Bartelt
* Carteasy is a web shop system
*/
// including libs
include_once './libs/smarty/libs/Smarty.class.php';
include_once './core/layout.class.php';
include_once './core/website.class.php';
include_once './core/structure.class.php';
include_once './core/metatag.class.php';
include_once './core/item.class.php';
include_once './core/shop_theme.class.php';
$layout_menu_id = false;
// start session
if (!isset($_REQUEST['nosess']) && session_status() === PHP_SESSION_NONE) {
session_start();
}
// language selection
if (isset($_GET['lang'])) {
$_SESSION['user_lang'] = $_GET['lang'];
}
// layout object
$layout_object = new layout();
$layout_object->start($base_object);
Registry::set('layout_object', $layout_object);
// website object
$website_object = new website($base_object);
$update_cart = 0;
// login
if (isset($_POST['shopLogin'])) {
$logindata = $_POST['shopLogin'];
$login_save_session = false;
if (isset($_POST['login_save_session']) && $_POST['login_save_session'] == 1) {
$login_save_session = true;
}
$request = $base_object->customer->login($logindata['user'], $logindata['pass'], $login_save_session);
if ($request == 1 && $base_object->config->shopConfiguration['save_customer_shoppingcart'] == 1) {
$update_cart = 1;
}
$layout_object->assign('login_state', $request);
//header('Location: '.$_SERVER['REQUEST_URI']);
} else if (isset($_GET['logout'])) { // logout
$base_object->customer->logout();
header('Location: '.STANDARD_DIR);
}
// Create metatag object
$layout_object->metaTagObject = new Metatag($layout_object, $base_object);
$layout_object->metaTagObject->get_by_group('DEFAULT');
// customer authentification
if ($base_object->customer->auth() > 0) {
$customer_data = $base_object->customer->get_data();
$layout_object->assign('customer', $customer_data);
}
if ($update_cart == 1) {
include_once './core/shoppingcart.class.php';
$shopping_cart_object = New Shoppingcart($base_object);
$shopping_cart_object->update_customer_cart();
}
// get customer group
if (isset($base_object->customer->group_id)) {
$base_object->customer_group->id = $base_object->customer->group_id;
} else {
$base_object->customer_group->id = 100;
}
$base_object->customer_group->load_data();
$show_prices_before_login = $base_object->config->shopConfiguration['show_prices_before_login'];
$no_prices = false;
if ($show_prices_before_login != '1') {
if (!$base_object->is_customer_logged_in()) {
$no_prices = true;
}
}
$layout_object->assign('no_prices', $no_prices);
$structure_id = '';
//include_once(ROOT_DIR.'core/website.class.php');
$website_object = new website($base_object);
// frontend ajax
if (!empty($_GET['website_modul'])) {
$website_modul = $_GET['website_modul'];
$module_file = 'modules/'.$website_modul.'.php';
if (file_exists($module_file)) {
include_once $module_file;
$modul_object = new $website_modul($base_object, $layout_object);
if (property_exists($modul_object, 'website_object')) {
$modul_object->website_object = $website_object;
}
if (isset($_POST['param_1'])) {
$website_content = $modul_object->run($_POST['param_1']);
} else {
$website_content = $modul_object->run();
}
echo $website_content;
} else {
$maincontent = $layout_object->_fetch('404.tpl');
}
exit();
}
// Domainhandling
if (isset($base_object->config->shopConfiguration['has_multiple_domains']) && is_array($base_object->config->shopConfiguration['has_multiple_domains'])) {
foreach ($base_object->config->shopConfiguration['has_multiple_domains'] as $domain_arr) {
if ($domain_arr['domain'] == str_replace('www.', '', $_SERVER['HTTP_HOST'])) {
$domain_dependend_layout = true;
$layout_menu_id = $domain_arr['menu_id'];
$_GET['menu_id'] = (is_numeric($_GET['menu_id'])) ? $_GET['menu_id'] : $layout_menu_id;
}
}
}
// start breadcrumb
$breadcrumb = array();
// item search redirect
if (isset($_POST['search_item']) && $_POST['search_item']) {
if (isset($_POST['search_item_categories']) && $_POST['search_item_categories'] > 0) {
header('Location: /index.php?search_item='.$_POST['search_item'].'&item_category='.$_POST['search_item_categories']);
} else if (is_array($_POST['search_item'])) {
$querystring = http_build_query($_POST['search_item']);
header('Location: /index.php?'.$querystring);
} else {
header('Location: /index.php?search_item='.$_POST['search_item']);
}
} else if (isset($_GET['search_item']) && $_GET['search_item']) { // item search per get
$breadcrumb[] = array('name' => 'Artikelsuche', 'short_uri' => '');
$search = array('search_item' => $_GET['search_item']);
if (isset($_GET['item_category']) && $_GET['item_category'] > 0) {
$search['item_category'] = $_GET['item_category'];
}
if (isset($_GET['search_item2']) && $_GET['search_item2']) {
$search['search_item2'] = $_GET['search_item2'];
}
if (isset($_GET['search_item3']) && $_GET['search_item3']) {
$search['search_item3'] = $_GET['search_item3'];
}
include_once(ROOT_DIR.'modules/website_item_search.php');
$content_object = new website_item_search($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($search);
} else if (isset($_POST['manufacturer_id']) && $_POST['manufacturer_id']) { // manufacturer item list
$breadcrumb[] = array('name' => 'Hersteller', 'short_uri' => '/manufacturers/');
$search = array('manufacturer_id' => $_POST['manufacturer_id']);
include_once(ROOT_DIR.'modules/website_item_search.php');
$content_object = new website_item_search($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($search);
} else if (isset($_GET['seo_manufacturer_suri']) && $_GET['seo_manufacturer_suri']) { // manufacturer details
$breadcrumb[] = array('name' => 'Hersteller', 'short_uri' => '/manufacturers/');
if (isset($_GET['structureSuri']) && $_GET['structureSuri']) {
include_once(ROOT_DIR.'modules/website_manufacturers_structure_details.php');
$content_object = new website_manufacturers_structure_details($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($_GET['seo_manufacturer_suri'], $_GET['structureSuri']);
} else {
include_once(ROOT_DIR.'modules/website_manufacturers_details.php');
$content_object = new website_manufacturers_details($base_object, $layout_object, $metatag_object);
$layout_object->maincontent = $content_object->run($_GET['seo_manufacturer_suri']);
}
}
// item details
else if (isset($_GET['item_id']) && $_GET['item_id'] && (!isset($_GET['action']) || $_GET['action'] != 'delete')) {
$layout_object->assign('site_type', 'full_width');
$item_id = $_GET['item_id'];
include_once(ROOT_DIR.'modules/website_item.php');
$content_object = new website_item($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($item_id);
// set last customer interesting groups
$group_id = (isset($_GET['menu_id']) && $_GET['menu_id']) ? $_GET['menu_id'] : $content_object->item_data->structure_id;
$base_object->customer->set_last_interesting_item_groups($group_id);
$layout_object->assign('menu_id', isset($_GET['menu_id']) ? $_GET['menu_id'] : null);
// Meta tags
$layout_object->metaTagObject->get_by_group('ARTIKEL');
$layout_object->metaTagObject->overwriteVar('Bezeichnung', $content_object->item_data->name);
$hersteller = Manufacturer::get_name_by_id_static($content_object->item_data->manufacturer_id);
$layout_object->metaTagObject->overwriteVar('VonHersteller', 'von '.$hersteller);
$layout_object->metaTagObject->overwriteVar('Hersteller', $hersteller);
$layout_object->metaTagObject->overwriteVar('ArtikelAttribut6', str_replace(';',',',$content_object->item_data->attribute_6));
$structure_id = (isset($_GET['menu_id']) && $_GET['menu_id']) ? $_GET['menu_id'] : $content_object->structure_data[0]->id;
$structure_object = new Structure($base_object);
$tree_ids = array_reverse($structure_object->get_all_tree_ids($structure_id));
$z = 0;
foreach ($tree_ids as $sid) {
$z++;
$layout_object->metaTagObject->overwriteVar('Struktur'.$z, Structure::get_name_by_id_static($sid));
}
$layout_object->metaTagObject->overwriteVar('Warengruppe', Structure::get_name_by_id_static($structure_id));
// multi domain handling
if (isset($base_object->config->shopConfiguration['multi_domain']) && $base_object->config->shopConfiguration['multi_domain']) {
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
// is domain found..
if (isset($base_object->config->shopConfiguration['multi_domain'][$domain])) {
// check domain with structure id
foreach ($base_object->config->shopConfiguration['multi_domain'] as $domain_name => $domain_structure_id) {
if (in_array($domain_structure_id, $tree_ids) && $domain != $domain_name) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$domain_name.$_SERVER['REQUEST_URI']);
}
}
}
}
$layout_object->metaTagObject->overwriteMetas(array(
'title' => $content_object->item_data->seo_title,
'keywords' => $content_object->item_data->seo_keywords,
'description' => $content_object->item_data->seo_description
));
} else { // load main modules
if (isset($_GET['menu_id']) && $_GET['menu_id']) {
$structure_id = $_GET['menu_id'];
$layout_object->assign('current_menu_id', $structure_id);
} else {
if (is_numeric($layout_menu_id)) {
$structure_id = $layout_menu_id;
} else {
$structure_id = 6;
$layout_object->assign('entrypage', true);
}
}
// get site configuration
$structure_object = new Structure($base_object);
$structure_object->structure_id = $structure_id;
$structure_data = $structure_object->get_data();
if ($structure_data->active == 2 && $structure_data->customer_group != $base_object->customer_group->id) {
$structure_id = 6;
$structure_object->structure_id = $structure_id;
$structure_data = $structure_object->get_data();
}
$breadcrumb[] = array('name' => $structure_data->name, 'short_uri' => $structure_data->short_uri, 'object' => $structure_data);
$layout_object->assign('structureData', $structure_data);
$manufacturers = Manufacturer::get_names_by_structure_id($structure_id);
$layout_object->assign('manufacturersOfCurrentStructureId', $manufacturers);
$content_modul = $structure_object->get_type_modul($structure_data->type);
// get maincontent
include_once(ROOT_DIR.'modules/'.$content_modul.'.php');
$content_object = new $content_modul($base_object, $layout_object);
$layout_object->maincontent = $content_object->run($structure_id);
// multi layout with redirect to correct domain
if (isset($base_object->config->shopConfiguration['multi_domain']) && $base_object->config->shopConfiguration['multi_domain']) {
$domain = str_replace('www.', '', $_SERVER['HTTP_HOST']);
// is domain found..
if (isset($base_object->config->shopConfiguration['multi_domain'][$domain])) {
$structure_object = new Structure($base_object);
$tree_ids = $structure_object->get_all_tree_ids($content_object->item_data->structure_id);
// check domain with structure id
foreach ($base_object->config->shopConfiguration['multi_domain'] as $domain_name => $domain_structure_id) {
if (in_array($domain_structure_id, $tree_ids) && $domain != $domain_name) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.'.$domain_name.$_SERVER['REQUEST_URI']);
}
}
}
}
// Meta tags
$structure_level = $structure_object->get_level($structure_data->id, 0);
if ($structure_level > 0 && $structure_level < 5) {
$layout_object->metaTagObject->get_by_group('MENU'.$structure_level);
} else {
$layout_object->metaTagObject->get_by_group('MENU');
}
$layout_object->metaTagObject->overwriteVar('Warengruppe', $structure_data->name);
$tree_ids = array_reverse($structure_object->get_all_tree_ids($structure_data->id));
$z = 0;
foreach ($tree_ids as $sid) {
$z++;
$layout_object->metaTagObject->overwriteVar('Struktur'.$z, Structure::get_name_by_id_static($sid));
}
$usedManus = array();
if ($manufacturers) {
$layout_object->metaTagObject->overwriteVar('Hersteller', implode(', ', $manufacturers));
foreach ($manufacturers as $manuName) {
$usedManus[] = $structure_data->name.' '.$manuName;
}
}
$usedSubs = $structure_object->get_subcategories($structure_id);
if ($usedSubs) {
$layout_object->metaTagObject->overwriteVar('Unterwarengruppen', implode(', ', $usedSubs));
}
$layout_object->metaTagObject->overwriteMetas(array(
'title' => $structure_data->seo_title,
'keywords' => ($structure_data->seo_keywords) ? $structure_data->seo_keywords : implode(', ', $usedManus),
'description' => $structure_data->seo_description
));
}
$layout_object->assign('layout_menu_id', $layout_menu_id);
$base_object->structure_id = $structure_id;
// get main widgets
if (is_array($base_object->config->shopConfiguration['widget_regions'])) {
foreach ($base_object->config->shopConfiguration['widget_regions'] as $region) {
if ($base_object->config->shopConfiguration['has_frontend_widget_config']) {
${$region.'_widget_list'} = $base_object->config->shopConfiguration['widget_'.$region.'_column'];
} else {
${$region.'_widget_list'} = $base_object->config->shopConfiguration['default_widget_list_'.$region];
}
${$region.'_bar'} = '';
if (gettype(${$region.'_widget_list'}) == 'array') {
${$region.'_bar'} = array();
foreach (${$region.'_widget_list'} as $widget) {
$widget_data = '';
if ($widget['widget']) {
$widget_data = $website_object->{$widget['widget']}(isset($widget['config']) ? $widget['config'] : false);
}
$layout_object->assign($widget['widget'], $widget_data);
${$region.'_bar'}[] = $layout_object->_fetch($widget['template']);
}
}
$layout_object->assign($region.'_widgets', ${$region.'_bar'});
}
}
// Ensure $structure_data is defined
if (!isset($structure_data)) {
$structure_data = new stdClass();
$structure_data->theme_id = null;
$structure_data->header_image = null;
$structure_data->header_image_link = null;
}
$main_theme_id = $structure_data->theme_id;
$header_image = $structure_data->header_image;
$header_link = $structure_data->header_image_link;
// full path breadcrump
if (isset($website_object->activated_structures) && $website_object->activated_structures) {
$breadcrumb = array();
foreach ($website_object->activated_structures as $structure_obj) {
$breadcrumb[] = array('name' => $structure_obj->name, 'short_uri' => $structure_obj->full_short_uri, 'object' => $structure_obj);
// get theme configuration from parent structures
if ($structure_obj->theme_id) {
$main_theme_id = $structure_obj->theme_id;
}
// get header image from parent structures
if ($structure_obj->header_image) {
$header_image = $structure_obj->header_image;
$header_link = $structure_obj->header_image_link;
}
}
}
// get dynamic theme data
$theme_data = new stdClass();
if ($main_theme_id) {
$shop_theme_object = new ShopTheme($base_object);
$theme_data = $shop_theme_object->get_data($main_theme_id);
}
$theme_data->header_image = $header_image;
$theme_data->header_image_link = $header_link;
$layout_object->assign('theme_data', $theme_data);
if ($layout_menu_id) {
$layout_object->assign('menu_items_allsubs', Structure::getLayoutMenu($layout_menu_id));
}
// multi layout with redirect to correct domain
if (isset($base_object->config->shopConfiguration['multi_layout']) && $base_object->config->shopConfiguration['multi_layout']) {
if (!isset($_SESSION['layout_id'])) {
$layout_id = $base_object->config->shopConfiguration['multi_layout_default'];
} else {
$layout_id = $_SESSION['layout_id'];
}
foreach ($base_object->config->shopConfiguration['multi_layout'] as $structure_id => $l_id) {
if (in_array($structure_id, $_GET['parent_ids'])) {
$layout_id = $l_id;
}
}
$_SESSION['layout_id'] = $layout_id;
$layout_object->assign('layout_id', $layout_id);
}
// assign meta tags to template / layout object
$layout_object->metaTagObject->assign();
// show breadcrumb
$layout_object->assign('breadcrumb', $breadcrumb);
// feature for sellavi
/*if ($structure_id == 75 && $_SESSION['load_first_page'] != 'false') {
$_SESSION['load_first_page'] = 'false';
$layout_object->assign('load_first_page', 1);
}*/
// _fetch animated header images from directory
/*if ($layout_menu_id) {
$directory = false;
if ($layout_menu_id == 11) {
$directory = 'trolly';
} else if ($layout_menu_id == 16) {
$directory = 'shower';
} else if ($layout_menu_id == 17) {
$directory = 'thera';
}
if ($directory) {
$images = array();
$directory = '/web/'.SHOP_SYSTEM.'/themes/'.$base_object->config->shopConfiguration['THEME'].'/media/images/header/'.$directory;
if ($handle = opendir(ROOT_DIR.$directory)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && is_file(ROOT_DIR.$directory.'/'.$file)) {
$images[] = array(
'imagefile' => $directory.'/'.$file,
'animation' => 'RANDOM',
'direction' => 'RANDOM',
'speed' => 2500,
'pause' => 2500
);
}
}
closedir($handle);
}
shuffle($images);
$layout_object->assign('header_animated_images', json_encode($images));
}
}*/
// read main template
$layout_object->show_site();
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
class website_internal_link {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
public function run($structure_id) {
$structure_object = new Structure($this->base_object);
$structure_data = $structure_object->get_data($structure_id);
$new_site_structure_data = $structure_object->get_data($structure_data->link_reference);
$short_uri = $new_site_structure_data->short_uri;
header('location: ' . '/'.$short_uri.'/');
exit();
}
}
+384
View File
@@ -0,0 +1,384 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>, John T. Daly <jd@ta-edv.de>
*
* Easyshop is a web e-commerce system
**/
include_once './core/item.class.php';
include_once './core/structure.class.php';
include_once './core/shoppingcart.class.php';
include_once './core/config.class.php';
include_once './core/memory.class.php';
include_once './core/itemhelper.class.php';
include_once './core/customer_group.class.php';
include_once './core/cs_ticket.class.php';
include_once './core/shop_klarna.class.php';
class website_item {
private $base_object;
private $layout_object;
private $item_object;
private $structure_object;
private $shoppingcart_object;
public $item_data;
private $klarna_variant;
private $klarna_accessories;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->item_object = new Item($base_object);
$this->structure_object = new Structure($base_object);
$this->shoppingcart_object = new Shoppingcart($base_object);
}
function run($item_id) {
$customer_id = $this->base_object->customer->customer_id;
if ($customer_id) {
$not_logged_in = false;
} else {
$not_logged_in = true;
}
$this->layout_object->assign('not_logged_in', $not_logged_in);
if (isset($_POST['create_opinion']) && $_POST['create_opinion']) {
$this->item_object->create_opinion(
array(
'item_id' => $item_id,
'rang' => $_POST['rang'],
'opinion_text' => $_POST['opinion_text'],
'user_id' => $this->base_object->customer->id,
'user_name' => $this->base_object->customer->firstname.' '.substr($this->base_object->customer->surname,0,1).' aus '.$this->base_object->customer->default_address_city
)
);
}
if (isset($_POST['amount']) && $_POST['amount']) {
$this->add_item_to_shopingcart($item_id);
}
if (isset($_POST['memorize'])) {
$this->add_item_to_memory($item_id);
}
if (isset($_POST['request_price_info'])) {
$this->send_request_price_info($item_id);
}
if (isset($_GET['action'])) {
$action = $_GET['action'];
} else {
$action = false;
}
$this->lock_shoppingcart();
if ($action == 'get_variant_price') {
$this->get_variant_price($item_id);
} elseif ($action == 'print') {
$this->item_print($item_id);
} elseif ($action == 'get_variant_data') {
$this->get_variant_data($item_id);
} elseif ($action == 'get_images') {
$this->get_images($item_id);
} else {
return $this->item_view($item_id);
}
}
private function lock_shoppingcart() {
if (isset($this->base_object->config->shopConfiguration['lock_shoppingcart']) && $this->base_object->config->shopConfiguration['lock_shoppingcart']) {
if ($this->shoppingcart_object->has_items()) {
$this->layout_object->assign('lock_shoppingcart', true);
}
}
}
private function send_request_price_info($item_id) {
$cs_ticket_objet = new Cs_ticket($this->base_object);
$title = "Preisanfrage von " . $_POST['request_name_field'] . "<" . $_POST['request_email_field'] . ">";
$message = "Name: " . $_POST['request_name_field'] . "\n";
$message .= "E-Mail: " . $_POST['request_email_field'] . "\n";
$message .= "Telefon: " . $_POST['request_telephone_field'] . "\n";
$message .= "Artikel: " . $_POST['request_item_name'] . "\n";
$message .= "Artikel-Nr.: " . $_POST['request_item_number'] . "\n";
$message .= "Nachricht: \n" . $_POST['request_message_field'];
$this->layout_object->assign('price_info_request_was_sent', true);
}
private function add_item_to_shopingcart($item_id) {
if (isset($_POST['is_combination']) && $_POST['is_combination'] == 'yes') {
$stamp = uniqid();
$this->shoppingcart_object->add_combi($item_id, $_POST['amount'], $_POST['variant'][1], $_POST['variant'][2], false, false, false, $stamp);
$multiplier = 1;
if ($this->item_object->is_combination_item()) {
$multiplier = (int)$_POST['amount'];
}
if (is_array($_POST['additionalItems'])) {
foreach ($_POST['additionalItems'] as $addItem) {
if (is_array($addItem)) {
$user_data = false;
if (isset($addItem['user_data']) && $addItem['user_data'] != '') {
$user_data = $addItem['user_data'];
}
$this->shoppingcart_object->add_combi($addItem['id'], ((int)$_POST['amount'] * $multiplier), $addItem['variant_1'], $addItem['variant_2'], false, $item_id, $user_data, $stamp);
} else {
$this->shoppingcart_object->add_combi($addItem, 1);
}
}
}
$this->layout_object->assign('itemAddedToCart', true);
} else {
$this->shoppingcart_object->add($item_id, $_POST['amount'], $_POST['variant'][1], $_POST['variant'][2]);
$multiplier = 1;
if ($this->item_object->is_combination_item()) {
$multiplier = (int)$_POST['amount'];
}
if (is_array($_POST['additionalItems'])) {
foreach ($_POST['additionalItems'] as $addItem) {
if (is_array($addItem)) {
$this->shoppingcart_object->add($addItem['id'], ((int)$_POST['amount'] * $multiplier), $addItem['variant_1'], $addItem['variant_2']);
} else {
$this->shoppingcart_object->add($addItem, 1);
}
}
}
$this->layout_object->assign('itemAddedToCart', true);
}
}
private function add_item_to_memory($item_id) {
$memory_object = new Memory();
$memory_object->add($item_id);
}
private function get_variant_price($item_id) {
$group_id = ($this->base_object->customer_group->adaptPricesFromId != 0) ? $this->base_object->customer_group->adaptPricesFromId : $this->base_object->customer_group->id;
$taxrate = ItemHelper::get_item_taxrate($item_id);
$data = ItemHelper::get_item_variant_prices($item_id, $group_id, $taxrate);
$data = $data[$_POST['data'][0]][$_POST['data'][1]];
$tax_type = Customer_group::get_taxation_type($this->base_object->customer_group->id);
if ($tax_type == 1) {
$data['price'] = $data['priceGross'];
}
$data['price'] = number_format($data['price'], 2, ',', ' ');
echo json_encode($data);
exit();
}
private function klarna_installments($price) {
$klarna_object = new Shop_klarna($this->base_object);
return $klarna_object->get_installments($price);
}
private function klarna_installments_for_variants($data) {
$this->klarna_variant = array();
foreach ($data as $level_one_key => $level_one_data) {
foreach ($level_one_data as $level_two_key => $level_two_data) {
$klarna_data = $this->klarna_installments($level_two_data['priceGross']);
$this->klarna_variant[$level_one_key][$level_two_key] = $klarna_data;
}
}
$this->layout_object->assign('klarna_variants', json_encode($this->klarna_variant));
}
private function klarna_installments_for_accessories($data) {
$this->klarna_accessories = array();
foreach ($data as $item) {
$this->klarna_accessories[$item->id] = $this->klarna_installments($item->shop_price_1);
}
$this->layout_object->assign('klarna_accessories', json_encode($this->klarna_accessories));
}
private function item_view($item_id) {
// get item data
$this->item_object->set_id($item_id);
$this->item_data = $this->item_object->get_data($this->base_object->customer_group->id);
$this->item_data->opinion = $this->item_object->get_opinion_list($this->item_data->id);
$this->item_data->avg_opinion = $this->item_object->get_avg_opinion($this->item_data->id);
// overwrite shippable
if ($this->item_data->inventory > 0) {
$this->item_data->shippable = $this->item_data->shippable_inventory;
}
// overwrite files with parent files, for variants
if (isset($this->item_data->parent_files)) {
$this->item_data->files = $this->item_data->parent_files;
}
// overwrite assigned items with parent assigend items, for variants
if (isset($this->item_data->parent_assignedItemSet)) {
$this->item_data->assignedItemSet = $this->item_data->parent_assignedItemSet;
}
$images = array() ;
$documents = array();
foreach ($this->item_data->files as $file) {
if ($file->type == 0) {
$images[] = $file;
}
else {
$documents[] = $file;
}
}
// default image
if (!$images) {
$file = new stdClass;
$file->file_name = 'default_image.png';
$images[] = $file;
}
$this->item_data->files = $images;
$this->item_data->documents = $documents;
// klarna
if ((isset($this->base_object->config->shopConfiguration['klarna_eid']) &&
$this->base_object->config->shopConfiguration['klarna_eid'] != '') &&
(isset($this->base_object->config->shopConfiguration['klarna_secret']) &&
$this->base_object->config->shopConfiguration['klarna_secret'] != ''))
{
$klarna_installments = $this->klarna_installments($this->item_data->price_1_tax);
$this->layout_object->assign('klarna_installments', $klarna_installments);
if ($this->item_data->schema_data->selectable_attribute_1 > 0) {
$this->klarna_installments_for_variants($this->item_data->variant_data);
}
if (count($this->item_data->assignedItemSet) > 0) {
$this->klarna_installments_for_accessories($this->item_data->assignedItemSet);
}
}
$this->layout_object->assign('shopArticle', $this->item_data);
$all_structurepath = $this->structure_object->get_all_tree_full_path(1);
// get structure data
//$structure_data = $this->structure_object->get_data($this->item_data->structure_id);
//echo var_dump($this->structure_object->get_all_item_categories());
$sd = $this->item_object->getStructureAssignment();
$structure_data = array();
foreach ($sd as $key => $value) {
$structure = $this->structure_object->get_data($key);
if ($structure) {
$structure->name = $all_structurepath[$structure->id]->path_name.'-&gt'.$structure->name;
if ($structure->id == $this->item_data->structure_id) {
$this->item_data->main_structure_uri_path = $all_structurepath[$structure->id]->uri_path.'/'.$structure->short_uri;
}
if ($structure->active == 1) {
$structure_data[] = $structure;
}
}
}
$this->structure_data = $structure_data;
$this->layout_object->assign('structure_data', $structure_data);
// get countries
include_once './core/countryhelper.class.php';
$countries = CountryHelper::get_delivery_and_shipping_info_for_all_countries();
$this->layout_object->assign('countries', $countries);
if (isset($_GET['opinion_show']) && $_GET['opinion_show']) {
$this->layout_object->assign('opinion_show', true);
}
return $this->layout_object->_fetch('content_item.tpl');
}
private function item_print($item_id) {
// get item data
$this->item_object->set_id($item_id);
$this->item_data = $this->item_object->get_data($this->base_object->customer_group->id);
$images = array() ;
$documents = array();
foreach ($this->item_data->files as $file) {
if ($file->type == 0) {
$images[] = $file;
}
else {
$documents[] = $file;
}
}
// default image
if (!$images) {
$file = new stdClass;
$file->file_name = 'default_image.png';
$images[] = $file;
}
$this->item_data->files = $images;
$this->layout_object->assign('shopArticle', $this->item_data);
// we asign the structure data to another variable in the website init, it never gets called if we call this module
// get structure data
$this->layout_object->assign('current_menu_id', $this->item_data->structure_id); // hack by jd for sh menu hack to work here too
$structure_data = $this->structure_object->get_data($this->item_data->structure_id);
$this->layout_object->assign('structure_data', $structure_data);
echo $this->layout_object->_fetch('content_item_print.tpl');
exit();
}
// copy of get_variant_prices
private function get_variant_data($item_id) {
$group_id = ($this->base_object->customer_group->adaptPricesFromId != 0) ? $this->base_object->customer_group->adaptPricesFromId : $this->base_object->customer_group->id;
$taxrate = ItemHelper::get_item_taxrate($item_id);
$data = ItemHelper::get_item_variant_prices($item_id, $group_id, $taxrate);
$data = $data[$_POST['data'][0]][$_POST['data'][1]];
$tax_type = Customer_group::get_taxation_type($this->base_object->customer_group->id);
if ($tax_type == 1) {
$data['price'] = $data['priceGross'];
}
$data['price'] = number_format($data['price'], 2, ',', ' ');
// end of c-n-p
$image = ItemHelper::get_item_variant_image($item_id, $_POST['data'][0], $_POST['data'][1]);
if ($image) {
$data['image'] = $image;
}
echo json_encode($data);
exit();
}
private function get_images($item_id) {
$images = ItemHelper::get_additional_item_images($item_id);
echo json_encode($images);
exit();
}
}
+52
View File
@@ -0,0 +1,52 @@
<?php
/**
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*/
include_once './core/memory.class.php';
include_once './core/item.class.php';
class website_item_memory {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run($search) {
$memory_object = new Memory();
// delete item
if (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['item_id']) {
$memory_object->delete($_GET['item_id']);
}
// get all items
$memory_items = $memory_object->get_all();
$item_list = array();
if ($memory_items) {
$item_object = new Item($this->base_object);
$item_list = $item_object->get_item_list_by_ids($memory_items, 'all');
}
$this->layout_object->assign('show_memory_items', 1);
$this->layout_object->assign('shopArticles', $item_list);
$this->layout_object->assign('hide_pagination', true);
$this->layout_object->assign('hide_listoptions', true);
// generate block element since there is none in old, non dynamic modules
$block = new stdClass();
$block->style = 'h2';
$this->layout_object->assign('block', $block);
// return $this->layout_object->_fetch('content_item_memory.tpl');
return $this->layout_object->_fetch('content_box_item_list.tpl');
}
}
+129
View File
@@ -0,0 +1,129 @@
<?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/structure.class.php';
include_once './core/shoppingcart.class.php';
class website_item_search {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run($search) {
// Structure change
if (!isset($_SESSION['lastsearch']) || $_SESSION['lastsearch'] != $search) {
unset($_SESSION['itemsPerPage']);
unset($_SESSION['currentPage']);
unset($_SESSION['currentManufacturer']);
unset($_SESSION['listStyleType']);
}
$_SESSION['lastsearch'] = $search;
// Per page change
if (isset($_POST['pagingSelector']) && $_POST['pagingSelector']) {
$possibilities = array(12, 24, 48, '9999');
if (in_array($_POST['pagingSelector'], $possibilities)) {
$_SESSION['itemsPerPage'] = $_POST['pagingSelector'];
$_SESSION['currentPage'] = 1;
}
}
if (!isset($_SESSION['itemsPerPage']) || !$_SESSION['itemsPerPage']) {
$_SESSION['itemsPerPage'] = 24;
}
// list style
if (isset($_POST['listStyleSelector']) && $_POST['listStyleSelector']) {
$possibilities = array(1, 2, 3);
if (in_array($_POST['listStyleSelector'], $possibilities)) {
$_SESSION['listStyleType'] = $_POST['listStyleSelector'];
}
}
if (!isset($_SESSION['listStyleType']) || !$_SESSION['listStyleType']) {
$_SESSION['listStyleType'] = 1;
}
// list sort by
if (isset($_POST['sort_by']) && $_POST['sort_by']) {
$_SESSION['sort_by'] = $_POST['sort_by'];
}
if (!isset($_SESSION['sort_by']) || !$_SESSION['sort_by']) {
if ($this->base_object->config->shopConfiguration['sort_item_list_by']) {
$_SESSION['sort_by'] = $this->base_object->config->shopConfiguration['sort_item_list_by'];
} else {
$_SESSION['sort_by'] = 'number_up';
}
}
// Page change
if (isset($_POST['page'])) {
$_GET['page'] = $_POST['page'];
}
if (isset($_GET['page']) && $_GET['page'] && is_numeric($_GET['page'])) {
$_SESSION['currentPage'] = $_GET['page'];
}
if (!isset($_SESSION['currentPage']) || !$_SESSION['currentPage']) {
$_SESSION['currentPage'] = 1;
}
if (!isset($_SESSION['currentManufacturer'])) {
$_SESSION['currentManufacturer'] = '';
}
$item_object = new Item($this->base_object);
$item_list = $item_object->search_items($search);
$item_ids = array();
if (is_array($item_list)) {
$item_ids = array_keys($item_list);
}
$search_groups = $item_object->search_group_items($search, $item_ids);
$this->layout_object->assign('search_item', $search['search_item']);
/*$this->layout_object->assign('search_item2', $search['search_item2']);
$this->layout_object->assign('search_item3', $search['search_item3']);*/
$this->layout_object->assign('search_item_categories', $search_groups);
$this->layout_object->assign('shopArticles', $item_list);
$this->layout_object->assign('itemsPerPage', $_SESSION['itemsPerPage']);
$this->layout_object->assign('listStyleType', $_SESSION['listStyleType']);
$this->layout_object->assign('sort_by', $_SESSION['sort_by']);
$this->layout_object->assign('itemsFound', $item_object->itemCount);
$this->layout_object->assign('found_pages', ceil($item_object->itemCount / $_SESSION['itemsPerPage']));
$this->layout_object->assign('found_showing_page', $_SESSION['currentPage']);
$this->layout_object->assign('hide_pagination', true);
$this->layout_object->assign('hide_listoptions', true);
//$this->layout_object->assign('content_box_title', 'Suchergebnisse');
$block = new stdClass();
$block->content = 'list';
$block->style = 'h2';
$this->layout_object->assign('block', $block);
if (!$item_list) {
$this->layout_object->assign('search_word', $search['search_item'].' '.$search['search_item2'].' '.$search['search_item3']);
return $this->layout_object->_fetch('content_item_search_empty.tpl');
} else {
$this->layout_object->assign('content_box_title', 'Suche nach: '.$search['search_item'].' '.$search['search_item2'].' '.$search['search_item3']);
return $this->layout_object->_fetch('content_box_item_list.tpl');
}
}
}
+185
View File
@@ -0,0 +1,185 @@
<?php
/**
* @version $Id: website_item_type_list.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/item.class.php';
include_once './core/structure.class.php';
include_once './core/shoppingcart.class.php';
class website_item_type_list {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$structure_id = $_GET['menu_id'];
$item_object = new Item($this->base_object);
include_once './core/structure.class.php';
$structure_object = new Structure($this->base_object);
$this->layout_object->assign('structure_data', $structure_object->get_by_id($structure_id));
// Structure change
if (!isset($_SESSION['lastStructureId']) || $_SESSION['lastStructureId'] != $structure_id) {
unset($_SESSION['itemsPerPage']);
unset($_SESSION['currentPage']);
unset($_SESSION['currentManufacturer']);
unset($_SESSION['listStyleType']);
}
$_SESSION['lastStructureId'] = $structure_id;
// Per page change
if (isset($_POST['pagingSelector']) && $_POST['pagingSelector']) {
$possibilities = array(12, 24, 48, '9999');
if (in_array($_POST['pagingSelector'], $possibilities)) {
$_SESSION['itemsPerPage'] = $_POST['pagingSelector'];
$_SESSION['currentPage'] = 1;
}
}
if (!isset($_SESSION['itemsPerPage']) || !$_SESSION['itemsPerPage']) {
$_SESSION['itemsPerPage'] = 24;
}
// list style
if (isset($_POST['listStyleSelector']) && $_POST['listStyleSelector']) {
$possibilities = array(1, 2, 3);
if (in_array($_POST['listStyleSelector'], $possibilities)) {
$_SESSION['listStyleType'] = $_POST['listStyleSelector'];
}
}
if (!isset($_SESSION['listStyleType']) || !$_SESSION['listStyleType']) {
if ($block->content) {
$_SESSION['listStyleType'] = $block->content;
}
else {
$_SESSION['listStyleType'] = 1;
}
}
// list sort by
if (isset($_POST['sort_by']) && $_POST['sort_by']) {
$_SESSION['sort_by'] = $_POST['sort_by'];
}
if (!isset($_SESSION['sort_by']) || !$_SESSION['sort_by']) {
if ($this->base_object->config->shopConfiguration['sort_item_list_by']) {
$_SESSION['sort_by'] = $this->base_object->config->shopConfiguration['sort_item_list_by'];
}
else {
$_SESSION['sort_by'] = 'number_up';
}
}
// Page change
if(isset($_POST['page'])) {
$_GET['page'] = $_POST['page'];
}
if (isset($_GET['page']) && $_GET['page'] && is_numeric($_GET['page'])) {
$_SESSION['currentPage'] = $_GET['page'];
}
if (!isset($_SESSION['currentPage']) || !$_SESSION['currentPage']) {
$_SESSION['currentPage'] = 1;
}
if(!isset($_SESSION['currentManufacturer'])) {
$_SESSION['currentManufacturer'] = '';
}
// Infinite scrolling?
$useInfinityScroll = false;
if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && isset($_GET['loadstep']) && is_numeric($_GET['loadstep']) && $_SESSION['itemsPerPage'] == '9999') {
$_SESSION['currentPage'] = ($_GET['loadstep'] > 0) ? $_GET['loadstep'] : 1;
$useInfinityScroll = true;
} else if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && $_SESSION['itemsPerPage'] == '9999') {
$_SESSION['currentPage'] = 1;
$useInfinityScroll = true;
}
// Load items
$article_list = $item_object->get_item_list_by_type(
$structure_id,
$_SESSION['itemsPerPage'],
$_SESSION['currentPage'],
true,
$_SESSION['currentManufacturer'],
$_SESSION['sort_by'],
$useInfinityScroll
);
// Still necessary?
if (isset($_GET['page']) && ($_GET['page'] > ceil($item_object->itemCount / $_SESSION['itemsPerPage']))) {
$_SESSION['currentPage'] = $_GET['page'] = ceil($item_object->itemCount / $_SESSION['itemsPerPage']);
$article_list = $item_object->get_item_list_new(
$structure_id,
$_SESSION['itemsPerPage'],
$_SESSION['currentPage'],
true,
$_SESSION['currentManufacturer'],
$_SESSION['sort_by'],
$useInfinityScroll
);
}
// Show the (first) item, if only one item exists in current category
if ($this->base_object->config->shopConfiguration['show_details_by_one_item_in_structure'] == 1 && count($article_list) == 1) {
$currentItem = current($article_list);
if ($currentItem->short_uri) {
header('Location: ./' . $currentItem->short_uri . '.html');
} else {
header('Location: /index.php?item_id=' . $currentItem->id);
}
exit();
}
$this->layout_object->assign('shopArticles', $article_list);
// Show only the items for infinite scrolling
if ($this->base_object->config->shopConfiguration['infinite_scrolling'] && isset($_GET['loadstep']) && is_numeric($_GET['loadstep'])) {
$data = array(
'template' => $this->layout_object->fetch('item_box_loop.tpl'),
'counter' => count($article_list)
);
echo json_encode($data);
exit();
// Show default item list
} else {
$this->layout_object->assign('itemsPerPage', $_SESSION['itemsPerPage']);
$this->layout_object->assign('listStyleType', $_SESSION['listStyleType']);
$this->layout_object->assign('sort_by', $_SESSION['sort_by']);
$this->layout_object->assign('itemsFound', $item_object->itemCount);
$this->layout_object->assign('found_pages', ceil($item_object->itemCount / $_SESSION['itemsPerPage']));
$this->layout_object->assign('found_showing_page', $_SESSION['currentPage']);
$this->layout_object->assign('currentManufacturer', $_SESSION['currentManufacturer']);
$this->layout_object->assign('useInfinityScroll', $useInfinityScroll);
return $this->layout_object->_fetch('content_box_item_type_list.tpl');
}
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/manufacturer.class.php';
class website_manufacturers {
private $base_object;
private $layout_object;
private $manufacturer_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->manufacturer_object = new Manufacturer($base_object);
}
public function run() {
$manufacturers = $this->manufacturer_object->get_all_active();
$path = $this->manufacturer_object->get_image_url();
$this->layout_object->assign('img_path', $path);
$this->layout_object->assign('manufacturers', $manufacturers);
return $this->layout_object->_fetch('content_manufacturers.tpl');
}
}
+84
View File
@@ -0,0 +1,84 @@
<?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/manufacturer.class.php';
include_once './core/structure.class.php';
include_once './core/item.class.php';
class website_manufacturers_details {
private $base_object;
private $layout_object;
private $manufacturer_object;
private $item_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->manufacturer_object = new Manufacturer($base_object);
$this->item_object = new Item($base_object);
}
public function run($suri) {
$path = $this->manufacturer_object->get_image_url();
$this->layout_object->assign('img_path', $path);
// get manufacturer
$manufacturer = $this->manufacturer_object->get_by_suri($suri);
$this->layout_object->assign('manufacturer', $manufacturer);
// get manufacturer items
$items = $this->item_object->get_by_manufacturer($id);
// get structures
$structure = new Structure($base_object);
$structureItems = $structure->getWhereManufacturerItems($manufacturer->id);
$structure_tree = $structure->get_all_tree_full_path(1);
$fullpath_tree = array();
foreach ($structure_tree as $obj) {
$fullpath_tree[$obj->id] = $obj;
}
$structureItems_new = array();
foreach ($structureItems as $structure_item) {
$structure_item->path = $fullpath_tree[$structure_item->id]->path_name;
$structure_item->name = $structure_item->name;
$path_name = ($fullpath_tree[$structure_item->id]->path_name) ? $fullpath_tree[$structure_item->id]->path_name.'->'.$structure_item->name : $structure_item->name;
$structureItems_new[$path_name] = $structure_item;
}
ksort($structureItems_new);
$this->layout_object->assign('structureItems', $structureItems_new);
foreach ($structureItems as $structureItem) {
$metaparts[] = $manufacturer->name.' '.$structureItem->name;
}
$this->layout_object->metaTagObject->get_by_group('HERSTELLERDETAILS');
$this->layout_object->metaTagObject->overwriteVar('Hersteller', $manufacturer->name);
$this->layout_object->metaTagObject->overwriteMeta('keywords', implode(', ', $metaparts));
$this->layout_object->metaTagObject->overwriteMeta('description', trim($manufacturer->description));
if (Config::has_key('manufacturers_show_items') && Config::is_set('manufacturers_show_items')) {
$show_items = Config::get_value('manufacturers_show_items');
} else {
$show_items = 0;
}
if ($show_items) {
//$manufacturer_items = $this->item_object->get_all_by_manufacturer($manufacturer->id);
$manufacturer_items = $this->item_object->search_items(array('manufacturer_id' => $manufacturer->id));
$this->layout_object->assign('manufacturer_items', $manufacturer_items);
}
return $this->layout_object->_fetch('content_manufacturers_details.tpl');
}
}
@@ -0,0 +1,51 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Darius Zylka <dz@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/manufacturer.class.php';
include_once './core/structure.class.php';
include_once './core/item.class.php';
class website_manufacturers_structure_details {
private $base_object;
private $layout_object;
private $manufacturer_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->manufacturer_object = new Manufacturer($base_object);
}
public function run($manufacturerSuri, $structureSuri) {
$manufacturer = $this->manufacturer_object->get_by_suri($manufacturerSuri);
$this->layout_object->assign('manufacturer', $manufacturer);
$structureId = URI::fetch_structure($structureSuri);
$structure = new Structure($this->base_object);
$structureItem = $structure->get_by_id($structureId);
$this->layout_object->assign('structure', $structureItem);
$item = new Item($this->base_object);
$itemList = $item->get_item_list_manufacturer($structureId, $manufacturer->id);
$this->layout_object->assign('items', $itemList);
foreach ($itemList as $item) {
$metaparts[] = $item->name;
}
$this->layout_object->metaTagObject->get_by_group('HERSTELLERWARENGRUPPENDETAILS');
$this->layout_object->metaTagObject->overwriteVar('Warengruppe', $structureItem->name);
$this->layout_object->metaTagObject->overwriteVar('Hersteller', $manufacturer->name);
$this->layout_object->metaTagObject->overwriteMeta('keywords', implode(', ', $metaparts));
$this->layout_object->metaTagObject->overwriteMeta('description', trim($structureItem->seo_description));
return $this->layout_object->_fetch('website_manufacturers_structure_details.tpl');
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* @version $Id: website_menu.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_menu {
public $base_object;
public $layout_object;
public $website_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$menuData = $this->website_object->main_widget_menu_advanced($_POST['config']);
$this->layout_object->assign('main_widget_menu_advanced', $menuData);
$this->layout_object->display('main_widget_menu.tpl');
exit();
}
}
+62
View File
@@ -0,0 +1,62 @@
<?php
/**
* @version $Id: website_new_opinion.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/shop_opinion.class.php';
class website_new_opinion {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$data = array(
'state' => 0
);
// create opinion
if (isset($_POST['customer_field'])) {
$form_data = $_POST['customer_field'];
if (
$form_data['opinion_rang1'] &&
$form_data['opinion_rang2'] &&
$form_data['opinion_rang3'] &&
$form_data['opinion_text'] &&
$form_data['user_firstname'] &&
$form_data['user_surename'] &&
$form_data['user_email'] &&
$form_data['user_address']
) {
$opinion_object = new Shop_opinion($this->base_object);
$result = $opinion_object->create($form_data);
if ($result) {
$data['state'] = 1;
header('Location: /Kundenbewertung_abschluss/');
} else {
$data['state'] = 3;
$data['form_data'] = $form_data;
}
}
else {
$data['state'] = 2;
$data['form_data'] = $form_data;
}
}
$this->layout_object->assign('data', $data);
return $this->layout_object->_fetch('content_new_opinion.tpl');
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
/**
* @version $Id: website_customer_registration.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/news.class.php';
class website_news {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$news_object = new News($this->base_object);
$list_data = $news_object->get_list();
$this->layout_object->assign('news_list', $list_data);
return $this->layout_object->_fetch('content_news.tpl');
}
}
@@ -0,0 +1,51 @@
<?php
/**
* @version $Id: website_newsletter_registration.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_newsletter_registration {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$form_data = array(
'state' => 0
);
// create opinion
if (isset($_POST['form_data'])) {
$form_data = $_POST['form_data'];
if (
$form_data['firstname'] &&
$form_data['surname'] &&
$form_data['email']
) {
include_once './core/newsletter_subscriber.class.php';
$newsletter_subscriber_object = new Newsletter_subscriber($this->base_object);
$result = $newsletter_subscriber_object->save($form_data, false);
if ($result) {
$form_data['state'] = 1;
} else {
$form_data['state'] = 3;
}
}
else {
$form_data['state'] = 2;
}
}
$this->layout_object->assign('formdata', $form_data);
return $this->layout_object->_fetch('content_newsletter_registration.tpl');
}
}
+339
View File
@@ -0,0 +1,339 @@
<?php
/**
* @package Easyway Shop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author John T. Daly <jd@ta-edv.de>
*
* Easyway Shop is a web e-commerce system
*/
include_once './core/customer.class.php';
include_once './core/customerorder.class.php';
include_once './core/customeraddress.class.php';
include_once './core/country.class.php';
include_once './core/honorific.class.php';
include_once './core/orderstatus.class.php';
include_once './core/order.class.php';
include_once './core/orderhelper.class.php';
include_once './core/customeraddress.class.php';
include_once './core/cancellationreasons.class.php';
include_once './core/cancellationrequests.class.php';
include_once './core/cancellationreasonshelper.class.php';
include_once './core/deliverer.class.php';
class website_order_editor {
private $base_object;
private $layout_object;
private $country_object;
private $order_object;
private $address_object;
private $cancellation_reason_object;
private $deliverer_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
$this->country_object = new Country($base_object);
$this->order_object = new Order($base_object);
$this->address_object = new CustomerAddress($base_object);
$this->cancellation_reason_object = new CancellationReasons($base_object);
$this->deliverer_object = new Deliverer($base_object);
}
public function run() {
if (isset($_GET['action'])) {
$action = $_GET['action'];
} elseif (isset($_POST['action'])) {
$action = $_POST['action'];
} else {
$action = false;
}
if ($action == 'cancel_order') {
$this->cancel_order();
} elseif ($action == 'edit_customer_comment') {
$this->edit_customer_comment();
} elseif ($action == 'edit_shipping_address') {
$this->edit_shipping_address();
} elseif ($action == 'edit_billing_address') {
$this->edit_billing_address();
} elseif ($action == 'get_address') {
$this->get_address();
} elseif ($action == 'get_order_address') {
$this->get_order_address();
} else {
return $this->view_order();
}
}
private function get_address() {
if (isset($_POST['address_id'])) {
$address_id = $_POST['address_id'];
} else {
$address_id = false;
}
if ($address_id) {
$address_data = $this->address_object->get($address_id);
unset($address_data->orders);
if ($address_data) {
$return_data = array('status' => 'success', 'data' => $address_data);
} else {
$return_data = array('status' => 'error', 'message' => 'no return data');
}
} else {
$return_data = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return_data);
exit();
}
private function get_order_address() {
if (isset($_POST['address_type'])) {
$address_type = $_POST['address_type'];
} else {
$address_type = false;
}
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($address_type && $order_id) {
$order_data = $this->order_object->get_by_id($order_id);
if ($order_data) {
if ($address_type == 'shipping') {
$shipping_address['company'] = $order_data->shipping_company;
$shipping_address['honorific'] = $order_data->shipping_honorific;
$shipping_address['firstname'] = $order_data->shipping_firstname;
$shipping_address['surname'] = $order_data->shipping_surname;
$shipping_address['street'] = $order_data->shipping_street;
$shipping_address['house_number'] = $order_data->shipping_house_number;
$shipping_address['zip_code'] = $order_data->shipping_zip_code;
$shipping_address['city'] = $order_data->shipping_city;
$shipping_address['country'] = $order_data->shipping_country;
$return_data = array('status' => 'success', 'data' => $shipping_address);
} elseif ($address_type == 'billing') {
$billing_address['company'] = $order_data->billing_company;
$billing_address['honorific'] = $order_data->billing_honorific;
$billing_address['firstname'] = $order_data->billing_firstname;
$billing_address['surname'] = $order_data->billing_surname;
$billing_address['street'] = $order_data->billing_street;
$billing_address['house_number'] = $order_data->billing_house_number;
$billing_address['zip_code'] = $order_data->billing_zip_code;
$billing_address['city'] = $order_data->billing_city;
$billing_address['country'] = $order_data->billing_country;
$return_data = array('status' => 'success', 'data' => $billing_address);
} else {
$return_data = array('status' => 'error', 'message' => 'unsupported argument type');
}
} else {
$return_data = array('status' => 'error', 'message' => 'no return data');
}
} else {
$return_data = array('status' => 'error', 'message' => 'missing argument');
}
echo json_encode($return_data);
exit();
}
private function view_order() {
$customer_id = $this->base_object->customer->customer_id;
if ($customer_id) {
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($order_id) {
$order_object = new Order($this->base_object);
$order = $order_object->get_order_by_id($order_id);
$order_header = $order['header'];
$deliverer_id = $order_header->shipping_method;
$deliverer_data = $this->deliverer_object->get_data($deliverer_id);
if ($deliverer_data) {
$tracking_url = $deliverer_data->tacking_url;
$tracking_code = $order_header->trackingcode;
if ($tracking_code != '') {
$tracking_url = str_replace('[trackingcode]', $tracking_code, $tracking_url);
} else {
$tracking_url = false;
}
} else {
$tracking_url = false;
}
$order_header->cancellable = OrderHelper::order_cancellability_status($order_id);
$order_footer = $order['footer'];
if ($order_header->customer_id == $customer_id) {
$order_items_data = $order['items'];
$customer_address_object = new CustomerAddress($this->base_object);
$customer_address_object->set_customer_id($customer_id);
$customer_address_data = $customer_address_object->get_all();
$this->layout_object->assign('addresses', $customer_address_data);
$this->layout_object->assign('orderitems', $order_items_data);
$this->layout_object->assign('countries', $this->country_object->get_all());
$this->layout_object->assign('order', $order_header);
$this->layout_object->assign('footer', $order_footer);
$this->layout_object->assign('tracking_url', $tracking_url);
// cancellation mechanism
$cancellation_reasons = $this->cancellation_reason_object->get_all('customer-active');
if ($cancellation_reasons) {
$this->layout_object->assign('cancellation_reasons', $cancellation_reasons);
}
} else {
$this->layout_object->assign('errormessage', "Keine Bestellung.");
}
} else {
$this->layout_object->assign('errormessage', "Keine Bestellung.");
}
return $this->layout_object->_fetch('content_order_editor.tpl');
} else {
return $this->layout_object->_fetch('content_login.tpl');
}
}
private function edit_customer_comment() {
if ($_GET['order_id']) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
$customer_id = $this->base_object->customer->customer_id;
if ($order_id) {
OrderHelper::set_order_comment($order_id, $_POST['customer_comment'], $customer_id);
}
header('location: ' . $_SERVER['HTTP_REFERER']);
}
private function edit_shipping_address() {
if ($_GET['order_id']) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($_POST['select_shipping_address'] == '-1') {
$save_address = true;
} else {
$save_address = false;
}
unset($_POST['select_shipping_address']);
unset($_POST['action']);
$customer_id = $this->base_object->customer->customer_id;
if ($order_id) {
OrderHelper::set_shipping_address($order_id, $_POST, $customer_id);
}
if ($save_address) {
$address['honorific'] = $_POST['shipping_honorific'];
$address['firstname'] = $_POST['shipping_firstname'];
$address['surname'] = $_POST['shipping_surname'];
$address['company'] = $_POST['shipping_company'];
$address['street'] = $_POST['shipping_street'];
$address['house_number'] = $_POST['shipping_house_number'];
$address['zip_code'] = $_POST['shipping_zip_code'];
$address['city'] = $_POST['shipping_city'];
$address['country'] = $_POST['shipping_country'];
$address['orders'] = 0;
$this->address_object->set_customer_id($customer_id);
$this->address_object->create($address);
}
header('location: ' . $_SERVER['HTTP_REFERER']);
}
private function edit_billing_address() {
if ($_GET['order_id']) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
if ($_POST['select_billing_address'] == '-1') {
$save_address = true;
} else {
$save_address = false;
}
unset($_POST['select_billing_address']);
unset($_POST['action']);
$customer_id = $this->base_object->customer->customer_id;
if ($order_id) {
OrderHelper::set_billing_address($order_id, $_POST, $customer_id);
}
if ($save_address) {
$address['honorific'] = $_POST['billing_honorific'];
$address['firstname'] = $_POST['billing_firstname'];
$address['surname'] = $_POST['billing_surname'];
$address['company'] = $_POST['billing_company'];
$address['street'] = $_POST['billing_street'];
$address['house_number'] = $_POST['billing_house_number'];
$address['zip_code'] = $_POST['billing_zip_code'];
$address['city'] = $_POST['billing_city'];
$address['country'] = $_POST['billing_country'];
$address['orders'] = 0;
$this->address_object->set_id($customer_id);
$this->address_object->add_address($address);
}
header('location: ' . $_SERVER['HTTP_REFERER']);
}
private function cancel_order() {
echo "bestellung stornieren";
if (isset($_GET['order_id'])) {
$order_id = $_GET['order_id'];
} else {
$order_id = false;
}
$data = array();
if (isset($_POST['cancellation_reason'])) {
if ($order_id) {
$date = getdate();
$data['cancellation_reason_id'] = $_POST['cancellation_reason'];
$data['cancellation_info'] = $_POST['cancellation_text'];
$data['cancellation_date'] = $date['year'] . '-' . $date['mon'] . '-' . $date['mday'];
$data['cancellation_status'] = 1;
}
} else {
$data = false;
}
if ($order_id) {
if ($data) {
OrderHelper::request_cancellation($order_id, $data);
}
}
header('location: ' . $_SERVER['HTTP_REFERER']);
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
/**
* @version $Id: website_password_forgotten.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_password_forgotten {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$state = 0;
if (isset($_POST['email']) && $_POST['email']) {
$state = $this->base_object->customer->lost_password($_POST['email']);
}
$this->layout_object->assign('state', $state);
return $this->layout_object->_fetch('content_lost_password.tpl');
}
}
+64
View File
@@ -0,0 +1,64 @@
<?php
/**
* @version $Id: website_contact.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
class website_recommendation {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
if ($_POST['recommendation']) {
$data = $_POST['recommendation'];
$email = $this->checkmail($data['r_email']);
$mailer = new mail_tools($this->base_object);
$message = 'Hallo '.$data['r_name'].'<br>';
$message .= 'es wurde Ihnen die Webseite '.$_SERVER['SERVER_NAME'].' empfohlen mit folgender Nachricht:<br>'.$data['message'];
$subject = 'Es wurde Ihnen eine Website empfohlen!';
$sent = $mailer->send_mail($subject, $message, $email, 'intern');
return $this->layout_object->_fetch('content_recommendation.tpl');
}
}
public function checkmail($email, $checkMX = true) {
$mail_addr = explode(';', $email);
$ready_mail = $mail_addr[0];
$mail_parts = explode('@', $ready_mail);
$domain = $mail_parts[1];
if (!$domain) {
return false;
}
if ($checkMX && function_exists('checkdnsrr')) {
if (checkdnsrr($domain, "MX")) {
if (function_exists('getmxrr')) {
if (!getmxrr($domain, $mxhosts)) {
return false;
}
}
} else {
return false;
}
}
return $ready_mail;
}
}
+91
View File
@@ -0,0 +1,91 @@
<?php
/**
* @version $Id: website_search.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/search.class.php';
class website_search {
public $base_object;
public $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$search = $_GET['search'];
if (isset($_GET['type']) && $_GET['type'] == 'shoppingcart') {
/**
* Theory ...
*/
// $searchAr = array('search_item' => $search);
// include_once './core/item.class.php';
// $Item = new Item($this->base_object);
// $item_list = $Item->search_items($searchAr);
//
// $this->layout_object->assign('search_item', $searchAr['search_item']);
// $this->layout_object->assign('shopArticles', $item_list);
// $this->layout_object->assign('itemsPerPage', $_SESSION['itemsPerPage']);
//
// $this->layout_object->assign('hide_pagination', true);
// $this->layout_object->assign('hide_listoptions', true);
//
// $block = new stdClass();
// $block->content = 'list';
// $block->style = 'h2';
// $this->layout_object->assign('block', $block);
//
// return $this->layout_object->_fetch('content_box_item_list.tpl');
$items = Search::items($search, 1);
$this->layout_object->assign('item_hits', $items['hits']);
$this->layout_object->assign('item_search', $items['results']);
return $this->layout_object->_fetch('shoppingcart_search.tpl');
} else {
// Include individual search
if (isset($this->base_object->config->shopConfiguration['custom_global_modules']) && $this->base_object->config->shopConfiguration['custom_global_modules']) {
include_once ROOT_DIR . 'web/' . SHOP_SYSTEM . '/php/website_live_search.inc.php';
if (isset($return)) {
return $return;
}
}
// Default search
if (isset($_GET['item_category']) && $_GET['item_category'] > 0) {
$items = Search::category_items($search, $_GET['item_category'], 1);
} else {
$items = Search::items($search, 1);
}
$item_result = array();
$c = 0;
foreach ($items['results'] as $item) {
$c++;
if (($c % 2) == 0) {
$item->cl = 1;
}
$item_result[] = $item;
}
$this->layout_object->assign('item_hits', $items['hits']);
$this->layout_object->assign('item_search', $item_result);
$manufacturers = Search::manufacturers($search);
$this->layout_object->assign('manufacturer_hits', $manufacturers['hits']);
$this->layout_object->assign('manufacturer_search', $manufacturers['results']);
return $this->layout_object->_fetch('live_search.tpl');
}
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
/**
* @version $Id: website_search.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/search.class.php';
include_once './core/itemsearch.class.php';
class website_search {
public $base_object;
public $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$search = $_GET['search'];
if (isset($_GET['type']) && $_GET['type'] == 'shoppingcart') {
$items = Search::items($search, 1);
$this->layout_object->assign('item_hits', $items['hits']);
$this->layout_object->assign('item_search', $items['results']);
return $this->layout_object->_fetch('shoppingcart_search.tpl');
} else {
if (isset($_GET['item_category']) && $_GET['item_category'] > 0) {
$items = Search::category_items($search, $_GET['item_category'], 1);
$item_result = array();
$c = 0;
foreach ($items['results'] as $item) {
$c++;
if (($c % 2) == 0) {
$item->cl = 1;
}
$item_result[] = $item;
}
$this->layout_object->assign('item_hits', $items['hits']);
$this->layout_object->assign('item_search', $item_result);
$manufacturers = Search::manufacturers($search);
$this->layout_object->assign('manufacturer_hits', $manufacturers['hits']);
$this->layout_object->assign('manufacturer_search', $manufacturers['results']);
return $this->layout_object->_fetch('live_search.tpl');
} else {
$ItemsClass = new ItemSearch($this->base_object);
$result = $ItemsClass->searchItems($search);
$this->layout_object->assign('item_search', $result);
return $this->layout_object->_fetch('live_search_new.tpl');
}
}
}
}
+31
View File
@@ -0,0 +1,31 @@
<?php
/**
* @version $Id: website_shippingtable.php
* @package Easyshop
* @copyright Copyright (C) 2005 - 2011 TA-EDV
* @license proprietary
* @author Richard Kammermayer <rk@ta-edv.de>
* Easyshop is a web shop system
*/
include_once './core/countryhelper.class.php';
class website_shippingtable {
private $base_object;
private $layout_object;
public function __construct($base_object, $layout_object) {
$this->base_object = $base_object;
$this->layout_object = $layout_object;
}
function run() {
$data = CountryHelper::get_delivery_and_shipping_info_for_all_countries();
$this->layout_object->assign('countries', $data);
return $this->layout_object->_fetch('content_shipping_info.tpl');
}
}

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