private function _processHistory($id, $daterange)
 {
     Larasset::start('header')->css('daterangepicker');
     Larasset::start('footer')->js('moment', 'daterangepicker');
     if (strpos($daterange, '-') !== FALSE) {
         $fromandto = explode('-', $daterange);
         $from = sqldate($fromandto[0]);
         $to_plus_1day = strtotime('now') - strtotime('yesterday') + strtotime($fromandto[1]);
         $to = sqldate(date('Y/n/d', $to_plus_1day));
         $data['todate'] = $fromandto[1];
     } else {
         $from = sqldate(date('Y/n/d', strtotime('first day of this month')));
         $to = sqldate('+1day');
         $data['todate'] = $to;
     }
     $customerlog = Salelog::with(array('product' => function ($q) {
         $q->select('id', 'name', 'productcat_id')->with(array('categories' => function ($qr) {
             $qr->select('id', 'type');
         }));
     }))->where('customer_id', '=', $id)->whereBetween('created_at', array($from, $to))->orderBy('id', 'desc');
     //tt(groupThem($customerlog->get()->toArray(), 'receipt_id'));
     $customerDetails = Customer::where('id', '=', $id)->first();
     //$data['customerhistory'] = $customerlog->get()->toArray();
     $data['customerhistory'] = groupThem($customerlog->get()->toArray(), 'receipt_id');
     $data['customerdetail'] = $customerDetails;
     $data['fromdate'] = $from;
     $this->layout->title = 'Customer History';
     $this->layout->content = View::make('admin.customerhistory', $data);
 }