Exemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchByProduct($params)
 {
     $query = SalesDtlModel::find();
     $query->select(['sales.date sdate', 'to_char(date, \'Day\') hari', 'product.name pname', 'product.category_id ctgr', 'sum(sales_dtl.qty) qty', 'sales_dtl.price', 'sum(sales_dtl.discount*sales_dtl.price*sales_dtl.qty/100) disc', 'array_to_string(array_agg(sales.number), \', \') faktur']);
     //$query->with(['sales', 'product', 'uom']);
     $query->leftJoin('sales', 'sales_dtl.sales_id=sales.id');
     $query->leftJoin('product', 'sales_dtl.product_id=product.id');
     $query->groupBy(['product.name', 'sales.date', 'price', 'product.category_id']);
     $query->orderBy('sales.date', 'product.name');
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $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;
     }
     $query->andFilterWhere(['between', 'sales.date', $this->fr_date, $this->to_date]);
     // grid filtering conditions
     $query->andFilterWhere(['sales_id' => $this->sales_id, 'product_id' => $this->product_id, 'uom_id' => $this->uom_id, 'qty' => $this->qty, 'price' => $this->price, 'total_release' => $this->total_release, 'cogs' => $this->cogs, 'discount' => $this->discount, 'tax' => $this->tax, 'sales.branch_id' => $this->branch_id]);
     return $dataProvider;
 }
Exemplo n.º 2
0
        <tr>
            <th style="width: 10%">#</th>
            <th>
                Product Name
            </th>
            <th class="items" style="width: 20%">
                Price
            </th>
            <th class="items" style="width: 20%">
                Qty
            </th>
            <th style="width: 10%">
                Uom
            </th>
        </tr>
        <tr>
            <td colspan="2">
                <div class="input-group" style="width:100%;">
                    <span class="input-group-addon">
                        <i class="fa fa-search"></i>
                    </span>
                    <input id="input-product" class="form-control" placeholder="Search Product..">
                </div>
            </td>
        </tr>
    </thead>
    <?php 
echo TabularInput::widget(['id' => 'detail-grid', 'allModels' => $model->items, 'model' => SalesDtl::className(), 'tag' => 'tbody', 'itemOptions' => ['tag' => 'tr'], 'itemView' => '_item_detail', 'clientOptions' => []]);
?>
</table>
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getItems()
 {
     return $this->hasMany(SalesDtl::className(), ['sales_id' => 'id']);
 }