diff --git a/backend/controllers/OrdersController.php b/backend/controllers/OrdersController.php index 03c0f37..8b284a6 100644 --- a/backend/controllers/OrdersController.php +++ b/backend/controllers/OrdersController.php @@ -16,7 +16,6 @@ use common\modules\product\models\ProductVariant; class OrdersController extends Controller { -// public $layout = 'update'; /** * @inheritdoc */ @@ -43,7 +42,6 @@ class OrdersController extends Controller if(!empty($searchModel->id))$query->andFilterWhere(['like', 'id', $searchModel->id]); if(!empty($searchModel->phone))$query->andFilterWhere(['like', 'phone', $searchModel->phone]); if(!empty($searchModel->name))$query->andFilterWhere(['like', 'name', $searchModel->name]); - if(!empty($searchModel->surname))$query->andFilterWhere(['like', 'surname', $searchModel->surname]); if(!empty($searchModel->total))$query->andFilterWhere(['like', 'total', $searchModel->total]); if(!empty($searchModel->reserve))$query->andFilterWhere(['like', 'reserve', $searchModel->reserve]); if(!empty($searchModel->status))$query->andFilterWhere(['like', 'status', $searchModel->status]); diff --git a/common/components/Mailer.php b/common/components/Mailer.php index d150fe0..dd3ff5a 100755 --- a/common/components/Mailer.php +++ b/common/components/Mailer.php @@ -6,7 +6,7 @@ use yii\base\Widget; class Mailer extends Widget{ public $message; - public $email = 'dockdep@gmail.com'; + public $email; public $text; public $subject; @@ -30,6 +30,7 @@ class Mailer extends Widget{ $mail->MsgHTML($this->text); $address = "dockdep@gmail.com"; $mail->AddAddress($address); + $mail->AddAddress($this->email); if(!$mail->send()) { \Yii::$app->getSession()->setFlash('error', 'Mailer Error: ' . $mail->ErrorInfo); return 'Mailer Error: ' . $mail->ErrorInfo; diff --git a/common/models/Customer.php b/common/models/Customer.php index b40091a..7208ab9 100755 --- a/common/models/Customer.php +++ b/common/models/Customer.php @@ -1,6 +1,7 @@ username; - $body .= "\n\r"; - $body .= 'Ваш пароль: '.$this->password; - - - Yii::$app->mailer->compose() - ->setTo($this->username) - ->setFrom(['send@artweb.ua' => 'send']) - ->setSubject('Rukzachok Ваш пароль') - ->setTextBody($body) - ->send(); + $body = 'Вас приветствует сайт Rukzachok'; + $body .= "\n\r"; + $body .= 'Ваш логин: '.$this->username; + $body .= "\n\r"; + $body .= 'Ваш пароль: '.$this->password; + + Mailer::widget(['text'=> $body, 'subject'=> 'Спасибо за регистрацию', 'email' => $this->username ]); } - public function afterSave($insert, $changedAttributes) - { - parent::afterSave($insert, $changedAttributes); -/* -$auth = new DbManager; -$auth->init(); -$role = $auth->createRole('company'); -$auth->add($role); -$role = $auth->createRole('customer'); -$auth->add($role); -*/ - // установка роли пользователя - $auth = Yii::$app->authManager; - $role = $auth->getRole($this->role); - if (!$insert) { - $auth->revokeAll($this->id); - } - $auth->assign($role, $this->id); - - $this->sendMsg(); - } + public function afterSave($insert, $changedAttributes) + { + parent::afterSave($insert, $changedAttributes); + + // установка роли пользователя + $auth = Yii::$app->authManager; + $role = $auth->getRole($this->role); + if (!$insert) { + $auth->revokeAll($this->id); + } + $auth->assign($role, $this->id); + + if($this->isNewRecord){ + $this->sendMsg(); + } + } public function beforeSave($insert) { @@ -135,37 +125,32 @@ $auth->add($role); return parent::beforeSave($insert); } - public function beforeDelete() { - //$this->deleteImage($this->image); - return parent::beforeDelete(); - } - - public function deleteImage($file){ - if(!empty($file)){ - @unlink('upload/profile/'.$file); - @unlink('upload/profile/ico/'.$file); - // @unlink('upload/fotos/big/'.$file); - } - } - - - public function getOld(){ - if(empty($this->birth_year) || empty($this->birth_mouth) || empty($this->birth_day))return; - $birthday = $this->birth_year.'-'.$this->birth_mouth.'-'.$this->birth_day; - if($birthday=="0000-00-00")return; - $birthday_timestamp = strtotime($birthday); - $age = date('Y') - date('Y', $birthday_timestamp); - if (date('md', $birthday_timestamp) > date('md')) { - $age--; - } - return $age; - + public function beforeDelete() { + //$this->deleteImage($this->image); + return parent::beforeDelete(); + } + + public function deleteImage($file){ + if(!empty($file)){ + @unlink('upload/profile/'.$file); + @unlink('upload/profile/ico/'.$file); + // @unlink('upload/fotos/big/'.$file); + } + } + + + public function getOld(){ + if(empty($this->birth_year) || empty($this->birth_mouth) || empty($this->birth_day))return; + $birthday = $this->birth_year.'-'.$this->birth_mouth.'-'.$this->birth_day; + if($birthday=="0000-00-00")return; + $birthday_timestamp = strtotime($birthday); + $age = date('Y') - date('Y', $birthday_timestamp); + if (date('md', $birthday_timestamp) > date('md')) { + $age--; } - -// public function getOfferCustomer(){ -// return $this->hasMany(OfferCustomer::className(), ['service_user_id' => 'id'])->where(['done'=>1]); -// } -// + return $age; + + } /** * @inheritdoc diff --git a/common/models/Orders.php b/common/models/Orders.php index 0df6d75..7f333ce 100755 --- a/common/models/Orders.php +++ b/common/models/Orders.php @@ -18,7 +18,7 @@ class Orders extends \yii\db\ActiveRecord return [ [['name', 'phone'], 'required','whenClient' => true], //['email', 'email'], - [['total','body','patronymic','surname','email','phone2','delivery','payment'], 'safe'], + [['total','body','email','phone2','delivery','payment'], 'safe'], [['email'],'email'], ]; } @@ -26,14 +26,12 @@ class Orders extends \yii\db\ActiveRecord public function attributeLabels() { return [ - 'name' => 'Имя', + 'name' => 'Ф.И.О', 'phone'=>'Телефон', 'phone2'=>'Дополнительный телефон', 'body'=>'Сообщение', 'adress'=>'Адрес', 'city'=>'Город', - 'patronymic'=>'Отчество', - 'surname'=>'Фамилия', 'email'=>'E-mail', 'date_time'=>'Дата', 'total'=>'Сума', @@ -60,10 +58,6 @@ class Orders extends \yii\db\ActiveRecord $body .= "\n\r"; $body .= 'Имя: '.$this->name; $body .= "\n\r"; - $body .= 'Фамилия: '.$this->surname; - $body .= "\n\r"; - $body .= 'Отчество: '.$this->patronymic; - $body .= "\n\r"; $body .= 'E-mail: '.$this->email; $body .= "\n\r"; $body .= 'Телефон: '.$this->phone; diff --git a/console/migrations/m160518_185644_change_order.php b/console/migrations/m160518_185644_change_order.php new file mode 100644 index 0000000..07dffdc --- /dev/null +++ b/console/migrations/m160518_185644_change_order.php @@ -0,0 +1,29 @@ +dropColumn('orders', 'surname'); + $this->dropColumn('orders', 'patronymic'); + } + + public function down() + { + $this->addColumn('orders', 'surname','string'); + $this->addColumn('orders', 'patronymic','string'); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/config/main.php b/frontend/config/main.php index 59afe50..2d867d5 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -85,6 +85,8 @@ return [ 'brends' => 'brends/index', 'blog' => 'articles/index', 'blog/-' => 'articles/show', + 'event' => 'event/index', + 'event/-' => 'event/show', '///' => '//', '//' => '/', '/admin' => 'admin/default/index', diff --git a/frontend/controllers/BasketController.php b/frontend/controllers/BasketController.php index 11b07d5..81f3adc 100644 --- a/frontend/controllers/BasketController.php +++ b/frontend/controllers/BasketController.php @@ -50,7 +50,7 @@ class BasketController extends Controller $modelOrdersProducts->load($data); $modelOrdersProducts->save(); } - if(!Yii::$app->user->id){ + if(!Yii::$app->user->id && !empty($modelOrder->email)){ $modelUser = new Customer(); $modelUser->role = 'person'; $modelUser->username = $modelOrder->email; @@ -72,7 +72,6 @@ class BasketController extends Controller $modelOrder->email = $user->username; $modelOrder->phone = $user->phone; $modelOrder->name = $user->name; - $modelOrder->surname = $user->surname; } return $this->render('index', [ diff --git a/frontend/controllers/EventController.php b/frontend/controllers/EventController.php old mode 100755 new mode 100644 index 34e09b1..db7a575 --- a/frontend/controllers/EventController.php +++ b/frontend/controllers/EventController.php @@ -1,48 +1,48 @@ - Event::find() ]); - - return $this->render('index', [ - 'dataProvider' => $dataProvider, - ]); - } - - - - public function actionView($alias) - { - - return $this->render('view', [ - 'model' => $this->findModel($alias), - ]); - } - - - protected function findModel($alias) - { - if (($model = Event::findOne(["alias"=>$alias])) !== null) { - return $model; - } else { - throw new NotFoundHttpException('The requested page does not exist.'); - } - } - - + Event::find() ]); + + return $this->render('index', [ + 'dataProvider' => $dataProvider, + ]); + } + + + + public function actionShow($alias) + { + + return $this->render('show', [ + 'model' => $this->findModel($alias), + ]); + } + + + protected function findModel($alias) + { + if (($model = Event::findOne(["alias"=>$alias])) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } + + } \ No newline at end of file diff --git a/frontend/views/basket/index.php b/frontend/views/basket/index.php index 4db06c3..7bd4e84 100755 --- a/frontend/views/basket/index.php +++ b/frontend/views/basket/index.php @@ -43,12 +43,10 @@ $('#order-delivery input[type=\"radio\"]').click(function(){ 'btn-success']) ?> false]); ?>
-
-field($modelOrder,'surname'); ?> +
field($modelOrder,'name'); ?> -field($modelOrder,'patronymic'); ?> field($modelOrder,'phone'); ?> -field($modelOrder,'phone2'); ?> +field($modelOrder,'phone2'); ?> field($modelOrder,'city'); ?> field($modelOrder,'adress'); ?> field($modelOrder,'email'); ?> diff --git a/frontend/views/event/_objects.php b/frontend/views/event/_objects.php old mode 100755 new mode 100644 index 20ae70b..84e2f38 --- a/frontend/views/event/_objects.php +++ b/frontend/views/event/_objects.php @@ -2,37 +2,10 @@ use yii\helpers\Html; use frontend\helpers\TextHelper; use yii\helpers\Url; - +use frontend\components\Text; ?> -
-
- -
-
- minImg($model->image, '200','200')),Url::toRoute(['event/view', 'alias' =>$model->alias ])) ?> -
-
- -
- - -
name,Url::toRoute(['event/view', 'alias' =>$model->alias ])) ?>
-
- Срок действия по: end_at?> -
-
-

