Ejemplo n.º 1
0
 public function searchDaily($params)
 {
     $query = SalesModel::find();
     $query->select(['date', 'sum(value) as value']);
     $query->groupBy(['date']);
     $query->orderBy(['date' => SORT_ASC]);
     if (isset($params['Sales']['Date'])) {
         $query->andWhere("date_part('month',date)=:dmonth", [':dmonth' => $params['Sales']['Date']]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 31]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'vendor_id' => $this->vendor_id, 'branch_id' => $this->branch_id, 'date' => $this->date, 'value' => $this->value, 'discount' => $this->discount, 'status' => $this->status, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'number', $this->number]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSales()
 {
     return $this->hasOne(Sales::className(), ['id' => 'sales_id']);
 }
Ejemplo n.º 3
0
 /**
  * Finds the Sales model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Sales the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Sales::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSales()
 {
     return $this->hasOne(\backend\models\sales\Sales::className(), ['id' => 'reff_id']);
 }
Ejemplo n.º 5
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\sales\Sales;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\sales\search\Sales */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Saless';
$this->params['breadcrumbs'][] = $this->title;
?>
<p class='pull-right'>
    <?php 
echo Html::a('Create Sales', ['create'], ['class' => 'btn btn-default']);
?>
</p>
<br>

<div class="sales-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table table-hover'], 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'number', ['attribute' => 'vendor_id', 'value' => 'vendor.name'], ['attribute' => 'branch_id', 'value' => 'branch.name'], ['attribute' => 'Date'], ['attribute' => 'status', 'value' => 'nmStatus', 'filter' => Sales::enums('STATUS_')], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>