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
@@ -0,0 +1,93 @@
<?php
// get for intelectra geraetezuordnung
/*if ($obj->attribute_17 != '') {
$sql = "SELECT * FROM import_geraetezuordnung WHERE anr='" . $obj->attribute_17 . "'";
$result = $this->db->query($sql);
}
else {
$sql = "SELECT * FROM import_geraetezuordnung WHERE anr='" . $obj->number . "'";
$result = $this->db->query($sql);
}*/
if ($obj->krempl_id) {
$sql = "SELECT * FROM krempl_artikelgeraet_22 ka
left join krempl_geraete_22 kg on kg.id=ka.geraet
WHERE ka.ersatzteil=" . $this->db->real_escape_string($obj->krempl_id) . " AND not isnull(nr)";
$result = $this->db->query($sql);
}
$obj->geraetezuordnung = array();
if ($result) {
while ($obj1 = $result->fetch_object()) {
$obj->geraetezuordnung[] = $obj1;
}
}
// get parent warengruppe
$sql = "select i.name, s.name, s2.name as wg from items i
left join item_structure_assign isa on isa.item_id=i.id
left join structure s on s.id=isa.structure_id
left join structure s2 on s2.id=s.parent_id
where i.id=" . $obj->id .' AND s.active=1 LIMIT 1';
$result = $this->db->query($sql);
$parent_warengruppe = '';
if ($result) {
while ($obj1 = $result->fetch_object()) {
$parent_warengruppe = $obj1->wg;
}
}
$table_data = array();
foreach ($obj->geraetezuordnung as $geraet) {
$nr1 = str_replace('#', '', $geraet->nr);
$nr1 = str_replace('_', ' ', $nr1);
$nr2 = str_replace('#', '', $geraet->produktionsstart);
$nr2 = str_replace('_', ' ', $nr2);
$nr3 = str_replace('#', '', $geraet->produktionsende);
$nr3 = str_replace('_', ' ', $nr3);
$nr3 = empty($nr3) ? "" : " - " . $nr3;
$nr2 = $nr2.$nr3;
$bezeichnungoriginal = str_replace('#', '', $geraet->bezeichnungoriginal);
$bezeichnungoriginal = str_replace('_', ' ', $bezeichnungoriginal);
$einkaufsmoeglichkeitencached = $geraet->einkaufsmoeglichkeitencached . ' ' . $geraet->zusatz;
$table_data[$einkaufsmoeglichkeitencached][$bezeichnungoriginal][] = array($nr1, $nr2);
}
$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] . '</td></tr>';
} else {
$html .= '<tr class="' . $color . '"><td>&nbsp;</td><td>' . $nummer[0] . '</td><td>' . $nummer[1] . '</td></tr>';
}
$z++;
}
$y++;
}
}
$html .= '</table>';
$obj->geraetezuordnung = $html;
// base price calc
if ($obj->attribute_11 && $obj->attribute_15) {
$obj->sample_unit = $obj->attribute_15;
if (strstr($obj->sample_unit, '100')) {
$obj->sample_price = $obj->shop_price_1 / ($obj->attribute_11 * 10);
} else {
$obj->sample_price = $obj->shop_price_1 / $obj->attribute_11;
}
}
@@ -0,0 +1,64 @@
if ($obj->krempl_id) {
$sql = "SELECT * FROM krempl_artikelgeraet ka
left join krempl_geraete kg on kg.id=ka.geraet
WHERE ersatzteil=" . $this->db->real_escape_string($obj->krempl_id);
$result = $this->db->query($sql);
}
$obj->geraetezuordnung = array();
if ($result) {
while ($obj1 = $result->fetch_object()) {
$obj->geraetezuordnung[] = $obj1;
}
}
// get parent warengruppe
$sql = "select i.name, s.name, s2.name as wg from items i
left join item_structure_assign isa on isa.item_id=i.id
left join structure s on s.id=isa.structure_id
left join structure s2 on s2.id=s.parent_id
where i.id=" . $obj->id .' AND s.active=1 LIMIT 1';
$result = $this->db->query($sql);
$parent_warengruppe = '';
if ($result) {
while ($obj1 = $result->fetch_object()) {
$parent_warengruppe = $obj1->wg;
}
}
$table_data = array();
foreach ($obj->geraetezuordnung as $geraet) {
$nr1 = str_replace('#', '', $geraet->nr);
$nr1 = str_replace('_', ' ', $nr1);
$nr2 = str_replace('#', '', $geraet->nr2);
$nr2 = str_replace('_', ' ', $nr2);
$bezeichnungoriginal = str_replace('#', '', $geraet->bezeichnungoriginal);
$bezeichnungoriginal = str_replace('_', ' ', $bezeichnungoriginal);
$einkaufsmoeglichkeitencached = $geraet->einkaufsmoeglichkeitencached . ' ' . $geraet->zusatz;
$table_data[$einkaufsmoeglichkeitencached][$bezeichnungoriginal][] = array($nr1, $nr2);
}
$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] . '</td></tr>';
} else {
$html .= '<tr class="' . $color . '"><td>&nbsp;</td><td>' . $nummer[0] . '</td><td>' . $nummer[1] . '</td></tr>';
}
$z++;
}
$y++;
}
}
$html .= '</table>';
$obj->geraetezuordnung = $html;
@@ -0,0 +1,322 @@
<?php
class ItemSearch {
private $config;
protected $base_object;
protected $db;
private $searchData = array();
public function __construct($base_object) {
$this->config = $base_object->config;
$this->db = $base_object->db;
$this->base_object = $base_object;
}
public function searchItems($searchString) {
$timer_start = microtime(true);
// $searchString_trimmed = trim($searchString);
// $searchString_filtered = preg_replace("@[^\p{L}\p{N}]@sui", '', $searchString_trimmed);
$results = false;
if (ctype_digit($searchString)) {
$results = $this->_getItemByNumber($searchString);
}
if (!$results) {
$results = $this->_searchItemWithinItemsAndAssociations('', $searchString);
}
if (!$results) {
$results = $this->_getItembyKremplNumber($searchString);
}
if (!$results) {
$results = Array();
}
$running_time = microtime(true) - $timer_start;
$result = array(
'searchstring' => $searchString,
'results' => count($results),
'queryTime' => $running_time,
'data' => $results
);
$this->searchData = array(
'string1' => $searchManufacturer,
'string2' => $searchString,
'used1' => $searchManufacturer_ready,
'used2' => $searchString_ready,
'results' => count($results)
);
return $result;
}
private function _searchItemWithinItemsAndAssociations($searchManufacturer, $searchString, $idsOnly = false, $searchManufacturer_filtered = false, $searchString_filtered = false, $searchRefinement_filtered = false) {
$queries = $this->_queryLike($searchManufacturer_filtered, $searchString);
$results = array();
$idArray = array();
foreach ($queries as $query) {
$rs = $this->db->query($query);
while ($I = $rs->fetch_object()) {
if ($I->anumber) {
$results[$I->anumber] = $I->anumber;
$idArray[] = $I->anumber;
}
}
}
//$idArray = $this->_getIdsByNumbers($results, true, $searchRefinement_filtered);
return $idArray;
}
private function _getIdsByNumbers($numbers, $withAlternatives = true, $refinement = false) {
if (is_array($numbers) && count($numbers) > 0) {
$numberList = implode("','", $numbers);
$queryAddAlternatives = '';
if ($withAlternatives) {
$queryAddAlternatives = "
OR
attribute_17 IN ('" . $numberList . "')
";
}
$queryAddRefinement = '';
if ($refinement) {
$refinement = $this->db->real_escape_string($refinement);
$queryAddRefinement = "
AND (
name LIKE '%" . $refinement . "%'
OR
detail_description LIKE '%" . $refinement . "%'
OR
detail_description LIKE '%" . htmlentities($refinement, null, 'UTF-8') . "%'
OR
attribute_1 LIKE '%" . $refinement . "%'
OR
attribute_9 LIKE '%" . $refinement . "%'
OR
attribute_20 LIKE '%" . $refinement . "%'
OR
attribute_6 LIKE '%" . $refinement . "%'
)
";
$queryAddRefinement = "
AND (
name LIKE '%" . $refinement . "%'
OR
attribute_1 LIKE '%" . $refinement . "%'
OR
attribute_9 LIKE '%" . $refinement . "%'
OR
attribute_20 LIKE '%" . $refinement . "%'
OR
attribute_6 LIKE '%" . $refinement . "%'
)
";
}
// $query = "
// SELECT
// id
// FROM
// items
// WHERE (
// number IN ('" . $numberList . "') OR
// attribute_7 IN ('" . $numberList . "')
// " . $queryAddAlternatives . "
// )
// " . $queryAddRefinement . "
// ";
$query = "
SELECT
id
FROM
items
WHERE
attribute_7 IN ('" . $numberList . "')
";
$rs = $this->db->query($query);
// echo '<pre>';echo $query;exit();
$idArray = array();
while ($I = $rs->fetch_object()) {
$idArray[$I->id] = $I->id;
}
return $idArray;
}
return array();
}
private function _queryLike($searchManufacturer_filtered, $searchString_filtered) {
$searchManufacturer_filtered = $this->db->real_escape_string($searchManufacturer_filtered);
$searchString_filtered = $this->db->real_escape_string($searchString_filtered);
$queries = array();
if (ctype_alpha($searchString_filtered)) {
$queries[] = "
SELECT
id AS anumber
FROM
items
WHERE
active = 1
AND
parent_id = 0
AND (
REPLACE(REPLACE(REPLACE(vendor_item_number, ' ', ''), '/', ''), '-', '') = '" . $searchString_filtered . "'
OR
REPLACE(REPLACE(REPLACE(name, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- mögliche Aufschrift
REPLACE(REPLACE(REPLACE(attribute_4, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Aufdrucke
REPLACE(REPLACE(REPLACE(attribute_9, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Merkmale
REPLACE(REPLACE(REPLACE(attribute_8, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Internes DB-Feld
REPLACE(REPLACE(REPLACE(attribute_20, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Synonyme
REPLACE(REPLACE(REPLACE(attribute_6, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
)
GROUP BY
number
LIMIT 150
";
}
else {
if (!ctype_digit($searchString_filtered) || (ctype_digit($searchString_filtered) && strlen($searchString_filtered) >= 7)) {
$queries[] = "
SELECT
DISTINCT i.id AS anumber
FROM
krempl_geraete kg
LEFT JOIN krempl_artikelgeraet ka on ka.geraet=kg.id
LEFT JOIN items i on i.krempl_id=ka.ersatzteil
WHERE
REPLACE(REPLACE(REPLACE(kg.nr, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
REPLACE(REPLACE(REPLACE(kg.bezeichnung1, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
LIMIT 150
";
}
$queries[] = "
SELECT
DISTINCT i.id AS anumber
FROM
passendwie_2018 pw
LEFT JOIN
items i on i.attribute_7=pw.navisionid
WHERE
REPLACE(REPLACE(REPLACE(bestellcode, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
LIMIT 150
";
$queries[] = "
SELECT
id AS anumber
FROM
items
WHERE
active = 1
AND
REPLACE(REPLACE(REPLACE(attribute_20, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
GROUP BY
number
LIMIT 50
";
}
return $queries;
}
private function _getItemByNumber($searchString_ready) {
$query = "
SELECT
id
FROM
items
WHERE
number = '" . $this->db->real_escape_string($searchString_ready) . "' OR
ean_code = '" . $this->db->real_escape_string($searchString_ready) . "' OR
name LIKE '%" . $this->db->real_escape_string($searchString_ready) . "%' OR
attribute_20 like '%" . $this->db->real_escape_string($searchString_ready) . "%' OR
attribute_7 = '" . $this->db->real_escape_string($searchString_ready) . "'
LIMIT 150
";
$rs = $this->db->query($query);
$idArray = array();
if ($rs->num_rows > 0) {
while ($I = $rs->fetch_object()) {
$idArray[$I->id] = $I->id;
}
return $idArray;
} else {
return false;
}
}
private function _getItembyKremplNumber($searchString_ready) {
$query = "
SELECT i.id FROM krempl_artikelgeraet_22 ka
LEFT JOIN krempl_geraete_22 kg ON kg.id = ka.geraet
LEFT JOIN krempl_id2022 ki ON ersatzteil = ki.id
LEFT JOIN items i ON ki.navisionid = i.attribute_7
WHERE not isnull(nr) AND nr LIKE '%".$this->db->real_escape_string($searchString_ready)."%' LIMIT 150;
";
$rs = $this->db->query($query);
$idArray = array();
if ($rs->num_rows > 0) {
while ($I = $rs->fetch_object()) {
if (isset($I->id))
$idArray[$I->id] = $I->id;
}
return $idArray;
} else {
return false;
}
}
public function makeHistory() {
$indexString = $this->searchData['used1'] . $this->searchData['used2'];
$query = "
INSERT INTO
search_history (id, string1, string2, used1, used2, results)
VALUES (
'" . $this->db->real_escape_string($indexString) . "',
'" . $this->db->real_escape_string($this->searchData['string1']) . "',
'" . $this->db->real_escape_string($this->searchData['string2']) . "',
'" . $this->db->real_escape_string($this->searchData['used1']) . "',
'" . $this->db->real_escape_string($this->searchData['used2']) . "',
'" . $this->db->real_escape_string($this->searchData['results']) . "'
)
ON DUPLICATE KEY
UPDATE
cnt = cnt + 1,
results = VALUES(results)
";
$this->db->query($query);
}
}
@@ -0,0 +1,297 @@
<?php
class ItemSearch {
private $config;
protected $base_object;
protected $db;
private $searchData = array();
public function __construct($base_object) {
$this->config = $base_object->config;
$this->db = $base_object->db;
$this->base_object = $base_object;
}
public function searchItems($searchString) {
$timer_start = microtime(true);
// $searchString_trimmed = trim($searchString);
// $searchString_filtered = preg_replace("@[^\p{L}\p{N}]@sui", '', $searchString_trimmed);
$results = false;
if (ctype_digit($searchString)) {
$results = $this->_getItemByNumber($searchString);
}
if (!$results) {
$results = $this->_searchItemWithinItemsAndAssociations('', $searchString);
}
$running_time = microtime(true) - $timer_start;
$result = array(
'searchstring' => $searchString,
'results' => count($results),
'queryTime' => $running_time,
'data' => $results
);
$this->searchData = array(
'string1' => $searchManufacturer,
'string2' => $searchString,
'used1' => $searchManufacturer_ready,
'used2' => $searchString_ready,
'results' => count($results)
);
return $result;
}
private function _searchItemWithinItemsAndAssociations($searchManufacturer, $searchString, $idsOnly = false, $searchManufacturer_filtered = false, $searchString_filtered = false, $searchRefinement_filtered = false) {
$queries = $this->_queryLike($searchManufacturer_filtered, $searchString);
$results = array();
$idArray = array();
foreach ($queries as $query) {
$rs = $this->db->query($query);
while ($I = $rs->fetch_object()) {
if ($I->anumber) {
$results[$I->anumber] = $I->anumber;
$idArray[] = $I->anumber;
}
}
}
//$idArray = $this->_getIdsByNumbers($results, true, $searchRefinement_filtered);
return $idArray;
}
private function _getIdsByNumbers($numbers, $withAlternatives = true, $refinement = false) {
if (is_array($numbers) && count($numbers) > 0) {
$numberList = implode("','", $numbers);
$queryAddAlternatives = '';
if ($withAlternatives) {
$queryAddAlternatives = "
OR
attribute_17 IN ('" . $numberList . "')
";
}
$queryAddRefinement = '';
if ($refinement) {
$refinement = $this->db->real_escape_string($refinement);
$queryAddRefinement = "
AND (
name LIKE '%" . $refinement . "%'
OR
detail_description LIKE '%" . $refinement . "%'
OR
detail_description LIKE '%" . htmlentities($refinement, null, 'UTF-8') . "%'
OR
attribute_1 LIKE '%" . $refinement . "%'
OR
attribute_9 LIKE '%" . $refinement . "%'
OR
attribute_20 LIKE '%" . $refinement . "%'
OR
attribute_6 LIKE '%" . $refinement . "%'
)
";
$queryAddRefinement = "
AND (
name LIKE '%" . $refinement . "%'
OR
attribute_1 LIKE '%" . $refinement . "%'
OR
attribute_9 LIKE '%" . $refinement . "%'
OR
attribute_20 LIKE '%" . $refinement . "%'
OR
attribute_6 LIKE '%" . $refinement . "%'
)
";
}
// $query = "
// SELECT
// id
// FROM
// items
// WHERE (
// number IN ('" . $numberList . "') OR
// attribute_7 IN ('" . $numberList . "')
// " . $queryAddAlternatives . "
// )
// " . $queryAddRefinement . "
// ";
$query = "
SELECT
id
FROM
items
WHERE
attribute_7 IN ('" . $numberList . "')
";
$rs = $this->db->query($query);
// echo '<pre>';echo $query;exit();
$idArray = array();
while ($I = $rs->fetch_object()) {
$idArray[$I->id] = $I->id;
}
return $idArray;
}
return array();
}
private function _queryLike($searchManufacturer_filtered, $searchString_filtered) {
$searchManufacturer_filtered = $this->db->real_escape_string($searchManufacturer_filtered);
$searchString_filtered = $this->db->real_escape_string($searchString_filtered);
$queries = array();
if (ctype_alpha($searchString_filtered)) {
$queries[] = "
SELECT
id AS anumber
FROM
items
WHERE
active = 1
AND
parent_id = 0
AND (
REPLACE(REPLACE(REPLACE(vendor_item_number, ' ', ''), '/', ''), '-', '') = '" . $searchString_filtered . "'
OR
REPLACE(REPLACE(REPLACE(name, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- mögliche Aufschrift
REPLACE(REPLACE(REPLACE(attribute_4, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Aufdrucke
REPLACE(REPLACE(REPLACE(attribute_9, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Merkmale
REPLACE(REPLACE(REPLACE(attribute_8, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Internes DB-Feld
REPLACE(REPLACE(REPLACE(attribute_20, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
-- Synonyme
REPLACE(REPLACE(REPLACE(attribute_6, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
)
GROUP BY
number
LIMIT 100
";
}
else {
// $queries[] = "
// SELECT
// DISTINCT anr AS anumber
// FROM
// import_geraetezuordnung
// WHERE
// REPLACE(REPLACE(REPLACE(nr, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
// OR
// REPLACE(REPLACE(REPLACE(bezeichnung1, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
// ";
$queries[] = "
SELECT
DISTINCT i.id AS anumber
FROM
import_geraetezuordnung kg
LEFT JOIN items i on i.attribute_7=kg.navisionid
WHERE
REPLACE(REPLACE(REPLACE(kg.nr, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
REPLACE(REPLACE(REPLACE(kg.bezeichnung1, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
LIMIT 100
";
/*$queries[] = "
SELECT
DISTINCT i.id AS anumber
FROM
krempl_geraete kg
LEFT JOIN krempl_artikelgeraet ka on ka.geraet=kg.id
LEFT JOIN items i on i.krempl_id=ka.ersatzteil
WHERE
REPLACE(REPLACE(REPLACE(kg.nr, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
OR
REPLACE(REPLACE(REPLACE(kg.bezeichnung1, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
";*/
$queries[] = "
SELECT
DISTINCT i.id AS anumber
FROM
passendwie_2018 pw
LEFT JOIN items i on i.attribute_7=pw.navisionid
WHERE
REPLACE(REPLACE(REPLACE(bestellcode, ' ', ''), '/', ''), '-', '') LIKE '%" . $searchString_filtered . "%'
LIMIT 100
";
}
return $queries;
}
private function _getItemByNumber($searchString_ready) {
$query = "
SELECT
id
FROM
items
WHERE
number = '" . $this->db->real_escape_string($searchString_ready) . "' OR
ean_code = '" . $this->db->real_escape_string($searchString_ready) . "' OR
attribute_7 = '" . $this->db->real_escape_string($searchString_ready) . "'
LIMIT 100
";
$rs = $this->db->query($query);
$idArray = array();
if ($rs->num_rows > 0) {
while ($I = $rs->fetch_object()) {
$idArray[$I->id] = $I->id;
}
return $idArray;
}
else {
return false;
}
}
public function makeHistory() {
$indexString = $this->searchData['used1'] . $this->searchData['used2'];
$query = "
INSERT INTO
search_history (id, string1, string2, used1, used2, results)
VALUES (
'" . $this->db->real_escape_string($indexString) . "',
'" . $this->db->real_escape_string($this->searchData['string1']) . "',
'" . $this->db->real_escape_string($this->searchData['string2']) . "',
'" . $this->db->real_escape_string($this->searchData['used1']) . "',
'" . $this->db->real_escape_string($this->searchData['used2']) . "',
'" . $this->db->real_escape_string($this->searchData['results']) . "'
)
ON DUPLICATE KEY
UPDATE
cnt = cnt + 1,
results = VALUES(results)
";
$this->db->query($query);
}
}
@@ -0,0 +1,106 @@
<?php
$matchingItemNumberFirst = true;
include_once 'itemsearch.class.php';
$searchString = $search['search_item'];
$ItemsClass = new ItemSearch($this->base_object);
$strings = explode(' ', $searchString);
if (count($strings) == 1) {
$searchString = trim($searchString);
}
else {
$searchString = '';
$string_type = 0;
$strings = array_reverse($strings);
foreach ($strings as $str) {
$str = trim($str);
// ganzzahl
if (ctype_digit($str)) {
$searchString = $str;
$string_type = 2;
}
elseif (!ctype_alpha($str) && $string_type != 2) {
$searchString = $str;
$string_type = 1;
}
elseif ($string_type == 0) {
$searchString = $str;
}
}
}
$result = $ItemsClass->searchItems($searchString);
$ItemsClass->makeHistory();
if (!isset($this->db)) {
$this->db = $this->base_object->db;
}
if ($result['data'] && count($result['data']) > 0) {
if (isset($search['item_category']) && $search['item_category'] > 0) {
$sql = "
SELECT
i.*,
i.default_image_file_name AS file_name,
ip.price_1, ip.bargain_price_1
FROM
item_prices ip
RIGHT JOIN
items i
ON
i.id = ip.item_id
AND
ip.customergroup_id = " . $this->db->real_escape_string($this->base_object->customer_group->price_group_id) . "
RIGHT JOIN
item_structure_assign isa
ON
i.id = isa.item_id
WHERE
i.active = 1
AND
i.id IN (
" . implode(',', $result['data']) . "
)
AND
i.parent_id = 0
AND
isa.structure_id = " . $this->db->real_escape_string($search['item_category']) . "
GROUP BY
i.id
ORDER BY
i.name DESC
";
} else {
$sql = "
SELECT
i.*,
i.default_image_file_name AS file_name,
ip.price_1, ip.bargain_price_1
FROM
item_prices ip
RIGHT JOIN
items i
ON
i.id = ip.item_id
AND
ip.customergroup_id = " . $this->db->real_escape_string($this->base_object->customer_group->price_group_id) . "
WHERE
i.active = 1
AND
i.id IN (
" . implode(',', $result['data']) . "
)
AND
parent_id = 0
GROUP BY
i.id
ORDER BY
i.name DESC
";
}
}
@@ -0,0 +1,32 @@
<?php
if (!is_array($item_ids) || count($item_ids) <= 0) {
include_once 'itemsearch.class.php';
$ItemsClass = new ItemSearch($this->base_object);
//$result = $ItemsClass->searchItems($search['search_item'], true);
$item_ids = $result['data'];
}
if (is_array($item_ids) && count($item_ids) > 0) {
$sql = "
SELECT
wg.id,
count(wg.id) AS found_items
FROM
structure wg
LEFT JOIN
item_structure_assign isa
ON
wg.id = isa.structure_id
WHERE
isa.item_id IN (
" . implode(',', $item_ids) . "
)
AND
wg.active=1
GROUP BY
wg.id
";
}
@@ -0,0 +1,9 @@
<?php
include_once 'itemsearch.class.php';
$ItemsClass = new ItemSearch($this->base_object);
$result = $ItemsClass->searchItems($search);
$this->layout_object->assign('item_search', $result);
$return = $this->layout_object->_fetch('live_search.tpl');