Ejemplo n.º 1
0
	public function on_success($data)
	{
		$order_id = $this->EasyForms->field("id", INPUT_GET);
		$order_id = intval($order_id);
		if (empty($order_id))
			Component::redirect ("Корзина");

		$order = $this->Orders->get($order_id);
		if ($order_id === false)
			Component::redirect ("Корзина");

		if ($order['opened'] == 1)
			Component::redirect ("Корзина");

		$this->Orders->edit_order($order_id, array('opened' => 1));
		$order['id'] = $this->format_order_number($order_id);
		$this->Templates->bind_params($order);
	}
Ejemplo n.º 2
0
	public function on_logout($data)
	{
		$this->Accounts->logout();
		Component::redirect("/");
	}
Ejemplo n.º 3
0
	/**
	 * Перенаправляет пользователя на другой обработчик в данном модуле
	 * @param $action String: Обработчик в модуле
	 * @param $params Array: Массив дополнительных параметров для GET запроса
	 */
	protected function go_action($action, $params = array())
	{
		$module = ManagerAdmin::get_module();

		$request = array('module' => $module, 'action' => $action);
		$request = array_merge($request, $params);

		Component::redirect($_SERVER['SCRIPT_NAME'], $request);
		exit;
	}
Ejemplo n.º 4
0
	public function on_add()
	{	
		$this->Templates->set_page("Добавление заказа");
		$this->bind_list_params();

		if (!$this->EasyForms->field("send", INPUT_POST))
			return;

		$fields = array('name'		=> array('require' => false),
				'lastname'	=> array('require' => false),
				'patronymic'	=> array('require' => false),
				'legal'		=> array(),
				'delivery'	=> array('caption' => "Способ доставки"),
				'status'	=> array(),
				'pay'		=> array('caption' => "Способ оплаты"),
				'address'	=> array('require' => false),
				'phone'		=> array('require' => false),
				'products'	=> array()
			);
		$fields = $this->EasyForms->fields($fields);

		if ($fields === false)
			return;

		$list_products = explode("&", $fields['products']);
		$products = array();
		$price = 0;
		$initial_price = 0;
		while (list(, $product) = each($list_products))
		{
			$data = explode("|", $product);
			if (count($data) < 2)
				continue;

			$product = $this->Products->get_by_code($data[0]);
			if ($product === false)
				continue;

			$product['count'] = $data[1];
			if (count($data) == 3)
				$product['size'] = $data[2];

			$products[] = $product;
			$price += $product['price'] * $data[1];
			$initial_price += $product['initial_price'] * $data[1];
		}
		$fields['products'] = $products;
		$fields['price'] = $price;
		$fields['initial_price'] = $initial_price;
		$this->Orders->add($fields, false);

		Component::redirect($_SERVER['SCRIPT_NAME'], array('module' => "orders", 'action' => "index"));
	}
