public function actionGetFeesCategory($id) { $rows = \app\modules\fees\models\FeesCollectCategory::find()->where(['is_status' => 0, 'fees_collect_batch_id' => $id])->all(); echo Html::tag('option', Html::encode(Yii::t('fees', 'Select Fees Collect Category')), ['value' => '']); foreach ($rows as $row) { echo Html::tag('option', Html::encode($row->fees_collect_name), ['value' => $row->fees_collect_category_id]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { //$query = FeesCollectCategory::find()->where(['fees_collect_category.is_status' => 0 ]); $query = FeesCollectCategory::find(); //$query->joinWith(['feesCollectBatch']); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['fees_collect_category_id' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['fees_collect_category_id' => $this->fees_collect_category_id, 'fees_collect_start_date' => $this->dbDateSearch($this->fees_collect_start_date), 'fees_collect_end_date' => $this->dbDateSearch($this->fees_collect_end_date), 'fees_collect_due_date' => $this->dbDateSearch($this->fees_collect_due_date), 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'is_status' => $this->is_status]); $query->andFilterWhere(['like', 'fees_collect_name', $this->fees_collect_name])->andFilterWhere(['like', 'fees_collect_details', $this->fees_collect_details])->andFilterWhere(['like', 'fees_collect_batch_id', $this->fees_collect_batch_id]); unset($_SESSION['exportData']); $_SESSION['exportData'] = $dataProvider; return $dataProvider; }
public function actionIndex() { $paidData = $unPaidData = $fcCategory = []; if (Yii::$app->session->get('stu_id')) { return $this->redirect(['/fees/fees-payment-transaction/stu-fees-data']); } //Course Wise Collection Count $cateWisePaid = 0; $courseWiseCollect = (new \yii\db\Query())->select(["(cs.course_name) AS '0'", 'SUM(fpt.fees_pay_tran_amount) AS "1"'])->from('fees_payment_transaction fpt')->join('JOIN', 'courses cs', 'cs.course_id = fpt.fees_pay_tran_course_id')->where(['cs.is_status' => 0, 'fpt.is_status' => 0])->groupBy('fpt.fees_pay_tran_course_id')->all(); $actFcc = \app\modules\fees\models\FeesCollectCategory::find()->where(['is_status' => 0])->asArray()->all(); foreach ($actFcc as $v) { $stuCount = \app\modules\student\models\StuMaster::find()->where(['is_status' => 0, 'stu_master_batch_id' => $v['fees_collect_batch_id']])->count(); $fccTotal = \app\modules\fees\models\FeesCategoryDetails::getFeeCategoryTotal($v['fees_collect_category_id']); $cateWisePaid += $stuCount * $fccTotal; } $paidTotal = (new \yii\db\Query())->from('fees_payment_transaction fpt')->join('JOIN', 'fees_collect_category fcc', 'fpt.fees_pay_tran_collect_id = fees_collect_category_id')->where(['fcc.is_status' => 0, 'fpt.is_status' => 0])->sum('fpt.fees_pay_tran_amount'); $paidPer = ' (' . ($cateWisePaid != 0 ? round($paidTotal * 100 / $cateWisePaid, 2) : 0) . '%)'; $unPaidPer = ' (' . ($cateWisePaid != 0 ? round(($cateWisePaid - $paidTotal) * 100 / $cateWisePaid, 2) : 0) . '%)'; $paidUnpaidData = [['name' => 'Paid' . $paidPer, 'y' => $paidTotal, 'color' => '#77C730'], ['name' => 'Unpaid' . $unPaidPer, 'y' => $cateWisePaid - $paidTotal, 'color' => '#F45B5B']]; //Individual Fees Collection Category Wise $fcWiseDetails = (new \yii\db\Query())->select(['fees_collect_category_id', 'fees_collect_batch_id', "CONCAT(fcc.fees_collect_name,'(',bt.batch_name,')') AS fc_name"])->from('fees_collect_category fcc')->join('JOIN', 'batches bt', 'bt.batch_id = fcc.fees_collect_batch_id')->where(['fcc.is_status' => '0'])->orderBy('fcc.fees_collect_category_id DESC')->limit('10')->all(); $fccTotal = $fccPaid = 0; foreach ($fcWiseDetails as $k => $v) { $stuCount = \app\modules\student\models\StuMaster::find()->where(['is_status' => 0, 'stu_master_batch_id' => $v['fees_collect_batch_id']])->count(); $fccTotalTmp = \app\modules\fees\models\FeesCategoryDetails::getFeeCategoryTotal($v['fees_collect_category_id']); $fccPaidTmp = (new \yii\db\Query())->from('fees_payment_transaction fpt')->where(['fpt.is_status' => 0, 'fpt.fees_pay_tran_collect_id' => $v['fees_collect_category_id']])->sum('fpt.fees_pay_tran_amount'); $fccTotal = $stuCount * $fccTotalTmp; $fccPaid = $fccPaidTmp === NULL ? 0 : $fccPaidTmp; $fccUnPaid = $fccTotal - $fccPaid; $fcCategory[] = $v['fc_name']; $paidData[] = $fccPaid; $unPaidData[] = $fccUnPaid; } $fccWisePaidUnPaid = [['name' => 'Paid Amount', 'data' => $paidData, 'color' => '#77C730'], ['name' => 'Unpaid Amount', 'data' => $unPaidData, 'color' => '#F45B5B']]; //Recently fees transaction $feeRecent = (new \yii\db\Query())->select(['fpt.fees_pay_tran_id', 'fpt.fees_pay_tran_amount', 'stu_unique_id', "CONCAT(si.stu_first_name, ' ', si.stu_last_name) AS 'stu_name'", 'fcc.fees_collect_name', 'DATE_FORMAT(fpt.fees_pay_tran_date, "%d-%m-%Y") AS tranDate'])->from('fees_payment_transaction fpt')->join('JOIN', 'fees_collect_category fcc', 'fcc.fees_collect_category_id = fpt.fees_pay_tran_collect_id')->join('JOIN', 'stu_info si', 'si.stu_info_stu_master_id = fpt.fees_pay_tran_stu_id')->where(['fpt.is_status' => '0'])->orderBy('fees_pay_tran_id DESC')->limit(10)->all(); return $this->render('index', ['feeRecent' => $feeRecent, 'courseWiseCollect' => $courseWiseCollect, 'paidUnpaidData' => $paidUnpaidData, 'fccWisePaidUnPaid' => $fccWisePaidUnPaid, 'fcCategory' => $fcCategory]); }