Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4c149b018d
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 126 lines (114 sloc) 5.093 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
<?php defined('SYSPATH')or die('No direct script access.');
/**
* @author d1ffuz0r gladk0w@mail.ru
* @license GPLv3
* @copyright 2011
*/
class Controller_Shop extends Controller_Tpl
    {
    
        /**
* @param int $id id продукта
* @return HTML вывод формы для оформления заказа
*/
        public function action_new_order($id)
            {
                if (Cookie::get('loged_in')==TRUE)
                    {
                        $shop = Model::factory('shop');

                        $product = $shop->view_product($id);

                        $this->template->title = __('Оформление заказа');
                        $this->template->content = View::factory('page/shop/new_order')
                                        ->set('product', $product);
                    }
                else
                    {
                        $this->template->title = __('Ошибка');
                        $this->template->content = View::factory('tpl/msg')
                                        ->set('msg',Kohana::message('msg','not_login'));
                    }
            }

        /**
* @param mixed POST данные из public action_new_order()
* @return HTML output
*/
        public function action_add_order()
            {
                $order = Model::factory('order');

                $post = Validate::factory($_POST)
                                ->filter(TRUE, 'trim')
                                ->filter('ord_username', 'strtolower');
                $post->rule('ord_id', 'not_empty');
                $post->rule('ord_count', 'not_empty');
                $post->rule('ord_username', 'not_empty');
                $post->rule('ord_realname', 'not_empty');
                $post->rule('ord_family', 'not_empty');
                $post->rule('ord_ot4estvo', 'not_empty');
                $post->rule('ord_email', 'not_empty');
                $post->rule('ord_telephone', 'not_empty');
                $post->rule('ord_country', 'not_empty');
                $post->rule('ord_region', 'not_empty');
                $post->rule('ord_city', 'not_empty');
                $post->rule('ord_postindex', 'not_empty');
                $post->rule('ord_typebuy', 'not_empty');
                $post->rule('ord_price', 'not_empty');
                    if ($post->check())
                        {
                            $this->template->title = __('Готово');
                            $this->template->content = View::factory('tpl/msg')
                                            ->set('msg', $order->add_order($post,1));
                        }
                    else
                        {
                            $this->template->title = __('Ошибка');
                            $this->template->content = View::factory('tpl/msg')
                                            ->set('msg', Kohana::message('msg','empty_field'));
                        }
            }

        /**
* @param string POST строка из формы поиска
* @return HTML вывод результата поиска
*/
        public function action_search()
            {
                $shop = Model::factory('shop');

                $post = Validate::factory($_POST);
                $post->rule('search_q', 'not_empty');


                if ($post->check())
                    {
                        $this->template->title = __('Готово');
                        $this->template->content = View::factory('page/view/search')
                                        ->set('id', $shop->search($post))
                                        ->set('query', $post);
                    }
                else
                    {
                        $this->template->title = __('Ошибка');
                        $this->template->content = View::factory('tpl/msg')
                                        ->set('msg', Kohana::message('msg','not_search'));
                    }
            }

        /**
* @param int $id id заказа
* @return HTML
*/
        public function action_order_y($id)
            {
                $order = Model::factory('order');
                $order->set_status($id, 3);
                $this->template->title = __('Подтверждено');
                $this->template->content = View::factory('tpl/msg')
                                ->set('msg', Kohana::message('msg','order_add'));
            }

        /**
* @param int $id id заказа
* @return HTML
*/
        public function action_order_n($id)
            {
                $order = Model::factory('order');
                $order->set_status($id, 2);
                $this->template->title = __('Подтверждено');
                $this->template->content = View::factory('tpl/msg')
                                ->set('msg', Kohana::message('msg','order_denied'));
            }

    }
Something went wrong with that request. Please try again.