- body, 200, '...') ?> -

-
- - - - - - - -
Заказать консультацию
-
-
+
+ + name?>
+ body,600);?>
\ No newline at end of file diff --git a/frontend/views/event/index.php b/frontend/views/event/index.php index a93a500..d485c3c 100755 --- a/frontend/views/event/index.php +++ b/frontend/views/event/index.php @@ -1,22 +1,42 @@ params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']]; -$this->params['seo']['seo_text'] = 'TEST SEO TEXT'; -$this->params['seo']['h1'] = 'TEST H1'; -$this->params['seo']['description'] = 'TEST DESCRIPTION'; -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD'; -?> +?> $dataProvider, - 'itemView'=>'_objects', - 'summary'=>'', - 'layout' => "
{items}
-
{pager}
" - ] ); +$this->title = 'Акции'; +$this->registerMetaTag(['name' => 'description', 'content' => 'Акции']); +$this->registerMetaTag(['name' => 'keywords', 'content' => 'Акции']); ?> -
- 'seo_text'])?> -
+ + + +
+ +
+

Акции

+ $dataProvider, + 'itemView'=>'_objects', + 'summary'=>'' + ] ); + ?> + +
+ + +
+ +
\ No newline at end of file diff --git a/frontend/views/event/show.php b/frontend/views/event/show.php new file mode 100755 index 0000000..1388486 --- /dev/null +++ b/frontend/views/event/show.php @@ -0,0 +1,29 @@ + +title = $model->name; + +?> + + + +
+ +
+

