/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BillPersonal::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(['id' => $this->id, 'bill_id' => $this->bill_id, 'personal_id' => $this->personal_id, 'amount' => $this->amount, 'paid' => $this->paid, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBillPerson()
 {
     return $this->hasOne(BillPersonal::className(), ['id' => 'bill_person_id']);
 }
示例#3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchWithPerson($params)
 {
     $query = Bill::find();
     $query->innerJoinWith('price');
     $query->joinWith('billPersonals');
     $query->orderBy(BillPersonal::tableName() . '.updated_at DESC');
     if (isset($params['id'])) {
         $query->where([BillPersonal::tableName() . '.personal_id' => $params['id']]);
         $query->orWhere([BillPersonal::tableName() . '.personal_id' => null]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new Sort(['attributes' => [self::tableName() . '.id', 'price_total' => ['asc' => ['price.total' => SORT_ASC], 'desc' => ['price.total' => SORT_DESC]], 'discount', 'bp_paid' => ['asc' => [BillPersonal::tableName() . '.paid' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.paid' => SORT_DESC]], 'bp_description' => ['asc' => [BillPersonal::tableName() . '.description' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.description' => SORT_DESC]], 'bp_amount' => ['asc' => [BillPersonal::tableName() . '.amount' => SORT_ASC], 'desc' => [BillPersonal::tableName() . '.amount' => SORT_DESC]], self::tableName() . '.created_at', self::tableName() . '.updated_at'], 'defaultOrder' => [self::tableName() . '.updated_at' => SORT_DESC]])]);
     $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;
     }
     if ($this->bp_paid == 0) {
         $this->bp_paid = null;
     }
     $query->andFilterWhere([self::tableName() . '.id' => $this->id, 'price_id' => $this->price_id, 'discount' => $this->discount, self::tableName() . '.created_at' => $this->created_at, self::tableName() . '.updated_at' => $this->updated_at, BillPersonal::tableName() . '.paid' => $this->bp_paid]);
     $query->andFilterWhere(['like', 'price.total', $this->price_total]);
     $query->andFilterWhere(['like', BillPersonal::tableName() . '.amount', $this->bp_amount]);
     $query->andFilterWhere(['like', BillPersonal::tableName() . '.description', $this->bp_description]);
     return $dataProvider;
 }
示例#4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBillPersonals()
 {
     return $this->hasMany(BillPersonal::className(), ['bill_id' => 'id']);
 }
示例#5
0
 public function actionPrint()
 {
     $person = null;
     $billPersonal = null;
     if (isset($_GET['p'], $_GET['s'])) {
         $ids = explode(',', $_GET['s']);
         $person = Person::findOne($_GET['p']);
         $billPersonal = BillPersonal::getAsociated($_GET['p'], $ids);
         if ($person !== null && count($billPersonal) > 0) {
             $content = $this->renderPartial('print', ['person' => $person, 'billPersonal' => $billPersonal]);
             $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_A4, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => Yii::t('app', 'Bill') . ' ' . Yii::t('app', 'Report')], 'methods' => ['SetHeader' => [Yii::t('app', 'Summary')], 'SetFooter' => ['{PAGENO}']]]);
             return $pdf->render();
         }
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Finds the BillPersonal model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return BillPersonal the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BillPersonal::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }