first commit

This commit is contained in:
2024-11-10 11:11:35 +01:00
commit 3f306ccb81
4417 changed files with 633288 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
<?
global $db;
ob_start();
echo \Html::input( [
'name' => 'group_id',
'id' => 'name',
'value' => $this -> category ? $this -> category['group_id'] : $this -> group_id,
'type' => 'hidden'
] );
echo \Html::input( [
'label' => 'Nazwa',
'name' => 'name',
'id' => 'name',
'value' => $this -> category['name'],
'class' => 'require',
'inline' => true
] );
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> id = 'category-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = \S::get( 'parent-id' ) ? 'edycja <strong>podkategorii</strong>' : 'edycja <strong>kategorii</strong>';
$grid -> title_small = \S::get( 'parent-id' ) ? 'Zarządzaj ustawieniami podkategorii' : 'Zarządzaj ustawieniami kategorii';
$grid -> fields = [
[
'db' => 'id',
'type' => 'hidden',
'value' => $this -> category['id']
], [
'db' => 'parent_id',
'type' => 'hidden',
'value' => $this -> category['id'] ? $this -> category['parent_id'] : \S::get( 'parent-id' )
]
];
$grid -> external_code = $out;
$grid -> actions = [
'save' => [ 'url' => '/finances/category_save/', 'back_url' => '/finances/main_view/' ],
'cancel' => [ 'url' => '/finances/main_view/' ]
];
$grid -> persist_edit = true;
$grid -> id_param = 'id';
echo $grid -> draw();
?>

View 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>

View File

@@ -0,0 +1,114 @@
<?
global $db;
ob_start();
if ( $this -> operation['id'] )
$date = $this -> operation['date'];
elseif ( $this -> operation_date )
$date = $this -> operation_date;
else
$date = date( 'Y-m-d' );
echo \Html::input( [
'label' => 'Data',
'name' => 'date',
'value' => $date,
'class' => 'date require',
'inline' => true
] );
echo \Html::input( [
'label' => 'Kwota',
'name' => 'amount',
'value' => $this -> operation['amount'],
'class' => 'price require',
'inline' => true
] );
echo \Html::input( [
'label' => 'Opis',
'name' => 'description',
'value' => $this -> operation['description'],
'inline' => true
] );
foreach ( $this -> operation['tags'] as $tag )
{
$tags_value .= $tag['tag'];
if ( $tag != end( $this -> operation['tags'] ) )
$tags_value .= ',';
}
echo \Html::input( [
'label' => 'Tagi',
'name' => 'tags',
'id' => 'tags',
'value' => $tags_value,
'inline' => true
] );
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> id = 'operation-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'edycja <strong>operacji</strong>';
$grid -> title_small = 'Zarządzaj parametrami operacji';
$grid -> fields = [
[
'db' => 'id',
'type' => 'hidden',
'value' => $this -> operation['id']
], [
'db' => 'category_id',
'type' => 'hidden',
'value' => $this -> operation['id'] ? $this -> operation['category_id'] : \S::get( 'category-id' )
]
];
$grid -> external_code = $out;
if ( \S::get( 'return' ) == 'category' or $this -> operation['id'] )
$return_url = '/finances/operations_list/category-id=' . $this -> category_id;
else
$return_url = '/finances/main_view/';
$grid -> actions = [
'save' => [ 'url' => '/finances/operation_save/', 'back_url' => $return_url ],
'cancel' => [ 'url' => $return_url ]
];
$grid -> persist_edit = true;
$grid -> id_param = 'id';
echo $grid -> draw();
?>
<link rel="stylesheet" type="text/css" href="/libraries/tagsinput/bootstrap-tagsinput.css">
<link rel="stylesheet" type="text/css" href="/libraries/tagsinput/app.css">
<script type="text/javascript" src="/libraries/typeahead.bundle.js"></script>
<script type="text/javascript" src="/libraries/tagsinput/bootstrap-tagsinput.min.js"></script>
<script type="text/javascript">
$( function() {
var tags_list = [ <? foreach ( $this -> tags_json as $tag ): echo '"' . $tag . '"'; if ( $tag != end( $this -> tags_json ) ) echo','; endforeach;?> ];
var tags_data = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: $.map( tags_list, function(item) {
return {
name: item
};
})
});
tags_data.initialize();
console.log( tags_data );
$( '#tags' ).tagsinput({
typeaheadjs: {
name: 'tags',
displayKey: 'name',
valueKey: 'name',
source: tags_data.ttAdapter()
}
});
});
</script>

View File

@@ -0,0 +1,125 @@
<div class="row block-header">
<div class="col-12">
<h2><?= $this -> category['name'];?></h2>
<small>lista <strong>operacji</strong></small>
</div>
</div>
<div class="row">
<div class="col-12 col-lg-3">
<a href="/finances/main_view/" class="btn btn-success"><i class="fa fa-reply"></i>Wstecz</a>
<a href="/finances/operation_edit/category-id=<?= $this -> category['id'];?>&return=category" class="btn btn-primary" title="dodaj operację">
<i class="fa fa-plus"></i>dodaj operację
</a>
</div>
<div class="col-12 col-lg-9">
<div class="input-group finance-calendar float-right">
<span class="input-group-addon cursor date-range-icon">
<i class="fa fa-calendar"></i>
</span>
<input type="text" name="date" class="form-control date-range" style="width: 200px; margin-top: 0px; height: 33px;" value="<?= $this -> date_from . ' - ' . $this -> date_to;?>" />
</div>
</div>
</div>
<div class="row categories">
<div class="col-12">
<table class="table table-sm" style="background: #FFF;">
<thead>
<tr class="dark">
<th class="text-right" style="width: 100px;">Data</th>
<th class="text-right" style="width: 100px;">Kwota</th>
<th>Opis</th>
<th>Tagi</th>
</tr>
</thead>
<tbody>
<? if ( is_array( $this -> operations ) ): foreach ( $this -> operations as $operation ):?>
<tr>
<td class="text-right">
<?= $operation['date'];?>
</td>
<td class="text-right">
<?= \S::number_display( $operation['amount'] );?>
</td>
<td>
<?= $operation['description'];?>
</td>
<td class="pl15 category-name">
<?
$tags_value = '';
foreach ( $operation['tags'] as $tag )
{
$tags_value .= $tag['tag'];
if ( $tag != end( $operation['tags'] ) )
$tags_value .= ', ';
};
echo $tags_value;
?>
<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="2"></th>
</tr>
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$( function()
{
$( 'body' ).on( 'click', '.operation-delete', function(e)
{
e.preventDefault();
var href = $( this ).attr( 'href' );
$.confirm(
{
title: 'Potwierdź',
type: 'orange',
columnClass: 'col-md-8 col-md-offset-2 col-12',
closeIcon: true,
closeIconClass: 'fa fa-close',
content: 'Na pewno chcesz oznaczyć wybraną operacje?',
theme: 'modern',
buttons:
{
submit:
{
text: '<i class="fa fa-check"></i>Zatwierdź',
btnClass: 'btn-success',
keys: ['enter'],
action: function ()
{
document.location.href = href;
}
},
cancel:
{
text: '<i class="fa fa-close"></i>Anuluj',
btnClass: 'btn-danger',
action: function() {}
}
}
});
return false;
});
$( '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>