private function _view() { $daterange = Input::get('record_range', ''); //Session::put('ss_select_expen', $type); Larasset::start('header')->css('daterangepicker'); Larasset::start('footer')->js('moment', 'daterangepicker'); Larasset::start('footer')->js('dataTables-min', 'dataTables-bootstrap'); $data['entries'] = Expenditure::with(array('user' => function ($q) { $q->select('id', 'name'); })); //Is the person Admin or not if (User::permitted('role.admin') !== true) { $data['entries'] = $data['entries']->where('user_id', Auth::user()->id); } if ($daterange !== '' && strpos($daterange, '-') !== FALSE) { $fromandto = explode('-', $daterange); $from = $fromandto[0]; $to_plus_1day = strtotime('now') - strtotime('yesterday') + strtotime($fromandto[1]); $to = date('Y/n/d', $to_plus_1day); $data['from'] = format_date2($fromandto[0]); $data['to'] = format_date2($fromandto[1]); } else { $to = date('Y/n/d', strtotime('today')); $from = date('Y/n/d', strtotime('first day of this month')); $data['to'] = format_date2($to); $data['from'] = format_date2($from); } $data['entries'] = $data['entries']->whereBetween('date', array(sqldate($from), sqldate($to))); //$data['entries'] = $data['entries']->orderby('date', 'desc')->paginate(10); $data['entries'] = $data['entries']->orderby('date', 'desc')->get(); //tt($data); return $data; }
private function _view() { $type = Input::get('type', 'created_at'); $daterange = Input::get('record_range', ''); //Session::put('ss_select_expen', $type); Larasset::start('header')->css('daterangepicker'); Larasset::start('footer')->js('moment', 'daterangepicker'); Larasset::start('footer')->js('dataTables-min', 'dataTables-bootstrap'); $data['entries'] = Expenditure::with(array('user' => function ($q) { $q->select('id', 'name'); })); //Is the person Admin or not if (User::permitted('role.admin') !== true) { $data['entries'] = $data['entries']->where('user_id', Auth::user()->id); } if ($daterange !== '' && strpos($daterange, '-') !== FALSE) { $fromandto = explode('-', $daterange); $from = $fromandto[0]; $to_plus_1day = strtotime('now') - strtotime('yesterday') + strtotime($fromandto[1]); $to = date('Y/n/d', $to_plus_1day); $data['from'] = format_date2($fromandto[0]); $data['to'] = format_date2($fromandto[1]); } else { $to = date('Y/n/d', strtotime('today')); $from = date('Y/n/d', strtotime('first day of this month')); $data['to'] = format_date2($to); $data['from'] = format_date2($from); } $data['entries'] = $data['entries']->whereBetween('date', array(sqldate($from), sqldate($to))); //$data['entries'] = $data['entries']->orderby($type, 'desc')->paginate(10); $data['entries'] = $data['entries']->orderby('date', 'asc')->get(); //dd($data['entries']->toArray()); $saleslog = Salelog::whereBetween('created_at', array(sqldate($from), sqldate($to)))->select('unitprice', 'costprice', 'quantity', 'total_unitprice')->orderby('receipt_id', 'desc')->get(); $profitmargin = 0; foreach ($saleslog as $field) { //tt( $field->total_unitprice - ( $field->costprice * $field->quantity ) , true); $profitmargin += $field->total_unitprice - $field->costprice * $field->quantity; } $data['profitmargin'] = $profitmargin; //tt($data); return $data; }
function validate_borrower_period($date1, $date2) { $date1 = format_date2($date1); $date2 = format_date2($date2); if (strtotime($date2) <= strtotime($date1)) { return "Issuing date cannot be less or equal to return date"; } elseif (get_date_difference2($date1, $date2) > 3) { return "Borrowing period must not exceed 3 days"; } else { return ""; } }
function display_date_range($from, $to, $force = false, $today = 'Today') { $from = format_date2($from); $to = format_date2($to); $now = format_date2(sqldate()); if ($from === $now && $force === false) { return $today; } elseif ($to === $from) { return 'Sales On the: ' . $to; } return "Sales From: " . $from . " - To: " . $to; }