name?>

+ + + body?> +
+ +
\ No newline at end of file diff --git a/frontend/views/event/view.php b/frontend/views/event/view.php deleted file mode 100755 index b6e8727..0000000 --- a/frontend/views/event/view.php +++ /dev/null @@ -1,51 +0,0 @@ -title = $model->name; -$this->params['breadcrumbs'][] = ['label' => 'Акции', 'url' => ['index']]; -$this->params['breadcrumbs'][] = $this->title; -$this->params['name'] = $this->title; -?> -
-

name?>

- minImg($model->image, '940','480')) ?> -
- Срок действия по: end_at?> -
-
- body?> -
- $this, - 'model' => $model->className(), - 'model_id' => $model->event_id, - 'comment_class' => \common\modules\comment\models\Comment::className(), - 'rating_class' => \common\modules\comment\models\Rating::className(), - 'class_options' => [ - 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, - 'user_id' => \Yii::$app->user->getId(), - 'guestComment' => true, - 'status' => \common\modules\comment\models\Comment::STATUS_ACTIVE, - ], - 'list_options' => [ - 'view' => 'list-comment-review', - ], - 'form_options' => [ - 'view' => 'form-comment-review', - 'tag' => 'span', - ], - 'options' => [ - 'class' => 'proektant-comments-wr style', - ], - ]); - ?> -
-
- 'seo_text'])?> -
diff --git a/frontend/views/layouts/main-menu.php b/frontend/views/layouts/main-menu.php new file mode 100644 index 0000000..02bb018 --- /dev/null +++ b/frontend/views/layouts/main-menu.php @@ -0,0 +1,24 @@ +all () as $category){ + $menu[] = ['label' => $category->name , + 'url' => Url::to(['catalog/category', 'category' => $category]), + 'active' => Yii::$app->request->get('category')->alias == $category->alias ? true : false ]; +} + +$main_menu = Menu::widget([ + 'items' => $menu, +]); +?> + + + diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index e4d7e1d..d3fbf18 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -154,19 +154,7 @@ @@ -306,7 +294,7 @@
  • Оплата и доставка
  • Личный кабинет
  • -
  • Акции
  • +
  • Акции
  • О магазине
  • -- libgit2 0.21.4