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

}

?>