first commit
This commit is contained in:
349
templates/finances/main-view.php
Normal file
349
templates/finances/main-view.php
Normal file
@@ -0,0 +1,349 @@
|
||||
<div class="row block-header">
|
||||
<div class="col-12">
|
||||
<h2>statystyki <strong>finansowe</strong><? if ( $this -> client_id ): echo ' - ' . \factory\Finances::client_name( $this -> client_id ); endif;?></h2>
|
||||
<small>Analiza kosztów i przychodów (wg kategorii)</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="panel panel-tile text-center br-a br-grey">
|
||||
<div class="panel-body">
|
||||
<h1 class="fs30 mt5 mbn <?= ( $this -> wallet_summary > 0 ) ? 'text-system' : 'text-danger';?>"><?= \S::number_display( $this -> wallet_summary );?></h1>
|
||||
</div>
|
||||
<div class="panel-footer br-t p12">
|
||||
<span class="fs12">
|
||||
<b>od początku</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="panel panel-tile text-center br-a br-grey">
|
||||
<div class="panel-body">
|
||||
<h1 class="fs30 mt5 mbn <?= ( $this -> wallet_summary_this_month > 0 ) ? 'text-system' : 'text-danger';?>"><?= \S::number_display( $this -> wallet_summary_this_month );?></h1>
|
||||
</div>
|
||||
<div class="panel-footer br-t p12">
|
||||
<span class="fs11">
|
||||
<b>suma w tym miesiącu</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="panel panel-tile text-center br-a br-grey">
|
||||
<div class="panel-body">
|
||||
<h1 class="fs30 mt5 mbn <?= ( $this -> wallet_income_this_month > 0 ) ? 'text-system' : 'text-danger';?>"><?= \S::number_display( $this -> wallet_income_this_month );?></h1>
|
||||
</div>
|
||||
<div class="panel-footer br-t p12">
|
||||
<span class="fs11">
|
||||
<b>dochody w tym miesiącu</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="panel panel-tile text-center br-a br-grey">
|
||||
<div class="panel-body">
|
||||
<h1 class="fs30 mt5 mbn <?= ( $this -> wallet_expenses_this_month > 0 ) ? 'text-system' : 'text-danger';?>"><?= \S::number_display( $this -> wallet_expenses_this_month );?></h1>
|
||||
</div>
|
||||
<div class="panel-footer br-t p12">
|
||||
<span class="fs11">
|
||||
<b>wydatki w tym miesiącu</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="finance-manager">
|
||||
<div class="column-left">
|
||||
<div class="clients-list-container">
|
||||
<div class="finance-tags">
|
||||
<a href="/finances/main_view/tag-clear=true" class="btn btn-sm btn-success"><i class="fa fa-bars"></i>wszystkie</a>
|
||||
<?
|
||||
$max = $this->tags[0]['count'];
|
||||
$min = $this->tags[count($this->tags) - 1]['count'];
|
||||
if (count($this->tags) === 1)
|
||||
$min = 0;
|
||||
$step = ($max - $min) / 10;
|
||||
?>
|
||||
<?
|
||||
if ($min == $max)
|
||||
$max++;
|
||||
|
||||
if (!$step)
|
||||
$step = 1;
|
||||
|
||||
if (is_array($this->tags)) foreach ($this->tags as $tag)
|
||||
{
|
||||
echo '<a href="/finances/main_view/tag-id=' . $tag['id'] . '" class="';
|
||||
$i = $max;
|
||||
$z = 100;
|
||||
while ($i >= $min)
|
||||
{
|
||||
if ($tag['count'] <= $i and $tag['count'] > ($i - $step))
|
||||
{
|
||||
echo 'zoom-' . $z;
|
||||
}
|
||||
$i -= $step;
|
||||
$z -= 10;
|
||||
}
|
||||
if ($tag['id'] == $this->tag_id) echo ' text-primary';
|
||||
echo '">' . $tag['tag'] . '</a>';
|
||||
};
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column-middle">
|
||||
<div class="row">
|
||||
<div class="col-12 flex">
|
||||
<div class="input-group finance-calendar" style="width: 240px;">
|
||||
<input type="text" name="date" class="form-control date-range" value="<?= $this->date_from . ' - ' . $this->date_to; ?>" />
|
||||
</div>
|
||||
<select class="form-control finance-group" name="group_id">
|
||||
<? foreach ($this->groups as $group) : ?>
|
||||
<option value="<?= $group['id']; ?>" <? if ($this->group_id == $group['id']) : ?>selected="selected"
|
||||
<? endif; ?>><?= $group['name']; ?>
|
||||
</option>
|
||||
<? endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row categories">
|
||||
<div class="col-12">
|
||||
<table class="table table-sm" style="background: #FFF;">
|
||||
<thead>
|
||||
<tr class="dark">
|
||||
<th>Kategoria <a href="/finances/category_edit/" class="btn btn-success btn-xs btn-add-category" title="dodaj kategorię"><i class="fa fa-plus"></i></a></th>
|
||||
<th class="text-right" style="width: 100px;">Koszty</th>
|
||||
<th class="text-right" style="width: 50px;">Ilość</th>
|
||||
<th class="text-right" style="width: 100px;">Przychód</th>
|
||||
<th class="text-right" style="width: 50px;">Ilość</th>
|
||||
<th class="text-right" style="width: 100px">Dochód</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if (is_array($this->categories)) : foreach ($this->categories as $category) : ?>
|
||||
<? unset($summary_costs);
|
||||
unset($summary_income); ?>
|
||||
<tr>
|
||||
<th colspan="6" class="category-name">
|
||||
<div class="manage-menu">
|
||||
<span class="context-menu" data-container-id="category-<?= $category['id'];?>-menu"></span>
|
||||
<div class="context-menu-container" id="category-<?= $category['id'];?>-menu">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/finances/category_edit/parent-id=<?= $category['id']; ?>" title="dodaj podkategorię">
|
||||
Dodaj podkategorię
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="category-delete" category_id="<?= $category['id']; ?>" title="usuń kategorię">
|
||||
Usuń kategorię
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
$(document).ready(function(){
|
||||
var tableContextMenu = new ContextMenu("category-<?= $category['id'];?>-menu", menuItemClickListener);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= $category['name']; ?>
|
||||
</th>
|
||||
</tr>
|
||||
<? if (is_array($category['subcategories'])) : foreach ($category['subcategories'] as $subcategory) : ?>
|
||||
<tr>
|
||||
<td class="pl15 category-name">
|
||||
<div class="manage-menu">
|
||||
<span class="context-menu" data-container-id="category-<?= $subcategory['id'];?>-menu"></span>
|
||||
<div class="context-menu-container" id="category-<?= $subcategory['id'];?>-menu">
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/finances/category_edit/id=<?= $subcategory['id']; ?>" title="edytuj podkategorię">
|
||||
Edytuj podkategorię
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/finances/operation_edit/category-id=<?= $subcategory['id']; ?>" title="dodaj operację">
|
||||
Dodaj operację
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/finances/operations_list/category-id=<?= $subcategory['id']; ?>" title="pokaż listę operacji">
|
||||
Pokaż listę operacji
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="category-delete" category_id="<?= $subcategory['id']; ?>" title="usuń kategorię">
|
||||
Usuń kategorię
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
$(document).ready(function(){
|
||||
var tableContextMenu = new ContextMenu("category-<?= $subcategory['id'];?>-menu", menuItemClickListener);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= $subcategory['name']; ?>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<?= \S::number_display( $subcategory['costs'] ); ?>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<?= $subcategory['costs_count'] * (-1); ?>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<?= \S::number_display( $subcategory['income'] ); ?>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<?= $subcategory['income_count']; ?>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span><?= \S::number_display( $subcategory['income'] + $subcategory['costs'] );?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?
|
||||
$summary_costs += $subcategory['costs'];
|
||||
$summary_income += $subcategory['income'];
|
||||
$total_costs += $subcategory['costs'];
|
||||
$total_income += $subcategory['income'];
|
||||
?>
|
||||
<? endforeach;
|
||||
endif; ?>
|
||||
<tr>
|
||||
<th class="text-right">
|
||||
Razem:
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<?= \S::number_display($summary_costs); ?>
|
||||
</th>
|
||||
<th class="text-right" colspan="2">
|
||||
<?= \S::number_display($summary_income); ?>
|
||||
</th>
|
||||
<th class="text-right" colspan="2">
|
||||
<span class="<? if ( $summary_income + $summary_costs > 0 ):?>text-success<? elseif ( $summary_income + $summary_costs < 0 ):?>text-danger<? endif;?>"><?= \S::number_display( $summary_income + $summary_costs );?></span>
|
||||
</th>
|
||||
</tr>
|
||||
<? endforeach;
|
||||
endif; ?>
|
||||
<tr>
|
||||
<th class="text-right">
|
||||
Razem:
|
||||
</th>
|
||||
<th class="text-right">
|
||||
<?= \S::number_display($total_costs); ?>
|
||||
</th>
|
||||
<th class="text-right" colspan="2">
|
||||
<?= \S::number_display($total_income); ?>
|
||||
</th>
|
||||
<th class="text-right" colspan="2">
|
||||
<span class="<? if ( $total_income + $total_costs > 0 ):?>text-success<? elseif ( $total_income + $total_costs < 0 ):?>text-danger<? endif;?>"><?= \S::number_display( $total_income + $total_costs );?></span>
|
||||
</th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column-right">
|
||||
<table class="table table-sm" style="background: #FFF;">
|
||||
<thead>
|
||||
<tr class="dark">
|
||||
<th class="text-right" style="width: 90px;">Data</th>
|
||||
<th class="text-right" style="width: 100px;">Kwota</th>
|
||||
<th>Szczegóły</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( is_array( $this -> operations_list ) ): foreach ( $this -> operations_list as $operation ):?>
|
||||
<tr>
|
||||
<td class="text-right">
|
||||
<?= $operation['date'];?>
|
||||
</td>
|
||||
<td class="text-right <?= $operation['amount'] > 0 ? 'text-success' : 'text-danger';?>">
|
||||
<?= \S::number_display( $operation['amount'] );?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $operation['name'];?>
|
||||
<? if ( $operation['description'] ):?>
|
||||
<br><small><?= $operation['description'];?></small>
|
||||
<? endif;?>
|
||||
<br><small><?= \factory\Finances::get_operation_tags( $operation['id'] );?></small>
|
||||
</td>
|
||||
<td class="pl15 category-name">
|
||||
<a href="/finances/operation_edit/category-id=<?= $operation['category_id'];?>&operation-id=<?= $operation['id'];?>" class="green" title="edytuj operację"><i class="fa fa-cog"></i></a>
|
||||
<a href="/finances/operation_delete/category-id=<?= $operation['category_id'];?>&operation-id=<?= $operation['id'];?>" class="red operation-delete" title="usuń operację"><i class="fa fa-times"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<? $total = $total + $operation['amount'];?>
|
||||
<? endforeach; endif;?>
|
||||
<tr>
|
||||
<th class="text-right" colspan='2'>
|
||||
<?= \S::number_display( $total );?>
|
||||
</th>
|
||||
<th colspan="3"></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/libraries/context-menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
function menuItemClickListener(menu_item, parent) {}
|
||||
|
||||
$(function() {
|
||||
|
||||
$('body').on('click', '.category-delete', function() {
|
||||
var category_id = $(this).attr('category_id');
|
||||
$.alert({
|
||||
title: 'Potwierdź',
|
||||
content: 'Na pewno chcesz usunąć wybraną kategorię',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-sm-8',
|
||||
theme: 'modern',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-default',
|
||||
action: function() {}
|
||||
},
|
||||
confirm: {
|
||||
text: 'Usuń kategorię',
|
||||
btnClass: 'btn-red',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = '/finances/category_delete/category_id=' + category_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('change', '.finance-group', function() {
|
||||
document.location.href = '/finances/main_view/group-id=' + $(this).val();
|
||||
});
|
||||
|
||||
$('body').on('change', '.date-range', function() {
|
||||
document.location.href = '/finances/main_view/dates=' + $(this).val();
|
||||
});
|
||||
|
||||
jQuery('body').on('click', '.date-range-icon', function() {
|
||||
$(this).parents('.input-group').children('input').trigger('click');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user