public function actionBackCall() { $success = null; $model = new SystemBackCall(); $settings = \Yii::$app->getModule('admin')->getSettings($this->module->id); if ($model->load(\Yii::$app->request->post()) && $model->save()) { if ($model->contact($settings['BackCallEmail']['value'], $settings['BackCallSubject']['value'])) { /* $url = 'https://docs.google.com/forms/d/e/1FAIpQLSf0kqkJFjt9booJyMOAVULkIWRUUgiU7nolOOzZaRNMc7RWzQ/formResponse'; $data = array(); // массив для отправки в гугл форм $data['entry.1339533031'] = $model->id; $data['entry.692682431'] = $model->name; $data['entry.2127229280'] = $model->phone; $data['entry.489867667'] = $model->email; $data['entry.715720461'] = $model->comment; $data = http_build_query($data); $options = array( // задаем параметры запроса 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => $data, ), ); $context = stream_context_create($options); // создаем контекст отправки $result = file_get_contents($url, false, $context); */ $success = ['success' => \Yii::t('system', $settings['BackCallSuccessText']['value'])]; } } return $this->formatResponse($success); }
function status($status) { switch ($status) { case 1: return '<span class="label label-primary">' . SystemBackCall::getStatus($status) . '</span>'; break; case 2: return '<span class="label label-success">' . SystemBackCall::getStatus($status) . '</span>'; break; } }
/* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('system', 'System Back Calls'); $this->params['breadcrumbs'][] = $this->title; $this->params['actions_buttons'] = [['tagName' => 'a', 'label' => Yii::t('system', 'Create'), 'options' => ['href' => Url::to(['create'])], 'icon' => 'fa fa-plus', 'iconPosition' => Button::ICON_POSITION_LEFT, 'size' => Button::SIZE_SMALL, 'disabled' => false, 'block' => false, 'type' => Button::TYPE_CIRCLE], ['label' => Yii::t('app', 'Control'), 'options' => ['class' => 'btn blue btn-outline btn-circle btn-sm', 'data-hover' => "dropdown", 'data-close-others' => "true"], 'dropdown' => ['options' => ['class' => 'pull-right'], 'encodeLabels' => false, 'items' => [['label' => '<span class="font-red"><i class="fa fa-trash-o"></i> ' . Yii::t('app', 'Delete') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'deleteA()']], ['label' => '<span class="font-green-turquoise"><i class="fa fa-toggle-on"></i> ' . Yii::t('app', 'Status Processed') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'publishedA()']], ['label' => '<span class="font-blue-chambray"><i class="fa fa-toggle-off"></i> ' . Yii::t('app', 'Status New') . '</span>', 'url' => 'javascript:void(0)', 'linkOptions' => ['onclick' => 'unpublishedA()']]]]], ['tagName' => 'a', 'options' => ['href' => Url::to(['/admin/modules/setting', 'name' => 'system'])], 'icon' => 'fa fa-cog', 'label' => '', 'type' => Button::TYPE_CIRCLE]]; ?> <div class="system-back-call-index"> <div class="table-responsive"> <?php echo GridView::widget(['id' => 'grid', 'tableOptions' => ['class' => 'table table-striped table-bordered table-advance table-hover'], 'dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:36px']], ['attribute' => 'id', 'options' => ['style' => 'width:100px']], 'name', 'email:email', 'phone', 'created_at:datetime', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($model, $index, $widget) { switch ($model->status) { case 1: return '<span class="label label-primary">' . SystemBackCall::getStatus($model->status) . '</span>'; break; case 2: return '<span class="label label-success">' . SystemBackCall::getStatus($model->status) . '</span>'; break; } }], ['class' => 'app\\modules\\admin\\components\\grid\\ActionColumn']]]); ?> </div> </div> <script> function deleteA() { var keys = $('#grid').yiiGridView('getSelectedRows'); window.location.href = '<?php echo Url::to(['/admin/system/back-call/delete-ids']); ?> ' + '?id=' + keys.join(); } function publishedA() {
/** * Finds the SystemBackCall model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return SystemBackCall the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = SystemBackCall::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }