/**
  * Update the specified account in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $account = Account::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Account::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $account->update($data);
     return Redirect::route('accounts.index');
 }
Beispiel #2
0
 public function debitAccount($data, $trans_no)
 {
     $journal = new Journal();
     $account = Account::findOrFail($data['debit_account']);
     $journal->account()->associate($account);
     $journal->date = $data['date'];
     $journal->trans_no = $trans_no;
     $journal->initiated_by = $data['initiated_by'];
     $journal->amount = $data['amount'];
     $journal->type = 'debit';
     $journal->description = $data['description'];
     $journal->save();
 }
Beispiel #3
0
 /**
  * Update the specified journal in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $journal = Journal::findOrFail($id);
     $validator = Validator::make($data = Input::all(), Journal::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $branch = Branch::findOrFail(Input::get('branch_id'));
     $account = Account::findOrFail(Input::get('account_id'));
     $journal->branch()->associate($branch);
     $journal->account()->associate($account);
     $journal->date = Input::get('date');
     $journal->trans_no = Input::get('trans_no');
     $journal->initiated_by = Input::get('initiated_by');
     $journal->amount = Input::get('amount');
     $journal->type = Input::get('type');
     $journal->description = Input::get('description');
     $journal->update();
     return Redirect::route('journals.index');
 }
 public function newNotaEntrega()
 {
     $client = null;
     $account = Account::findOrFail(Auth::user()->account_id);
     // if ($clientPublicId)
     // {
     // 	$client = Client::scope($clientPublicId)->first();
     //  		}
     $branch = Branch::where('id', '=', Session::get('branch_id'))->first();
     $today = date("Y-m-d");
     $expire = $branch->deadline;
     $today_time = strtotime($today);
     $expire_time = strtotime($expire);
     if ($expire_time < $today_time) {
         Session::flash('error', 'La fecha límite de emisión caducó, porfavor actualice su Dosificación');
         return Redirect::to('sucursales/' . $branch->public_id . '/edit');
     }
     $last_invoice = Invoice::where('account_id', Auth::user()->account_id)->where('branch_id', Session::get('branch_id'))->max('invoice_date');
     $last_date = strtotime($last_invoice);
     $secs = $today_time - $last_date;
     // == <seconds between the two times>
     $days = $secs / 86400;
     $invoiceDesigns = TypeDocument::where('account_id', \Auth::user()->account_id)->orderBy('public_id', 'desc')->get();
     $data = array('entityType' => ENTITY_INVOICE, 'account' => $account, 'invoice' => null, 'showBreadcrumbs' => false, 'data' => Input::old('data'), 'invoiceDesigns' => $invoiceDesigns, 'method' => 'POST', 'url' => 'factura', 'title' => trans('texts.new_invoice'), 'vencido' => 0, 'last_invoice_date' => $days);
     $data = array_merge($data, self::getViewModel());
     return View::make('factura.newNotaEntrega', $data);
 }
Beispiel #5
0
 /**
  * Remove the specified account from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $account = Account::findOrFail($id);
     Account::destroy($id);
     Audit::logaudit('Accounts', 'delete', 'deleted:' . $account->name . ' ' . $account->code);
     return Redirect::route('accounts.index');
 }
Beispiel #6
0
 public function handleBankStatement()
 {
     $account = Account::findOrFail(Input::get('account'));
     if (Input::get('bank_statement') == 1) {
         $account->bank_statement = Input::get('bank_statement');
         // store bank statement;
         $account->save();
         //update information to Valid table
         $member_id = $account->membership_id;
         //submit money to date
         $toDate = $account->to;
         //return $date;
         //converting date to srting
         $date = AppHelper::dateToString($toDate);
         //validateion upto date
         $upToDate = AppHelper::addThreeYear($toDate);
         //converting date to srting
         $upToDate = AppHelper::dateToString($upToDate);
         $currentDate = AppHelper::currentDate();
         //update valid database
         DB::update('update valids set valid=1,toDate =' . $date . ',upToDate=' . $upToDate . ' where membership_id=' . $member_id);
         if ($currentDate < $upToDate) {
             DB::update('update members set status=1 where membership_id=' . $member_id);
         }
         return Redirect::action('AdminAccountController@index')->with('flash_edit_success', 'Congratulation,You have submitted a bank statement');
     } else {
         return Redirect::action('AdminAccountController@index')->with('flash_dlt_success', 'Sorry, You do not submitted any bank statement.');
     }
 }
 public function recordpayment($id)
 {
     $order = Order::findOrFail($id);
     $order->amount_paid = Input::get('amount_paid');
     $order->update();
     $account = Account::findOrFail(Input::get('payment_method'));
     $amount = $account->balance + Input::get('amount_paid');
     $account->balance = $amount;
     $account->update();
     return Redirect::route('orders.index');
 }
 private function savePayments()
 {
     $rules = array();
     $recommendedId = Input::get('recommendedGateway_id');
     if ($gatewayId = $recommendedId == 1000000 ? Input::get('gateway_id') : $recommendedId) {
         $gateway = Gateway::findOrFail($gatewayId);
         $paymentLibrary = $gateway->paymentlibrary;
         $fields = $gateway->getFields();
         foreach ($fields as $field => $details) {
             if (!in_array($field, ['testMode', 'developerMode', 'headerImageUrl', 'solutionType', 'landingPage', 'brandName'])) {
                 if (strtolower($gateway->name) == 'beanstream') {
                     if (in_array($field, ['merchant_id', 'passCode'])) {
                         $rules[$gateway->id . '_' . $field] = 'required';
                     }
                 } else {
                     $rules[$gateway->id . '_' . $field] = 'required';
                 }
             }
         }
     }
     $creditcards = Input::get('creditCardTypes');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to('company/payments')->withErrors($validator)->withInput();
     } else {
         $account = Account::findOrFail(Auth::user()->account_id);
         if ($gatewayId) {
             $accountGateway = AccountGateway::createNew();
             $accountGateway->gateway_id = $gatewayId;
             $config = new stdClass();
             foreach ($fields as $field => $details) {
                 $value = trim(Input::get($gateway->id . '_' . $field));
                 if ($value && $value === str_repeat('*', strlen($value))) {
                     Session::flash('error', trans('validation.notmasked'));
                     return Redirect::to('company/payments');
                 }
                 $config->{$field} = $value;
             }
             $cardCount = 0;
             if ($creditcards) {
                 foreach ($creditcards as $card => $value) {
                     $cardCount += intval($value);
                 }
             }
             $accountGateway->config = json_encode($config);
             $accountGateway->accepted_credit_cards = $cardCount;
             $account->account_gateways()->delete();
             $account->account_gateways()->save($accountGateway);
             Session::flash('message', trans('texts.updated_settings'));
         } else {
             Session::flash('error', trans('validation.required', ['attribute' => 'gateway']));
         }
         return Redirect::to('company/payments');
     }
 }