diff --git a/backend/controllers/VisitController.php b/backend/controllers/VisitController.php
new file mode 100644
index 0000000..21a24fe
--- /dev/null
+++ b/backend/controllers/VisitController.php
@@ -0,0 +1,190 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => [ 'POST' ],
+ ],
+ ],
+ 'access' => [
+ 'class' => AccessControl::className(),
+ 'rules' => [
+ [
+ 'allow' => true,
+ 'roles' => [ '@' ],
+ ],
+ ],
+ ],
+ ];
+ }
+ public function actions()
+ {
+ return [
+ 'index' => [
+ 'class' => Index::className(),
+ 'columns' => [
+ 'name' => [
+ 'type' => Index::ACTION_COL,
+ ],
+ 'email' => [
+ 'type' => Index::STRING_COL
+ ],
+ 'phone' => [
+ 'type' => Index::STRING_COL
+ ],
+ 'status' => [
+ 'type' => Index::STATUS_COL,
+ ],
+ 'created_at' => [
+ 'type' => Index::DATETIME_COL,
+ ]
+ ],
+ 'model' => Visit::className(),
+ 'hasLanguage' => false,
+ 'enableMassDelete' => true,
+ 'modelPrimaryKey' => 'id',
+ 'defaultSort' => [
+ 'created_at' => 'DESC',
+ ],
+ 'create' => false,
+ ],
+ 'view' => [
+ 'class' => View::className(),
+ 'model' => Visit::className(),
+ 'hasAlias' => false,
+ 'hasGallery' => false,
+
+ 'languageFields' => [
+ ],
+ 'fields' => [
+ [
+ 'name' => 'name',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'email',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'phone',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'message',
+ 'type' => Form::TEXTAREA,
+ ],
+ [
+ 'name' => 'created_at',
+ 'type' => Form::STRING,
+ ],
+
+ ],
+ ],
+ 'delete' => [
+ 'class' => Delete::className(),
+ ],
+ ];
+ }
+ public function actionUpdate($id)
+ {
+ $model = $this->findModel($id);
+
+ $model->status = true;
+ $model->save(false, [ 'status' ]);
+
+ if ($model->load(\Yii::$app->request->post()) && $model->save()) {
+ return $this->redirect('index');
+ } else {
+ return $this->render(
+ 'update',
+ [
+ 'model' => $model,
+ ]
+ );
+ }
+ }
+ public function findModel($id)
+ {
+ $model = Visit::find()
+ ->where([ 'id' => $id ])
+ ->one();
+ if ($model !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+
+ public function newModel()
+ {
+ return new Visit();
+ }
+
+ public function deleteModel($id)
+ {
+ $category = Visit::find()
+ ->where(
+ [
+ 'id' => $id,
+ ]
+ )
+ ->one();
+
+ return $category->delete();
+ }
+
+ protected static function fieldsConfig()
+ {
+ return [
+ 'model' => Visit::className(),
+ 'hasAlias' => false,
+ 'hasGallery' => false,
+ 'languageFields' => [
+ ],
+ [
+ 'name' => 'name',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'email',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'phone',
+ 'type' => Form::STRING,
+ ],
+ [
+ 'name' => 'message',
+ 'type' => Form::TEXTAREA,
+ ],
+ [
+ 'name' => 'updated_at',
+ 'type' => Form::STRING,
+ ],
+ ];
+ }
+
+
+ }
diff --git a/backend/views/layouts/menu_items.php b/backend/views/layouts/menu_items.php
index b7d42f1..75ccf62 100755
--- a/backend/views/layouts/menu_items.php
+++ b/backend/views/layouts/menu_items.php
@@ -70,6 +70,11 @@
'url' => [ '/doctor/index' ],
],
+ [
+ 'label' => \Yii::t('app', 'Записи на прием'),
+ 'url' => [ '/visit/index' ],
+
+ ],
],
],
diff --git a/backend/views/visit/_form.php b/backend/views/visit/_form.php
new file mode 100644
index 0000000..5a4b0ca
--- /dev/null
+++ b/backend/views/visit/_form.php
@@ -0,0 +1,48 @@
+
+
+
diff --git a/backend/views/visit/update.php b/backend/views/visit/update.php
new file mode 100644
index 0000000..3a11f82
--- /dev/null
+++ b/backend/views/visit/update.php
@@ -0,0 +1,45 @@
+title = Yii::t(
+ 'core',
+ 'Update {modelClass}: ',
+ [
+ 'modelClass' => 'Visit',
+ ]
+ ) . $model->name;
+ $this->params[ 'breadcrumbs' ][] = [
+ 'label' => Yii::t('core', 'Visits'),
+ 'url' => [ 'index' ],
+ ];
+ $this->params[ 'breadcrumbs' ][] = [
+ 'label' => $model->name,
+ 'url' => [
+ 'view',
+ 'id' => $model->id,
+ ],
+ ];
+ $this->params[ 'breadcrumbs' ][] = Yii::t('core', 'Update');
+?>
+
+ $this->title,
+ 'options' => [
+ 'class' => 'x_panel feedback-update',
+ ],
+ ]
+) ?>
+
+= $this->render(
+ '_form',
+ [
+ 'model' => $model,
+ ]
+) ?>
+
+
diff --git a/common/config/main.php b/common/config/main.php
index efd2a4d..1e146bf 100644
--- a/common/config/main.php
+++ b/common/config/main.php
@@ -27,7 +27,7 @@
],
'components' => [
'cache' => [
- 'class' => 'yii\caching\FileCache',
+ 'class' => 'yii\caching\DummyCache',
],
'i18n' => [
'translations' => [
diff --git a/common/models/Visit.php b/common/models/Visit.php
new file mode 100644
index 0000000..123bda0
--- /dev/null
+++ b/common/models/Visit.php
@@ -0,0 +1,112 @@
+ TimestampBehavior::className(),
+ 'updatedAtAttribute' => false,
+ ],
+ ];
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public static function tableName()
+ {
+ return 'visit';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function rules()
+ {
+ return [
+ [
+ [
+ 'phone'
+ ],
+ 'required'
+ ],
+ [
+ [
+ 'status'
+ ],
+ 'boolean'
+ ],
+ [
+ [
+ 'email'
+ ],
+ 'email'
+ ],
+ [
+ [ 'message' ],
+ 'string',
+ ],
+ [
+ [ 'entity_id' ],
+ 'default',
+ 'value' => null,
+ ],
+ [
+ [ 'entity_id', 'created_at' ],
+ 'integer',
+ ],
+ [
+ [
+ 'name',
+ 'phone',
+ 'entity',
+ 'email'
+ ],
+ 'string',
+ 'max' => 255,
+ ],
+ ];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function attributeLabels()
+ {
+ return [
+ 'id' => Yii::t('app', 'ID'),
+ 'name' => Yii::t('app', 'Name'),
+ 'phone' => Yii::t('app', 'Phone'),
+ 'message' => Yii::t('app', 'Message'),
+ 'entity' => Yii::t('app', 'Entity'),
+ 'entity_id' => Yii::t('app', 'Entity ID'),
+ 'email' => Yii::t('app', 'Email'),
+ ];
+ }
+
+ public function getEntity(){
+ if ($this->entity !== null){
+ return $this->hasOne($this->entity, ['id' => 'entity_id']);
+ }
+ return null;
+ }
+ }
diff --git a/console/migrations/m180601_065055_create_visit_table.php b/console/migrations/m180601_065055_create_visit_table.php
new file mode 100644
index 0000000..2b05714
--- /dev/null
+++ b/console/migrations/m180601_065055_create_visit_table.php
@@ -0,0 +1,35 @@
+createTable('visit', [
+ 'id' => $this->primaryKey(),
+ 'name' => $this->string(),
+ 'phone' => $this->string(),
+ 'message' => $this->text(),
+ 'entity' => $this->string(),
+ 'entity_id' => $this->integer(),
+ 'email' => $this->string(),
+ 'status' => $this->boolean(),
+ 'created_at'=> $this->integer()
+ ]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropTable('visit');
+ }
+}
diff --git a/frontend/config/main.php b/frontend/config/main.php
index 20c8701..b02beef 100755
--- a/frontend/config/main.php
+++ b/frontend/config/main.php
@@ -188,6 +188,76 @@
}',
],
+
+ 'visit' => [
+ 'class' => 'artbox\core\forms\Module',
+ 'activeRecord' => "common\models\Visit",
+ 'attributes' => [
+ 'name',
+ 'phone',
+ 'email',
+ 'message',
+
+ 'entity',
+ 'entity_id'
+ ],
+ 'rules' => [
+ [
+ [
+ 'phone',
+ ],
+ 'required',
+ ]
+ ],
+ 'labels' => [
+ 'name' => 'ФИО',
+ 'email' => 'Email',
+ 'phone' => 'Телефон',
+ 'message' => 'Сообщение',
+ 'entity_id' => false,
+ 'entity' => false
+ ],
+
+ 'inputOptions' => [
+ 'entity' => [
+ 'type' => 'hiddenInput'
+ ],
+ 'entity_id' => [
+ 'type' => 'hiddenInput'
+ ],
+ 'name' => [
+ 'template' => '{input}
'
+ ],
+ 'email' => [
+ 'template' => '{input}
'
+ ],
+ 'phone' => [
+ 'template' => '{input}
',
+ 'options' => [
+ 'placeholder' => '(0__)___-__-__'
+ ]
+ ],
+ 'message' => [
+ 'type' => 'textarea',
+ 'options' => ['cols' => 30, 'rows'=> 10],
+ 'template' => '{input}
'
+ ],
+ ],
+ 'buttonTemplate' => '',
+ 'buttonOptions' => [],
+ 'buttonContent' => 'Отправить',
+ 'sendEmail' => false,
+ 'ajax' => true,
+ 'formId' => 'visit-form',
+ 'scenario' => 'default',
+ 'successCallback' => 'function (data) {
+ document.getElementById("visit-form").reset();
+ var data = $("#visit-form").data(\'yiiActiveForm\');
+ data.validated = false;
+ success();
+ }',
+
+ ],
],
'components' => [
'assetManager' => [
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index e2994dc..2799dec 100755
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -18,6 +18,7 @@
use artbox\core\seo\widgets\SeoBreadcrumbs;
use common\models\Service;
use common\models\Settings;
+ use common\models\Visit;
use frontend\assets\AppAsset;
use frontend\assets\SliderAsset;
use frontend\widgets\ArtboxModalWidget;
@@ -408,31 +409,39 @@
ArtboxModalWidget::end();
?>
-
+ getModule('visit');
+ if (isset($this->params['entity']) and isset($this->params['entity_id'])){
+ $moduleVisit->inputOptions = array_merge($moduleVisit->inputOptions, ['entity' => [
+ 'type' => 'hiddenInput',
+ 'options' => ['value' => $this->params['entity']],
+ ],
+ 'entity_id' => [
+ 'type' => 'hiddenInput',
+ 'options' => ['value' => $this->params['entity_id']],
+ ]
+ ]);
+ }
+ ArtboxModalWidget::begin([
+ 'modalTagOptions' => [
+ 'id' => 'write-to'
+ ],
+ 'titleTagOptions' => [
+ 'class' => 'style form-title'
+ ],
+ 'headerText' => \Yii::t('app', 'Записаться на прием'),
+ 'closeTagButton' => 'span',
+ 'closeTagContent' => '',
+ 'closeButtonOptions' => [
+ 'id' => 'modal_close'
+ ]
+ ]);
+
+ $moduleVisit->renderForm($this);
+
+ ArtboxModalWidget::end();
+ ?>
diff --git a/frontend/views/service/view.php b/frontend/views/service/view.php
index 6c481be..01d3854 100644
--- a/frontend/views/service/view.php
+++ b/frontend/views/service/view.php
@@ -4,8 +4,13 @@
* @var \common\models\Service[] $others;
* @var \artbox\core\forms\Module $moduleComment;
* @var \artbox\core\forms\Module $moduleQuestion;
+ * @var \yii\web\View $this
*/
use artbox\core\helpers\Url;
+ use common\models\Service;
+
+ $this->params['entity'] = Service::className();
+ $this->params['entity_id'] = $model->id;
$moduleComment = \Yii::$app->getModule('comments');
$this->params[ 'breadcrumbs' ][] = $model->title;
diff --git a/frontend/web/js/script.js b/frontend/web/js/script.js
index 31a630c..788d81b 100644
--- a/frontend/web/js/script.js
+++ b/frontend/web/js/script.js
@@ -154,11 +154,11 @@ $(document).ready(function() {
var text = $(this).val();
$(this).val(text);
if(($(this).val())== '') {$(this).val('(0')}
- })
+ });
$(phoneInput).focusout(function () {
var phoneVal = $(this).val()
//if(phoneVal == '+38(0' || phoneVal == '+38(' || phoneVal == '+38' || phoneVal == '+3' || phoneVal == '+') {$(this).val('')}
- if(phoneVal.length <17) {$(this).val('')}
+ if(phoneVal.length <15) {$(this).val('')}
})
}
}
@@ -312,7 +312,7 @@ $(document).ready(function() {
},400)
}
-
+ window.success = success;
if($(window).width() >= 768) {
animations();
}
--
libgit2 0.21.4