Пример #1
0
 /**
  * Finds the Cashdrawer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Cashdrawer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cashdrawer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #2
0
 public function search($params)
 {
     $query = CashdrawerModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('1=0');
         return $dataProvider;
     }
     $query->andFilterWhere(['id_cashdrawer' => $this->id_cashdrawer, 'client_machine' => $this->client_machine, 'id_branch' => $this->id_branch, 'cashier_no' => $this->cashier_no, 'id_user' => $this->id_user, 'init_cash' => $this->init_cash, 'close_cash' => $this->close_cash, 'variants' => $this->variants, 'status' => $this->status, 'create_date' => $this->create_date, 'create_by' => $this->create_by, 'update_date' => $this->update_date, 'update_by' => $this->update_by]);
     return $dataProvider;
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCashdrawers()
 {
     return $this->hasMany(Cashdrawer::className(), ['id_branch' => 'id_branch']);
 }
Пример #4
0
 public function actionSavePos()
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $post = Yii::$app->request->post();
     try {
         $transaction = Yii::$app->db->beginTransaction();
         $drawer = Cashdrawer::findOne(['id_cashdrawer' => $post['id_drawer']]);
         $hdr = new SalesHdr(['id_cashdrawer' => $post['id_drawer'], 'id_branch' => $drawer->id_branch, 'create_by' => $drawer->id_user]);
         $total = 0.0;
         $dtls = [];
         foreach ($post['detail'] as $detail) {
             $cogs = Cogs::findOne(['id_product' => $detail['id_product']]);
             $dtl = new SalesDtl(['id_product' => $detail['id_product'], 'id_uom' => $detail['id_uom'], 'sales_price' => $detail['price'], 'sales_qty' => $detail['qty'], 'discount' => $detail['discon'], 'cogs' => $cogs ? $cogs->cogs : 0]);
             $total += $detail['qty'] * $detail['price'] * (1 - 0.01 * $detail['discon']);
             $dtls[] = $dtl;
         }
         $transaction->commit();
     } catch (\Exception $exc) {
         $transaction->rollback();
     }
     return ['type' => 'E'];
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdCashdrawer()
 {
     return $this->hasOne(Cashdrawer::className(), ['id_cashdrawer' => 'id_cashdrawer']);
 }