當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AppHelper::range_week方法代碼示例

本文整理匯總了PHP中AppHelper::range_week方法的典型用法代碼示例。如果您正苦於以下問題:PHP AppHelper::range_week方法的具體用法?PHP AppHelper::range_week怎麽用?PHP AppHelper::range_week使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppHelper的用法示例。


在下文中一共展示了AppHelper::range_week方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: get_report

 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);
 }
開發者ID:gigikiri,項目名稱:masjid-l3,代碼行數:51,代碼來源:accounts.php


注:本文中的AppHelper::range_week方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。