Example #1
0
 /**
  * View employees with loan
  *
  * @param  int  $id
  * @return Response
  */
 public function updateLoan(AddLoanRequest $request, $id)
 {
     $loan_id = $request->input('id');
     $loan = Loan::find($loan_id)->update($request->except('id'));
     $labor_id = Labor::where('employee_no', $id)->first()->id;
     $interval = intval($request->input('interval'));
     $noOfMonths = intval($request->input('months-to-pay'));
     $start_date = Carbon::parse($request->input('starting_date'));
     $loanId = $loan_id;
     Labor::where('employee_no', $id)->first()->LoanMonths()->where('loan_id', $loanId)->delete();
     for ($noOfMonths, $start_date; $noOfMonths > 0; $noOfMonths--, $start_date->addMonth($interval)) {
         $loan = new LoanMonths();
         $loan->deduction_date = $start_date;
         $loan->loan_id = $loanId;
         $loan->save();
     }
     $loans = Loan::where('labor_id', $labor_id)->get();
     flash()->success('Loan successfully updated.');
     return view('pages.index_loan', compact('loans', 'id'));
 }
Example #2
0
Route::get('/ajax-product-price', function () {
    $branch = Auth::user()->branch;
    $pid = Input::get('pid');
    //$products=Product::where('pid', '=', $pid)->get();
    $products = \DB::select('SELECT p.pid, p.cid, p.p_name, ROUND(p.buying_price,2) as buying_price, ROUND(p.selling_price, 2) as selling_price, ROUND(s.quantity, 2) as quantity FROM product p, stock s WHERE p.pid=s.pid AND p.pid=' . $pid . ' AND s.branch=' . "'" . $branch . "'");
    return Response::json($products);
});
Route::get('/ajax-stock-product-price', function () {
    $branch = Auth::user()->branch;
    $pid = Input::get('pid');
    $products = Product::where('pid', '=', $pid)->get();
    return Response::json($products);
});
Route::get('/ajax-loan-installment', function () {
    $lid = Input::get('lid');
    $loan = Loan::where('lid', '=', $lid)->get();
    return Response::json($loan);
});
Route::get('/balance', function () {
    $branch = Auth::user()->branch;
    $sheet = \DB::select('SELECT @a:=@a+1 sl, xx.* FROM
(SELECT income_title AS title, invoice_no AS address, "-" AS dr, amount AS cr, created_at FROM income where branch=' . "'" . $branch . "'" . '
UNION ALL
SELECT payment_title AS title, purpose AS address, amount AS dr, "-" AS cr, created_at FROM payment where branch=' . "'" . $branch . "'" . ' ORDER BY created_at DESC) xx, (SELECT @a:= 0) AS a;');
    return Response::json($sheet);
});
Route::get('/ajax-client', function () {
    $cname = Input::get('term');
    $client = \DB::select('SELECT name, address FROM consumer WHERE type=' . '"client" and name like ' . '"%' . $cname . '%"');
    foreach ($client as $row) {
        $data[] = $row->name;