/** * Manages all models. */ public function actionAdmin() { $model = new UserCredit('search'); $model->unsetAttributes(); // clear any default values if (isset($_GET['UserCredit'])) $model->attributes = $_GET['UserCredit']; $this->render('admin', array( 'model' => $model, )); }
public function actionTransaction($id) { $user_id = $id; $user = Users::model()->findByPk($id); $sql = "SELECT id, COALESCE(SUM(credit),0) - COALESCE(SUM(debit),0) AS balance from user_trans where user_id = '" . $id . "'"; $result = BaseModel::executeSimpleQueryFirstRow($sql); if(!empty($result['balance'])) { $balance = $result['balance']; } else { $balance = 0; } $c_sql = "SELECT SUM(credit) AS credited FROM user_trans WHERE credit IS NOT NULL AND user_id = '$id'"; $c_result = BaseModel::executeSimpleQueryFirstRow($c_sql); if(empty($c_result['credited'])){ $credit = 0; } else { $credit = $c_result['credited']; } $d_sql = "SELECT SUM(debit) AS debited FROM user_trans WHERE debit IS NOT NULL AND user_id = '$id'"; $d_result = BaseModel::executeSimpleQueryFirstRow($d_sql); if(empty($d_result['debited'])){ $debit = 0; } else { $debit = $d_result['debited']; } $donations = new Donation('users'); $donations->unsetAttributes(); $payments = new UserCredit('users'); $payments->unsetAttributes(); $logs = new Log('users'); $logs->unsetAttributes(); $this->render('transaction', array( 'user' => $user, 'balance' => $balance, 'credit' => $credit, 'debit' => $debit, 'donations' => $donations, 'payments' => $payments, 'logs' => $logs )); }
/** * Manages all models. */ public function actionManage() { $model = new UserCredit('search'); $model->unsetAttributes(); // clear any default values $users_lists = BaseModel::getAll('Users'); $users = array(); foreach ($users_lists as $user) { $users[$user->id] = $user->first_name . ' ' . $user->last_name . '(' . $user->username . ')'; } if (isset($_GET['UserCredit'])) { $model->attributes = $_GET['UserCredit']; } $this->render('admin', array('model' => $model, 'users' => $users)); }