public function approvepayment()
 {
     $payment = DB::table('payment_recieved')->where('id', '=', Input::get('paymentid'))->first();
     if ($this->create_bank_transaction($payment->bank_account_no, $payment->date_recieved, $payment->amount_recieved, 'Payment recieved for P.F Contribution for the period ' . $payment->contribution_period, 1, $payment->payment_method, $payment->bankers_id, $payment->cheque_no, 'N/A')) {
         $affectedRows = UploadHistory::where('Contribution_Period', '=', $payment->contribution_period)->update(array('Payment_Amount' => $payment->amount_recieved, 'Updated_By' => Auth::user()->get_user_id(), 'Updated_At' => date('Y-m-d')));
         if ($affectedRows > 0) {
             $affected = Payments::where('Id', '=', $payment->id)->update(array('status' => 1, 'Updated_By' => Auth::user()->get_user_id(), 'Updated_At' => date('Y-m-d')));
             if ($affected > 0) {
                 $ini = array('OK' => 'OK');
                 return Response::json($ini);
             } else {
                 $ini = array('No Data' => 'Payment was not set active, please try again');
                 return Response::json($ini);
             }
         } else {
             $ini = array('No Data' => 'Amount paid was not updated for the specified period');
             return Response::json($ini);
         }
     } else {
         $ini = array('No Data' => 'Payment was not saved.');
         return Response::json($ini);
     }
 }
 public function editContribution()
 {
     $rules = array('contributionid' => 'required', 'contributionperiod' => 'required', 'staffid' => 'required', 'employeecontribution' => 'required', 'employercontribution' => 'required');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return redirect('/ViewContributions')->with('error_message', $validation->errors()->first())->withInput();
     }
     $affectedRows = Contributions::where('Id', Input::get('contributionid'))->update(array('Employee_Contribution' => Input::get('employeecontribution'), 'Employer_Contribution' => Input::get('employercontribution'), 'Updated_By' => Auth::user()->get_user_id(), 'Updated_At' => date('Y-m-d')));
     if ($affectedRows > 0) {
         $results = DB::table('contributions')->join('staff_info', 'contributions.staff_id', '=', 'staff_info.staff_id')->select('contributions.Id', 'staff_info.Staff_Id', 'contributions.Contribution_Date', 'staff_info.Other_Names', 'staff_info.Surname', 'contributions.Employee_Contribution', 'contributions.Employer_Contribution', 'contributions.Status')->where('contributions.Contribution_Period', [Input::get('contributionperiod')])->get();
         $employer_contribution = DB::table('contributions')->where('contributions.Contribution_Period', [Input::get('contributionperiod')])->sum('Employer_Contribution');
         $employee_contribution = DB::table('contributions')->where('contributions.Contribution_Period', [Input::get('contributionperiod')])->sum('Employee_Contribution');
         $approved = UploadHistory::where('Contribution_Period', '=', Input::get('contributionperiod'))->update(array('Updated_By' => Auth::user()->get_user_id(), 'Updated_At' => date('Y-m-d'), 'Total_Contributions_Amount' => $employer_contribution + $employee_contribution));
         return View::make('Operations.contributions')->with('conts', $results)->with('cont_period', Input::get('contributionperiod'));
     } else {
         //Say something
     }
 }