mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-13 19:51:30 +00:00
updated streamline-setup v2
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Budgets'
|
||||
];
|
||||
+681
@@ -0,0 +1,681 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Budgets\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Streamline\Models\Budget;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Barryvdh\Snappy\Facades\SnappyPdf;
|
||||
|
||||
class BudgetController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$this->middleware('permission:budget-list', ['only' => ['index']]);
|
||||
$this->middleware('permission:budget-create', ['only' => ['create', 'clone', 'store']]);
|
||||
$this->middleware('permission:budget-edit', ['only' => ['edit', 'update', 'edit_all', 'update_all']]);
|
||||
$this->middleware('permission:budget-delete', ['only' => ['destroy', 'inactive', 'activate']]);
|
||||
$this->middleware('permission:budget-performance-report', ['only' => ['budget_performance']]);
|
||||
$this->middleware('permission:budget-detail-performance-report', ['only' => ['budget_performance']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$created_by = $request->created_by;
|
||||
$dates = $request->dates;
|
||||
$filters = [];
|
||||
|
||||
if ($created_by == null) :
|
||||
// pass
|
||||
elseif ($created_by != 'all') :
|
||||
array_push($filters, ['created_by', '=', $created_by]);
|
||||
endif;
|
||||
|
||||
switch ($dates) {
|
||||
case 'today':
|
||||
$today = Carbon::today()->format('Y-m-d');
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereDate('created_at', $today)->paginate(1000);
|
||||
break;
|
||||
|
||||
case 'yesterday':
|
||||
$yesterday = Carbon::yesterday()->format('Y-m-d');
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereDate('created_at', $yesterday)->paginate(1000);
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$week_ago = Carbon::today()->subDays(7)->format('Y-m-d');
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereDate('created_at', '>=', $week_ago)->paginate(1000);
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$month_ago = Carbon::today()->subDays(30)->format('Y-m-d');
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereDate('created_at', '>=', $month_ago)->paginate(1000);
|
||||
break;
|
||||
|
||||
case 'custom-date':
|
||||
$start_date = Carbon::parse($request->start_date)->format('Y-m-d');
|
||||
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereDate('created_at', '=', $start_date)->paginate(1000);
|
||||
break;
|
||||
|
||||
case 'custom-range':
|
||||
$start_date = Carbon::parse($request->start_date)->format('Y-m-d');
|
||||
$end_date = Carbon::parse($request->end_date)->format('Y-m-d');
|
||||
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->whereBetween('created_at', [$start_date, $end_date])->paginate(1000);
|
||||
break;
|
||||
|
||||
default:
|
||||
$budgets = Budget::orderBy('created_at', 'desc')->where($filters)->paginate(1000);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ($budgets->count() <= 0) {
|
||||
flash("There are no budgets found!")->error();
|
||||
}
|
||||
|
||||
// users with activity
|
||||
$created_by_array = DB::table('budgets')->groupBy('created_by')->select('created_by')->get()->toArray();
|
||||
$created_by = array(count($created_by_array));
|
||||
|
||||
foreach ($created_by_array as $value) {
|
||||
$created_by[$value->created_by] = get_full_name($value->created_by, 'id', 'first_name', 'last_name', 'users');
|
||||
}
|
||||
|
||||
// remove the count from the array
|
||||
unset($created_by[0]);
|
||||
|
||||
// add --select--
|
||||
$created_by = ['all' => 'ALL'] + $created_by;
|
||||
|
||||
// $budgets = Budget::orderBy('id', 'asc')->paginate(2000);
|
||||
$budgets = DB::table('budgets')->leftJoin('users', 'users.id', '=', 'budgets.created_by')
|
||||
->whereNull('budgets.deleted_at')
|
||||
->select('budgets.*', DB::raw("CONCAT(users.first_name,' ',users.last_name) AS user_by"))
|
||||
->orderBy('budgets.id', 'desc')
|
||||
->paginate(2000);
|
||||
|
||||
return view('budgets::budgets.index', compact('budgets', 'created_by'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$this_year = Carbon::today()->year;
|
||||
$accounts = DB::table('chart_of_accounts as c')
|
||||
->leftJoin('account_types AS a', 'a.id', '=', 'c.type')
|
||||
->select('c.id', 'c.name', 'c.sub_account_of', 'a.name as type')
|
||||
->whereIn('c.type', [1, 2, 7]) // 1 - Income, 2 - Expense, 7 - Cost of Goods
|
||||
->get();
|
||||
return view('budgets::budgets.create', compact('this_year', 'accounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'period' => 'required',
|
||||
'budget_name' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
$logged_in_user_id = Auth::user()->id;
|
||||
$budget = new Budget;
|
||||
|
||||
$period = $request->period;
|
||||
$period_count = 0;
|
||||
$period_start = 0;
|
||||
|
||||
switch ($period) {
|
||||
case 'months':
|
||||
$period_count = $request->period_count_months;
|
||||
// $period_start = $request->period_start;
|
||||
break;
|
||||
case 'quarters':
|
||||
$period_count = $request->period_count_quarters;
|
||||
// $period_start = $request->period_start;
|
||||
break;
|
||||
case 'years':
|
||||
$period_count = $request->period_count_years;
|
||||
// $period_start = $request->period_start;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$entries = [];
|
||||
$accs = [];
|
||||
$row_entry = explode(',', $request->accountsNumber);
|
||||
for ($i = 0; $i < count($row_entry); $i++) {
|
||||
$acc_id = 'account_id_row_' . $row_entry[$i];
|
||||
$entry_id = 'budget_entry_row_' . $row_entry[$i];
|
||||
$account = preg_split("/\~/", $request->$acc_id);
|
||||
$entry = ['account_id' => $account[0], 'name' => $account[1], 'type' => $account[2], 'sub_account'=>$account[3], 'account_entries' => $request->$entry_id];
|
||||
array_push($entries, $entry);
|
||||
array_push($accs, $account[0]);
|
||||
}
|
||||
|
||||
try {
|
||||
Budget::create([
|
||||
"name" => $request->budget_name,
|
||||
"period" => $period, // dropdown months, quarters, years
|
||||
"period_count" => $period_count, // no. of months, quarters, years
|
||||
"period_start" => $request->period_start, // date
|
||||
"accounts" => implode(",", $accs),
|
||||
"entries" => json_encode($entries),
|
||||
"affected_tables" => implode(",", []),
|
||||
"created_by" => $logged_in_user_id,
|
||||
]);
|
||||
flash($request->budget_name . " Budget has been saved")->success();
|
||||
return redirect('/budgets/');
|
||||
} catch (QueryException $e) {
|
||||
if ($e->errorInfo != null) {
|
||||
flash($request->budget_name . " Budget already exists!")->error();
|
||||
return back()->withInput();
|
||||
} else {
|
||||
flash($e->getMessage())->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
$arr3 = json_decode($budget->entries, true);
|
||||
$income = $income_section = $income_sub_accounts = $expense = $expense_section = $expense_sub_accounts = [];
|
||||
$cost_of_goods = $cost_of_goods_section = $cost_of_goods_sub_accounts = $options = [];
|
||||
foreach ($arr3 as $rkey => $resource) {
|
||||
if ($resource['type'] == 'Income') {
|
||||
$income[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $income_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $income_section[] = $resource;
|
||||
}
|
||||
else if ($resource['type'] == 'Cost Of Goods') {
|
||||
$cost_of_goods[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $cost_of_goods_sub_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $cost_of_goods_section[] = $resource;
|
||||
}
|
||||
else {
|
||||
$expense[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $expense_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $expense_section[] = $resource;
|
||||
}
|
||||
}
|
||||
$options[] = ['section_header' => 'Income', 'total_header' => 'Total Income', 'entries' => $income, 'sub_accounts' =>$income_sub_accounts, 'section'=>$income_section];
|
||||
$options[] = ['section_header' => 'Cost of Goods', 'total_header' => 'Cost of Goods Total', 'entries' => $cost_of_goods, 'sub_accounts' =>$cost_of_goods_sub_accounts, 'section' => $cost_of_goods_section];
|
||||
$options[] = ['section_header' => 'Expenses', 'total_header' => 'Total Expenditure', 'entries' => $expense, 'sub_accounts' =>$expense_sub_accounts, 'section'=>$expense_section];
|
||||
// echo '<pre>' . var_export($budgets, true) . '</pre>';exit;
|
||||
return view('budgets::budgets.show', compact('budget', 'options'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function print_budget($id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
$arr3 = json_decode($budget->entries, true);
|
||||
$income = $income_section = $income_sub_accounts = $expense = $expense_section = $expense_sub_accounts = [];
|
||||
$cost_of_goods = $cost_of_goods_section = $cost_of_goods_sub_accounts = $options = [];
|
||||
foreach ($arr3 as $rkey => $resource) {
|
||||
if ($resource['type'] == 'Income') {
|
||||
$income[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $income_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $income_section[] = $resource;
|
||||
}
|
||||
else if ($resource['type'] == 'Cost Of Goods') {
|
||||
$cost_of_goods[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $cost_of_goods_sub_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $cost_of_goods_section[] = $resource;
|
||||
}
|
||||
else {
|
||||
$expense[] = $resource;
|
||||
if(!empty($resource['sub_account'])) $expense_sub_accounts[$resource['sub_account']][] = $resource;
|
||||
else $expense_section[] = $resource;
|
||||
}
|
||||
}
|
||||
$options[] = ['section_header' => 'Income', 'total_header' => 'Total Income', 'entries' => $income, 'sub_accounts' =>$income_sub_accounts, 'section'=>$income_section];
|
||||
$options[] = ['section_header' => 'Cost of Goods', 'total_header' => 'Cost of Goods Total', 'entries' => $cost_of_goods, 'sub_accounts' =>$cost_of_goods_sub_accounts, 'section' => $cost_of_goods_section];
|
||||
$options[] = ['section_header' => 'Expenses', 'total_header' => 'Total Expenditure', 'entries' => $expense, 'sub_accounts' =>$expense_sub_accounts, 'section'=>$expense_section];
|
||||
$data = [
|
||||
'budget' => $budget,
|
||||
'options' => $options
|
||||
];
|
||||
$pdf = SnappyPDF::loadView('budgets::budgets/print_budget', $data)
|
||||
->setOrientation('landscape')
|
||||
->setOption('margin-bottom', 7)
|
||||
->setOption('margin-top', 5)
|
||||
->setOption('footer-html', '<i>Stre@mline - Printed On ' . date('Y-m-d') . ' By ' . auth()->user()->first_name . " " . auth()->user()->last_name . '</i>');
|
||||
|
||||
return $pdf->inline(ucfirst($budget->name) . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the clone resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function clone($id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
$this_year = Carbon::today()->year;
|
||||
$accounts = DB::table('chart_of_accounts as c')
|
||||
->leftJoin('account_types AS a', 'a.id', '=', 'c.type')
|
||||
->select('c.id', 'c.name', 'c.sub_account_of', 'a.name as type')
|
||||
->whereIn('c.type', [1, 2, 7])
|
||||
->get();
|
||||
$arr = explode(',', $budget->accounts);
|
||||
$budget_accounts_ids = [];
|
||||
for ($i = 0; $i < count($arr); $i++) array_push($budget_accounts_ids, $arr[$i]);
|
||||
$arr2 = explode(',', $budget->entries);
|
||||
$entries = [];
|
||||
for ($i = 0; $i < count($arr2); $i++) array_push($entries, $arr2[$i]);
|
||||
$budget_accounts = DB::table('chart_of_accounts as c')
|
||||
->leftJoin('account_types AS a', 'a.id', '=', 'c.type')
|
||||
->select('c.id', 'c.name', 'c.sub_account_of', 'a.name as type')
|
||||
->whereIn('c.id', $budget_accounts_ids)
|
||||
->orderByRaw("FIELD(c.id, " . $budget->accounts . ")")
|
||||
->get();
|
||||
return view('budgets::budgets.clone', compact('budget', 'budget_accounts', 'entries', 'this_year', 'accounts'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
$this_year = Carbon::today()->year;
|
||||
$accounts = DB::table('chart_of_accounts as c')
|
||||
->leftJoin('account_types AS a', 'a.id', '=', 'c.type')
|
||||
->select('c.id', 'c.name', 'c.sub_account_of', 'a.name as type')
|
||||
->whereIn('c.type', [1, 2, 7])
|
||||
->get();
|
||||
$arr2 = explode(',', $budget->entries);
|
||||
$entries = [];
|
||||
for ($i = 0; $i < count($arr2); $i++) array_push($entries, $arr2[$i]);
|
||||
return view('budgets::budgets.edit', compact('budget', 'this_year', 'accounts', 'entries'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
$validator = Validator::make($request->all(), [
|
||||
'budget_name' => 'required',
|
||||
'period' => 'required',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$string = "";
|
||||
foreach ($validator->errors()->getMessages() as $item) {
|
||||
$string .= "{$item[0]}<br>";
|
||||
}
|
||||
flash($string)->error();
|
||||
return back()->withErrors($validator)->withInput();
|
||||
} else {
|
||||
|
||||
$period_count = 0;
|
||||
$period = $request->period;
|
||||
switch ($period) {
|
||||
case 'months':
|
||||
$period_count = $request->period_count_months;
|
||||
// $period_start = $request->period_start_month;
|
||||
break;
|
||||
case 'quarters':
|
||||
$period_count = $request->period_count_quarters;
|
||||
// $period_start = $request->period_start_quarter;
|
||||
break;
|
||||
case 'years':
|
||||
$period_count = $request->period_count_years;
|
||||
// $period_start = $request->period_start_year;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
$entries = [];
|
||||
$row_ids = explode(',', $request->accountsNumber);
|
||||
$accs = [];
|
||||
for ($i = 0; $i < count($row_ids); $i++) {
|
||||
$acc_id = 'account_id_row_' . $row_ids[$i];
|
||||
$entry_id = 'budget_entry_row_' . $row_ids[$i];
|
||||
$account = preg_split("/\~/", $request->$acc_id);
|
||||
$entry = ['account_id' => $account[0], 'name' => $account[1], 'type' => $account[2], 'sub_account'=>$account[3], 'account_entries' => $request->$entry_id];
|
||||
array_push($entries, $entry);
|
||||
array_push($accs, $account[0]);
|
||||
}
|
||||
|
||||
try {
|
||||
$budget->update([
|
||||
'name' => $request->budget_name,
|
||||
'period' => $request->period,
|
||||
'period_count' => $period_count, // no. of months, quarters, years
|
||||
'period_start' => $request->period_start,
|
||||
'accounts' => implode(",", $accs),
|
||||
'entries' => $entries,
|
||||
'updated_by' => Auth::user()->id,
|
||||
]);
|
||||
flash($request->budget_name . " has been updated")->success();
|
||||
return redirect("/budgets/");
|
||||
} catch (QueryException $e) {
|
||||
flash($request->budget_name . " already exists!")->error();
|
||||
return back()->withInput();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$budget = Budget::findOrFail($id);
|
||||
|
||||
if ($budget->delete()) {
|
||||
flash("Budget has been deleted.")->success();
|
||||
return redirect('/budgets/');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the inactive resource(s).
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function inactive()
|
||||
{
|
||||
$budgets = Budget::onlyTrashed()->orderBy('name', 'asc')->paginate(50);
|
||||
// users with activity
|
||||
$created_by_array = DB::table('budgets')->groupBy('created_by')->select('created_by')->get()->toArray();
|
||||
$created_by = array(count($created_by_array));
|
||||
|
||||
foreach ($created_by_array as $value) {
|
||||
$created_by[$value->created_by] = get_full_name($value->created_by, 'id', 'first_name', 'last_name', 'users');
|
||||
}
|
||||
|
||||
// remove the count from the array
|
||||
unset($created_by[0]);
|
||||
|
||||
// add --select--
|
||||
$created_by = ['all' => 'ALL'] + $created_by;
|
||||
|
||||
if ($budgets->isEmpty()) {
|
||||
flash()->error("There is no inactive budget.");
|
||||
return redirect('/budgets/');
|
||||
} else {
|
||||
return view('budgets::budgets.inactive', compact('budgets', 'created_by'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function activate($id)
|
||||
{
|
||||
$budget = Budget::onlyTrashed()->findOrFail($id);
|
||||
|
||||
if ($budget->restore()) {
|
||||
flash("Budget has been activated.")->success();
|
||||
return redirect('/budgets/');
|
||||
} else {
|
||||
flash()->error("Budget hasn't been activated.");
|
||||
return redirect()->route('budgets.inactive');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search a resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
|
||||
$filters = [];
|
||||
if ($request->created_by != 'all') $filters[] = ['created_by', '=', $request->created_by];
|
||||
if ($request->dates && $request->dates != 'all') {
|
||||
switch ($request->dates) {
|
||||
case 'today':
|
||||
$end_date = Carbon::today()->endOfDay();
|
||||
$start_date = Carbon::today()->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
|
||||
case 'yesterday':
|
||||
$end_date = Carbon::yesterday()->endOfDay();
|
||||
$start_date = Carbon::yesterday()->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
|
||||
case 'week':
|
||||
$end_date = Carbon::today()->endOfDay();
|
||||
$start_date = Carbon::today()->subDays(7)->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$end_date = Carbon::today()->endOfDay();
|
||||
$start_date = Carbon::today()->subDays(7)->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
|
||||
case 'custom-date':
|
||||
$end_date = Carbon::parse($request->start_date)->endOfDay();
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
|
||||
case 'custom-range':
|
||||
$end_date = Carbon::parse($request->end_date)->endOfDay();
|
||||
$start_date = Carbon::parse($request->start_date)->startOfDay();
|
||||
$filters[] = ['created_at', '>=', $start_date];
|
||||
$filters[] = ['created_at', '<=', $end_date];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$created_by_array = DB::table('budgets')->groupBy('created_by')->select('created_by')->get()->toArray();
|
||||
$created_by = array(count($created_by_array));
|
||||
|
||||
foreach ($created_by_array as $value) {
|
||||
$created_by[$value->created_by] = get_full_name($value->created_by, 'id', 'first_name', 'last_name', 'users');
|
||||
}
|
||||
|
||||
// remove the count from the array
|
||||
unset($created_by[0]);
|
||||
|
||||
// add --select--
|
||||
$created_by = ['all' => 'ALL'] + $created_by;
|
||||
|
||||
if ($request->query_active) {
|
||||
if ($request->active_state == 'active') $budgets = Budget::where($filters)->orderBy('id', 'desc')->get();
|
||||
else $budgets = Budget::withTrashed()->where($filters)->orderBy('id', 'desc')->get();
|
||||
return view('budgets::budgets.index', compact('budgets', 'created_by'));
|
||||
} else {
|
||||
$budgets = Budget::where($filters)->onlyTrashed()->orderBy('deleted_at', 'desc')->get();
|
||||
return view('budgets::budgets.inactive', compact('budgets', 'created_by'));
|
||||
}
|
||||
}
|
||||
|
||||
public function get_budgets()
|
||||
{
|
||||
//code to be returned to view
|
||||
$code = "<option> -- select -- </option>";
|
||||
|
||||
$budgets = Budget::orderBy('name', 'asc')->get();
|
||||
|
||||
foreach ($budgets as $budget) {
|
||||
$code .= "<option value='" . $budget->id . "'>" . $budget->name . "</option>";
|
||||
}
|
||||
|
||||
return $code;
|
||||
}
|
||||
|
||||
/* test server side scolling with datatables */
|
||||
public function datatable_test()
|
||||
{
|
||||
$budgets = Budget::orderBy('name', 'asc')->get();
|
||||
|
||||
return response()->json($budgets);
|
||||
}
|
||||
|
||||
//budget vs actual report
|
||||
public function budget_performance(Request $request)
|
||||
{
|
||||
$budget = (!empty($request->budget_id))? Budget::findOrFail($request->budget_id) : Budget::latest()->first();
|
||||
if (empty($budget)) return redirect('/budgets/');
|
||||
$other_budgets = Budget::where('id', '<>', $budget->id)->select('name', 'id')->get();
|
||||
$entries = json_decode($budget->entries, true);
|
||||
$income = $income_ids = $expense = $expense_ids = $cost_of_goods = $cost_of_goods_ids = $options = [];
|
||||
|
||||
foreach ($entries as $rkey => $resource) {
|
||||
if ($resource['type'] == 'Income') $income_ids[] = $resource['account_id'];
|
||||
else if ($resource['type'] == 'Cost Of Goods') $cost_of_goods_ids[] = $resource['account_id'];
|
||||
else $expense_ids[] = $resource['account_id'];
|
||||
}
|
||||
|
||||
$budget_start_date = Carbon::parse($budget->period_start)->startOfDay()->toDateString();
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$budget_end_date = date("Y-m-t", strtotime("+". $budget->period_count - 1 ." month", strtotime($budget_start_date)));
|
||||
$end_date =Carbon::parse($budget_end_date)->endOfDay()->toDateString();
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$budget_end_date = date("Y-m-t", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$end_date = Carbon::parse($budget_end_date)->endOfDay()->toDateString();
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$day = (date('d', strtotime($budget_start_date)) > 28)? date('Y-m-d', strtotime('-3 day', strtotime($budget_start_date))) : $budget_start_date;
|
||||
$budget_end_date = date("Y-m-t", strtotime("+". $budget->period_count - 1 ." year", strtotime('-1 month', strtotime($day))));
|
||||
$end_date =Carbon::parse($budget_end_date)->endOfDay()->toDateString();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$request->request->add(['dates' => 'custom_date_range']);
|
||||
$request->request->add(['start_date' => $budget_start_date]);
|
||||
$request->request->add(['end_date' => $end_date]);
|
||||
$request->request->add(['cost_of_goods_ids' => $cost_of_goods_ids]);
|
||||
$request->request->add(['expense_ids' => $expense_ids]);
|
||||
$request->request->add(['income_ids' => $income_ids]);
|
||||
// echo '<pre>' . var_export($budget, true) . '</pre>';exit;
|
||||
$data = getNetIncome($request);
|
||||
|
||||
$actual_income = $data['accrual_income_total'] + $data['cash_income_total'];
|
||||
$actual_cost_of_goods = $data['cog_accrual_total'] + $data['cog_cash_total'];
|
||||
$actual_expense = $data['expenses_accrual_total'] + $data['expenses_cash_total'];
|
||||
foreach ($entries as $entry) {
|
||||
if ($entry['type'] == 'Income') {
|
||||
$actual_entry = isset($data['revenue'][0][$entry['account_id']]['cash'])? $data['revenue'][0][$entry['account_id']]['cash'] + $data['revenue'][0][$entry['account_id']]['accrual'] : 0;
|
||||
$entry['actual_entry'] = $actual_entry;
|
||||
$income [] = $entry;
|
||||
}
|
||||
else if ($entry['type'] == 'Cost Of Goods') {
|
||||
$actual_entry = isset($data['revenue'][1][$entry['account_id']]['cash'])? $data['revenue'][1][$entry['account_id']]['cash'] + $data['revenue'][1][$entry['account_id']]['accrual'] : 0;
|
||||
$entry['actual_entry'] = $actual_entry;
|
||||
$cost_of_goods[] = $entry;
|
||||
}
|
||||
else {
|
||||
$actual_entry = isset($data['expense_accounts'][$entry['account_id']]['cash'])? $data['expense_accounts'][$entry['account_id']]['cash'] + $data['expense_accounts'][$entry['account_id']]['accrual'] : 0;
|
||||
$entry['actual_entry'] = $actual_entry;
|
||||
$expense[] = $entry;
|
||||
}
|
||||
}
|
||||
$options[] = ['section_header' => 'Income', 'total_header' => 'Total Income', 'entries' => $income, 'actual' => $actual_income];
|
||||
$options[] = ['section_header' => 'Cost of Goods', 'total_header' => 'Cost of Goods Total', 'entries' => $cost_of_goods, 'actual' => $actual_cost_of_goods];
|
||||
$options[] = ['section_header' => 'Expenses', 'total_header' => 'Total Expenditure', 'entries' => $expense, 'actual' => $actual_expense];
|
||||
|
||||
$type = explode('/',$request->url());
|
||||
$view = ($type[count($type) - 1] == 'summary') ? 'budgets::budgets.budget_performance' : 'budgets::budgets.budget_performance_detail';
|
||||
return view($view, compact('budget', 'options', 'data','budget_start_date','budget_end_date','other_budgets'));
|
||||
|
||||
}
|
||||
|
||||
function print_budget_report(Request $request){
|
||||
|
||||
$budget = json_decode($request->budget);
|
||||
$options = json_decode($request->options, true);
|
||||
$data = json_decode($request->data, true);
|
||||
$range = $request->range;
|
||||
if ($request->type == 'summary') {
|
||||
$view = 'budgets::budgets.print_budget_performance';
|
||||
$orientation = 'portrait';
|
||||
}
|
||||
else {
|
||||
$view = 'budgets::budgets.print_budget_performance_detail';
|
||||
$orientation = 'landscape';
|
||||
}
|
||||
$pdf = SnappyPDF::loadView($view, compact('budget', 'options','data', 'range'))
|
||||
->setOrientation($orientation)
|
||||
->setOption('margin-bottom', 7)
|
||||
->setOption('margin-top', 5)
|
||||
->setOption('footer-html', '<i>Stre@mline - Printed On ' . date('Y-m-d') . ' By ' . auth()->user()->first_name . " " . auth()->user()->last_name . '</i>');
|
||||
return $pdf->inline(ucfirst($budget->name) . date(" d-m-y h:ia") . '.pdf');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Budgets\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;
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Budgets\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Budgets\Providers\RouteServiceProvider;
|
||||
|
||||
class BudgetsServiceProvider extends ServiceProvider{
|
||||
/**
|
||||
* @var string $moduleName
|
||||
*/
|
||||
protected $moduleName = 'Budgets';
|
||||
|
||||
/**
|
||||
* @var string $moduleNameLower
|
||||
*/
|
||||
protected $moduleNameLower = 'budgets';
|
||||
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerTranslations();
|
||||
$this->registerConfig();
|
||||
$this->registerViews();
|
||||
$this->loadMigrationsFrom(module_path($this->moduleName, 'Database/Migrations'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->register(RouteServiceProvider::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register config.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerConfig()
|
||||
{
|
||||
$this->publishes([
|
||||
module_path($this->moduleName, 'Config/config.php') => config_path($this->moduleNameLower . '.php'),
|
||||
], 'config');
|
||||
$this->mergeConfigFrom(
|
||||
module_path($this->moduleName, 'Config/config.php'), $this->moduleNameLower
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register views.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerViews()
|
||||
{
|
||||
$viewPath = resource_path('views/modules/' . $this->moduleNameLower);
|
||||
|
||||
$sourcePath = module_path($this->moduleName, 'Resources/views');
|
||||
|
||||
$this->publishes([
|
||||
$sourcePath => $viewPath
|
||||
], ['views', $this->moduleNameLower . '-module-views']);
|
||||
|
||||
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register translations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerTranslations()
|
||||
{
|
||||
$langPath = resource_path('lang/modules/' . $this->moduleNameLower);
|
||||
|
||||
if (is_dir($langPath)) {
|
||||
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom($langPath);
|
||||
} else {
|
||||
$this->loadTranslationsFrom(module_path($this->moduleName, 'Resources/lang'), $this->moduleNameLower);
|
||||
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'Resources/lang'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the services provided by the provider.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function provides()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
private function getPublishableViewPaths(): array
|
||||
{
|
||||
$paths = [];
|
||||
foreach (\Config::get('view.paths') as $path) {
|
||||
if (is_dir($path . '/modules/' . $this->moduleNameLower)) {
|
||||
$paths[] = $path . '/modules/' . $this->moduleNameLower;
|
||||
}
|
||||
}
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Budgets\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'Modules\Budgets\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(module_path('Budgets', '/Routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(module_path('Budgets', '/Routes/api.php'));
|
||||
}
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@push('styles')
|
||||
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row bg-title">
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
|
||||
<h4 class="page-title">{{ __('finance.budgets') }}</h4>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> Finance Home</a></li>
|
||||
<li class="active"><i class="fa fa-file"></i> {{ __('finance.budgets') }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- @include('budgets::budgets.menu')
|
||||
@include('flash::message') --}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="white-box">
|
||||
@php
|
||||
$period_months = getMonthsList();
|
||||
$columns = ['Account', 'Budget Total', 'Actual Total', 'Percentage Variance <br> Actual vs Budget', 'Actual Variance <br> Actual vs Budget'];
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d",
|
||||
strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[]=$quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
// $period_range = $budget_start_date . " to " . $budget_end_date;
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
<div class="row">
|
||||
@if(isset($other_budgets))
|
||||
<div class="dropdown col-md-2">
|
||||
<a href="#" class="btn btn-success btn-rounded dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select Previous budget</a>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
{{ Form::open(['method' => 'POST', 'route' => ['budgets.performance','summary'], 'id' =>'budgetPerformance']) }}
|
||||
<input type="hidden" name="budget_id" id="budget_id" />
|
||||
@php
|
||||
foreach($other_budgets as $other_budget){
|
||||
echo '<a class="dropdown-item" onclick="performance_budget(this)" href="#" data-href="'.$other_budget->id.'">'.$other_budget->name.'</a>';
|
||||
}
|
||||
@endphp
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class='col-md-6'></div>
|
||||
<div class="col-md-2">
|
||||
<a href="#" onclick="download_table_as_csv('table', '{{ __('budgets.performance') . ': ' . $budget->name }}');"
|
||||
title="Download CSV of budget" class="btn btn-success btn-rounded"><span class="glyphicon glyphicon-download"></span> Download CSV</a>
|
||||
|
||||
</div>
|
||||
{{ Form::open(['method' => 'POST', 'route' => 'budgets.print_reports', 'id' =>'budgetPrint']) }}
|
||||
<input type="hidden" name="budget" id="budget" value='{{ json_encode($budget) }}' />
|
||||
<input type="hidden" name="options" id="options" value='{{ json_encode($options) }}' />
|
||||
<input type="hidden" name="data" id="data" value='{{ json_encode($data) }}' />
|
||||
<input type="hidden" name="type" id="type" value='summary' />
|
||||
<input type="hidden" name="range" id="range" value='{{ $period_range }}' />
|
||||
<div class='col-md-2'>
|
||||
<button title= '{{ __('budgets.performance_detail') . ": print to pdf " }}' type='submit' class='btn btn-rounded btn-success'><span class="glyphicon glyphicon-print"></span> Print Report</button>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<hr />
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p>
|
||||
<h4>{{ __('budgets.performance') . ": " . $budget->name }}</h4>
|
||||
</p>
|
||||
<p>
|
||||
<h4>{{ "Period(" . ucfirst($budget->period) . "): " . $period_range }}</h4>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<table id="table" class="table color-bordered-table success-bordered-table">
|
||||
<thead>
|
||||
<tr style='display:none;'>
|
||||
<td colspan='<?php echo count($columns); ?>'>
|
||||
Budget Name: {{ ucfirst($budget->name) .' - Period('. ucfirst($budget->period) .'): '.$period_range }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$actual_totals = $totals_budgets = $summary_colums = $income_column_totals=[];
|
||||
$expense_column_totals=[];$cost_of_goods_column_totals=[];
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach ($option['entries'] as $entry )
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j]; $col_percent=($entry['actual_entry']>0)? round(((($entry['actual_entry'] - $sum) / $entry['actual_entry']) * 100),2).'%' : 'N/A';
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i == 1) echo "<td>" . ugandan_shillings($sum) . "</td>" ;//Budget Total
|
||||
else if ($i == 2) echo "<td>" . ugandan_shillings($entry['actual_entry']) . "</td>" ; //Actual Total
|
||||
else if ($i == 3) echo "<td>" . $col_percent . "</td>" ; //Percentage variance
|
||||
else if ($i == 4) echo "<td>" . ugandan_shillings($entry['actual_entry'] - $sum) . "</td>" ; //Actual Variance
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Budget Section column Totals --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section = $columnTotal_section = 0;
|
||||
if ($i==0) echo '<td>' .$option['total_header']. '</td>' ;
|
||||
else if ($i==1){ //Budget totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" . ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else if ($i==2) {
|
||||
array_push($actual_totals, $option['actual']);
|
||||
echo "<td>" . ugandan_shillings($option['actual']) . "</td>" ; //Actual Total
|
||||
} else if ($i==3) {
|
||||
$percent=($option['actual'] != 0)? round(((($option['actual'] - $totals_budgets[count($totals_budgets) - 1]) / $option['actual'] ) * 100),2) .'%' : 'N/A';
|
||||
echo "<td>" . $percent . "</td>" ; //Percentage variance
|
||||
}
|
||||
else if ($i == 4) echo "<td>" .ugandan_shillings($option['actual'] - $totals_budgets[count($totals_budgets) - 1]). "</td>" ; //Actual Variance
|
||||
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Overall Budget Performance --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
array_push($summary_colums, $overall_projection);
|
||||
$total_actual = $data['accrual_net_income'] + $data['cash_net_income'];
|
||||
array_push($summary_colums, $total_actual);
|
||||
$overall_percentage = ($summary_colums[1] != 0)? round(((($summary_colums[1] - $summary_colums[0]) / $summary_colums[1]) * 100),2) .'%' : 'N/A';
|
||||
@endphp
|
||||
<td>Performance</td>
|
||||
<td> {{ ugandan_shillings($overall_projection) }} </td> {{-- Budget Projection --}}
|
||||
<td> {{ ugandan_shillings($total_actual) }} </td> {{-- Actual Total --}}
|
||||
<td> {{ $overall_percentage }} </td> {{-- Percentage variance --}}
|
||||
<td> {{ ugandan_shillings($summary_colums[1] - $summary_colums[0]) }} </td> {{-- Actual Variance --}}
|
||||
</tr>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
{{-- </div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
|
||||
<script src="{{ asset('js/streamline_functions.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function performance_budget(data) {
|
||||
var cell = data.getAttribute('data-href');
|
||||
$('#budget_id').val(cell);
|
||||
$("#budgetPerformance").submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@push('styles')
|
||||
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
<style type="text/css">
|
||||
td {
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row bg-title">
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
|
||||
<h4 class="page-title">{{ __('finance.budgets') }}</h4>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> Finance Home</a></li>
|
||||
<li class="active"><i class="fa fa-file"></i> {{ __('finance.budgets') }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- @include('budgets::budgets.menu')
|
||||
@include('flash::message') --}}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="white-box">
|
||||
@php
|
||||
$period_months = getMonthsList();
|
||||
$column_1 = ['Account'];
|
||||
$colum_2 = ['Budget Total', 'Actual Total', 'Percentage Variance <br> (Actual vs Budget)', 'Actual Variance <br> (Actual vs Budget)'];
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d",
|
||||
strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
$columns = array_merge($column_1, $months_data);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[]=$quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
$columns = array_merge($column_1, $other_columns);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
// $period_range = $budget_start_date . " to " . $budget_end_date;
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$columns = array_merge($column_1, $years_data);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<a href="#" onclick="download_table_as_csv('table', '{{ __('budgets.performance_detail') . ': ' . $budget->name }}');"
|
||||
title="Download CSV of budget" class="btn btn-success btn-rounded"><span
|
||||
class="glyphicon glyphicon-download"></span> Download CSV</a>
|
||||
</div>
|
||||
{{ Form::open(['method' => 'POST', 'route' => 'budgets.print_reports', 'id' =>'budgetPrint']) }}
|
||||
<input type="hidden" name="budget" id="budget" value='{{ json_encode($budget, true) }}' />
|
||||
<input type="hidden" name="options" id="options" value='{{ json_encode($options, true) }}' />
|
||||
<input type="hidden" name="data" id="data" value='{{ json_encode($data, true) }}' />
|
||||
<input type="hidden" name="range" id="range" value='{{ $period_range }}' />
|
||||
<input type="hidden" name="type" id="type" value='detail' />
|
||||
<div class='col-md-2'>
|
||||
<button title= '{{ __('budgets.performance_detail') . ": print to pdf " }}' type='submit' class='btn btn-rounded btn-success'><span class="glyphicon glyphicon-print"></span> Print Report</button>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
@if(isset($other_budgets))
|
||||
<div class="dropdown col-md-2">
|
||||
<a href="#" class="btn btn-success btn-rounded dropdown-toggle" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Select Previous budget</a>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
{{ Form::open(['method' => 'POST', 'route' => ['budgets.performance','detail'], 'id' =>'budgetPerformance']) }}
|
||||
<input type="hidden" name="budget_id" id="budget_id" />
|
||||
@php
|
||||
foreach($other_budgets as $other_budget){
|
||||
echo '<a class="dropdown-item" onclick="performance_budget(this)" href="#" data-href="'.$other_budget->id.'">'.$other_budget->name.'</a>';
|
||||
}
|
||||
@endphp
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
<div class='col-md-6'></div>
|
||||
</div>
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<hr />
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p>
|
||||
<h4>{{ __('budgets.performance_detail') . ": " . $budget->name }}</h4>
|
||||
</p>
|
||||
<p>
|
||||
<h4>{{ "Period(" .ucfirst($budget->period) . "): " . $period_range }}</h4>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<table id="table" class="table color-bordered-table table-responsive success-bordered-table">
|
||||
<thead>
|
||||
<tr style='display:none;'>
|
||||
<td colspan='<?php echo count($columns); ?>'>
|
||||
Budget Name: {{ ucfirst($budget->name) .' - Period('. ucfirst($budget->period) .'): '.$period_range }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$actual_totals = $totals_budgets = $summary_colums = $income_column_totals=[];
|
||||
$expense_column_totals = $cost_of_goods_column_totals=[];
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach ($option['entries'] as $entry)
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j]; $col_percent=($entry['actual_entry']>0)? round(((($entry['actual_entry'] - $sum) / $entry['actual_entry']) * 100),2).'%' : 'N/A';
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i === $counter) echo "<td>" . ugandan_shillings($sum) . "</td>" ;//Budget Total
|
||||
else if ($i == $counter + 1) echo "<td>" . ugandan_shillings($entry['actual_entry']) . "</td>" ; //Actual Total
|
||||
else if ($i == $counter + 2) echo "<td>" . $col_percent . "</td>" ; //Percentage variance
|
||||
else if ($i == $counter + 3) echo "<td>" . ugandan_shillings($entry['actual_entry'] - $sum) . "</td>" ; //Actual Variance
|
||||
else {
|
||||
echo "<td>" .ugandan_shillings($entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Budget Section column Totals --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section = $columnTotal_section = 0;
|
||||
if ($i==0) echo '<td>' .$option['total_header']. '</td>' ;
|
||||
else if ($i == $counter){ //Budget totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" . ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else if ($i == $counter + 1) {
|
||||
array_push($actual_totals, $option['actual']);
|
||||
echo "<td>" . ugandan_shillings($option['actual']) . "</td>" ; //Actual Total
|
||||
} else if ($i== $counter+2) {
|
||||
$percent=($option['actual']> 0)? round(((($option['actual'] - $totals_budgets[count($totals_budgets) - 1]) / $option['actual'] ) * 100),2) .'%' : 'N/A';
|
||||
echo "<td>" . $percent . "</td>" ; //Percentage variance
|
||||
}
|
||||
else if ($i == $counter+3) echo "<td>" .ugandan_shillings($option['actual'] - $totals_budgets[count($totals_budgets) - 1]). "</td>" ; //Actual Variance
|
||||
else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
//Push to column total arrays
|
||||
if($entry['type'] == 'Income') array_push($income_column_totals, $columnTotal_section);
|
||||
else if($entry['type'] == 'Expense') array_push($expense_column_totals, $columnTotal_section);
|
||||
else array_push($cost_of_goods_column_totals, $columnTotal_section);
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Overall Budget Performance --}}
|
||||
|
||||
<tr class="total">
|
||||
@php
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
array_push($summary_colums, $overall_projection);
|
||||
$total_actual = $data['accrual_net_income'] + $data['cash_net_income'];
|
||||
array_push($summary_colums, $total_actual);
|
||||
$overall_percentage = ($summary_colums[1] > 0)? round(((($summary_colums[1] - $summary_colums[0]) / $summary_colums[1]) * 100),2) .'%' : 'N/A';
|
||||
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
if ($i==0) echo '<td>Summary</td>' ;
|
||||
else if ($i == $counter){ //Budget Totals
|
||||
echo "<td>" . ugandan_shillings($overall_projection) . "</td>" ;
|
||||
} else if ($i == $counter + 1) {
|
||||
echo "<td>" . ugandan_shillings($total_actual) . "</td>" ;
|
||||
} else if ($i == $counter + 2) {
|
||||
echo "<td>" . $overall_percentage . "</td>" ;
|
||||
} else if ($i == $counter + 3) {
|
||||
echo "<td>" . ugandan_shillings($summary_colums[1] - $summary_colums[0]) . "</td>" ;
|
||||
} else {
|
||||
$columnTotal_projection=$income_column_totals[$i-1] - $expense_column_totals[$i-1] - $cost_of_goods_column_totals[$i-1];
|
||||
echo "<td>".ugandan_shillings($columnTotal_projection). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
{{-- </div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
|
||||
<script src="{{ asset('js/streamline_functions.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function performance_budget(data) {
|
||||
var cell = data.getAttribute('data-href');
|
||||
$('#budget_id').val(cell);
|
||||
$("#budgetPerformance").submit();
|
||||
}
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
File diff suppressed because it is too large
Load Diff
+1000
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,243 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@push('styles')
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row bg-title">
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
|
||||
<h4 class="page-title">{{ __('finance.budgets') }}</h4>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> Finance Home</a></li>
|
||||
<li><a href="{{ route('budgets.index') }}"><i class="fa fa-book"></i> {{ __('budgets.budgets') }}</a></li>
|
||||
<li class="active"><i class="fa fa-undo"></i> Inactive Budgets </li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- @include('budgets::budgets.menu') --}}
|
||||
|
||||
<div class="white-box">
|
||||
{{ Form::open(['route' => 'budgets.search']) }}
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
{{ Form::label('created_by', "Staff member") }}
|
||||
{{ Form::select('created_by', $created_by, null, ['class' => 'form-control compulsory','required']) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
{{ Form::label('date_range', "Select the date") }}
|
||||
<div class="input-group">
|
||||
<select class="form-control compulsory required" id="dates" name="dates" required>
|
||||
<option value="ALL">ALL DATES</option>
|
||||
<option value="today">TODAY</option>
|
||||
<option value="yesterday">YESTERDAY</option>
|
||||
<option value="week">LAST 7 DAYS</option>
|
||||
<option value="month">LAST 30 DAYS</option>
|
||||
<option value="custom-date">CUSTOM DAY</option>
|
||||
<option value="custom-range">DATE RANGE</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3" style="display: none;" id="start-date-div">
|
||||
<div class="form-group">
|
||||
{{ Form::label('start_date', "Date From") }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('start_date','',['class' => 'form-control compulsory',
|
||||
'required','readonly','id'=>'datepicker-from']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3" style="display: none;" id="end-date-div">
|
||||
<div class="form-group">
|
||||
{{ Form::label('end_date', "Date To") }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('end_date','',['class' => 'form-control compulsory',
|
||||
'required','readonly','id'=>'datepicker-to']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-11"></div>
|
||||
<div class="col-md-1">
|
||||
{{ Form::button("Search", ['type'=>'submit','style'=>"border-radius: 5px;", 'class'=>'btn btn-success
|
||||
waves-effect waves-light m-r-10'])
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
@include('flash::message')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="white-box">
|
||||
{{-- <p class="text-muted m-b-30">{{ __('finance.export_data_to_copy_csv_pdf_print') }}</p> --}}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Budget Breakdown</th>
|
||||
<th>Period</th>
|
||||
<th>Created By</th>
|
||||
<th>Date & Time Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@if(count($budgets) > 0)
|
||||
@foreach($budgets as $budget)
|
||||
@php
|
||||
$period = "N/A";
|
||||
$period_count = $budget->period_count;
|
||||
$period_start = $budget->period_start;
|
||||
$period_range = "N/A";
|
||||
|
||||
switch ($budget->period) {
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
|
||||
$period_months = getMonthsList();
|
||||
if (isset($period_months[$period_start]) && isset($period_months[$period_start +
|
||||
$period_count])) {
|
||||
$period_range = $period_months[$period_start] . " - " . $period_months[$period_start +
|
||||
$period_count];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
|
||||
$period_quarters = array("First", "Second", "Third", "Fourth");
|
||||
if (isset($period_quarters[$period_start]) && isset($period_quarters[$period_start +
|
||||
$period_count])) {
|
||||
$period_range = $period_quarters[$period_start] . " - " . $period_quarters[$period_start +
|
||||
$period_count];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
|
||||
if (is_numeric($period_start)) {
|
||||
$period_range = $period_start . " - " . ($period_start + $period_count);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $budget->name }}</td>
|
||||
<td>{{ ucfirst($budget->period) }}</td>
|
||||
<td>{{ $period_range }}</td>
|
||||
<td>{{ get_full_name($budget->created_by, 'id', 'first_name', 'last_name', 'users') }}
|
||||
</td>
|
||||
<td>{{ streamline_date_time_short($budget->created_at) }}</td>
|
||||
|
||||
<td>
|
||||
@if( Auth::user()->can('budget-delete'))
|
||||
{{ Form::model($budget->id ,['method' => 'POST', 'route' => ['budgets.activate',
|
||||
$budget->id]]) }}
|
||||
<button type="submit" class="btn btn-sm btn-warning btn-rounded"
|
||||
onclick="return confirm('Are you sure you want to activate this budget?')"><i
|
||||
class="fa fa-check"></i> {{ __('budgets.activate') }}</button>
|
||||
{{ Form::close() }}
|
||||
@endif
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Budget Breakdown</th>
|
||||
<th>Period</th>
|
||||
<th>Created By</th>
|
||||
<th>Date & Time Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
|
||||
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/jszip.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$('.table').DataTable({
|
||||
responsive: true,
|
||||
order: []
|
||||
});
|
||||
|
||||
function show(id) {
|
||||
if (document.getElementById(id).style.display === 'none') {
|
||||
document.getElementById(id).style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
function hide(id) {
|
||||
document.getElementById(id).style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#datepicker-from, #datepicker-to').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
format: 'dd-mm-yyyy',
|
||||
});
|
||||
|
||||
$('#dates').change(function() {
|
||||
var val = $(this).val();
|
||||
switch (val) {
|
||||
case 'custom-date':
|
||||
$('#end-date-div').hide();
|
||||
$('#start-date-div').show();
|
||||
break;
|
||||
case 'custom-range':
|
||||
$('#end-date-div').show();
|
||||
$('#start-date-div').show();
|
||||
break;
|
||||
default:
|
||||
$('#end-date-div').hide();
|
||||
$('#start-date-div').hide();
|
||||
break;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@push('styles')
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row bg-title">
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
|
||||
<h4 class="page-title">{{ __('finance.budgets') }}</h4>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> Finance Home</a></li>
|
||||
<li class="active"><i class="fa fa-file"></i> {{ __('finance.budgets') }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('budgets::budgets.menu')
|
||||
|
||||
<div class="white-box">
|
||||
{{ Form::open(['route' => 'budgets.search']) }}
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
{{ Form::label('created_by', "Staff member") }}
|
||||
{{ Form::select('created_by', $created_by, null, ['class' => 'form-control compulsory','required']) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
{{ Form::label('date_range', "Select the date") }}
|
||||
<div class="input-group">
|
||||
<select class="form-control compulsory required" id="dates" name="dates" required>
|
||||
<option value="ALL">ALL DATES</option>
|
||||
<option value="today">TODAY</option>
|
||||
<option value="yesterday">YESTERDAY</option>
|
||||
<option value="week">LAST 7 DAYS</option>
|
||||
<option value="month">LAST 30 DAYS</option>
|
||||
<option value="custom-date">CUSTOM DAY</option>
|
||||
<option value="custom-range">DATE RANGE</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
{{ Form::label('active_state', "Select Active/Inactive Budgets") }}
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="active_state" name="active_state">
|
||||
<option value="active">ACTIVE</option>
|
||||
<option value="inactive">INACTIVE</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6"></div>
|
||||
<div class="col-md-3" style="display: none;" id="start-date-div">
|
||||
<div class="form-group">
|
||||
{{ Form::label('start_date', "Date From") }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('start_date','',['class' => 'form-control compulsory',
|
||||
'required','readonly','id'=>'datepicker-from']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3" style="display: none;" id="end-date-div">
|
||||
<div class="form-group">
|
||||
{{ Form::label('end_date', "Date To") }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('end_date','',['class' => 'form-control compulsory',
|
||||
'required','readonly','id'=>'datepicker-to']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-11"></div>
|
||||
<div class="col-md-1">
|
||||
{{ Form::hidden('query_active', 'active') }}
|
||||
{{ Form::button("Search", ['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
|
||||
</div>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</div>
|
||||
|
||||
@include('flash::message')
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="white-box">
|
||||
<p class="text-muted m-b-30">{{ __('finance.export_data_to_copy_csv_pdf_print') }}</p>
|
||||
{{-- <div class="table-responsive"> --}}
|
||||
<table class="table table-striped table-responsive">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Budget Breakdown</th>
|
||||
<th>Period</th>
|
||||
<th>Income</th>
|
||||
<th>Cost of Goods</th>
|
||||
<th>Expense</th>
|
||||
<th>Projected Net Income</th>
|
||||
<th>Created By</th>
|
||||
<th>Date Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@if(!empty($budgets))
|
||||
@foreach($budgets as $budget)
|
||||
@php
|
||||
$period = "N/A";
|
||||
$period_count = $budget->period_count;
|
||||
$period_start = $budget->period_start;
|
||||
$period_range = "N/A";
|
||||
|
||||
$arr3 = json_decode($budget->entries, true);
|
||||
$income =[]; $expense=[]; $cost_of_goods =[];
|
||||
$income_total=0;$expense_total=0;$cost_of_goods_total = 0;
|
||||
foreach ($arr3 as $rkey => $resource){
|
||||
if ($resource['type'] == 'Income') $income[] = $resource;
|
||||
else if ($resource['type'] == 'Cost Of Goods') $cost_of_goods[] = $resource;
|
||||
else $expense[] = $resource;
|
||||
}
|
||||
if(!empty($income)) {
|
||||
for($counter =0; $counter < count($income); $counter++ ) if(!empty($income[$counter]['account_entries'])) $income_total +=array_sum($income[$counter]['account_entries']);
|
||||
}
|
||||
if(!empty($expense)) {
|
||||
for($counter =0; $counter < count($expense); $counter++ ) if(!empty($expense[$counter]['account_entries'])) $expense_total +=array_sum($expense[$counter]['account_entries']);
|
||||
}
|
||||
if(!empty($cost_of_goods)) {
|
||||
for($counter =0; $counter < count($cost_of_goods); $counter++ ) if(!empty($cost_of_goods[$counter]['account_entries'])) $cost_of_goods_total +=array_sum($cost_of_goods[$counter]['account_entries']);
|
||||
}
|
||||
$projection_total = $income_total - $expense_total - $cost_of_goods_total;
|
||||
|
||||
switch ($budget->period) {
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
|
||||
$period_months = getMonthsList();
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[] = $quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
<tr>
|
||||
<td>{{ $budget->name }}</td>
|
||||
<td>{{ $period }}</td>
|
||||
<td>{{ $period_range }}</td>
|
||||
<td>{{ ugandan_shillings($income_total) }}</td>
|
||||
<td>{{ ugandan_shillings($cost_of_goods_total) }}</td>
|
||||
<td>{{ ugandan_shillings($expense_total) }}</td>
|
||||
<td>{{ ugandan_shillings($projection_total) }}</td>
|
||||
{{-- <td>{{ get_full_name($budget->created_by, 'id', 'first_name', 'last_name', 'users') }}</td> --}}
|
||||
<td>{{ $budget->user_by }}</td>
|
||||
<td>{{ streamline_date_time_short($budget->created_at) }}</td>
|
||||
|
||||
<td>
|
||||
@if( Auth::user()->can('budget-view'))
|
||||
<a class="btn btn-sm btn-rounded btn-info"
|
||||
href="{{ route('budgets.show',$budget->id) }}"><i class="fa fa-info-circle"></i> {{
|
||||
__('budgets.view') }}</a>
|
||||
@endif
|
||||
|
||||
@if( Auth::user()->can('budget-edit'))
|
||||
<a class="btn btn-sm btn-warning btn-rounded"
|
||||
href="{{ route('budgets.edit',$budget->id) }}"><i class="fa fa-pencil"></i> {{
|
||||
__('budgets.edit') }}</a>
|
||||
@endif
|
||||
|
||||
@if( Auth::user()->can('budget-delete'))
|
||||
{{ Form::model($budget->id ,['method' => 'DELETE', 'route' => ['budgets.destroy',
|
||||
$budget->id], 'style'=>'display:inline']) }}
|
||||
<button type="submit" class="btn btn-sm btn-rounded btn-danger"
|
||||
onclick="return confirm('<?php echo __('budgets.are_you_sure') ?>')"><i
|
||||
class="fa fa-trash"></i> {{ __('budgets.delete') }}</button>
|
||||
{{ Form::close() }}
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Budget Breakdown</th>
|
||||
<th>Period</th>
|
||||
<th>Income</th>
|
||||
<th>Cost of Goods</th>
|
||||
<th>Expense</th>
|
||||
<th>Projected Net Income</th>
|
||||
<th>Created By</th>
|
||||
<th>Date Created</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
{{-- </div> --}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
|
||||
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
|
||||
{{-- <script src="{{ asset('elite/tables/js/jszip.min.js') }}"></script> --}}
|
||||
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$('.table').DataTable({
|
||||
responsive: true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'copy', 'csv', 'excel', 'pdf', 'print'
|
||||
],
|
||||
pageLength: 5,
|
||||
order: [],
|
||||
});
|
||||
|
||||
function show(id) {
|
||||
if (document.getElementById(id).style.display === 'none') {
|
||||
document.getElementById(id).style.display = '';
|
||||
}
|
||||
}
|
||||
|
||||
function hide(id) {
|
||||
document.getElementById(id).style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('#datepicker-from, #datepicker-to').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
format: 'dd-mm-yyyy',
|
||||
});
|
||||
|
||||
$('#dates').change(function() {
|
||||
var val = $(this).val();
|
||||
switch (val) {
|
||||
case 'custom-date':
|
||||
$('#end-date-div').hide();
|
||||
$('#start-date-div').show();
|
||||
break;
|
||||
case 'custom-range':
|
||||
$('#end-date-div').show();
|
||||
$('#start-date-div').show();
|
||||
break;
|
||||
default:
|
||||
$('#end-date-div').hide();
|
||||
$('#start-date-div').hide();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function clone_budget(data) {
|
||||
var cell = data.getAttribute('data-href').split("_");
|
||||
if (confirm(`Are you sure you want to clone ${cell[1]}?`) == true)
|
||||
window.location.href = cell[2];
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
@if( Auth::user()->can('budget-list'))
|
||||
<a href="{{ route('budgets.index') }}" class="nav-item btn btn-info" style="border-radius: 5px;"><i class="fa fa-eye" aria-hidden="true"></i> <span style="margin-left: 5px">{{ __('budgets.view_budgets') }}</span></a>
|
||||
@endif
|
||||
@if( Auth::user()->can('budget-create') )
|
||||
<a href="{{ route('budgets.create') }}" class="nav-item btn btn-success" title='Create new Budget' style="border-radius: 5px;"><i class="fa fa-plus" aria-hidden="true"></i> <span style="margin-left: 5px">{{ __('budgets.add_new_budget') }}</span></a>
|
||||
@if(isset($budgets))
|
||||
<div class="dropdown" style="display: inline-block !important;" title='Create from Previous Budgets'>
|
||||
<a href="#" class="btn btn-success dropdown-toggle" id="dropdownMenuButton" style="border-radius: 5px;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span style="margin-left: 5px">Clone Previous budget</span></a>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
@php
|
||||
foreach($budgets as $budget){
|
||||
echo '<a class="dropdown-item" onclick="clone_budget(this)" href="#" data-href="'.$budget->id.'_'.$budget->name.'_'.route('budgets.clone',$budget->id).'">'.$budget->name.'</a>';
|
||||
}
|
||||
@endphp
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endif
|
||||
@if( Auth::user()->can('budget-delete'))
|
||||
<a href="{{ route('budgets.inactive') }}" class="nav-item btn btn-danger" title='Deleted Budgets' style="border-radius: 5px;"><i class="fa fa-undo" aria-hidden="true"></i> <span style="margin-left: 5px">{{ __('budgets.view_inactive_budgets') }}</span></a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,314 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<link rel="icon" type="image/png" sizes="16x16"
|
||||
href="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
|
||||
<title>{{ config('app.name', 'Streamline') }}</title>
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{{ asset('elite/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<!-- Custom CSS -->
|
||||
<link href="{{ asset('elite/css/style.css') }}" rel="stylesheet">
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
tr {
|
||||
page-break-before: always;
|
||||
page-break-after: always;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Preloader -->
|
||||
<div class="preloader">
|
||||
<div class="cssload-speeding-wheel"></div>
|
||||
</div>
|
||||
<div class="white-box">
|
||||
<div class='col-md-12'>
|
||||
@php
|
||||
$second_col = "Account"; $end_col = "Budget Total";
|
||||
$hospital_info = \Streamline\Models\HospitalInformation::find(1);
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d", strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $months_data);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[] = $quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $other_columns);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
// if (is_numeric($year)) $period_range = $year . " to " . ($year + $budget->period_count-1);
|
||||
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $years_data);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if(is_null($hospital_info->pdf_print_header))
|
||||
<img style="max-width: 300px; max-height: 100px;" src="{{ asset($hospital_info->logo) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
<p class="h6 text-center mt-0 font-weight-bold">
|
||||
{{ $hospital_info->name . ' | ' . $hospital_info->phone_number . ' | ' .
|
||||
$hospital_info->email . ' | ' . $hospital_info->address . ' ' .
|
||||
$hospital_info->country }}
|
||||
</p>
|
||||
@else
|
||||
<img style="max-height: 150px;" src="{{ asset($hospital_info->pdf_print_header) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
@endif
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p><h4>{{ __('budgets.budget_name') . ": " . $budget->name }}</h4></p>
|
||||
<p><h4>{{ "Period(" .ucfirst($budget->period) . "): " . $period_range }}</h4></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table color-bordered-table success-bordered-table">
|
||||
<thead>
|
||||
<tr style='display:none;'>
|
||||
<td colspan='<?php echo count($columns); ?>'>
|
||||
Budget Name: {{ ucfirst($budget->name) . " - Period(" .ucfirst($budget->period) . "): " . $period_range }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$totals_budgets = $sub_accounts = $totals_budgets_colums = $income_column_totals = $expense_column_totals = $cost_of_goods_column_totals = [];
|
||||
$sub_account_total= 0;
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- @foreach ($option['sub_accounts'] as $sub_account)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5>{{ get_name(key($option['sub_accounts']), 'id', 'name','chart_of_accounts') }}</h5>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach ($sub_account as $sub_account_entry)
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($sub_account_entry['account_entries']); $j++) $sum +=(int)$sub_account_entry['account_entries'][$j];
|
||||
if ($i==0) echo '<td>' .$sub_account_entry['name']. '</td>' ;
|
||||
else if ($i==$collength - 1) echo "<td style='background-color: #34394D !important; color: #fff !important;'>" . ugandan_shillings($sum) . "</td>" ;
|
||||
else echo "<td>" .ugandan_shillings($sub_account_entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach --}}
|
||||
{{-- Sub Account Section column Totals --}}
|
||||
{{-- <tr style='background-color: rgba(0, 0, 0, 0.075) !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sub_account_total_section = $sub_account_columnTotal_section=0; $keys = array_keys($option['sub_accounts']);
|
||||
if ($i==0) echo '<td>'. get_name(key($option['sub_accounts']), 'id', 'name','chart_of_accounts') . ' Total</td>' ;
|
||||
else if ($i==$collength - 1){ //Sub account totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['sub_accounts']); $m++) {
|
||||
for ($l = 0; $l < count($option['sub_accounts'][$keys[$m]]); $l++) $columnTotal +=(int)($option['sub_accounts'][$keys[$m]][$l]['account_entries'][$k]);
|
||||
}
|
||||
$sub_account_total_section += $columnTotal;
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($sub_account_total_section) . "</td>" ;
|
||||
} else {
|
||||
for ($b=0; $b < count($option['sub_accounts']); $b++) {
|
||||
for ($l = 0; $l < count($option['sub_accounts'][$keys[$b]]); $l++) $sub_account_columnTotal_section +=(int)($option['sub_accounts'][$keys[$b]][$l]['account_entries'][$i - 1]);
|
||||
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($sub_account_columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach --}}
|
||||
{{-- @if (!empty($option['sub_accounts']))
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5>{{ 'Other '. $option['section_header'] }}</h5>
|
||||
</td>
|
||||
</tr>
|
||||
@endif --}}
|
||||
@foreach ($option['entries'] as $entry )
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j];
|
||||
$total=ugandan_shillings($sum);
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i==$collength - 1) echo "<td style='background-color: #34394D !important; color: #fff !important;'>" .$total. "</td>" ;
|
||||
else echo "<td>" .ugandan_shillings($entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Other income Section column Totals --}}
|
||||
{{-- @if (!empty($option['sub_accounts']))
|
||||
|
||||
<tr style='background-color: rgba(0, 0, 0, 0.075) !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section=0; $columnTotal_section=0;
|
||||
if ($i==0) echo '<td> Other '.$option['total_header']. '</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget totals for
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) {
|
||||
$columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
}
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
}
|
||||
else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endif --}}
|
||||
{{-- Operating Budget Section Totals --}}
|
||||
<tr style='background-color: #34394D !important; color: #fff !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section=0; $columnTotal_section=0;
|
||||
if ($i==0) echo '<td class="font-weight-bold">'.$option['total_header']. '</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget totals for
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) {
|
||||
$columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
}
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" .ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
//Push to column total arrays
|
||||
if($entry['type'] == 'Income') array_push($income_column_totals, $columnTotal_section);
|
||||
else if($entry['type'] == 'Expense') array_push($expense_column_totals, $columnTotal_section);
|
||||
else array_push($cost_of_goods_column_totals, $columnTotal_section);
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Budget Projections --}}
|
||||
<tr style='background-color: #34394D !important; color: #fff !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
if ($i==0) echo '<td>Projected Net Income</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget Totals
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
echo "<td>" . ugandan_shillings($overall_projection) . "</td>" ;
|
||||
} else {
|
||||
$columnTotal_projection=$income_column_totals[$i-1] - $expense_column_totals[$i-1] - $cost_of_goods_column_totals[$i-1];
|
||||
echo "<td>".ugandan_shillings($columnTotal_projection). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /#wrapper -->
|
||||
<!-- jQuery -->
|
||||
<script src="{{ asset('elite/bower_components/jquery/dist/jquery.min.js') }}"></script>
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/tether.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bower_components/sidebar-nav/src/metisMenu.js') }}"></script>
|
||||
<!--slimscroll JavaScript -->
|
||||
<script src="{{ asset('elite/js/jquery.slimscroll.js') }}"></script>
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="{{ asset('elite/js/custom.min.js') }}"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+222
@@ -0,0 +1,222 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<link rel="icon" type="image/png" sizes="16x16"
|
||||
href="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
|
||||
<title>{{ config('app.name', 'Streamline') }}</title>
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{{ asset('elite/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<!-- Custom CSS -->
|
||||
<link href="{{ asset('elite/css/style.css') }}" rel="stylesheet">
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 14px;
|
||||
/* line-height: 1.2; */
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
tr {
|
||||
page-break-before: always;
|
||||
page-break-after: always;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
.total {
|
||||
background-color: #34394D !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Preloader -->
|
||||
<div class="preloader">
|
||||
<div class="cssload-speeding-wheel"></div>
|
||||
</div>
|
||||
<div class="white-box">
|
||||
<div class='col-md-12'>
|
||||
@php
|
||||
$hospital_info = \Streamline\Models\HospitalInformation::find(1);
|
||||
$period_months = getMonthsList();
|
||||
$columns = ['Account', 'Budget Total', 'Actual Total', 'Percentage Variance <br> Actual vs Budget', 'Actual Variance <br> Actual vs Budget'];
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d",
|
||||
strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[]=$quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
// $period_range = $range;
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$columns = array_merge($column_1, $years_data);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if(is_null($hospital_info->pdf_print_header))
|
||||
<img style="max-width: 300px; max-height: 100px;" src="{{ asset($hospital_info->logo) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
<p class="h6 text-center mt-0 font-weight-bold">
|
||||
{{ $hospital_info->name . ' | ' . $hospital_info->phone_number . ' | ' .
|
||||
$hospital_info->email . ' | ' . $hospital_info->address . ' ' .
|
||||
$hospital_info->country }}
|
||||
</p>
|
||||
@else
|
||||
<img style="max-height: 150px;" src="{{ asset($hospital_info->pdf_print_header) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
@endif
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p><h4>{{ __('budgets.budget_name') . ": " . $budget->name }}</h4></p>
|
||||
<p><h4>Period: {{ ucfirst($budget->period) . " (" . $period_range . ") " }}</h4></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table class="table color-bordered-table success-bordered-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$actual_totals = $totals_budgets = $summary_colums = $income_column_totals=[];
|
||||
$expense_column_totals=[];$cost_of_goods_column_totals=[];
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach ($option['entries'] as $entry )
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j]; $col_percent=($entry['actual_entry']>0)? round(((($entry['actual_entry'] - $sum) / $entry['actual_entry']) * 100),2).'%' : 'N/A';
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i == 1) echo "<td>" . ugandan_shillings($sum) . "</td>" ;//Budget Total
|
||||
else if ($i == 2) echo "<td>" . ugandan_shillings($entry['actual_entry']) . "</td>" ; //Actual Total
|
||||
else if ($i == 3) echo "<td>" . $col_percent . "</td>" ; //Percentage variance
|
||||
else if ($i == 4) echo "<td>" . ugandan_shillings($entry['actual_entry'] - $sum) . "</td>" ; //Actual Variance
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Budget Section column Totals --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section = $columnTotal_section = 0;
|
||||
if ($i==0) echo '<td>' .$option['total_header']. '</td>' ;
|
||||
else if ($i==1){ //Budget totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" . ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else if ($i==2) {
|
||||
array_push($actual_totals, $option['actual']);
|
||||
echo "<td>" . ugandan_shillings($option['actual']) . "</td>" ; //Actual Total
|
||||
} else if ($i==3) {
|
||||
$percent=($option['actual']> 0)? round(((($option['actual'] - $totals_budgets[count($totals_budgets) - 1]) / $option['actual'] ) * 100),2) .'%' : 'N/A';
|
||||
echo "<td>" . $percent . "</td>" ; //Percentage variance
|
||||
}
|
||||
else if ($i == 4) echo "<td>" .ugandan_shillings($option['actual'] - $totals_budgets[count($totals_budgets) - 1]). "</td>" ; //Actual Variance
|
||||
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Overall Budget Performance --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
array_push($summary_colums, $overall_projection);
|
||||
$total_actual = $data['accrual_net_income'] + $data['cash_net_income'];
|
||||
array_push($summary_colums, $total_actual);
|
||||
$overall_percentage = ($summary_colums[1] > 0)? round(((($summary_colums[1] - $summary_colums[0]) / $summary_colums[1]) * 100),2) .'%' : 'N/A';
|
||||
@endphp
|
||||
<td>Performance</td>
|
||||
<td> {{ ugandan_shillings($overall_projection) }} </td> {{-- Budget Projection --}}
|
||||
<td> {{ ugandan_shillings($total_actual) }} </td> {{-- Actual Total --}}
|
||||
<td> {{ $overall_percentage }} </td> {{-- Percentage variance --}}
|
||||
<td> {{ ugandan_shillings($summary_colums[1] - $summary_colums[0]) }} </td> {{-- Actual Variance --}}
|
||||
</tr>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- /#wrapper -->
|
||||
<!-- jQuery -->
|
||||
<script src="{{ asset('elite/bower_components/jquery/dist/jquery.min.js') }}"></script>
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/tether.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bower_components/sidebar-nav/src/metisMenu.js') }}"></script>
|
||||
<!--slimscroll JavaScript -->
|
||||
<script src="{{ asset('elite/js/jquery.slimscroll.js') }}"></script>
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="{{ asset('elite/js/custom.min.js') }}"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ app()->getLocale() }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<link rel="icon" type="image/png" sizes="16x16"
|
||||
href="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
|
||||
<title>{{ config('app.name', 'Streamline') }}</title>
|
||||
<!-- Bootstrap Core CSS -->
|
||||
<link href="{{ asset('elite/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<!-- Custom CSS -->
|
||||
<link href="{{ asset('elite/css/style.css') }}" rel="stylesheet">
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-size: 14px;
|
||||
/* line-height: 1.2; */
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.total {
|
||||
background-color: #34394D !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
tr {
|
||||
page-break-before: always;
|
||||
page-break-after: always;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- Preloader -->
|
||||
<div class="preloader">
|
||||
<div class="cssload-speeding-wheel"></div>
|
||||
</div>
|
||||
<div class="white-box">
|
||||
<div class='col-md-12'>
|
||||
@php
|
||||
$hospital_info = \Streamline\Models\HospitalInformation::find(1);
|
||||
$period_months = getMonthsList();
|
||||
$column_1 = ['Account'];
|
||||
$colum_2 = ['Budget Total', 'Actual Total', 'Percentage Variance <br> (Actual vs Budget)', 'Actual Variance <br> (Actual vs Budget)'];
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d",
|
||||
strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
$columns = array_merge($column_1, $months_data);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[]=$quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
$columns = array_merge($column_1, $other_columns);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
// $period_range = $range;
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$columns = array_merge($column_1, $years_data);
|
||||
$counter = count($columns);
|
||||
$columns = array_merge($columns, $colum_2);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if(is_null($hospital_info->pdf_print_header))
|
||||
<img style="max-width: 300px; max-height: 100px;" src="{{ asset($hospital_info->logo) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
<p class="h6 text-center mt-0 font-weight-bold">
|
||||
{{ $hospital_info->name . ' | ' . $hospital_info->phone_number . ' | ' .
|
||||
$hospital_info->email . ' | ' . $hospital_info->address . ' ' .
|
||||
$hospital_info->country }}
|
||||
</p>
|
||||
@else
|
||||
<img style="max-height: 150px;" src="{{ asset($hospital_info->pdf_print_header) }}" class="mx-auto d-block mx-3" alt="Responsive image">
|
||||
@endif
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p><h4>{{ __('budgets.budget_name') . ": " . $budget->name }}</h4></p>
|
||||
<p><h4>Period: {{ ucfirst($budget->period) . " (" . $period_range . ") " }}</h4></p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table class="table color-bordered-table table-responsive success-bordered-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$actual_totals = $totals_budgets = $summary_colums = $income_column_totals=[];
|
||||
$expense_column_totals = $cost_of_goods_column_totals=[];
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
@foreach ($option['entries'] as $entry)
|
||||
<tr>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j]; $col_percent=($entry['actual_entry']>0)? round(((($entry['actual_entry'] - $sum) / $entry['actual_entry']) * 100),2).'%' : 'N/A';
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i === $counter) echo "<td>" . ugandan_shillings($sum) . "</td>" ;//Budget Total
|
||||
else if ($i == $counter + 1) echo "<td>" . ugandan_shillings($entry['actual_entry']) . "</td>" ; //Actual Total
|
||||
else if ($i == $counter + 2) echo "<td>" . $col_percent . "</td>" ; //Percentage variance
|
||||
else if ($i == $counter + 3) echo "<td>" . ugandan_shillings($entry['actual_entry'] - $sum) . "</td>" ; //Actual Variance
|
||||
else {
|
||||
echo "<td>" .ugandan_shillings($entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Budget Section column Totals --}}
|
||||
<tr class="total">
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section = $columnTotal_section = 0;
|
||||
if ($i==0) echo '<td>' .$option['total_header']. '</td>' ;
|
||||
else if ($i == $counter){ //Budget totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) $columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" . ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else if ($i == $counter + 1) {
|
||||
array_push($actual_totals, $option['actual']);
|
||||
echo "<td>" . ugandan_shillings($option['actual']) . "</td>" ; //Actual Total
|
||||
} else if ($i== $counter+2) {
|
||||
$percent=($option['actual']> 0)? round(((($option['actual'] - $totals_budgets[count($totals_budgets) - 1]) / $option['actual'] ) * 100),2) .'%' : 'N/A';
|
||||
echo "<td>" . $percent . "</td>" ; //Percentage variance
|
||||
}
|
||||
else if ($i == $counter+3) echo "<td>" .ugandan_shillings($option['actual'] - $totals_budgets[count($totals_budgets) - 1]). "</td>" ; //Actual Variance
|
||||
else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
//Push to column total arrays
|
||||
if($entry['type'] == 'Income') array_push($income_column_totals, $columnTotal_section);
|
||||
else if($entry['type'] == 'Expense') array_push($expense_column_totals, $columnTotal_section);
|
||||
else array_push($cost_of_goods_column_totals, $columnTotal_section);
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Overall Budget Performance --}}
|
||||
|
||||
<tr class="total">
|
||||
@php
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
array_push($summary_colums, $overall_projection);
|
||||
$total_actual = $data['accrual_net_income'] + $data['cash_net_income'];
|
||||
array_push($summary_colums, $total_actual);
|
||||
$overall_percentage = ($summary_colums[1] > 0)? round(((($summary_colums[1] - $summary_colums[0]) / $summary_colums[1]) * 100),2) .'%' : 'N/A';
|
||||
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
if ($i==0) echo '<td>Summary</td>' ;
|
||||
else if ($i == $counter){ //Budget Totals
|
||||
echo "<td>" . ugandan_shillings($overall_projection) . "</td>" ;
|
||||
} else if ($i == $counter + 1) {
|
||||
echo "<td>" . ugandan_shillings($total_actual) . "</td>" ;
|
||||
} else if ($i == $counter + 2) {
|
||||
echo "<td>" . $overall_percentage . "</td>" ;
|
||||
} else if ($i == $counter + 3) {
|
||||
echo "<td>" . ugandan_shillings($summary_colums[1] - $summary_colums[0]) . "</td>" ;
|
||||
} else {
|
||||
$columnTotal_projection=$income_column_totals[$i-1] - $expense_column_totals[$i-1] - $cost_of_goods_column_totals[$i-1];
|
||||
echo "<td>".ugandan_shillings($columnTotal_projection). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<!-- /#wrapper -->
|
||||
<!-- jQuery -->
|
||||
<script src="{{ asset('elite/bower_components/jquery/dist/jquery.min.js') }}"></script>
|
||||
<!-- Bootstrap Core JavaScript -->
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/tether.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bootstrap/dist/js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/bower_components/sidebar-nav/src/metisMenu.js') }}"></script>
|
||||
<!--slimscroll JavaScript -->
|
||||
<script src="{{ asset('elite/js/jquery.slimscroll.js') }}"></script>
|
||||
<!-- Custom Theme JavaScript -->
|
||||
<script src="{{ asset('elite/js/custom.min.js') }}"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
+353
@@ -0,0 +1,353 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@push('styles')
|
||||
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet"
|
||||
type="text/css" />
|
||||
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
|
||||
<style type="text/css">
|
||||
td {
|
||||
min-width: 130px;
|
||||
}
|
||||
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row bg-title">
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12">
|
||||
<h4 class="page-title">{{ __('finance.budgets') }}</h4>
|
||||
</div>
|
||||
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> Finance Home</a></li>
|
||||
<li class="active"><i class="fa fa-file"></i> {{ __('finance.budgets') }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('budgets::budgets.menu')
|
||||
@include('flash::message')
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="white-box">
|
||||
<div class="row">
|
||||
<div class='col-md-2'>
|
||||
<div id="divCloneBudget" style='margin-top: 20px;'>
|
||||
<a id="add_item" title='Create a new budget from this one'
|
||||
href="{{ route('budgets.clone',$budget->id) }}" class='btn btn-rounded btn-success'><span
|
||||
class="glyphicon glyphicon-copy"></span> Clone Budget</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class='col-md-2'>
|
||||
<div id="editBudget" style='margin-top: 20px;'>
|
||||
<a id="edit_item" title='Edit this Budget' href="{{ route('budgets.edit',$budget->id) }}"
|
||||
class='btn btn-rounded btn-warning'><span class="glyphicon glyphicon-edit"></span> Edit
|
||||
Budget</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div style="margin-top: 20px;">
|
||||
<a href="#" onclick="download_table_as_csv('table', '<?php echo ucfirst($budget->name);?>');"
|
||||
title="Download CSV of budget" class="btn btn-success btn-rounded"><span
|
||||
class="glyphicon glyphicon-download"></span> Download CSV</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- <div class="col-md-2">
|
||||
<div style="margin-top: 20px;">
|
||||
<a href="#" onclick="print_div('divToPrint')" title="Print to Pdf"
|
||||
class="btn btn-success btn-rounded"> <span class="glyphicon glyphicon-print"></span> Web
|
||||
Print</a>
|
||||
</div>
|
||||
</div> --}}
|
||||
|
||||
<div class='col-md-2'>
|
||||
<div id="divPrintBudget" style='margin-top: 20px;'>
|
||||
<a title='Print this Budget to pdf' target="_blank"
|
||||
href="{{ route('budgets.print',$budget->id) }}" class='btn btn-rounded btn-success'><span
|
||||
class="glyphicon glyphicon-print"></span> Print Budget</a>
|
||||
</div>
|
||||
</div>
|
||||
@php
|
||||
$period_months = getMonthsList();
|
||||
$second_col = "Account"; $end_col = "Budget Total";
|
||||
switch ($budget->period)
|
||||
{
|
||||
case 'months':
|
||||
$period = "Months";
|
||||
$budget_start_date = strtotime($budget->period_start);//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". $budget->period_count - 1 ." month", $budget_start_date));
|
||||
$period_range = date("M-Y", $budget_start_date) . " to " . date("M-Y", strtotime($budget_end_date));
|
||||
$interval = DateInterval::createFromDateString('1 month');
|
||||
$period = new DatePeriod(new DateTime($budget->period_start), $interval, new DateTime(date("Y-m-d", strtotime("+". $budget->period_count ." month", $budget_start_date))));
|
||||
foreach ($period as $dt) $months_data[] = $dt->format("M-Y");
|
||||
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $months_data);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
|
||||
break;
|
||||
|
||||
case 'quarters':
|
||||
$period = "Quarters";
|
||||
$other_columns =[];$quarter_start_dates =['-01-01', '-04-01', '-07-01', '-10-01']; //m-d
|
||||
$budget_start_date = $budget->period_start;//y-m-d
|
||||
$budget_end_date = date("Y-m-d", strtotime("+". ($budget->period_count-1) * 3 ." month", strtotime('-1 day', strtotime($budget_start_date))));
|
||||
$quarters_data = get_quarters($budget_start_date, $budget_end_date);
|
||||
for($y =0; $y < count($quarters_data); $y++) $other_columns[] = $quarters_data[$y]->period;
|
||||
$period_range = $other_columns[0] . " to " . $other_columns[count($other_columns)-1];
|
||||
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $other_columns);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
case 'years':
|
||||
$period = "Years";
|
||||
$year=date('Y', strtotime($budget->period_start));
|
||||
$sec = substr($year, -2);
|
||||
$years_data = [$year.'/'. ++$sec];
|
||||
for ($i = 1; $i <$budget->period_count; $i++) array_push($years_data, $year + $i .'/'. ++$sec);
|
||||
$period_range = $years_data[0] . " to " . $years_data[count($years_data)-1];
|
||||
$column_1 = [$second_col];
|
||||
$columns = array_merge($column_1, $years_data);
|
||||
array_push($columns, $end_col);
|
||||
$collength = count($columns);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@endphp
|
||||
|
||||
<div class='col-md-4'></div>
|
||||
</div>
|
||||
<div id='divToPrint'>
|
||||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<hr />
|
||||
<div class="row text-center m-t-10">
|
||||
<div class="col-md-12">
|
||||
<p>
|
||||
<h4>{{ __('budgets.budget_name') . ": " . $budget->name }}</h4>
|
||||
</p>
|
||||
<p>
|
||||
<h4>{{ "Period(" .ucfirst($budget->period) . "): " . $period_range }}</h4>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row table-responsive">
|
||||
<table class="table color-bordered-table success-bordered-table" id="table">
|
||||
<thead>
|
||||
<tr style='display:none;'>
|
||||
<td colspan='<?php echo count($columns); ?>'>
|
||||
Budget Name: {{ ucfirst($budget->name) .' - Period('. ucfirst($budget->period) .'): '.$period_range }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
$totals_budgets = $sub_accounts = $totals_budgets_colums = $income_column_totals = $expense_column_totals = $cost_of_goods_column_totals = [];
|
||||
$sub_account_total= 0;
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($options as $option)
|
||||
<tr>
|
||||
<td colspan='<?php echo $collength; ?>'>
|
||||
<h5><strong>{{ $option['section_header'] }}</strong></h5>
|
||||
</td>
|
||||
</tr>
|
||||
{{-- @foreach ($option['sub_accounts'] as $keyid => $sub_account) --}}
|
||||
{{-- <tr>
|
||||
<td class='other' data-section='{{ 'other-rows-'.$keyid }}' onclick='toggler(this);' colspan='<?php echo $collength; ?>'>
|
||||
<h5>{{ get_name($keyid, 'id', 'name','chart_of_accounts') }} <span id={{ 'other-rows-'.$keyid }}>-</span></h5>
|
||||
</td>
|
||||
</tr> --}}
|
||||
{{-- @foreach ($sub_account as $sub_account_entry)
|
||||
<tr class={{ 'other-rows-'.$keyid }}>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($sub_account_entry['account_entries']); $j++) $sum +=(int)$sub_account_entry['account_entries'][$j];
|
||||
if ($i==0) echo '<td>' .$sub_account_entry['name']. '</td>' ;
|
||||
else if ($i==$collength - 1) echo "<td style='background-color: #34394D !important; color: #fff !important;'>" . ugandan_shillings($sum) . "</td>" ;
|
||||
else echo "<td>" .ugandan_shillings($sub_account_entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach --}}
|
||||
{{-- Sub Account Section column Totals --}}
|
||||
{{-- <tr class={{ 'other-rows-'.$keyid }} style='background-color: rgba(0, 0, 0, 0.075) !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sub_account_total_section = $sub_account_columnTotal_section=0; $keys = array_keys($option['sub_accounts']);
|
||||
if ($i==0) echo '<td>'. get_name($keyid, 'id', 'name','chart_of_accounts') . ' Total</td>' ;
|
||||
else if ($i==$collength - 1){ //Sub account totals
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['sub_accounts'][$keyid]); $m++) {
|
||||
$columnTotal +=(int)($option['sub_accounts'][$keyid][$m]['account_entries'][$k]);
|
||||
}
|
||||
$sub_account_total_section += $columnTotal;
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($sub_account_total_section) . "</td>" ;
|
||||
} else {
|
||||
for ($b=0; $b < count($option['sub_accounts'][$keyid]); $b++) {
|
||||
$sub_account_columnTotal_section +=(int)($option['sub_accounts'][$keyid][$b]['account_entries'][$i - 1]);
|
||||
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($sub_account_columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr> --}}
|
||||
{{-- @endforeach
|
||||
@if (!empty($option['sub_accounts']))
|
||||
<tr>
|
||||
<td class='other' data-section='{{ 'other-rows-'.$option['section_header'] }}' onclick='toggler(this);' colspan='<?php echo $collength; ?>'>
|
||||
<h5>{{ 'Other '. $option['section_header'] }} <span id={{ 'other-rows-'.$option['section_header'] }}>-</span></h5>
|
||||
</td>
|
||||
</tr>
|
||||
@endif --}}
|
||||
@foreach ($option['entries'] as $entry )
|
||||
<tr class={{ 'other-rows-'.$option['section_header'] }}>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$sum=0;
|
||||
for ($j=0; $j < count($entry['account_entries']); $j++) $sum +=(int)$entry['account_entries'][$j];
|
||||
$total=ugandan_shillings($sum);
|
||||
|
||||
if ($i==0) echo '<td>' .$entry['name']. '</td>' ;
|
||||
else if ($i==$collength - 1) echo "<td style='background-color: #34394D !important; color: #fff !important;'>" .$total. "</td>" ;
|
||||
else echo "<td>" .ugandan_shillings($entry['account_entries'][$i - 1]). "</td>" ;
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
{{-- Other income Section column Totals --}}
|
||||
{{-- @if (!empty($option['sub_accounts']))
|
||||
|
||||
<tr class={{ 'other-rows-'.$option['section_header'] }} style='background-color: rgba(0, 0, 0, 0.075) !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section=0; $columnTotal_section=0;
|
||||
if ($i==0) echo '<td> Other '.$option['section_header']. ' total</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget totals for
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) {
|
||||
$columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
}
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
echo "<td>" .ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
}
|
||||
else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endif --}}
|
||||
{{-- Operating Budget Section Totals --}}
|
||||
<tr style='background-color: #34394D !important; color: #fff !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
$budget_total_section=0; $columnTotal_section=0;
|
||||
if ($i==0) echo '<td class="font-weight-bold">'.$option['total_header']. '</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget totals for
|
||||
for($k=0; $k < $budget->period_count; $k++){
|
||||
$columnTotal = 0;
|
||||
for ($m = 0; $m < count($option['entries']); $m++) {
|
||||
$columnTotal +=(int)($option['entries'][$m]['account_entries'][$k]);
|
||||
}
|
||||
$budget_total_section +=$columnTotal;
|
||||
}
|
||||
array_push($totals_budgets, $budget_total_section);
|
||||
echo "<td>" .ugandan_shillings($budget_total_section) . "</td>" ;
|
||||
} else {
|
||||
for ($b=0; $b < count($option['entries']); $b++) {
|
||||
$columnTotal_section +=(int)($option['entries'][$b]['account_entries'][$i - 1]);
|
||||
}
|
||||
//Push to column total arrays
|
||||
if($entry['type'] == 'Income') array_push($income_column_totals, $columnTotal_section);
|
||||
else if($entry['type'] == 'Expense') array_push($expense_column_totals, $columnTotal_section);
|
||||
else array_push($cost_of_goods_column_totals, $columnTotal_section);
|
||||
|
||||
echo "<td>" .ugandan_shillings($columnTotal_section). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
</tr>
|
||||
@endforeach
|
||||
|
||||
{{-- Budget Projections --}}
|
||||
<tr style='background-color: #34394D !important; color: #fff !important;'>
|
||||
@php
|
||||
for ($i =0; $i < $collength; $i++) {
|
||||
if ($i==0) echo '<td class="font-weight-bold">Projected Net Income</td>' ;
|
||||
else if ($i==$collength - 1){ //Budget Totals
|
||||
$overall_projection = $totals_budgets[0] - $totals_budgets[1] - $totals_budgets[2];
|
||||
echo "<td>" . ugandan_shillings($overall_projection) . "</td>" ;
|
||||
} else {
|
||||
$columnTotal_projection=$income_column_totals[$i-1] - $expense_column_totals[$i-1] - $cost_of_goods_column_totals[$i-1];
|
||||
echo "<td>".ugandan_shillings($columnTotal_projection). "</td>" ;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
<tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
@php
|
||||
for ($i = 0; $i < count($columns); $i++) echo '<th>' .$columns[$i].'</th>';
|
||||
@endphp
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
|
||||
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
|
||||
<script src="{{ asset('js/streamline_functions.js') }}"></script>
|
||||
<script type="text/javascript">
|
||||
function toggler(data){
|
||||
let section = data.getAttribute('data-section'); console.log(section);
|
||||
$('#'+section).text(function(_, value){return value=='-'?'+':'-'});
|
||||
$('.' + section).toggle(1000);
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::middleware('auth:api')->get('/budgets', function () {
|
||||
return "Budgets";
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::group(['middleware' => ['auth', 'disablebackbutton', 'user-locale','subscription-tracking', 'password-expiry']], function () {
|
||||
/* budgets */
|
||||
Route::any('budgets_search', 'BudgetController@search')->name('budgets.search');
|
||||
Route::any('budget/performance/{type}', 'BudgetController@budget_performance')->name('budgets.performance');
|
||||
Route::get('budgets_inactive', 'BudgetController@inactive')->name('budgets.inactive');
|
||||
Route::get('budgets/clone/{id}', 'BudgetController@clone')->name('budgets.clone');
|
||||
Route::get('budgets/print/{id}', 'BudgetController@print_budget')->name('budgets.print');
|
||||
Route::post('budgets_activate/{id}', 'BudgetController@activate')->name('budgets.activate');
|
||||
Route::any('/budgets/get_budgets', 'BudgetController@get_budgets')->name('budgets.get_outcomes');
|
||||
Route::post('budgets/print_budget_report', 'BudgetController@print_budget_report')->name('budgets.print_reports');
|
||||
Route::resource('budgets', 'BudgetController');
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
image: alpine/git:latest
|
||||
|
||||
pipelines:
|
||||
branches:
|
||||
main:
|
||||
- step:
|
||||
name: Merge To Beta
|
||||
script:
|
||||
- git remote set-url origin https://Kabricks:${APP_SECRET}@bitbucket.org/dcsammi/${BITBUCKET_REPO_SLUG}
|
||||
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||
- git fetch
|
||||
- git checkout beta
|
||||
- git merge main
|
||||
- git commit --amend -m "[skip ci] Merge changes from main"
|
||||
- git push
|
||||
- step:
|
||||
name: Deploy To Test
|
||||
script:
|
||||
- echo "Ready to deploy to demo or production!"
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "Budgets",
|
||||
"alias": "budgets",
|
||||
"description": "Budgets",
|
||||
"keywords": [],
|
||||
"priority": 0,
|
||||
"providers": [
|
||||
"Modules\\Budgets\\Providers\\BudgetsServiceProvider"
|
||||
],
|
||||
"files": []
|
||||
}
|
||||
Reference in New Issue
Block a user