Commit 9e38e76b authored by Шакарим Сапа's avatar Шакарим Сапа

Merge remote-tracking branch 'origin/master'

parents 300fdde8 9a707a6d
......@@ -10,6 +10,7 @@ use yii\web\Response;
use yii\web\UploadedFile;
use common\modules\bids\models\Bid;
use common\modules\bids\models\BidFile;
/**
* BidAdminController implements the CRUD actions for Bid model.
......@@ -30,31 +31,46 @@ class BidController extends \common\components\BaseController
*/
public function actionAdd()
{
Yii::$app->response->format = Response::FORMAT_JSON;
$model = new Bid;
$model->scenario = Yii::$app->request->post('scenario');
if(Yii::$app->request->isAjax)
if(Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()))
{
$model->load(Yii::$app->request->post());
$model->file = UploadedFile::getInstance($model, 'file');
$transaction = Yii::$app->db->beginTransaction();
Yii::$app->response->format = Response::FORMAT_JSON;
$model->filename = $_POST['file_name'];
if($model->validate())
try
{
/*if($model->file)
if($model->save())
{
$model->upload();
$model->file = null;
}*/
// Yii::$app->user->identity->afterSubscribe(12);
if($model->file)
{
foreach ($model->file as $filename)
{
$file = new BidFile;
$file->bid_id = $model->id;
$file->filename = $filename;
$model->save();
$model->send();
$file->save();
}
}
return ['success' => true];
}
else
{
return ActiveForm::validate($model);
$model->send();
$transaction->commit();
return ['success' => true];
}
else
{
return ActiveForm::validate($model);
}
}
catch (Exception $e)
{
$transaction->rollBack();
throw $e;
}
}
else
......@@ -66,16 +82,24 @@ class BidController extends \common\components\BaseController
public function actionUploadFiles()
{
$model = new Bid();
if (!empty($_FILES)) {
Yii::$app->response->format = Response::FORMAT_JSON;
$model = new BidFile;
$model->file = UploadedFile::getInstanceByName('file');
$tempFile = $_FILES['file']['tmp_name'];
if($model->file)
{
if(!file_exists(BidFile::path()))
{
mkdir(BidFile::path(), 0777, true);
}
$targetPath = $model->getPath();
$targetFile = $targetPath. $_FILES['file']['name'];
$model->filename = date('dmYHis-') . uniqid() . '.' . $model->file->extension;
$model->file->saveAs(BidFile::path() . $model->filename);
move_uploaded_file($tempFile,$targetFile);
return $_FILES['file']['name'];
return [
'filename' => $model->filename
];
}
}
}
......@@ -30,10 +30,6 @@ class Bid extends \common\components\ActiveRecordModel
const TAG_INVOLVEMENT = 'Вовлечение';
const TAG_TREATMENT = 'Обращение';
const FILE_FOLDER = '/uploads/bids/';
public $file;
public static $form_titles = [
self::FORM_PROJECT => 'Расчитать проект',
self::FORM_CALLBACK => 'Обратный звонок',
......@@ -46,6 +42,8 @@ class Bid extends \common\components\ActiveRecordModel
self::FORM_SUBSCRIBE => 'Ошибки',
];
public $file;
/**
* @inheritdoc
*/
......@@ -81,12 +79,13 @@ class Bid extends \common\components\ActiveRecordModel
[['email'], 'required', 'on' => self::SCENARIO_SUBSCRIBE],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif, xls, xlsx, doc, docx, pdf'],
[['text'], 'string'],
[['name'], 'string', 'max' => 100],
[['phone'], 'string', 'max' => 30],
[['email'], 'string', 'max' => 70],
[['filename', 'form'], 'string', 'max' => 50],
[['form'], 'string', 'max' => 50],
[['file'], 'safe'],
];
}
......@@ -100,8 +99,6 @@ class Bid extends \common\components\ActiveRecordModel
'name' => 'Имя',
'phone' => 'Телефон',
'email' => 'Email',
'filename' => 'Прикрепленный файл',
'file' => 'Прикрепленный файл',
'text' => 'Сообщение',
'form' => 'Форма отправки',
'created_at' => 'Дата добавления',
......@@ -109,26 +106,13 @@ class Bid extends \common\components\ActiveRecordModel
];
}
public function getUrl()
{
return Yii::$app->params['frontUrl'] . self::FILE_FOLDER . $this->filename;
}
public function getPath()
{
return Yii::getAlias('@frontend/web') . self::FILE_FOLDER;
}
public function upload()
/**
* @return \yii\db\ActiveQuery
*/
public function getFiles()
{
if(!file_exists($this->getPath()))
{
mkdir($this->getPath(), 0777, true);
}
$this->filename = date('dmYHis-') . uniqid() . '.' . $this->file->extension;
$this->file->saveAs($this->getPath() . $this->filename);
}
return $this->hasMany(BidFile::className(), ['bid_id' => 'id']);
}
public function send()
{
......
<?php
namespace common\modules\bids\models;
use Yii;
/**
* This is the model class for table "bids_files".
*
* @property integer $id
* @property integer $bid_id
* @property string $filename
*
* @property Bids $bid
*/
class BidFile extends \common\components\ActiveRecordModel
{
const FILE_FOLDER = '/uploads/bids/';
public $file;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'bids_files';
}
/**
* @inheritdoc
*/
public function name()
{
return 'Файл заявки';
}
/**
* @inheritdoc
*/
public function behaviors()
{
return [
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['bid_id'], 'required'],
[['bid_id'], 'integer'],
[['filename'], 'string', 'max' => 100],
[['file'], 'file', 'skipOnEmpty' => true, 'extensions' => 'png, jpg, jpeg, gif, xls, xlsx, doc, docx, pdf', 'maxFiles' => 4],
[['bid_id'], 'exist', 'skipOnError' => true, 'targetClass' => Bid::className(), 'targetAttribute' => ['bid_id' => 'id']],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'file' => 'Прикрепленный файл',
'bid_id' => 'Заявка',
'filename' => 'Файл',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getBid()
{
return $this->hasOne(Bid::className(), ['id' => 'bid_id']);
}
public function getUrl()
{
return Yii::$app->params['frontUrl'] . self::FILE_FOLDER . $this->filename;
}
public static function path()
{
return Yii::getAlias('@frontend/web') . self::FILE_FOLDER;
}
}
......@@ -19,7 +19,7 @@ class SearchBid extends Bid
{
return [
[['id'], 'integer'],
[['name', 'phone', 'email', 'filename', 'text', 'created_at', 'form'], 'safe'],
[['name', 'phone', 'email', 'text', 'created_at', 'form'], 'safe'],
];
}
......@@ -67,7 +67,6 @@ class SearchBid extends Bid
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'phone', $this->phone])
->andFilterWhere(['like', 'email', $this->email])
->andFilterWhere(['like', 'filename', $this->filename])
->andFilterWhere(['like', 'text', $this->text]);
return $dataProvider;
......
......@@ -26,11 +26,19 @@ $this->params['breadcrumbs'][] = $this->title;
'phone',
'email:email',
[
'attribute' => 'filename',
'header' => 'Файлы',
'format' => 'html',
'value' => function($model)
{
return ($model->filename?Html::a($model->filename, $model->getUrl()):null);
$files = [];
if($model->files)
{
foreach ($model->files as $file)
{
$files[] = Html::a($file->filename, $file->getUrl());
}
}
return implode('<br>', $files);
}
],
'text:ntext',
......
<?php
use yii\helpers\Html;
use common\modules\bids\models\Bid;
use common\modules\bids\models\BidFile;
?>
Имя: <?=$model->name?><br>
......@@ -12,7 +12,15 @@ Email: <?=$model->email?><br>
Сообщение: <?=$model->text?><br>
Файл: <?=($model->filename?Html::a($model->filename,\Yii::$app->params['frontUrl'].Bid::FILE_FOLDER.$model->filename):'')?><br>
<?php if($model->files) : ?>
<hr>
Файлы:
<?php foreach ($model->files as $file)
{
echo Html::a($file->filename,\Yii::$app->params['frontUrl'].BidFile::FILE_FOLDER.$file->filename) . '<br>';
} ?>
<hr>
<?php endif; ?>
Дата добавления заявки: <?=date('d.m.Y H:i:s', $model->created_at)?><br>
......
......@@ -82,4 +82,16 @@ class PostLang extends \common\components\ActiveRecordModel
{
return $this->hasOne(Languages::className(), ['id' => 'lang_id']);
}
public function cutText($chars)
{
$text = strip_tags($this->text, '<a>');
$text = $text . " ";
$text = substr($text, 0, $chars);
$text = substr($text, 0, strrpos($text, ' '));
$text = $text . "...";
return '<p>'.$text.'</p>';
}
}
......@@ -17,16 +17,7 @@ use yii\helpers\Url;
<span class="article_short_view">
<?=$model->getViews()->count()?>
<div class="blog_toltip_left">Количество просмотров</div>
</span>
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
</span>
</div>
<div class="article_short_tags">
......@@ -43,7 +34,7 @@ use yii\helpers\Url;
echo Html::img($model->preview);
endif; ?>
<?=$model->lang->text?>
<?=$model->lang->cutText(650)?>
</div>
</article>
......
......@@ -122,8 +122,8 @@ use common\modules\bids\models\Bid;
<?php echo $form->field($model, 'message')->textArea([
'placeholder' => 'Что хочу почитать?
Например: Хочу почитать про то, как настраивается контекстная реклама.
Про то как выставляются ставки.',
Например: Хочу почитать про то, как настраивается контекстная реклама.
Про то как выставляются ставки.',
'class' => 'sect_cont_form__textarea'
])->label(false); ?>
......
<ul class="article_short_social">
<li>
<a href="#" onclick="window.open('http://vkontakte.ru/share.php?url=<?=$link?>&title=<?=$title?>', 'Soc', 'screenX=100,screenY=100,height=500,width=500,location=no,toolbar=no,directories=no,menubar=no,status=no'); return false;"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#" onclick="window.open('http://www.facebook.com/share.php?u=<?=$title?>', 'Soc', 'screenX=100,screenY=100,height=500,width=500,location=no,toolbar=no,directories=no,menubar=no,status=no'); return false;"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#" onclick="window.open('http://twitter.com/timeline/home?status=<?=$title?>%20<?=$link?>', 'Soc', 'screenX=100,screenY=100,height=500,width=500,location=no,toolbar=no,directories=no,menubar=no,status=no'); return false;"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#" onclick="window.open('https://plus.google.com/share?url=<?=$link?>', 'Soc', 'screenX=100,screenY=100,height=500,width=500,location=no,toolbar=no,directories=no,menubar=no,status=no'); return false;"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<!-- <a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a> -->
</li>
</ul>
\ No newline at end of file
<?php
use yii\helpers\Html;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model common\modules\blog\models\Post */
......@@ -21,15 +22,9 @@ use yii\helpers\Html;
<?=$model->getViews()->count()?>
<div class="blog_toltip_left">Количество просмотров</div>
</span>
<!-- <ul class="article_short_social">
<li>
<a href="#"><img src="/images/icon/sh_social_vk.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_fb.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_tw.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_gp.png" height="30" width="30" alt=""></a>
<a href="#"><img src="/images/icon/sh_social_t.png" height="30" width="30" alt=""></a>
</li>
</ul> -->
<?=$this->render('_social', ['link' => Url::to(['/blog/'.$model->url], true), 'title' => $model->lang->title])?>
</div>
<div class="article_short_tags">
......
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160224_162315_upgrade_bids_files extends Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
$this->createTable('bids_files', [
'id' => Schema::TYPE_PK,
'bid_id' => Schema::TYPE_INTEGER . '(11) NOT NULL',
'filename' => Schema::TYPE_STRING . '(100) DEFAULT NULL'
]);
$this->dropColumn('bids', 'filename');
$this->addForeignKey(
'fk_bids_files_bid_id_bids_id',
'bids_files', 'bid_id',
'bids', 'id'
);
}
public function safeDown()
{
$this->dropForeignKey('fk_bids_files_bid_id_bids_id', 'bids_files');
$this->dropTable('bids_files');
$this->addColumn('bids', 'filename', Schema::TYPE_STRING . '(50) DEFAULT NULL');
}
}
......@@ -40,8 +40,8 @@ $more = CoContent::find()
<div class="col-md-6 col-xs-6 col-sm-12">
<div class="subsc_block">
<h2 class="subsc_block_title">Подписаться на обновление</h2>
<div class="subsc_block_txt">Нам будет приятно, если вы захотите подписаться на обновление наших проектов</div>
<h2 class="subsc_block_title">Подписаться на обновления</h2>
<div class="subsc_block_txt">Нам будет приятно, если вы захотите подписаться на обновления наших проектов</div>
<?php
$model = new Bid;
$model->scenario = Bid::SCENARIO_SUBSCRIBE;
......
......@@ -75,9 +75,6 @@ FileUploadBundle::register($this);
<div class="file_upload_bt">
<div class="file-upload">
<label>
<?php/* echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])->fileInput();*/ ?>
<span>Выбрать файл</span>
</label>
</div>
......@@ -85,7 +82,9 @@ FileUploadBundle::register($this);
<div class="file_drop">Перетащите файл в данную область<br/> или выберите файл с компьютера</div>
</div>
</div>
<input type="hidden" name="file_name" id='file_name' value=""/>
<div id="files-zone">
</div>
<?php echo Html::submitButton('Рассчитать проект', ['class' => 'btn-default save-button']); ?>
<?php ActiveForm::end(); ?>
......
......@@ -66,7 +66,7 @@ FileUploadBundle::register($this);
</div>
<div class="col-md-5 col-xs-6 col-sm 12">
<div class="support_block">
<div class="support_block__txt">Для вашего удобства мы подготовили видео в котором рассказывается как правильно ставить задачу в отдел технической поддержки.</div>
<div class="support_block__txt">Для вашего удобства мы подготовили видео, в котором рассказывается, как правильно ставить задачу в отдел технической поддержки.</div>
<div class="support_block__link_pv"><a href="#" class="">Смотреть видео</a></div>
</div>
</div>
......@@ -129,17 +129,15 @@ FileUploadBundle::register($this);
<div class="file_upload_bt_cs">
<div class="file-upload_cs">
<label>
<?php /*echo $form->field($model, 'file', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>'
])->fileInput(); */?>
<span>Выбрать файл</span>
</label>
</div>
<!--<input type="text" id="filename" class="filename_cs" disabled>-->
<div class="file_drop_cs">Перетащите файл в данную область<br/> или выберите файл с компьютера</div>
</div>
</div>
<input type="hidden" name="file_name" id='file_name' value=""/>
<div id="files-zone">
</div>
<?php echo Html::submitButton('Отправить', ['class' => 'btn-default save-button']); ?>
......
......@@ -5,7 +5,8 @@
.field-bid-file {
margin: 0;
}
.has-error input {
.has-error input,
.has-error textarea {
background: #fff url(../images/icon-fail.png) no-repeat 96% center !important;
border: 1px solid #E9A2A2 !important;
}
......@@ -159,6 +160,11 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
.video_sec a.toggle_bottom {
margin-top: 153px;
}
.top_keys_soc a.toggle_bottom {
position: relative;
top: 128px;
margin-top: 0;
}
.bx-wrapper .bx-prev {
background: #344555 url(../images/arrow_left.png) no-repeat center center;
}
......@@ -404,6 +410,10 @@ a.toggle_bottom:hover .icon-arrowDown2:after, a.toggle_bottom:active .icon-arrow
float: none;
margin: 20px auto 40px;
}
.top_keys_soc a.toggle_bottom {
top: 0px;
margin: 30px auto;
}
}
@media only screen and (max-width: 479px) and (min-width: 320px) {
......
......@@ -32,19 +32,22 @@ $('form.bids-form').on('beforeSubmit', function(e) {
var response = xhr.responseText;
}
form.find('.has-error').removeClass('has-error');
if(response.success)
{
form.find('input:not(.not_clear), textarea').val('');
$('.send_secce').show();
form.find('#files-zone').html('');
$('.dz-preview.dz-processing').remove();
dataLayer.push({
'event': 'UA_event',
'Catagory': form.data('tag'),
'Action': form.data('title'),
'Label': 'Успешно'
});
form.find('.has-error').removeClass('has-error');
}
else
{
......
......@@ -6,17 +6,18 @@ $(document).ready(function() {
// var myDropzone = new Dropzone("div#block_upload", {url: "/bids/bid/upload-files", maxFiles: 1});
Dropzone.options.blockUpload = {
url: "/bids/bid/upload-files",
maxFiles: 1,
maxFiles: 4,
addRemoveLinks: true,
dictRemoveFile: 'Удалить',
/*accept: function(file, done) {
$('#file_name').val(file.name);
done();
},*/
success: function(first,response) {
$('#file_name').val(response);
success: function(first, response)
{
$('#files-zone').append('<input type="hidden" name="Bid[file][]" value="'+response.filename+'" />');
$('.file_drop').hide();
$('.file_drop_cs').hide();
}
};
};
});
\ 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