コード例 #1
0
ファイル: SiteController.php プロジェクト: dench/resistor
 /**
  * Displays homepage.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new SaleSearch();
     $lastItems = Sale::lastItems();
     $weekItems = Sale::weekItems();
     return $this->render('index', ['searchModel' => $searchModel, 'last' => $lastItems, 'week' => $weekItems]);
 }
コード例 #2
0
ファイル: SaleSearch.php プロジェクト: dench/resistor
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Sale::find();
     //$query->joinWith(['views', 'facilities']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]], 'pagination' => ['pageSize' => 20]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     if (!empty($this->name)) {
         $query->leftJoin('sale_lang', 'sale_lang.id = sale.id');
         $query->groupBy('sale.id');
     }
     if ($this->view_ids) {
         $query->leftJoin('sale_view', 'sale_view.sale_id = sale.id');
         $query->groupBy('sale.id');
     }
     if ($this->facility_ids) {
         $query->leftJoin('sale_facilities', 'sale_facilities.sale_id = sale.id');
         $query->groupBy('sale.id');
     }
     $query->andFilterWhere(['sale.id' => $this->id, 'code' => $this->code, 'object_id' => $this->object_id, 'region_id' => $this->region_id, 'district_id' => $this->district_id, 'type_id' => $this->type_id, 'parking_id' => $this->parking_id, 'bathroom' => $this->bathroom, 'bedroom' => $this->bedroom, 'solarpanel' => $this->solarpanel, 'sauna' => $this->sauna, 'furniture' => $this->furniture, 'conditioner' => $this->conditioner, 'heating' => $this->heating, 'storage' => $this->storage, 'tennis' => $this->tennis, 'status' => $this->status, 'sold' => $this->sold, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'top' => $this->top]);
     $query->andFilterWhere(['like', 'sale_lang.name', $this->name])->andFilterWhere(['like', 'commission', $this->commission])->andFilterWhere(['like', 'gps', $this->gps])->andFilterWhere(['like', 'contacts', $this->contacts])->andFilterWhere(['like', 'owner', $this->owner])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['>=', 'price', $this->price_from])->andFilterWhere(['<=', 'price', $this->price_to])->andFilterWhere(['>=', 'year', $this->year_from])->andFilterWhere(['<=', 'year', $this->year_to])->andFilterWhere(['>=', 'covered', $this->covered_from])->andFilterWhere(['<=', 'covered', $this->covered_to])->andFilterWhere(['>=', 'uncovered', $this->uncovered_from])->andFilterWhere(['<=', 'uncovered', $this->uncovered_to])->andFilterWhere(['>=', 'plot', $this->plot_from])->andFilterWhere(['<=', 'plot', $this->plot_to])->andFilterWhere(['>=', 'bathroom', $this->bathroom_from])->andFilterWhere(['<=', 'bathroom', $this->bathroom_to])->andFilterWhere(['>=', 'bedroom', $this->bedroom_from])->andFilterWhere(['<=', 'bedroom', $this->bedroom_to])->andFilterWhere(['in', 'sale_view.view_id', $this->view_ids])->andFilterWhere(['in', 'sale_facilities.facility_id', $this->facility_ids]);
     //$command = $query->createCommand();
     //echo $command->sql;
     return $dataProvider;
 }
コード例 #3
0
ファイル: SaleController.php プロジェクト: dench/resistor
 public function actionIndex($id)
 {
     $model = Sale::findOne($id);
     if (!$model || $model->status != 1) {
         throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
     }
     return $this->render('index', ['model' => $model]);
 }
コード例 #4
0
ファイル: SearchController.php プロジェクト: dench/resistor
 /**
  * Finds the Sale model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Sale the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Sale::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: ParserAlias.php プロジェクト: dench/resistor
 public static function type()
 {
     $alias = static::getCategory('type');
     $temp = Sale::getTypeList();
     $origin = [];
     foreach ($temp as $id => $value) {
         $origin[$value] = $id;
     }
     return array_merge($origin, $alias);
 }
コード例 #6
0
ファイル: AjaxController.php プロジェクト: dench/resistor
 public function actionDistrictList()
 {
     if (isset($_POST['depdrop_parents'])) {
         if ($parents = $_POST['depdrop_parents']) {
             $district_ids = Sale::find()->select('district_id')->where(['region_id' => $parents[0]])->groupBy(['district_id'])->column();
             $out = District::getListByIds($district_ids);
             foreach ($out as $key => $value) {
                 $result[] = ['id' => $key, 'name' => $value];
             }
             print Json::encode(['output' => @$result, 'selected' => '']);
             return;
         }
     }
 }
コード例 #7
0
ファイル: SalePhoto.php プロジェクト: dench/resistor
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSale()
 {
     return $this->hasOne(Sale::className(), ['id' => 'sale_id']);
 }
コード例 #8
0
ファイル: Product.php プロジェクト: baranov-nt/some-2
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSales()
 {
     return $this->hasMany(Sale::className(), ['product_id' => 'id']);
 }
コード例 #9
0
ファイル: prepareItem.php プロジェクト: dench/resistor
echo $form->field($sale, 'district_id', ['template' => '{input}'])->widget(DepDrop::className(), ['data' => $district_list, 'options' => ['id' => 'district_id_' . $form->id, 'prompt' => '- ' . @$origin['district'] . ' -', 'data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('district_id'), 'data-value' => @$origin['district']], 'pluginOptions' => ['depends' => ['region_id_' . $form->id], 'placeholder' => false, 'url' => Url::to(['/district/list'])]]);
?>
            </div>
            <div class="col-md-2">
                <?php 
echo $form->field($sale, 'gps', ['template' => '{input}'])->textInput(['data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('gps')]);
?>
            </div>
            <div class="col-md-1">
                <?php 
echo $form->field($sale, 'price', ['template' => '{input}'])->textInput(['data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('price')]);
?>
            </div>
            <div class="col-md-2">
                <?php 
echo $form->field($sale, 'vat', ['template' => '{input}'])->dropDownList(Sale::getVatList(), ['prompt' => '- ' . @$origin['vat'] . ' -', 'class' => 'form-control', 'data-toggle' => 'tooltip', 'title' => $sale->getAttributeLabel('vat')]);
?>
            </div>
            <div class="col-md-1">
                <?php 
echo Html::submitButton(Yii::t('app', 'Send'), ['class' => 'btn btn-default btn-block']);
?>
                <?php 
echo Html::activeHiddenInput($sale, 'id');
?>
                <?php 
echo Html::activeHiddenInput($sale, 'user_id');
?>
                <?php 
echo Html::activeHiddenInput($parse, 'id');
?>
コード例 #10
0
ファイル: _form.php プロジェクト: dench/resistor
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'solarpanel')->dropDownList(Sale::getYesList(), ['prompt' => '']);
?>
                                </div>
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'tennis')->dropDownList(Sale::getYesList(), ['prompt' => '']);
?>
                                </div>
                            </div>

                            <div class="row">
                                <div class="col-md-6">
                                    <?php 
echo $form->field($model, 'storage')->dropDownList(Sale::getYesList(), ['prompt' => '']);
?>
                                </div>
                                <div class="col-md-6">

                                </div>
                            </div>

                            <?php 
echo $form->field($model, 'facility_ids')->checkBoxList(Facilities::getList());
?>

                        </div>
                    </div>
                </div>
            </div>
コード例 #11
0
ファイル: SaleController.php プロジェクト: dench/resistor
 public function actionMarkers($district_id)
 {
     print json_encode(Sale::gpsMarkers($district_id));
 }
コード例 #12
0
ファイル: Object.php プロジェクト: dench/resistor
 public function getSale()
 {
     return $this->hasOne(Sale::className(), ['object_id' => 'id'])->orderBy(['sale.id' => SORT_DESC]);
 }
コード例 #13
0
ファイル: index.php プロジェクト: dench/resistor
<?php

use backend\components\SetColumn;
use common\models\District;
use common\models\Lang;
use common\models\Region;
use common\models\Sale;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel common\models\SaleSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Sales');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-body table-responsive">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'code', 'headerOptions' => ['width' => '100']], ['class' => SetColumn::className(), 'attribute' => 'name', 'name' => 'name', 'value' => 'content.name'], ['class' => SetColumn::className(), 'attribute' => 'region_id', 'filter' => Region::getList(), 'name' => 'region.content.name'], ['class' => SetColumn::className(), 'attribute' => 'district_id', 'filter' => District::getListAll(), 'name' => 'district.content.name'], 'address', ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.Y'], 'options' => ['width' => '80']], ['class' => SetColumn::className(), 'attribute' => 'top', 'filter' => Sale::getTopList(), 'name' => 'topName', 'cssClasses' => [Sale::TOP_DISABLED => 'default', Sale::TOP_ENABLED => 'success']], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => Sale::getStatusList(), 'name' => 'statusName', 'cssClasses' => [Sale::STATUS_HIDE => 'default', Sale::STATUS_ACTIVE => 'success', Sale::STATUS_AWAITING => 'warning']], ['class' => SetColumn::className(), 'attribute' => 'sold', 'filter' => Sale::getSoldList(), 'name' => 'soldName', 'cssClasses' => [Sale::SOLD_ACTUAL => 'success', Sale::SOLD_US => 'default', Sale::SOLD_OTHER => 'default']], ['class' => 'yii\\grid\\ActionColumn', 'headerOptions' => ['width' => '70'], 'template' => '{link} {update} {delete}', 'buttons' => ['link' => function ($url, $model, $key) {
    return Html::a('<span class="fa fa-eye"></span>', Url::to(Yii::$app->params['http'] . '/' . Lang::getCurrent()->code . '/sale/' . $model->id), ['target' => '_blank']);
}]]]]);
?>
    </div>
    <div class="box-footer">
        <?php 
echo Html::a(Yii::t('app', 'Create'), ['create'], ['class' => 'btn btn-success']);
?>
    </div>
</div>
コード例 #14
0
ファイル: index.php プロジェクト: dench/resistor
<?php

use backend\components\SetColumn;
use common\models\District;
use common\models\Region;
use common\models\Sale;
use yii\bootstrap\Html;
use yii\grid\GridView;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ObjectSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Objects');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="box">
    <div class="box-body table-responsive">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'id', 'headerOptions' => ['width' => '50']], ['class' => SetColumn::className(), 'label' => Yii::t('app', 'Name'), 'attribute' => 'name', 'value' => 'sale.name'], ['class' => SetColumn::className(), 'attribute' => 'region_id', 'filter' => Region::getList(), 'value' => 'sale.region.content.name'], ['class' => SetColumn::className(), 'attribute' => 'district_id', 'filter' => District::getListAll(), 'value' => 'sale.district.content.name'], ['class' => SetColumn::className(), 'label' => Yii::t('app', 'Address'), 'attribute' => 'address', 'value' => 'sale.address'], ['attribute' => 'sale.created_at', 'format' => ['date', 'dd.MM.Y'], 'options' => ['width' => '80']], ['class' => SetColumn::className(), 'attribute' => 'status', 'filter' => Sale::getStatusList(), 'name' => 'statusName', 'cssClasses' => [Sale::STATUS_HIDE => 'default', Sale::STATUS_ACTIVE => 'success', Sale::STATUS_AWAITING => 'warning']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{link} {create}', 'buttons' => ['link' => function ($url, $model, $key) {
    return Html::a(Yii::t('app', 'View'), Url::toRoute(['sale/update', 'id' => $model->sale->id]), ['class' => 'btn btn-primary btn-xs']);
}, 'create' => function ($url, $model, $key) {
    return Html::a(Yii::t('app', 'Create'), Url::toRoute(['sale/create', 'object_id' => $model->id]), ['class' => 'btn btn-success btn-xs']);
}]]]]);
?>
    </div>
</div>
コード例 #15
0
ファイル: _search.php プロジェクト: dench/resistor
    echo $form->field($model, 'furniture')->dropDownList(Sale::getYesList(), ['class' => 'form-control selectpicker', 'data-style' => 'form-control', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'solarpanel')->dropDownList(Sale::getYesList(), ['class' => 'form-control selectpicker', 'data-style' => 'form-control', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'tennis')->dropDownList(Sale::getYesList(), ['class' => 'form-control selectpicker', 'data-style' => 'form-control', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <?php 
    echo $form->field($model, 'storage')->dropDownList(Sale::getYesList(), ['class' => 'form-control selectpicker', 'data-style' => 'form-control', 'title' => Yii::t('app', 'Choose One'), 'prompt' => Yii::t('app', 'Any')]);
    ?>
        </div>
        <div class="col-xs-6 col-sm-4 col-md-2">
            <label class="search"><i class="fa fa-search"></i> <?php 
    echo Html::a(Yii::t('app', 'Simple search'), Url::toRoute(['/search']));
    ?>
</label>
            <?php 
    echo Html::hiddenInput('advanced', 1);
    ?>
            <?php 
    echo Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary btn-block']);
    ?>
        </div>
    </div>
コード例 #16
0
ファイル: ParserController.php プロジェクト: dench/resistor
 public function actionSend()
 {
     $data = Yii::$app->request->post();
     if (!empty($data['Parse']['id'])) {
         $parse = Parse::findOne($data['Parse']['id']);
     } else {
         return false;
     }
     if (!empty($data['Sale']['id'])) {
         $sale = Sale::findOne($data['Sale']['id']);
         $content = $sale->content;
     }
     if (empty($sale)) {
         $sale = new Sale();
         $sale->user_id = @$data['Sale']['user_id'];
     }
     if (empty($content)) {
         $content = new SaleLang();
         $content->lang_id = Lang::getCurrent()->id;
         $content->id = 0;
     }
     if ($sale->load($data) && $content->load($data) && $sale->validate() && $content->validate()) {
         $sale->save(false);
         if (!$content->id) {
             for ($i = 1; $i <= Lang::find()->count(); $i++) {
                 $model_content[$i] = new SaleLang();
                 $model_content[$i]['lang_id'] = $i;
                 $model_content[$i]['id'] = $sale->id;
                 $model_content[$i]['description'] = $content->description;
                 $model_content[$i]['name'] = $content->name;
                 $model_content[$i]->save(false);
             }
             $parse->sale_id = $sale->id;
             $parse->save();
         } else {
             $content->save(false);
         }
         return true;
     } else {
         Yii::trace(print_r($sale->errors, true));
         Yii::trace(print_r($content->errors, true));
         return false;
     }
 }
コード例 #17
0
ファイル: index.php プロジェクト: dench/resistor
use common\models\Sale;
use common\models\User;
$this->title = 'Admin Panel';
?>

<div class="row">
    <div class="col-xs-6 col-md-4">
        <div class="info-box">
            <span class="info-box-icon bg-red"><i class="fa fa-home"></i></span>
            <div class="info-box-content">
                <span class="info-box-text"><?php 
echo Yii::t('app', 'Sales');
?>
</span>
                <span class="info-box-number"><?php 
echo Sale::find()->count();
?>
</span>
            </div>
        </div>
    </div>
    <div class="col-xs-6 col-md-4">
        <div class="info-box">
            <span class="info-box-icon bg-aqua"><i class="fa fa-user"></i></span>
            <div class="info-box-content">
                <span class="info-box-text"><?php 
echo Yii::t('app', 'Users');
?>
</span>
                <span class="info-box-number"><?php 
echo User::find()->count();