Example #1
0
 public static function createAccount($id)
 {
     $member = Member::find($id);
     $share = new Share();
     $acc = 'SH-' . $member->membership_no;
     $shareaccount = new Shareaccount();
     $shareaccount->member()->associate($member);
     $shareaccount->account_number = $acc;
     $shareaccount->opening_date = date('Y-m-d');
     $shareaccount->save();
 }
Example #2
0
 /**
  * Store a newly created member in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Member::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $member = new Member();
     if (Input::get('branch_id') != null) {
         $branch = Branch::findOrFail(Input::get('branch_id'));
         $member->branch()->associate($branch);
     }
     if (Input::get('group_id') != null) {
         $group = Group::findOrFail(Input::get('group_id'));
         $member->group()->associate($group);
     }
     if (Input::hasFile('photo')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('photo')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('photo')->move($destination, $photo);
         $member->photo = $photo;
     }
     if (Input::hasFile('signature')) {
         $destination = public_path() . '/uploads/photos';
         $filename = str_random(12);
         $ext = Input::file('signature')->getClientOriginalExtension();
         $photo = $filename . '.' . $ext;
         Input::file('signature')->move($destination, $photo);
         $member->signature = $photo;
     }
     $member->name = Input::get('name');
     $member->id_number = Input::get('id_number');
     $member->membership_no = Input::get('membership_no');
     $member->phone = Input::get('phone');
     $member->email = Input::get('email');
     $member->address = Input::get('address');
     $member->monthly_remittance_amount = Input::get('monthly_remittance_amount');
     $member->gender = Input::get('gender');
     if (Input::get('active') == '1') {
         $member->is_active = TRUE;
     } else {
         $member->is_active = FALSE;
     }
     $member->save();
     $member_id = $member->id;
     if (Input::get('share_account') == '1') {
         Shareaccount::createAccount($member_id);
     }
     Audit::logAudit(date('Y-m-d'), Confide::user()->username, 'member creation', 'Member', '0');
     return Redirect::route('members.index');
 }
 /**
  * Display the specified sharetransaction.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $account = Shareaccount::findOrFail($id);
     $credit = DB::table('sharetransactions')->where('shareaccount_id', '=', $account->id)->where('type', '=', 'credit')->sum('amount');
     $debit = DB::table('sharetransactions')->where('shareaccount_id', '=', $account->id)->where('type', '=', 'debit')->sum('amount');
     $balance = $credit - $debit;
     $sh = Share::findOrFail(1);
     $sharevalue = $sh->value;
     if ($sharevalue != 0) {
         $shares = $balance / $sharevalue;
     } else {
         $shares = 0;
     }
     return View::make('sharetransactions.show', compact('account', 'shares'));
 }
 /**
  * Remove the specified shareaccount from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Shareaccount::destroy($id);
     return Redirect::route('shareaccounts.index');
 }