示例#1
0
文件: Coa.php 项目: deesoft/biz3-api
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CoaModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['code' => SORT_ASC]], 'pagination' => ['pageSize' => 100]]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'type' => $this->type, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'normal_balance', $this->normal_balance]);
     return $dataProvider;
 }
示例#2
0
文件: Coa.php 项目: deesoft/biz3-api
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCoas()
 {
     return $this->hasMany(Coa::className(), ['parent_id' => 'id']);
 }
示例#3
0
 public function getMasters()
 {
     $result = [];
     // master product
     $query_product = Product::find()->select(['id', 'code', 'name'])->andWhere(['status' => Product::STATUS_ACTIVE])->indexBy('id')->asArray();
     $result['products'] = $query_product->all();
     // uoms
     $_uoms = Uom::find()->indexBy('id')->asArray()->all();
     $uoms = [];
     foreach (ProductUom::find()->asArray()->all() as $row) {
         $uoms[$row['product_id']][] = ['id' => $row['uom_id'], 'name' => $_uoms[$row['uom_id']]['name'], 'isi' => $row['isi']];
     }
     $result['product_uoms'] = $uoms;
     // barcodes
     $barcodes = [];
     $query_barcode = ProductChild::find()->select(['barcode', 'id' => 'product_id'])->union(Product::find()->select(['code', 'id']))->asArray();
     foreach ($query_barcode->all() as $row) {
         $barcodes[strtoupper($row['barcode'])] = $row['id'];
     }
     $result['barcodes'] = $barcodes;
     // price_category
     $price_category = [];
     $query_price_category = PriceCategory::find()->asArray();
     foreach ($query_price_category->all() as $row) {
         $price_category[$row['id']] = $row['name'];
     }
     $result['price_category'] = $price_category;
     // prices
     $prices = [];
     $query_prices = Price::find()->asArray();
     foreach ($query_prices->all() as $row) {
         $prices[$row['product_id']][$row['price_category_id']] = $row['price'];
     }
     $result['prices'] = $prices;
     // customer
     $result['customers'] = Customer::find()->select(['id', 'name'])->asArray()->all();
     // supplier
     $result['suppliers'] = Supplier::find()->select(['id', 'name'])->asArray()->all();
     // product_supplier
     $prod_supp = [];
     $query_prod_supp = ProductSupplier::find()->select(['supplier_id', 'product_id'])->asArray();
     foreach ($query_prod_supp->all() as $row) {
         $prod_supp[$row['supplier_id']][] = $row['product_id'];
     }
     $result['product_supplier'] = $prod_supp;
     // product_stock
     $prod_stock = [];
     $query_prod_stock = ProductStock::find()->select(['warehouse_id', 'product_id', 'qty'])->asArray();
     foreach ($query_prod_stock->all() as $row) {
         $prod_stock[$row['warehouse_id']][$row['product_id']] = $row['qty'];
     }
     $result['product_stock'] = $prod_stock;
     // branch
     $result['branchs'] = Branch::find()->asArray()->all();
     // warehouse
     $warehouses = Warehouse::find()->asArray()->all();
     $result['warehouses'] = [];
     foreach ($warehouses as $warehouse) {
         $result['warehouses'][$warehouse['branch_id']][] = $warehouse;
     }
     //apicode
     $result['mvconfig'] = $this->module->mvConfig;
     // coa
     $result['coa'] = Coa::find()->select(['id', 'cd' => 'code', 'text' => 'name', 'label' => 'name'])->asArray()->all();
     return $result;
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCoa()
 {
     return $this->hasOne(Coa::className(), ['id' => 'coa_id']);
 }