mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-11 18:51:31 +00:00
updated streamline-setup v2
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Expenses\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
+1454
File diff suppressed because it is too large
Load Diff
+197
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Expenses\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Streamline\Models\ChartOfAccount;
|
||||
use Streamline\Models\PaymentItem;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class PaymentItemController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$payment_items = PaymentItem::orderBy('name', 'asc')->paginate(5000);
|
||||
return view('expenses::payment_items.index', compact('payment_items'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$expense_accounts = ChartOfAccount::orderBy('name', 'asc')->where('type', 2)->pluck('name', 'id')->prepend('-select-', '')->toArray();
|
||||
$payable_accounts = ChartOfAccount::orderBy('name', 'asc')->where('type', 6)->orWhere('type', 9)->pluck('name', 'id')->toArray();
|
||||
|
||||
return view('expenses::payment_items.create', compact('expense_accounts', 'payable_accounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required',
|
||||
'unit_cost' => 'required'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//validation failed
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
|
||||
//validation passed
|
||||
$payment_item = new PaymentItem;
|
||||
|
||||
$payment_item->name = $request->name;
|
||||
$payment_item->unit_cost = $request->unit_cost;
|
||||
$payment_item->account_id = $request->account_id;
|
||||
$payment_item->payable_account = $request->payable_account;
|
||||
$payment_item->created_by = Auth::user()->id;
|
||||
|
||||
try {
|
||||
$payment_item->save();
|
||||
flash($request->name . " Payment Item has been saved")->success();
|
||||
return redirect("/payment_items/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
*/
|
||||
public function show()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$payment_item = PaymentItem::where(['id' => $id])->first();
|
||||
|
||||
$expense_accounts = ChartOfAccount::orderBy('name', 'asc')->where('type', 2)->pluck('name', 'id')->prepend('-select-', '')->toArray();
|
||||
$payable_accounts = ChartOfAccount::orderBy('name', 'asc')->where('type', 6)->orWhere('type', 9)->pluck('name', 'id')->prepend('-select-', '')->toArray();
|
||||
|
||||
if (!$payment_item) {
|
||||
flash()->error("Payment Item not found");
|
||||
return redirect('/payment_items/');
|
||||
} else {
|
||||
return view('expenses::payment_items.edit', compact('payment_item', 'expense_accounts', 'payable_accounts'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function quick_update(Request $request)
|
||||
{
|
||||
$payment_item = PaymentItem::find($request->item_id);
|
||||
|
||||
$old_name = $payment_item->name;
|
||||
$old_created_by = $payment_item->created_by;
|
||||
$old_account_id = $payment_item->account_id;
|
||||
|
||||
$logged_in_user_id = Auth::id();
|
||||
$payment_item->name = $old_name;
|
||||
$payment_item->unit_cost = (int)$request->amount;
|
||||
$payment_item->account_id = $request->account_id;
|
||||
$payment_item->payable_account = $request->payable_account;
|
||||
$payment_item->created_by = $old_created_by;
|
||||
$payment_item->updated_by = $logged_in_user_id;
|
||||
|
||||
if($payment_item->save()){
|
||||
return 'success';
|
||||
}else{
|
||||
return $payment_item;
|
||||
}
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required'
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
//validation failed
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
}
|
||||
else {
|
||||
//validation passed
|
||||
$payment_item = PaymentItem::find($id);
|
||||
$logged_in_user_id = Auth::user()->id;
|
||||
|
||||
$payment_item->name = $request->name;
|
||||
$payment_item->unit_cost = $request->unit_cost;
|
||||
$payment_item->account_id = $request->account_id;
|
||||
$payment_item->payable_account = $request->payable_account;
|
||||
$payment_item->updated_by = $logged_in_user_id;
|
||||
|
||||
try {
|
||||
$payment_item->save();
|
||||
flash($request->name . " Payment Item has been updated")->success();
|
||||
return redirect("/payment_items/");
|
||||
} catch (QueryException $e) {
|
||||
flash("An error occurred")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function destroy($id) {
|
||||
$payment_item = PaymentItem::find($id);
|
||||
|
||||
if ($payment_item->delete()) {
|
||||
flash("Payment Item has been deleted.")->success();
|
||||
}
|
||||
return redirect('/payment_items/');
|
||||
}
|
||||
|
||||
public function inactive() {
|
||||
|
||||
$payment_items = PaymentItem::onlyTrashed()
|
||||
->orderBy('name', 'asc')
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
if (count($payment_items) < 1) {
|
||||
flash()->error("There is no inactive PaymentItem");
|
||||
return redirect('/payment_items/');
|
||||
} else {
|
||||
|
||||
return view('expenses::payment_items.inactive', compact('payment_items'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function activate($id) {
|
||||
$payment = PaymentItem::withTrashed()->find($id);
|
||||
|
||||
if($payment->restore()){
|
||||
flash("Parish has been activated.")->success();
|
||||
return redirect('/payment_items/inactive');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user