Ejemplo n.º 5
0
	public function on_item($data)
	{
		$names = explode(" ", $data['postfix']);
		if (count($names) < 2)
			Component::redirect("");

		$code = $names[count($names) - 1];
		$product = $this->Products->get_by_code($code);
		if ($product === false)
			Component::redirect("");

		$this->Templates->set_page("Шаблоны/Изделие");

		$product['image_big'] = $this->Products->get_image_big($product['id']);

		if (!empty($product['metal_id']))
		{
			$metal = $this->Dictionaries->Metals->get_by_id($product['metal_id']);
			$product['metal'] = $metal['name'];
		}

		if (!empty($product['probe_id']))
		{
			$probe = $this->Dictionaries->Probes->get_by_id($product['probe_id']);
			$product['probe'] = $probe['name'];
		}

		$stone_item = $this->Templates->stone_item;
		if ($stone_item === false)
			$this->Log->error("Can't find 'stone_item' param");
		$stones = "";
		$stones_fields = array("stone_id", "stone2_id", "stone3_id");
		foreach($stones_fields as $field)
		{
			if (empty($product['stone_id']))
				continue;

			$stone = $this->Dictionaries->Stones->get_by_id($product[$field]);
			if ($stone === false)
				continue;

			$stone_item->bind_params($stone);
			$stones .= (string) $stone_item;
		}

		$this->Templates->stones = $stones;

		$complect_item = $this->Templates->complect_item;
		if ($complect_item === false)
			$this->Log->error("Can't find 'complect_item' param");
		$product['complects'] = $this->get_products($product['complects'], $complect_item);

		$link_item = $this->Templates->link_item;
		if ($link_item === false)
			$this->Log->error("Can't find 'link_item' param");
		$product['links'] = $this->get_products($product['links'], $link_item);

		if (!empty($product['collection']))
		{
			$collection = $this->Dictionaries->Collections->get_by_id($product['collection']);
			if ($collection !== false)
				$this->Templates->bind_params($collection, "Collection::");
		}

		$this->Templates->bind_params($product);
		
		if (!$this->Products->bind_path_params($this->Templates, $product))
			Component::redirect ("/");

		$this->Basket->bind_product($this->Templates, $product['id']);

		$caregory_parent = $this->Categories->get($product['parent_id']);
		$this->Templates->{$caregory_parent->name} = true;
	}
Ejemplo n.º 6
0
	private function block()
	{
		if (!$this->Templates->exist("/Ошибки/404"))
			Component::redirect("");

		header("Not Found", true, 404);

		if (empty($_SERVER['REDIRECT_URL']))
			$redirect_url = "/";
		else
			$redirect_url = $_SERVER['REDIRECT_URL'];

		$template = $this->Templates->get("/Ошибки/404");
		$template->REDIRECT_URL = htmlspecialchars($redirect_url, ENT_QUOTES);

		echo (string) $template;
		exit;
	}
Ejemplo n.º 7
0
	public function on_open()
	{
		$id = $this->EasyForms->field("id", INPUT_GET);
		if (empty($id))
			Component::redirect($_SERVER['SCRIPT_NAME'], array('module' => "questions", 'action' => "index"));

		$question = $this->Questions->get($id);
		if ($question === false)
			Component::redirect($_SERVER['SCRIPT_NAME'], array('module' => "questions", 'action' => "index"));

		$this->Templates->set_page("Вопрос");

		$this->Templates->bind_params($question);
	}
Ejemplo n.º 8
0
	/**
	 * Отображение содержания корзины
	*/
	public function on_get($data)
	{
		$account = false;
		if ($this->Accounts->is_authed())
			$account = $this->Accounts->get();


		if (!$this->EasyForms->field("send"))
		{
			$this->set_items();

			if ($account === false)
				return;

			$name = $account['name'];
			if (!empty($account['lastname']))
				$name .= " ".$account['lastname'];
			if (!empty($account['patronymic']))
				$name .= " ".$account['patronymic'];

			$account['name'] = $name;
			$this->Templates->bind_params($account, "field_");

			return;
		}

		$params = $data['params'];
		$this->check_params($params, array("email"));
		if (empty($params['email']))
			$this->Log->error("not exist param email");

		$fields = array('name'		=> array(),
				'phone'		=> array(),
				'email'		=> array(),
				'address'	=> array(),
				'comment'	=> array()
		    );
		$fields = $this->EasyForms->fields($fields, array('require' => false));

		$basket = $this->Basket->summary();
		$this->Templates->price = $basket['price'];
		$this->Templates->bind_params($fields, "field_");

		$fields['phone'] = trim($fields['phone']);
		$fields['email'] = trim($fields['email']);
		if (empty($fields['phone']) && empty($fields['email']))
		{
			$this->Errors->add("simple", array('phone' => "Необходимо указать телефон или email"));
			$this->set_items();
			return;
		}

		if ($basket['price'] < 1000)
		{
			$this->Errors->add(array('price'), "Минимальная сумма заказа 1000 рублей");
			$this->set_items();
			return;
		}

		$template = $this->Templates->get("/Страницы/Шаблоны/Письма/Заказ/Обычный");
		$product_item = $template->product_item;
		if ($product_item === false)
			$this->Log->error("Can't find 'product_item' param");

		$basket = $this->Basket->summary();
		$products = $basket['products'];
		$fields['price'] = $basket['price'];
		reset($products);
		$products_list = "";
		while (list(, $product) = each($products))
		{
			$product['image_small'] = $this->Products->get_image_small($product['id']);
			$product_item->bind_params($product);
			$products_list .= (string) $product_item;
		}

		$fields['account_id'] = $account['id'];
		$order_id = $this->Orders->add_order($fields);

		$this->Orders->add_order_items($order_id, $products);

		$fields['orders'] = $products_list;
		$fields['id'] = $order_id;

		if (!empty($fields['email']))
			$this->Mail->send($fields['email'], "Шаблоны/Письма/Заказ/Обычный", $fields);
		else if (!$this->Accounts->is_authed() && isset($_SESSION['email']))
			$this->Mail->send($_SESSION['email'], "Шаблоны/Письма/Заказ/Обычный", $fields);

		$this->Mail->send(MAIL_SUPPORT, "Шаблоны/Письма/Заказ/Обычный_техническое", $fields);

		$this->Basket->clear();

		$this->Templates->account = $this->Accounts->is_authed();

		Component::redirect("Заказ", array('id' => $order_id));
	}
