Commit ac08a4b4 authored by Виталий Мурашко's avatar Виталий Мурашко

Merge branch 'master' of http://git.task-on.com/ktask/task-on.com

Conflicts:
	frontend/views/layouts/foot.php
parents 3a7a76b0 84d833e0
...@@ -26,7 +26,7 @@ $base_url = ...@@ -26,7 +26,7 @@ $base_url =
'://'. '://'.
// Get domain portion // Get domain portion
$_SERVER['HTTP_HOST']; // DON'T TOUCH (base url (only domain) of site (without final /)). $_SERVER['HTTP_HOST']; // DON'T TOUCH (base url (only domain) of site (without final /)).
$upload_dir = '/source/'; // path from base_url to base of upload folder (with start and final /) $upload_dir = '/uploads/source/'; // path from base_url to base of upload folder (with start and final /)
$current_path = '../../../frontend/web/uploads/source/'; // relative path from filemanager folder to upload folder (with final /) $current_path = '../../../frontend/web/uploads/source/'; // relative path from filemanager folder to upload folder (with final /)
//thumbs folder can't put inside upload folder //thumbs folder can't put inside upload folder
$thumbs_base_path = '../../../frontend/web/uploads/thumbs/'; // relative path from filemanager folder to thumbs folder (with final /) $thumbs_base_path = '../../../frontend/web/uploads/thumbs/'; // relative path from filemanager folder to thumbs folder (with final /)
......
<?php
/**
* API UniSender
*
* @see http://www.unisender.com/ru/help/api/
* @version 1.3
*/
class UnisenderAPI {
/**
* @var string
*/
protected $ApiKey;
/**
* @var string
*/
protected $Encoding = 'UTF8';
/**
* @var int
*/
protected $RetryCount = 0;
/**
* @var float
*/
protected $Timeout;
/**
* @var bool
*/
protected $Compression = false;
/**
* @param string $ApiKey
* @param string $Encoding
* @param int $RetryCount
* @param null $Timeout
* @param bool $Compression
*/
function __construct($ApiKey = '5p7mt1be5x6axqniwu937gqohj9k9hn7gbex1efo', $Encoding = 'UTF8', $RetryCount = 4, $Timeout = null, $Compression = false) {
$this->ApiKey = $ApiKey;
if (!empty($Encoding)) {
$this->Encoding = $Encoding;
}
if (!empty($RetryCount)) {
$this->RetryCount = $RetryCount;
}
if (!empty($Timeout)) {
$this->Timeout = $Timeout;
}
if ($Compression) {
$this->Compression = $Compression;
}
}
/**
* @param string $Name
* @param array $Arguments
* @return string
*/
function __call($Name, $Arguments) {
if (!is_array($Arguments) || empty($Arguments)) {
$Params = array();
} else {
$Params = $Arguments[0];
}
return $this->callMethod($Name, $Params);
}
public function createList($title=null){
if ($title===null) {
$date = new DateTime;
$title = $date->format('YmdHis').(rand(100000, 999999));
}
return $this->callMethod(
'createList',
[
'title' => $title
]
);
}
public function createCampaign($message_id){
return $this->callMethod(
'createCampaign',
[
'message_id' => $message_id
]
);
}
public function createEmailMessage($sender_name, $sender_email, $subject, $body, $list_id){
return $this->callMethod(
'createEmailMessage',
[
'sender_name' => $sender_name,
'sender_email' => $sender_email,
'subject' => $subject,
'body' => $body,
'list_id' => $list_id
]
);
}
/**
* @param array $Params
* @return string
*/
function subscribe($Params) {
$Params = (array)$Params;
if (empty($Params['request_ip'])) {
$Params['request_ip'] = $this->getClientIp();
}
return $this->callMethod('subscribe', $Params);
}
/**
* @param string $JSON
* @return mixed
*/
protected function decodeJSON($JSON) {
return json_decode($JSON);
}
/**
* @return string
*/
protected function getClientIp() {
$Result = '';
if (!empty($_SERVER["REMOTE_ADDR"])) {
$Result = $_SERVER["REMOTE_ADDR"];
} else if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$Result = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
$Result = $_SERVER["HTTP_CLIENT_IP"];
}
if (preg_match('/([0-9]|[0-9][0-9]|[01][0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[0-9][0-9]|[01][0-9][0-9]|2[0-4][0-9]|25[0-5])){3}/', $Result, $Match)) {
return $Match[0];
}
return $Result;
}
/**
* @param string $Value
* @param string $Key
*/
protected function iconv(&$Value, $Key) {
$Value = iconv($this->Encoding, 'UTF8//IGNORE', $Value);
}
/**
* @param string $Value
* @param string $Key
*/
protected function mb_convert_encoding(&$Value, $Key) {
$Value = mb_convert_encoding($Value, 'UTF8', $this->Encoding);
}
/**
* @param string $MethodName
* @param array $Params
* @return array
*/
protected function callMethod($MethodName, $Params = array()) {
if ($this->Encoding != 'UTF8') {
if (function_exists('iconv')) {
array_walk_recursive($Params, array($this, 'iconv'));
} else if (function_exists('mb_convert_encoding')) {
array_walk_recursive($Params, array($this, 'mb_convert_encoding'));
}
}
$Url = $MethodName . '?format=json';
if ($this->Compression) {
$Url .= '&api_key=' . $this->ApiKey . '&request_compression=bzip2';
$Content = bzcompress(http_build_query($Params));
} else {
$Params = array_merge((array)$Params, array('api_key' => $this->ApiKey));
$Content = http_build_query($Params);
}
$ContextOptions = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $Content,
)
);
if ($this->Timeout) {
$ContextOptions['http']['timeout'] = $this->Timeout;
}
$RetryCount = 0;
$Context = stream_context_create($ContextOptions);
do {
$Host = $this->getApiHost($RetryCount);
$Result = file_get_contents($Host . $Url, false, $Context);
$RetryCount++;
} while ($Result === false && $RetryCount < $this->RetryCount);
return $Result;
}
/**
* @param int $RetryCount
* @return string
*/
protected function getApiHost($RetryCount = 0) {
if ($RetryCount % 2 == 0) {
return 'http://api.unisender.com/ru/api/';
} else {
return 'http://www.api.unisender.com/ru/api/';
}
}
}
\ No newline at end of file
...@@ -22,8 +22,6 @@ class Module extends \common\components\WebModule ...@@ -22,8 +22,6 @@ class Module extends \common\components\WebModule
public function init() public function init()
{ {
parent::init(); parent::init();
// custom initialization code goes here
} }
public static function name() public static function name()
......
...@@ -4,6 +4,8 @@ namespace common\modules\bids\models; ...@@ -4,6 +4,8 @@ namespace common\modules\bids\models;
use Yii; use Yii;
use \common\models\Settings;
/** /**
* This is the model class for table "bids". * This is the model class for table "bids".
* *
...@@ -99,6 +101,20 @@ class Bid extends \common\components\ActiveRecordModel ...@@ -99,6 +101,20 @@ class Bid extends \common\components\ActiveRecordModel
public function send() public function send()
{ {
$email = Settings::getValue('bids-support-email');
$message = Yii::$app->controller->view->render('@common/modules/bids/views/bid/mail-all', [
'model' => $this
]);
$headers = "MIME-Version: 1.0\r\n".
"Content-Transfer-Encoding: 8bit\r\n".
"Content-Type: text/html; charset=\"UTF-8\"\r\n".
"X-Mailer: PHP v.".phpversion()."\r\n".
"From: Заявка с сайта TaskOn <robot@task-on.com>\r\n";
$subject = "Заявка с сайта TaskOn";
mail($email, $subject, $message, $headers);
} }
} }
<?php
use yii\helpers\Html;
use common\modules\bids\models\Bid;
?>
Имя: <?=$model->name?><br>
Телефон: <?=$model->phone?><br>
Email: <?=$model->email?><br>
Сообщение: <?=$model->text?><br>
Файл: <?=($model->filename?Html::a($model->filename,\Yii::$app->params['frontUrl'].Bid::FILE_FOLDER.$model->filename):'')?><br>
Дата добавления заявки: <?=date('d.m.Y H:i:s', $model->created_at)?><br>
\ No newline at end of file
...@@ -26,7 +26,7 @@ use yii\grid\GridView; ...@@ -26,7 +26,7 @@ use yii\grid\GridView;
'attribute' => 'url', 'attribute' => 'url',
'format' => 'raw', 'format' => 'raw',
'value' => function($data) { 'value' => function($data) {
return Html::a($data->url, 'http://soc-zaim.ru/'.$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);$data->category->name; return Html::a($data->url, Yii::$app->params['frontUrl'].($data->url!='/'?'/':'').$data->url, ['target' => '_blank', 'title' => 'Просмотреть как страницу видит пользователь', 'data-toggle'=>"tooltip"]);$data->category->name;
} }
], ],
[ [
......
...@@ -79,7 +79,7 @@ class AuthItem extends \common\components\ActiveRecordModel ...@@ -79,7 +79,7 @@ class AuthItem extends \common\components\ActiveRecordModel
} }
public function getAssignment() { public function getAssignment() {
return $this->hasOne(AuthAssignment::className(), ['name' => 'item_name']); return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
} }
public function relations() public function relations()
...@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel ...@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel
'auth_items_childs(parent, child)', 'auth_items_childs(parent, child)',
'condition' => 'type = "' . self::TYPE_TASK . '"' 'condition' => 'type = "' . self::TYPE_TASK . '"'
), ),
'assignments' => array(self::HAS_MANY, 'AuthAssignment', 'itemname'),
'users' => array(self::HAS_MANY, 'User', 'userid', 'through' => 'assignments') 'users' => array(self::HAS_MANY, 'User', 'userid', 'through' => 'assignments')
); );
} }
...@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel ...@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel
if(!$roles) if(!$roles)
{ {
$roles = $this->findAllByAttributes(array( $roles = $this->findAllByAttributes(array(
'type' => self::TYPE_ROLE //'type' => self::TYPE_ROLE
'rule_name' => 'group'
)); ));
} }
return $roles; return $roles;
......
...@@ -9,6 +9,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface ...@@ -9,6 +9,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface
public $name = 'Был произведен переход по ссылке'; public $name = 'Был произведен переход по ссылке';
public $params=[];
/** /**
* @param null|string $conditionName * @param null|string $conditionName
* @return $this mixed * @return $this mixed
...@@ -16,4 +18,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface ...@@ -16,4 +18,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface
public static function init($conditionName=__CLASS__){ public static function init($conditionName=__CLASS__){
return parent::init($conditionName); return parent::init($conditionName);
} }
public function check(){
return true;
}
} }
\ No newline at end of file
...@@ -9,6 +9,8 @@ class CheckEmailToOpening extends ConditionBase implements ConditionInterface { ...@@ -9,6 +9,8 @@ class CheckEmailToOpening extends ConditionBase implements ConditionInterface {
public $name = 'Письмо было открыто'; public $name = 'Письмо было открыто';
public $params=[];
/** /**
* @param null|string $conditionName * @param null|string $conditionName
* @return $this mixed * @return $this mixed
...@@ -16,4 +18,8 @@ class CheckEmailToOpening extends ConditionBase implements ConditionInterface { ...@@ -16,4 +18,8 @@ class CheckEmailToOpening extends ConditionBase implements ConditionInterface {
public static function init($conditionName=__CLASS__){ public static function init($conditionName=__CLASS__){
return parent::init($conditionName); return parent::init($conditionName);
} }
public function check(){
return true;
}
} }
\ No newline at end of file
...@@ -4,4 +4,6 @@ namespace common\modules\triggers\components\conditions\vendor; ...@@ -4,4 +4,6 @@ namespace common\modules\triggers\components\conditions\vendor;
interface ConditionInterface { interface ConditionInterface {
// Функция инициализации // Функция инициализации
public static function init($conditionName=null); public static function init($conditionName=null);
public function check();
} }
\ No newline at end of file
<?php <?php
$email = 'bystrov@kupitsite.ru';
use \common\modules\triggers\components\conditions\Conditions; $sender = new UnisenderAPI();
// Create the send list
$q = Conditions::init()->getConditionById(2); $newListId = $sender->createList();
var_dump($q->params); // Subscribe user to new List
\ No newline at end of file $sender->subscribe(['list_ids' => $newListId, 'fields' => ['email' => $email]]);
// Create new message
$newMessageId=$sender->createEmailMessage('bystrov', $email, 'Testing Subject', 'Testing Body', $newListId);
// Create new campaign
$newCampaign = $sender->createCampaign($newMessageId);
...@@ -370,8 +370,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -370,8 +370,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public function relations() public function relations()
{ {
return array( return array(
'assignment' => array(self::HAS_ONE, 'AuthAssignment', 'userid'), 'assignment' => array(self::HAS_ONE, 'AuthAssignment', 'user_id'),
'city' => array(self::BELONGS_TO, 'City', 'city_id') 'city' => array(self::BELONGS_TO, 'City', 'city_id')
); );
} }
...@@ -409,18 +409,23 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -409,18 +409,23 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public function getRole() public function getRole()
{ {
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one(); $auth = AuthItem::find()->joinWith('assignment', true)
->andWhere(['rule_name' => 'group'])
->andWhere(['auth_assignment.user_id' => $this->id])
->one();
if (!$assigment) return $auth->name;
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
if (!$assigment)
{ {
$assigment = new AuthAssignment(); $assigment = new AuthAssignment();
$assigment->item_name = AuthItem::ROLE_DEFAULT; $assigment->item_name = AuthItem::ROLE_DEFAULT;
$assigment->user_id = $this->id; $assigment->user_id = $this->id;
$assigment->save(false); $assigment->save(false);
} }
return $assigment->role;*/ return $assigment->role;
return 'admin'; return 'admin';*/
} }
public function getRoleName() public function getRoleName()
......
<?php
use yii\db\Migration;
use \yii\db\Schema;
class m160204_115214_add_schedule_table extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->createTable(
'trigger_schedule',
[
'id' => Schema::TYPE_PK,
'sended' => Schema::TYPE_BOOLEAN.' DEFAULT 0 NOT NULL',
'checked' => Schema::TYPE_BOOLEAN.' DEFAULT 0 NOT NULL',
'message_id' => Schema::TYPE_INTEGER.' DEFAULT NULL',
'message' => Schema::TYPE_TEXT.' NOT NULL',
'email' => Schema::TYPE_STRING.' NOT NULL',
'time' => Schema::TYPE_DATETIME,
'date_create' => Schema::TYPE_DATETIME
]
);
}
public function safeDown()
{
$this->dropTable(
'trigger_schedule'
);
}
}
...@@ -82,7 +82,7 @@ return [ ...@@ -82,7 +82,7 @@ return [
//'css_linebreak_pos' => false, //'css_linebreak_pos' => false,
], ],
'user' => [ 'user' => [
'identityClass' => 'common\modules\scoring\models\ScClient', 'identityClass' => 'common\modules\users\models\User',
'loginUrl' => ['/site/login'], 'loginUrl' => ['/site/login'],
'enableAutoLogin' => true, 'enableAutoLogin' => true,
], ],
...@@ -166,6 +166,7 @@ return [ ...@@ -166,6 +166,7 @@ return [
'school' => 'school/course/index', 'school' => 'school/course/index',
'school/course/<id>' => 'school/course/view', 'school/course/<id>' => 'school/course/view',
'school/lesson/<id>' => 'school/lesson/view', 'school/lesson/<id>' => 'school/lesson/view',
'login' => 'site/login',
'<page:(/)>' => 'content/page/view', '<page:(/)>' => 'content/page/view',
'<_m>/<_c>/<_a>/<id:\d+>' => '<_m>/<_c>/<_a>', '<_m>/<_c>/<_a>/<id:\d+>' => '<_m>/<_c>/<_a>',
...@@ -179,10 +180,10 @@ return [ ...@@ -179,10 +180,10 @@ return [
], ],
'authManager' => [ 'authManager' => [
'class' => 'yii\rbac\DbManager', 'class' => 'yii\rbac\DbManager',
/*'connectionID' => 'db', 'connectionID' => 'db',
'itemTable' => 'auth_items', 'itemTable' => 'auth_items',
'assignmentTable' => 'auth_assignments', 'assignmentTable' => 'auth_assignments',
'itemChildTable' => 'auth_item_child',*/ 'itemChildTable' => 'auth_item_child',
'defaultRoles' => [ 'defaultRoles' => [
'user', 'user',
'moderator', 'moderator',
......
...@@ -3,7 +3,7 @@ namespace frontend\controllers; ...@@ -3,7 +3,7 @@ namespace frontend\controllers;
use common\modules\scoring\models\ScRequest; use common\modules\scoring\models\ScRequest;
use Yii; use Yii;
use frontend\models\LoginForm; //use frontend\models\LoginForm;
use frontend\models\PasswordResetRequestForm; use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm; use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm; use frontend\models\SignupForm;
...@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac; ...@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac;
use \yii\web\Response; use \yii\web\Response;
use \yii\widgets\ActiveForm; use \yii\widgets\ActiveForm;
use common\modules\scoring\models\ScClient; use common\modules\scoring\models\ScClient;
use common\models\LoginForm;
/** /**
* Site controller * Site controller
...@@ -115,6 +116,14 @@ class SiteController extends BaseController ...@@ -115,6 +116,14 @@ class SiteController extends BaseController
} }
public function actionLogin() public function actionLogin()
{
//Yii::$app->user->getIdentity()->getRole()
$model = new LoginForm();
$model->load(Yii::$app->request->post());
$model->login();
}
/*public function actionLogin()
{ {
$this->layout = '//main-short'; $this->layout = '//main-short';
$model = new \frontend\models\LoginForm(); $model = new \frontend\models\LoginForm();
...@@ -178,7 +187,7 @@ class SiteController extends BaseController ...@@ -178,7 +187,7 @@ class SiteController extends BaseController
'model' => $model, 'model' => $model,
]); ]);
} }
} }*/
public function actionLogout() public function actionLogout()
{ {
......
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use common\modules\bids\models\Bid;
?>
<div class="hidden">
<div id="zvonok_form" class="popup">
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<?php
$model = new Bid;
$model->scenario = Bid::SCENARIO_CALLBACK;
$form = ActiveForm::begin([
'action' => '/',
'options' => [
'class' => 'valid_form bids-form',
],
]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя',
'class' => 'input_st'
])->label(false); ?>
<?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваш телефон',
'class' => 'input_st'
])->label(false); ?>
<?php echo Html::submitButton('Заказать звонок', ['class' => 'save-button popup_bt_send']); ?>
<?php ActiveForm::end(); ?>
</div>
</div>
\ No newline at end of file
...@@ -22,5 +22,6 @@ ...@@ -22,5 +22,6 @@
<?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/jquery.inputmask.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/inputmask.phone.extensions.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/common.js', ['position' => yii\web\View::POS_END ]);?>
<?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?> <?php $this->registerJsFile('/js/jquery.form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file <?php $this->registerJsFile('/js/bids-form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
...@@ -6,67 +6,6 @@ use yii\helpers\Url; ...@@ -6,67 +6,6 @@ use yii\helpers\Url;
use common\modules\bids\models\Bid; use common\modules\bids\models\Bid;
?> ?>
<style type="text/css">
.footer_form input,
.footer_form textarea {
margin-bottom: 9px;
}
.field-bid-file {
margin: 0;
}
</style>
<?php
$js = <<<JS
$('#bid-phone').inputmask("phone", {
url: "js/phone-codes/phone-codes.js",
});
$('form#form_foot').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, filebool = false, file, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
data.append("Bid[file]", file);
}
xhr.open("POST", '/bids/bid/add', true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
if(response.success)
{
form.find('input[name!="scenario"], textarea').val('');
}
}
}
}).on('submit', function(e){
return false;
});
JS;
$this->registerJs($js);
?>
<footer> <footer>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
...@@ -84,27 +23,36 @@ $this->registerJs($js); ...@@ -84,27 +23,36 @@ $this->registerJs($js);
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/',
'options' => [ 'options' => [
'class' => 'footer_form', 'class' => 'footer_form bids-form',
'enctype' => 'multipart/form-data' 'enctype' => 'multipart/form-data'
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?> <?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name')->textInput([ <?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя*', 'placeholder' => 'Ваше имя*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'phone')->textInput([ <?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Телефон*', 'placeholder' => 'Телефон*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'email')->textInput([ <?php echo $form->field($model, 'email', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'E-mail*', 'placeholder' => 'E-mail*',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
])->label(false); ?> ]); ?>
<?php echo $form->field($model, 'text')->textArea([ <?php echo $form->field($model, 'text')->textArea([
'placeholder' => 'Опишите в двух словах ваш проект', 'placeholder' => 'Опишите в двух словах ваш проект',
...@@ -115,7 +63,9 @@ $this->registerJs($js); ...@@ -115,7 +63,9 @@ $this->registerJs($js);
<div class="file_upload_bt"> <div class="file_upload_bt">
<div class="file-upload"> <div class="file-upload">
<label> <label>
<?php echo $form->field($model, 'file')->fileInput()->label(false); ?> <?php echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])->fileInput(); ?>
<span>Выбрать файл</span> <span>Выбрать файл</span>
</label> </label>
</div> </div>
...@@ -166,15 +116,4 @@ $this->registerJs($js); ...@@ -166,15 +116,4 @@ $this->registerJs($js);
</div> </div>
</footer> </footer>
<div class="hidden"> <?php echo $this->render('block/callback'); ?>
<div id="zvonok_form" class="popup"> \ No newline at end of file
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<form class="valid_form">
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя">
<input type="tel" class="input_st field-input required email" placeholder="Ваш телефон">
<button class="save-button popup_bt_send">Заказать звонок</button>
</form>
</div>
</div>
\ No newline at end of file
...@@ -36,15 +36,4 @@ ...@@ -36,15 +36,4 @@
</div> </div>
</footer> </footer>
<div class="hidden"> <?php echo $this->render('block/callback'); ?>
<div id="zvonok_form" class="popup"> \ No newline at end of file
<div class="txtbtnclose">Закрыть</div>
<span class="popup__title">Заказать звонок</span>
<span class="popup__subtittle">Чтобы мы могли вам перезвонить укажите свой номер телефона:</span>
<form class="valid_form">
<input type="text" class="input_st field-input required alphanumeric" placeholder="Ваше имя">
<input type="tel" class="input_st field-input required email" placeholder="Ваш телефон">
<button class="save-button popup_bt_send">Заказать звонок</button>
</form>
</div>
</div>
\ No newline at end of file
...@@ -19,4 +19,5 @@ ...@@ -19,4 +19,5 @@
<?php $this->registerCssFile('/css/fonts.css');?> <?php $this->registerCssFile('/css/fonts.css');?>
<?php $this->registerCssFile('/css/screen.css');?> <?php $this->registerCssFile('/css/screen.css');?>
<?php $this->registerCssFile('/css/media.css');?> <?php $this->registerCssFile('/css/media.css');?>
\ No newline at end of file <?php $this->registerCssFile('/css/custom.css');?>
\ No newline at end of file
<?php <?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use \common\models\Settings; use \common\models\Settings;
use \common\modules\bids\models\Bid;
?> ?>
<script type="text/javascript"> <script type="text/javascript">
...@@ -75,24 +79,60 @@ use \common\models\Settings; ...@@ -75,24 +79,60 @@ use \common\models\Settings;
<div class="row"> <div class="row">
<div class="col-md-12 col-xs-12 col-sm-12"> <div class="col-md-12 col-xs-12 col-sm-12">
<div class="sect_cont_block"> <div class="sect_cont_block">
<form class="sect_cont_form" id="form_foot"> <?php
<input type="text" placeholder="Ваше имя*" name="name" class="sect_cont_form__input field-input required alphanumeric"> $model = new Bid;
<input type="tel" placeholder="Телефон*" name="phone" class="sect_cont_form__input field-input required alphanumeric"> $model->scenario = Bid::SCENARIO_CALLBACK;
<textarea placeholder="Текст сообщения" class="sect_cont_form__textarea"></textarea>
$form = ActiveForm::begin([
'id' => 'form_foot',
'action' => '/',
'options' => [
'class' => 'sect_cont_form bids-form',
'enctype' => 'multipart/form-data'
],
]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario); ?>
<?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Ваше имя*',
'class' => 'sect_cont_form__input'
]); ?>
<?php echo $form->field($model, 'phone', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => []
])->textInput([
'placeholder' => 'Телефон*',
'class' => 'sect_cont_form__input'
]); ?>
<?php echo $form->field($model, 'text')->textArea([
'placeholder' => 'Опишите в двух словах ваш проект',
'class' => 'sect_cont_form__textarea'
])->label(false); ?>
<div class="file-upload_block_cs"> <div class="file-upload_block_cs">
<div class="file_upload_bt_cs"> <div class="file_upload_bt_cs">
<div class="file-upload_cs"> <div class="file-upload_cs">
<label> <label>
<input type="file" name="file"> <?php echo $form->field($model, 'file', [
<span>Выбрать файл</span> 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
</label> ])->fileInput(); ?>
<span>Выбрать файл</span>
</label>
</div> </div>
<input type="text" id="filename" class="filename_cs" disabled> <input type="text" id="filename" class="filename_cs" disabled>
<div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</div> <div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</div>
</div> </div>
</div> </div>
<button class="btn-default save-button">Отправить</button>
</form> <?php echo Html::submitButton('Отправить', ['class' => 'btn-default save-button']); ?>
<?php ActiveForm::end(); ?>
</div> </div>
</div> </div>
</div> </div>
......
.bids-form input,
.bids-form textarea {
margin-bottom: 9px;
}
.field-bid-file {
margin: 0;
}
.has-error input {
background: #fff url(../images/icon-fail.png) no-repeat 96% center;
border: 1px solid #E9A2A2;
}
\ No newline at end of file
$('.bids-form input[name="Bid[phone]"]').inputmask("phone", {
mask: "+7(999)999-99-99"
});
$('form.bids-form').on('beforeSubmit', function(e) {
var form = $(this), xhr = new XMLHttpRequest, filebool = false, file, data = new FormData();
form.find('input, textarea').each(function(){
data.append($(this).attr('name'), $(this).val());
});
if(form.find('input[type=file]').length) {
file = form.find('input[type=file]')[0].files[0];
filebool = !filebool;
data.append("Bid[file]", file);
}
xhr.open("POST", '/bids/bid/add', true);
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.send(data);
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4){
try
{
var response = JSON.parse(xhr.responseText);
}
catch(e)
{
var response = xhr.responseText;
}
if(response.success)
{
form.find('input[name!="scenario"], textarea').val('');
}
}
}
}).on('submit', function(e){
return false;
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment