Source for file OrderForm.class.php
Documentation is available at OrderForm.class.php
* Содержит класс OrderForm
* @copyright ColoCall 2006
//require_once('core/modules/share/components/DBDataSet.class.php');
//require_once('core/modules/shop/components/Order.class.php');
//require_once('core/modules/shop/components/CurrencyConverter.class.php');
//require_once('core/framework/Mail.class.php');
* Предназначен для формирования заказа пользователем
* @param Document $document
public function __construct($name, $module, Document $document, array $params = null) {
parent::__construct($name, $module, $document, $params);
* Переопределен параметр active
* Если корзина - пуста то что заказывать?
protected function main() {
* Подтягиваем перечень полей из таблицы пользователей
if (!in_array($fieldName, array('order_id', 'order_delivery_comment'))) {
unset ($result[$fieldName]);
$result = array_merge($result, $this->dbh->getColumnsInfo('user_users'));
unset ($result['u_is_active'], $result['u_password'], $result['u_avatar_prfile']);
$commentField = $result['order_delivery_comment'];
unset ($result['order_delivery_comment']);
$result['order_delivery_comment'] = $commentField;
* Если пользователь аутентифицирован загружаем его данные из объекта AuthUser
if ($user->isAuthenticated()) {
foreach (array_keys($user->getFields()) as $fieldName) {
$data[$fieldName] = $user->getValue($fieldName);
$result->load(array($data));
* Сохраняет данные о заказе
protected function save() {
$this->dbh->beginTransaction();
$userData = $_POST['user_users'];
if (!$this->document->getUser()->isAuthenticated()) {
$this->order->setUser($newUser);
$data['order_id'] = $this->order->create(array_merge($userData, array('order_delivery_comment'=> $data['order_delivery_comment'])));
$_SESSION['order_saved'] = true;
$this->order->getBasket()->purify();
$this->response->redirectToCurrentSection('success/');
catch (Exception $error) {
$this->failure($error->getMessage());
* Метод отрабатывающий если что то не так пошло
protected function failure($errors) {
$dataDescription->addFieldDescription($ddi);
$di = new Field('message');
if ($component = $this->document->componentManager->getComponentByName('textBlock_order')) {
if ($component = $this->document->componentManager->getComponentByName('basket')) {
* Метод выводящий сообщение об успешном сохранении данных
//если в сессии нет переменной saved значит этот метод пытаются дернуть напрямую. Не выйдет!
if (!isset ($_SESSION['order_saved'])) {
//Мавр сделал свое дело...
unset ($_SESSION['order_saved']);
$dataDescription->addFieldDescription($ddi);
$di = new Field('success_message');
if ($component = $this->document->componentManager->getComponentByName('textBlock_order')) {
if ($component = $this->document->componentManager->getComponentByName('basket')) {
|