public function actionStep3() { if (isFrontUserLoggedIn()) { $visit_code = Yii::app()->session['visit_code']; $visit_model = Visits::model()->find(array('condition' => 'visit_code = "' . $visit_code . '" ')); $step3_model = new Step3(); if (isset($_POST['Step3'])) { $step3_model->attributes = $_POST['Step3']; if ($step3_model->validate()) { $donation_model = new Donation(); $donation_model->user_id = Yii::app()->session['user_id']; $donation_model->visit_id = $visit_model->id; $donation_model->mobile = '123456789'; $donation_model->solicitor_id = $visit_model->solicitor->id; $donation_model->amount = $step3_model->amount; $donation_model->mode = 'web'; $donation_model->short_note = $step3_model->message; $donation_model->payment_status = 'pending'; $donation_model->reference_number = getToken(8); $donation_model->validate(); $donation_model->save(); // calculating the debit amount to be inserted in the user_trans table $user_id = Yii::app()->session['user_id']; $user_balance = Users::model()->getUserBalance($user_id); $user_model = Users::model()->findByPk($user_id); $credit_limits = $user_model->credit_limits; $actual_don_amt = $step3_model->amount; // if ($actual_don_amt > $user_balance) { // // deducting the user credit // if ($user_balance > 0) { // $from_user_credit = $actual_don_amt - $user_balance; // } else { // $from_user_credit = $actual_don_amt; // } // $final_user_credit = $credit_limits - $from_user_credit; // $user_model->credit_limits = $final_user_credit; // $user_model->validate(); // $user_model->save(); // } // for storing in the user_trans table $trans_model = new UserTrans(); $trans_model->tran_type = 'DONATION'; $trans_model->user_id = $donation_model->user_id; $trans_model->debit = $actual_don_amt; $trans_model->donation_id = $donation_model->id; $trans_model->save(); unset(Yii::app()->session['visit_code']); $this->redirect(array("/user/default/accountSummary")); } } $this->render('step3', array('visit_model' => $visit_model, 'step3_model' => $step3_model)); } else { $this->redirect(array("/user")); } }
public function actionDetails($id) { $visit = Visits::model()->findByPk($id); $visit_sql = "SELECT d.solicitor_id,d.user_id,d.visit_id,s.first_name,s.last_name,v.visit_code, CASE WHEN v.status = 1 THEN 'Yes' ELSE 'No' END AS visit_active, v.start_date,v.end_date, SUM( d.amount ) AS amount FROM `user_donation` d LEFT JOIN visits v ON d.visit_id = v.id LEFT JOIN solicitor s ON d.solicitor_id = s.id WHERE d.visit_id = '{$id}' GROUP BY d.visit_id"; $visits = BaseModel::executeSimpleQuery($visit_sql); // pre($visits,true); $donation = new Donation('users'); $donation->unsetAttributes(); $payments = new SolicitorCredit('solicitor'); $payments->unsetAttributes(); $this->render('donations', array('visit' => $visit->visit_code, 'visits' => $visits, 'donation' => $donation, 'payments' => $payments)); }
function donations() { $donations = Donation::where('amount', '>=', '10')->orderBy('amount', 'desc')->lists('name'); $gateways = Gateway::orderBy('name')->get(); $this->stylesheet('assets/stylesheets/donations.css'); $this->autoRender(compact('donations', 'gateways'), 'Donations'); }
public function delete() { // get user id $user_id = Auth::user()->id; $result = Donation::whereIn('id', Input::get('donations'))->where('user_id', '=', $user_id)->update(array('status' => 3)); Session::flash('success', 'Proses pembatalam donasi Anda berhasil dilakukan. Terima kasih.'); return serialize(Input::get('donations')); }
public function actionIndex() { $users = new Users('search'); $users->unsetAttributes(); $solicitors = new Solicitor('search'); $solicitors->unsetAttributes(); $donations = new Donation('search'); $donations->unsetAttributes(); $payments = new SolicitorCredit('search'); $payments->unsetAttributes(); $user = Users::model()->count(); $solicitor = Solicitor::model()->count(); $donation = BaseModel::getAll("Donation"); $t_donation = 0; foreach($donation as $d){ $t_donation = $t_donation + $d->amount; } $debit = BaseModel::getAll("SolicitorCredit"); $t_debit = 0; foreach ($debit as $d) { $t_debit = $t_debit + $d->amount; } $this->render('index',array( 'users'=>$users, 'solicitors'=>$solicitors, 'donations'=>$donations, 'payments'=>$payments, 'user' => $user, 'solicitor' => $solicitor, 't_donation' => $t_donation, 't_debit' => $t_debit )); }
public function get_report() { $account_id = Input::get('account_id'); $periode = Input::get('periode', 'weekly'); $date = Input::get('date'); $end_date = Input::get('end_date'); $today = strtotime(date('Y-m-d')); if (is_null($date) || empty($date)) { $last_week = $today - 3600 * 24 * 7; $date = date('Y-m-d', $last_week); } if ('daily' == $periode) { $range = array('start' => $date, 'end' => $date); } else { if ('weekly' == $periode) { $range = AppHelper::range_week($date); } else { if ('monthly' == $periode) { $range = AppHelper::range_month($date); } else { if ('custom' == $periode) { $range = array('start' => $date, 'end' => $end_date); } } } } $account = Account::find($account_id); $donations = Donation::where_between('donation_date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('donation_date', 'asc')->get(); $expenses = Expense::where_between('expense_date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('expense_date', 'asc')->get(); $transactions = Transaction::where_between('date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('date', 'asc')->get(); if (isset($donations[0]) || isset($expenses[0])) { $last_transaction = Transaction::earlier_than($transactions[0])->where_account_id($account_id)->first(); } else { $last_transaction = Transaction::earlier_than_date($range['start'])->where_account_id($account_id)->first(); } // var_dump($last_transaction); die; if (is_null($last_transaction)) { $last_transaction_balance = 0; } else { $last_transaction_balance = $last_transaction->balance->balance_amount; } $end_transaction = Transaction::where_between('date', $range['start'], $range['end'])->where_account_id($account_id)->order_by('date', 'desc')->order_by('id', 'desc')->first(); if (is_null($end_transaction)) { $end_balance = 0; } else { $end_balance = $end_transaction->balance->balance_amount; } $data = array('range' => $range, 'account' => $account, 'donations' => $donations, 'expenses' => $expenses, 'last_transaction_balance' => $last_transaction_balance, 'end_balance' => $end_balance, 'periode' => $periode); return View::make('account.report', $data); // echo var_dump($end_balance); }
public function show($id) { // get social target $social_action = SocialAction::with(array('city', 'category', 'user'))->where('id', '=', $id)->orderBy('id', 'desc')->first(); if ($social_action == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Target Sosial - ' . $social_action->name, 'description' => '', 'breadcrumb' => array('Kategori Aksi Social' => route('admin.social-action'), $social_action->name => route('admin.social-action.show', $social_action->id))); // Get category $data['social_actions'] = $social_action; // Get Donations that related with this $data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_action->id)->orderBy('id', 'desc')->get(); // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_action->id)->orderBy('id', 'desc')->get(); return View::make('admin.pages.social-action.show')->with($data); }
public function getSession($id) { $data = array(); $social_actions = SocialAction::with('socialTarget', 'user')->where('id', $id)->first(); if ($social_actions == false) { return App::abort('404'); } $photos = Photo::where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->get(); $donations = Donation::with(array('user'))->where('type_name', '=', 'social_actions')->where('type_id', '=', $social_actions->id)->where('status', '=', 1)->orderBy('id', 'desc')->get(); $user = User::getUserId($social_actions->user_id); $social_target_id = SocialTarget::getAll(); $social_action_category_id = SocialActionCategory::getAll(); $city_id = City::getAll(); $data = array('social_action' => $social_actions, 'photos' => $photos, 'donations' => $donations, 'user' => $user, 'social_target_id' => $social_target_id, 'social_action_category_id' => $social_action_category_id, 'city_id' => $city_id); Session::put('type_name', 'SocialAction'); Session::put('type_id', $social_actions->social_target_id); return Redirect::route('buat-aksi-sosial'); }
public function show($id) { // get social target $user = User::with('city')->find($id); if ($user == null) { return App::abort('404'); } // init $data = array('menu' => $this->_menu, 'title' => 'Nama pengguna - ' . $user->firstname . ' ' . $user->lastname, 'description' => '', 'breadcrumb' => array('Pengguna Bagikasih' => route('admin.user'), $user->firstname => route('admin.user.show', $user->id))); $data['users'] = $user; $social_target = SocialTarget::with(array('city', 'category', 'user'))->where('user_id', $user->id)->get(); // Get Social Target $data['social_target'] = $social_target; // Get Social Actions that related with this $data['social_actions'] = SocialAction::with(array('city', 'category', 'user'))->where('user_id', '=', $user->id)->orderBy('id', 'desc')->get(); // Get Donations that related with this $data['donations'] = Donation::with(array('user'))->where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get(); // Get Photos that related with this $data['photos'] = Photo::where('type_name', '=', 'users')->where('type_id', '=', $user->id)->orderBy('id', 'desc')->get(); return View::make('admin.pages.user.show')->with($data); }
protected function execute($arguments = array(), $options = array()) { $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true); $this->databaseManager = new sfDatabaseManager($configuration); $this->databaseManager->initialize($configuration); $db = $this->databaseManager->getDatabase('main'); $this->db = Doctrine_Manager::connection($db->getParameter('dsn'), 'main'); $cycle = $options["cycle"]; //get relationships with fec filings in the cycle $sql = "SELECT DISTINCT(f.relationship_id) FROM fec_filing f WHERE f.crp_cycle = ?"; $stmt = $this->db->execute($sql, array($cycle)); $rel_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); //delete fec filings in the cycle $sql = "DELETE FROM fec_filing WHERE crp_cycle = ?"; $stmt = $this->db->execute($sql, array($cycle)); foreach ($rel_ids as $rel_id) { if (Donation::updateRelationshipFromFecFilings($rel_id)) { $this->printDebug("Updated relationship: " . $rel_id); } else { $this->printDebug("Deleted relationship with no fec filings: " . $rel_id); } } }
public static function getSocialActivity($id) { // init $data = array(); // get user data /*$user = User::find($id); dd($user->created_at); // get signup date $data[$user->created_at] = array('type' => 'user');*/ // get social target $social_targets = SocialTarget::where('user_id', '=', $id)->where('status', '=', 1)->get(); foreach ($social_targets as $social_target) { $data[$social_target->created_at->timestamp] = array('type' => 'social_target', 'object_name' => $social_target->name, 'object_slug' => $social_target->slug); } // get social action $social_actions = SocialAction::where('user_id', '=', $id)->where('status', '=', 1)->get(); foreach ($social_actions as $social_action) { $data[$social_action->created_at->timestamp] = array('type' => 'social_action', 'object_name' => $social_action->name, 'object_slug' => $social_action->slug); } // get event $events = Events::where('user_id', '=', $id)->where('status', '=', 1)->get(); foreach ($events as $event) { $data[$event->created_at->timestamp] = array('type' => 'event', 'object_name' => $event->name, 'object_slug' => $event->slug); } // get donation $donations = Donation::where('user_id', '=', $id)->where('status', '=', 1)->where('as_noname', '=', 0)->get(); foreach ($donations as $donation) { $donation->setAppends(array('type')); $data[$donation->created_at->timestamp] = array('type' => 'donation', 'object_type' => $donation->type_name, 'object_name' => $donation->type->name, 'object_slug' => $donation->type->slug); } // sort krsort($data); return $data; }
public function actionProcessPending($id) { $visit_model = Visits::model()->findByPk($id); $attributes = array('payment_status' => 'transferred'); //Donation::model()->updateAll($attributes, 'payment_status=:payment_status', array(':payment_status' => 'pending')); Donation::model()->updateAll($attributes, array('condition' => "payment_status = 'pending' AND visit_id = '{$id}' ")); $this->redirect(array('donations', 'id' => $visit_model->solicitor_id)); }
public function getDonationDetails() { $donations = Donation::get(); $result = View::make('reports.donationslist', ['donations' => $donations]); return $result; }
public static function reject($id) { $payment = Payment::with(array('user', 'donations'))->find($id); if ($payment == null) { return array('success' => false, 'errors' => array('Pembayaran tidak ditemukan.')); } if ($payment->status != 0) { return array('success' => false, 'errors' => array('Pembayaran sudah pernah direspon oleh admin sebelumnya.')); } // delete // $payment->delete(); $payment->status = 2; $payment->save(); // update donation Donation::where('payment_id', '=', $payment->id)->update(array('status' => 0, 'payment_id' => NULL)); // set type for each donation foreach ($payment->donations as $donation) { $donation->setAppends(array('type')); } // send email to donor Newsletter::addPaymentNewsletter($payment); return array('success' => true, 'data' => $payment); }
/** * undocumented function * * @return void * @author **/ public function deleteDo() { $id = Input::get('id'); $validator = $this->deleteValid($id); if ($validator) { $donation = Donation::remove($id); if ($donation) { return Redirect::route('admin.donation')->withStatuses(['delete' => 'Hapus Sukses!']); } return Redirect::route('admin.donation')->withErrors(['delete' => 'Hapus Gagal!']); } return Redirect::route('admin.donation')->withErrors(['used' => 'Maaf, data ini masih digunakan! Hapus Gagal.']); }
/** * Conditionally displays a message if the $post_id is 2 * * @param array $field_args Array of field parameters * @param CMB2_Field object $field Field object */ public function transaction_details($field, $escaped_value, $object_id, $object_type, $field_type_object) { $donation = new Donation($object_id); $details = '<table class="form-table">'; foreach ($donation->getTransaction() as $k => $v) { $k = ucfirst(str_replace('_', ' ', $k)); $v = urldecode($v); $details .= "<tr><td class=\"row-title\">{$k}</td>"; $details .= "<td><em>{$v}</em></td></tr>"; } $details .= '</table>'; echo $details; }
/** * Simple function to create a donation associated with this Registration * * @param array $data * @return Donation */ public function createDonation($data) { $donation = new Donation($this->client, $data, $this->event, $this); $donation->create(); $this->setDonation($donation); return $donation; }
die(""); // Bad currency.. } elseif ($receiver_email != $Email) { die(""); // Bad receiver email.. } elseif ($payment_status != "Completed") { die(""); // Transaction not complete } /* Fetch the User Account */ $User = User::GetByField("User", "SteamID", $custom); if ($User == false || $User->IsReal() == false) { // They don't have an account.. wtf, lets make one to be safe $User = User::RegisterUser($custom, "0.0.0.0"); } /* MAKE SURE THEY DIDNT ALREADY GET THEIR SHIT */ $Donation = Donation::GetByField("Donation", "TransactionID", $txn_id); if ($Donation->IsReal() == true) { die(""); // They already got their shit } /* GIVE THEM THEIR SHIT */ $time = time(); $uid = $User->Data["ID"]; $User->ChangeValue("Credit", $User->Data["Credit"] + $payment_amount); Database::Query("INSERT INTO `gmd_donations` VALUES ( NULL, 1, '{$txn_id}', '{$custom}', '{$payer_email}', '{$first_name}', '{$last_name}', {$time}, {$payment_amount}, '{$payment_currency}' );"); } else { fwrite($FileObj, "bad ipn"); die(""); // Could not validate IPN }
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 )); }
public function getDonationDetails() { $donations = Donation::get(); $result = View::make('reports.donationslist', ['donations' => $donations]); return PDF::load($result, 'A4', 'portrait')->download(); }
public function delete_destroy($object_id = false) { $donation = Donation::find($object_id); $donation->delete(); return Redirect::to_action('donations@index'); }
/** * undocumented function * * @return void * @author **/ public static function remove($id) { $data = Donation::findOrFail($id); return $data->delete(); }
<div class="panel-body"> <div class="row"> <div class="col-sm-6 col-md-4" style="text-align: right;line-height: 34px;"><b>Past 24 Hours</b></div> <div class="col-sm-6 col-md-8" style="text-align: left;line-height: 34px;"> <img src="includes/images/money_dollar.png" /> <?php echo number_format((double) Donation::SumDonations(1), 2, '.', ''); ?> </div> </div> <div class="row"> <div class="col-sm-6 col-md-4" style="text-align: right;line-height: 34px;"><b>Daily Average Donations</b></div> <div class="col-sm-6 col-md-8" style="text-align: left;line-height: 34px;"> <img src="includes/images/money_dollar.png" /> <?php echo number_format((double) Donation::DailyAverage(30), 2, '.', ''); ?> </div> </div> <div class="row"> <div class="col-sm-6 col-md-4" style="text-align: right;line-height: 34px;"><b>Total Donations</b></div> <div class="col-sm-6 col-md-8" style="text-align: left;line-height: 34px;"> <img src="includes/images/money_dollar.png" /> <?php echo number_format((double) Donation::SumDonations(), 2, '.', ''); ?> </div> </div> </div>
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Donation the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Donation::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php list($cmd, $update_count_date) = $argv; $new = $db->query("SELECT DISTINCT donate_page_KEY FROM donation WHERE Date_Created >= " . $update_count_date); if ($new->num_rows > 0) { while ($new_arr = $new->fetch_assoc()) { $donate_page_info = $db->query("SELECT * FROM email_blast_statistics WHERE email_blast_KEY=" . $new_arr['action_KEY'])->fetch_assoc(); $donate_page = new DonatePage($donate_page_info); $donate_page->UpdateDonatePageCounts(); $donate_page->db_update(); $donate_page->data['key'] = $email->data['donate_page_KEY']; //$dia->save('donate_page', $donate_page->data); } } $new = $db->query("SELECT * FROM donation WHERE Date_Created >= " . $update_count_date); if ($new->num_rows > 0) { while ($new_arr = $new->fetch_assoc()) { $donation_info = $db->query("SELECT * FROM donation WHERE donation_KEY=" . $new_arr['action_KEY'])->fetch_assoc(); $donaton = new Donation($donation_info); $donaton->UpdateDonationCounts(); $donaton->db_update(); $donaton->data['key'] = $email->data['donation_KEY']; //$dia->save('donation', $donaton->data); } }
public function GetDonations() { return Donation::GetAllByField("Donation", "AccountID", $this->Data["ID"]); }
<?php include "../../_setup.php"; include "classes/donate-paypalclass.php"; include "classes/donation.php"; include "classes/campaign.php"; $donationPlugin = new btPlugin($mysqli); if ($donationPlugin->selectByName("Donations")) { $donationObj = new Donation($mysqli); $p = new paypal_class(); $arrColumns = array("donationcampaign_id", "member_id", "name", "message", "datesent", "amount", "paypalemail", "transaction_id", "response"); $p->setMode($donationPlugin->getConfigInfo("mode")); if ($p->validate_ipn() && $p->ipn_data['payment_status'] != "Failed" && $p->ipn_data['payment_status'] != "Denied") { $member = new Member($mysqli); $campaignObj = new DonationCampaign($mysqli); $arrData = $p->ipn_data; $data = json_encode($arrData); $customVars = json_decode($arrData['custom'], true); if ($campaignObj->select($customVars['campaign_id']) && $member->select($customVars['member_id'])) { $campaignName = $campaignObj->get_info_filtered("title"); $medalID = $campaignObj->get_info("awardmedal"); $member->awardMedal($medalID, "Donated to " . $campaignName . " campaign"); } $arrValues = array($customVars['campaign_id'], $customVars['member_id'], $customVars['name'], $customVars['message'], time(), $arrData['mc_gross'], $arrData['payer_email'], $arrData['txn_id'], $data); $donationObj->addNew($arrColumns, $arrValues); } else { $data = json_encode($p->ipn_data); $data = "ERROR: - " . $p->last_error . " - " . $data; $donationObj->logError($data); } }
/** * Add or edit donation * CODE: donation_create */ public function executeUpdate(sfWebRequest $request) { # security if (!$this->getUser()->hasCredential(array('Administrator'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } if ($request->getParameter('id')) { $dona = DonationPeer::retrieveByPK($request->getParameter('id')); $this->forward404Unless($dona); $this->title = 'Edit donation'; $success = 'Donation information has been successfully changed!'; } else { $dona = new Donation(); $this->title = 'Add new donation'; $success = 'Donation information has been successfully created!'; } $this->form = new DonationForm($dona); if ($request->isMethod('post')) { $this->referer = $request->getParameter('referer'); $this->form->bind($request->getParameter('dona')); if ($this->form->isValid() && $this->form->getValue('campain_id') && $this->form->getValue('donor_id') && $this->form->getValue('fund_id') && $this->form->getValue('gift_type')) { $donor = DonorPeer::getByPersonId($this->form->getValue('donor_id')); if ($donor) { $id = $donor->getId(); } $dona->setDonorId($id); $dona->setGiftDate($this->form->getValue('gift_date')); $dona->setGiftAmount($this->form->getValue('gift_amount')); $dona->setDeductibleAmount($this->form->getValue('deductible_amount')); $dona->setGiftType($this->form->getValue('gift_type')); $dona->setCheckNumber($this->form->getValue('check_number')); $dona->setCampainId($this->form->getValue('campain_id')); $dona->setFundId($this->form->getValue('fund_id')); $dona->setGiftNote($this->form->getValue('gift_note')); $dona->setPrintedNote($this->form->getValue('printed_note')); $dona->setReceiptGeneratedDate($this->form->getValue('receipt_generated_date')); if ($this->form->getValue('follow_up') == null) { $dona->setFollowUp(0); } else { $dona->setFollowUp($this->form->getValue('follow_up')); } $dona->setPremiumOrderDate($this->form->getValue('premium_order_date')); $dona->save(); $this->getUser()->setFlash('success', $success); $this->redirect('@donation'); } else { $this->getUser()->setFlash('success', 'Please choice Donor, Gift Type, Campaign or Fund!'); } } else { # Set referer URL $this->referer = $request->getReferer() ? $request->getReferer() : '@danation'; } $this->dona = $dona; }
}); $api->get('/donation/get_donations_for_approval/{poc_id}', function ($poc_id) { $donation = new Donation(); $donations_for_approval = $donation->getDonationsForApproval($poc_id); if ($donations_for_approval) { showSuccess(count($donations_for_approval) . " donation(s) waiting for approval", array('donations' => $donations_for_approval)); } else { $error = $donation->error; if (!$error) { $error = "Can't find any donations that need approval for this user"; } showError($error); } }); $api->get('/donation/{donation_id}/approve/{poc_id}', function ($donation_id, $poc_id) { $donation = new Donation(); $donation->approveDonation($donation_id, $poc_id); showSuccess("Donation approved", array('donation_id' => $donation_id)); }); $api->request("/user/login", function () { global $QUERY; $user = new User(); $phone = i($QUERY, 'phone'); $password = i($QUERY, 'password'); if (!$user->login($phone, $password)) { showError($user->error, array('')); exit; } $return = array('user' => $user->user); $return['user']['roles'] = $user->getRoles(); showSuccess("Login successful", $return);
public function actionDonations($id){ $visit_sql = "SELECT d.user_id,d.visit_id,s.first_name,s.last_name,v.visit_code, CASE WHEN v.status = 1 THEN 'Yes' ELSE 'No' END AS visit_active, v.start_date,v.end_date, SUM( d.amount ) AS amount FROM `user_donation` d LEFT JOIN visits v ON d.visit_id = v.id LEFT JOIN solicitor s ON d.solicitor_id = s.id WHERE s.id = '$id' GROUP BY d.visit_id ORDER BY d.date_entered DESC"; $visits = BaseModel::executeSimpleQuery($visit_sql); $c_sql = "SELECT SUM(amount) AS amount FROM solicitor_credit WHERE solicitor_id = '$id'"; $c_result = BaseModel::executeSimpleQueryFirstRow($c_sql); if($c_result === null){ $amount = 0; } else { $amount = $c_result['amount']; } $d_sql = "SELECT SUM(amount) AS amount FROM user_donation WHERE solicitor_id = '$id'"; $d_result = BaseModel::executeSimpleQueryFirstRow($d_sql); if($d_result === null){ $damount = 0; } else { $damount = $d_result['amount']; } $solicitor = Solicitor::model()->findByPk($id); $donation = new Donation('users'); $donation->unsetAttributes(); $payments = new SolicitorCredit('solicitor'); $payments->unsetAttributes(); $this->render('donations', array( 'visits' => $visits, 'donation' => $donation, 'solicitor' => $solicitor, 'amount' => $amount, 'damount' => $damount, 'payments' => $payments )); }