public function postDelete(Request $request)
 {
     if ($this->access['is_remove'] == 0) {
         return Redirect::to('dashboard')->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus', 'error');
     }
     // delete multipe rows
     if (count($request->input('id')) >= 1) {
         foreach ($request->input('id') as $cid) {
             $userdata = $this->model->getUserFromCustomerID($cid);
             //delete PAYG balance if available
             $this->model->setPaygBalanceDefault($userdata->id, 'delete');
             //delete user object
             $authen = new User();
             $authen->destroy($userdata->id);
             $notif = array('url' => url('/ycustomers'), 'userid' => '5', 'title' => 'A customer record has been deleted.', 'note' => 'A customer has been deleted. Please review this change as soon as possible.');
             \SximoHelpers::storeNote($notif);
         }
         $this->model->destroy($request->input('id'));
         \SiteHelpers::auditTrail($request, "ID : " . implode(",", $request->input('id')) . "  , Has Been Removed Successful");
         // redirect
         return Redirect::to('ycustomers')->with('messagetext', \Lang::get('core.note_success_delete'))->with('msgstatus', 'success');
     } else {
         return Redirect::to('ycustomers')->with('messagetext', 'No Item Deleted')->with('msgstatus', 'error');
     }
 }
 public function postDelete(Request $request)
 {
     if ($this->access['is_remove'] == 0) {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_restric')));
         die;
     }
     // delete multipe rows
     if (count($request->input('id')) >= 1) {
         $this->model->destroy($request->input('id'));
         $notif = array('url' => url('/weightbasedpricing'), 'userid' => '5', 'title' => 'A record has been deleted.', 'note' => 'A record has been deleted in the weight based pricing records. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         return response()->json(array('status' => 'success', 'message' => \Lang::get('core.note_success_delete')));
     } else {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_error')));
     }
 }
 function postSave(Request $request)
 {
     $rules = $this->validateForm();
     $validator = Validator::make($request->all(), $rules);
     if ($validator->passes()) {
         $data = $this->validatePost('tb_bulkdelivery');
         $id = $this->model->insertRow($data, $request->input('id'));
         if (!is_null($request->input('apply'))) {
             $return = 'bulkdelivery/update/' . $id . '?return=' . self::returnUrl();
         } else {
             $return = 'bulkdelivery?return=' . self::returnUrl();
         }
         // Insert logs into database
         if ($request->input('id') == '') {
             \SiteHelpers::auditTrail($request, 'New Data with ID ' . $id . ' Has been Inserted !');
         } else {
             \SiteHelpers::auditTrail($request, 'Data with ID ' . $id . ' Has been Updated !');
         }
         $notif = array('url' => url('/viewbulkdeliveries/show/' . $id), 'userid' => '5', 'title' => 'New request in Bulk Delivery.', 'note' => 'There has been a new bulk delivery request. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         $notif = array('url' => url('/viewbulkdeliveries/show/' . $id), 'userid' => '26', 'title' => 'New request in Bulk Delivery.', 'note' => 'There has been a new bulk delivery request. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         return Redirect::to($return)->with('messagetext', \Lang::get('core.note_success'))->with('msgstatus', 'success');
     } else {
         return Redirect::to('bulkdelivery/update/' . $id)->with('messagetext', \Lang::get('core.note_error'))->with('msgstatus', 'error')->withErrors($validator)->withInput();
     }
 }
 public function postDelete(Request $request)
 {
     if ($this->access['is_remove'] == 0) {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_restric')));
         die;
     }
     // delete multipe rows
     if (count($request->input('id')) >= 1) {
         $this->model->destroy($request->input('id'));
         \DB::table('tb_users')->where('activation', $num)->update(array('active' => 1, 'activation' => ''));
         $notif = array('url' => url('/states'), 'userid' => '5', 'title' => 'State record deleted.', 'note' => 'A state has just been removed. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         return response()->json(array('status' => 'success', 'message' => \Lang::get('core.note_success_delete')));
     } else {
         return response()->json(array('status' => 'error', 'message' => \Lang::get('core.note_error')));
     }
 }
 public function postDelete(Request $request)
 {
     if ($this->access['is_remove'] == 0) {
         return Redirect::to('dashboard')->with('messagetext', \Lang::get('core.note_restric'))->with('msgstatus', 'error');
     }
     // delete multipe rows
     if (count($request->input('id')) >= 1) {
         $this->model->destroy($request->input('id'));
         \SiteHelpers::auditTrail($request, "ID : " . implode(",", $request->input('id')) . "  , Has Been Removed Successfull");
         $notif = array('url' => url('/viewbulkdeliveries/show/'), 'userid' => '5', 'title' => 'Bulk Delivery Removal.', 'note' => 'A bulk delivery has been removed. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         $notif = array('url' => url('/viewbulkdeliveries/show/'), 'userid' => '26', 'title' => 'Bulk Delivery Removal.', 'note' => 'A bulk delivery has been removed. Please review this change as soon as possible.');
         \SximoHelpers::storeNote($notif);
         // redirect
         return Redirect::to('viewbulkdeliveries')->with('messagetext', \Lang::get('core.note_success_delete'))->with('msgstatus', 'success');
     } else {
         return Redirect::to('viewbulkdeliveries')->with('messagetext', 'No Item Deleted')->with('msgstatus', 'error');
     }
 }
 function postSave(Request $request)
 {
     $rules = $this->validateForm();
     $validator = Validator::make($request->all(), $rules);
     if ($validator->passes()) {
         $data = $this->validatePost('tb_getdeliveries');
         //for Platinum, Gold, Silver customers ensure that their limit has not been reached for the selected date
         if (!\SiteHelpers::is_payg_customer(\SiteHelpers::getUserIdFromCustomerId($request->input('cid'))) && !\SiteHelpers::check_daily_limit(\SiteHelpers::getUserIdFromCustomerId($request->input('cid'), $request->input('prefered_date_of_delivery')))) {
             return Redirect::to('getdeliveries?return=' . self::returnUrl())->with('messagetext', 'This user has exceeded his/her daily limit for ' . $request->input('prefered_date_of_delivery'))->with('msgstatus', 'error')->withErrors($validator)->withInput();
         }
         //ensure the delivery is made at the right time
         //dd(\SiteHelpers::check_cut_off_time($request->input('parcel_delivery_priority')));
         if (!\SiteHelpers::check_cut_off_time($request->input('parcel_delivery_priority'), $request->input('parcel_pickup_zone'), $request->input('parcel_dropoff_zone'))) {
             return Redirect::to('getdeliveries?return=' . self::returnUrl())->with('messagetext', 'You cannot make delivery requests at this time')->with('msgstatus', 'error')->withErrors($validator)->withInput();
         }
         //add delivery
         $id = $this->model->insertRow($data, $request->input('id'));
         if ($request->input('id') == '') {
             if (\SiteHelpers::is_payg_customer(\SiteHelpers::getUserIdFromCustomerId($request->input('cid')))) {
                 $bill = \SiteHelpers::calc_delivery_fee($request->input('parcel_delivery_code'));
                 //dd($bill);
                 $this->model->add_bill($id, $bill, $request->input('cid'), 'initial');
                 \SiteHelpers::billing_account_types($request->input('cid'), $bill);
             } else {
                 //set the limit table
                 \SiteHelpers::set_deliver_count_for_limit($request->input('cid'), $id, $request->input('prefered_date_of_delivery'));
             }
         }
         if (!is_null($request->input('apply'))) {
             $return = 'getdeliveries/update/' . $id . '?return=' . self::returnUrl();
         } else {
             $return = 'getdeliveries?return=' . self::returnUrl();
         }
         // Insert logs into database
         if ($request->input('id') == '') {
             \SiteHelpers::auditTrail($request, 'New Data with ID ' . $id . ' Has been Inserted !');
         } else {
             \SiteHelpers::auditTrail($request, 'Data with ID ' . $id . ' Has been Updated !');
         }
         $notif = array('url' => url('/viewdeliveries'), 'userid' => '5', 'title' => 'New Delivery Request', 'note' => 'Hi Admin. A user just sent in a delivery request. Have a look.');
         \SximoHelpers::storeNote($notif);
         return Redirect::to($return)->with('messagetext', \Lang::get('core.note_success'))->with('msgstatus', 'success');
     } else {
         return Redirect::to('getdeliveries/update/' . $id)->with('messagetext', \Lang::get('core.note_error'))->with('msgstatus', 'error')->withErrors($validator)->withInput();
     }
 }
 public function postDoreset(Request $request, $token = '')
 {
     $rules = array('password' => 'required|alpha_num|between:6,12|confirmed', 'password_confirmation' => 'required|alpha_num|between:6,12');
     $validator = Validator::make($request->all(), $rules);
     if ($validator->passes()) {
         $user = User::where('reminder', '=', $token);
         if ($user->count() >= 1) {
             $data = $user->get();
             $user = User::find($data[0]->id);
             $user->reminder = '';
             $user->password = \Hash::make($request->input('password'));
             $user->save();
         }
         \DB::table('tb_users')->where('activation', $num)->update(array('active' => 1, 'activation' => ''));
         $notif = array('url' => url('/core/users/'), 'userid' => '5', 'title' => 'A user\'s password has just been reset.', 'note' => 'A user\'s password has just been reset.');
         \SximoHelpers::storeNote($notif);
         return Redirect::to('user/login')->with('message', \SiteHelpers::alert('success', 'Password has been saved!'));
     } else {
         return Redirect::to('user/reset/' . $token)->with('message', \SiteHelpers::alert('error', 'The following errors occurred'))->withErrors($validator)->withInput();
     }
 }