Ejemplo n.º 9
0
	/**
	 * Добавлени новости
	 */
	public function on_add()
	{
		$fields = array('name'			=> array('require' => false),
				'category'		=> array('require' => false),
				'title'			=> array('require' => false),
				'short_text'		=> array('require' => false),
				'text'			=> array('require' => false),

				'position'		=> array('require' => false),
				'clear'			=> array('require' => false),

				'use_title'		=> array('require' => false),
				'use_text'		=> array('require' => false),
				'use_image'		=> array('require' => false),

				'files_names'		=> array('require' => false));
		$fields = $this->EasyForms->fields($fields);
		if ($fields === false)
			return;

		try
		{
			$this->News->save_image($fields);
			$this->News->save_files($fields);
		}
		catch(Exception $e)
		{
			$this->News->remove_files($fields['name'], $fields['category']);
			$this->Errors->add(array("news", "add"), $e->getMessage());
		}

		$params = $this->parse_params($fields);
		$this->News->add($fields, $params);

		$this->reset_cache();
		$this->reset_cache();
		Component::redirect($_SERVER['SCRIPT_NAME'], array('module' => "news", 'action' => "index"));
	}
Ejemplo n.º 10
0
	/**
	 * Отображает титульную страницу модуля
	 */
	public function on_index()
	{
		$this->Admin->logout();
		Component::redirect($_SERVER['SCRIPT_NAME']);
	}
Ejemplo n.º 11
0
	public function on_edit()
	{
		$this->Templates->set_page("Редактирование");
		if (!$this->EasyForms->field("send"))
		{
			$client_id = $this->EasyForms->field("id", INPUT_GET);
			$client_id = intval($client_id);
			if (empty($client_id))
				return;

			$client = $this->Accounts->get($client_id);
			if ($client === false)
				return;

			$this->Templates->bind_params($client);
			return;
		}

		$fields = array('id'		=> array('require' => true),
				'name'		=> array(),
				'phone'		=> array(),
				'day_birth'	=> array(),
				'month_birth'	=> array(),
				'year_birth'	=> array(),
				'lastname'	=> array(),
				'patronymic'	=> array(),
				'email'		=> array(),
				'card'		=> array());
		$fields = $this->EasyForms->fields($fields, array('type' => INPUT_POST, 'require' => false));
		$this->Templates->bind_params($fields);
		$client_id = $fields['id'];
		unset($fields['id']);
		$email = $fields['email'];
		unset($fields['email']);
		$this->Accounts->update_user($client_id, array('email' => $email));
		$this->Accounts->update_user_data($client_id, $fields);
		Component::redirect("admin", array('module' => "clients", 'action' => "index"));
	}