/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Entrada::find(); $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(['idEntrada' => $this->idEntrada, 'producto_idProducto' => $this->producto_idProducto, 'cantidad' => $this->cantidad]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Entrada::find(); $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(['identrada' => $this->identrada, 'data' => $this->data, 'valor' => $this->valor, 'venda_idvenda' => $this->venda_idvenda, 'forma_pagamento_idforma_pagamento' => $this->forma_pagamento_idforma_pagamento, 'loja_idloja' => $this->loja_idloja, 'cliente_idcliente' => $this->cliente_idcliente]); return $dataProvider; }
public function updateInventario() { $sum = 0; $entradas = Entrada::findAll(['producto_IdProducto' => $this->producto_idProducto]); foreach ($entradas as $e) { $sum += $e->cantidad; } $inv = Inventario::findOne(['producto_IdProducto' => $this->producto_idProducto]); if ($inv == null) { $inv = new Inventario(); $inv->producto_idProducto = $this->producto_idProducto; } $inv->stock = $sum; $inv->save(); }
/** * Finds the Entrada model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Entrada the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Entrada::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getEntradas() { return $this->hasMany(Entrada::className(), ['cliente_idcliente' => 'idcliente']); }
/** * @return \yii\db\ActiveQuery */ public function getEntradas() { return $this->hasMany(Entrada::className(), ['producto_idProducto' => 'idProducto']); }
/** * Finds the Entrada model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $idEntrada * @param integer $producto_idProducto * @return Entrada the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($idEntrada, $producto_idProducto) { if (($model = Entrada::findOne(['idEntrada' => $idEntrada, 'producto_idProducto' => $producto_idProducto])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }