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 =
'://'.
// Get domain portion
$_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 /)
//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 /)
......
<?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
public function init()
{
parent::init();
// custom initialization code goes here
}
public static function name()
......
......@@ -4,6 +4,8 @@ namespace common\modules\bids\models;
use Yii;
use \common\models\Settings;
/**
* This is the model class for table "bids".
*
......@@ -99,6 +101,20 @@ class Bid extends \common\components\ActiveRecordModel
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;
'attribute' => 'url',
'format' => 'raw',
'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
}
public function getAssignment() {
return $this->hasOne(AuthAssignment::className(), ['name' => 'item_name']);
return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
}
public function relations()
......@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel
'auth_items_childs(parent, child)',
'condition' => 'type = "' . self::TYPE_TASK . '"'
),
'assignments' => array(self::HAS_MANY, 'AuthAssignment', 'itemname'),
'users' => array(self::HAS_MANY, 'User', 'userid', 'through' => 'assignments')
);
}
......@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel
if(!$roles)
{
$roles = $this->findAllByAttributes(array(
'type' => self::TYPE_ROLE
//'type' => self::TYPE_ROLE
'rule_name' => 'group'
));
}
return $roles;
......
......@@ -9,6 +9,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface
public $name = 'Был произведен переход по ссылке';
public $params=[];
/**
* @param null|string $conditionName
* @return $this mixed
......@@ -16,4 +18,8 @@ class CheckClickingOnTheLink extends ConditionBase implements ConditionInterface
public static function init($conditionName=__CLASS__){
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 {
public $name = 'Письмо было открыто';
public $params=[];
/**
* @param null|string $conditionName
* @return $this mixed
......@@ -16,4 +18,8 @@ class CheckEmailToOpening extends ConditionBase implements ConditionInterface {
public static function init($conditionName=__CLASS__){
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;
interface ConditionInterface {
// Функция инициализации
public static function init($conditionName=null);
public function check();
}
\ No newline at end of file
<?php
use \common\modules\triggers\components\conditions\Conditions;
$q = Conditions::init()->getConditionById(2);
var_dump($q->params);
\ No newline at end of file
$email = 'bystrov@kupitsite.ru';
$sender = new UnisenderAPI();
// Create the send list
$newListId = $sender->createList();
// Subscribe user to new List
$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,7 +370,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public function relations()
{
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')
);
}
......@@ -409,8 +409,13 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
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();
return $auth->name;
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
if (!$assigment)
{
$assigment = new AuthAssignment();
......@@ -419,8 +424,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
$assigment->save(false);
}
return $assigment->role;*/
return 'admin';
return $assigment->role;
return 'admin';*/
}
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 [
//'css_linebreak_pos' => false,
],
'user' => [
'identityClass' => 'common\modules\scoring\models\ScClient',
'identityClass' => 'common\modules\users\models\User',
'loginUrl' => ['/site/login'],
'enableAutoLogin' => true,
],
......@@ -166,6 +166,7 @@ return [
'school' => 'school/course/index',
'school/course/<id>' => 'school/course/view',
'school/lesson/<id>' => 'school/lesson/view',
'login' => 'site/login',
'<page:(/)>' => 'content/page/view',
'<_m>/<_c>/<_a>/<id:\d+>' => '<_m>/<_c>/<_a>',
......@@ -179,10 +180,10 @@ return [
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
/*'connectionID' => 'db',
'connectionID' => 'db',
'itemTable' => 'auth_items',
'assignmentTable' => 'auth_assignments',
'itemChildTable' => 'auth_item_child',*/
'itemChildTable' => 'auth_item_child',
'defaultRoles' => [
'user',
'moderator',
......
......@@ -3,7 +3,7 @@ namespace frontend\controllers;
use common\modules\scoring\models\ScRequest;
use Yii;
use frontend\models\LoginForm;
//use frontend\models\LoginForm;
use frontend\models\PasswordResetRequestForm;
use frontend\models\ResetPasswordForm;
use frontend\models\SignupForm;
......@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac;
use \yii\web\Response;
use \yii\widgets\ActiveForm;
use common\modules\scoring\models\ScClient;
use common\models\LoginForm;
/**
* Site controller
......@@ -115,6 +116,14 @@ class SiteController extends BaseController
}
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';
$model = new \frontend\models\LoginForm();
......@@ -178,7 +187,7 @@ class SiteController extends BaseController
'model' => $model,
]);
}
}
}*/
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
......@@ -24,3 +24,4 @@
<?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/bids-form.js', ['position' => yii\web\View::POS_END ]);?>
\ No newline at end of file
......@@ -6,67 +6,6 @@ use yii\helpers\Url;
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>
<div class="container">
<div class="row">
......@@ -84,27 +23,36 @@ $this->registerJs($js);
'id' => 'form_foot',
'action' => '/',
'options' => [
'class' => 'footer_form',
'class' => 'footer_form bids-form',
'enctype' => 'multipart/form-data'
],
]); ?>
<?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' => 'Ваше имя*',
'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' => 'Телефон*',
'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*',
'class' => 'footer_form__input'
])->label(false); ?>
]); ?>
<?php echo $form->field($model, 'text')->textArea([
'placeholder' => 'Опишите в двух словах ваш проект',
......@@ -115,7 +63,9 @@ $this->registerJs($js);
<div class="file_upload_bt">
<div class="file-upload">
<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>
</label>
</div>
......@@ -166,15 +116,4 @@ $this->registerJs($js);
</div>
</footer>
<div class="hidden">
<div id="zvonok_form" class="popup">
<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
<?php echo $this->render('block/callback'); ?>
\ No newline at end of file
......@@ -36,15 +36,4 @@
</div>
</footer>
<div class="hidden">
<div id="zvonok_form" class="popup">
<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
<?php echo $this->render('block/callback'); ?>
\ No newline at end of file
......@@ -20,3 +20,4 @@
<?php $this->registerCssFile('/css/fonts.css');?>
<?php $this->registerCssFile('/css/screen.css');?>
<?php $this->registerCssFile('/css/media.css');?>
<?php $this->registerCssFile('/css/custom.css');?>
\ No newline at end of file
<?php
use yii\widgets\ActiveForm;
use yii\helpers\Html;
use \common\models\Settings;
use \common\modules\bids\models\Bid;
?>
<script type="text/javascript">
......@@ -75,15 +79,49 @@ use \common\models\Settings;
<div class="row">
<div class="col-md-12 col-xs-12 col-sm-12">
<div class="sect_cont_block">
<form class="sect_cont_form" id="form_foot">
<input type="text" placeholder="Ваше имя*" name="name" class="sect_cont_form__input field-input required alphanumeric">
<input type="tel" placeholder="Телефон*" name="phone" class="sect_cont_form__input field-input required alphanumeric">
<textarea placeholder="Текст сообщения" class="sect_cont_form__textarea"></textarea>
<?php
$model = new Bid;
$model->scenario = Bid::SCENARIO_CALLBACK;
$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_bt_cs">
<div class="file-upload_cs">
<label>
<input type="file" name="file">
<?php echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])->fileInput(); ?>
<span>Выбрать файл</span>
</label>
</div>
......@@ -91,8 +129,10 @@ use \common\models\Settings;
<div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</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>
......
.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