feat: Refactor CRM and Finances modules

- Updated client-edit template to change 'Firma' to 'Nazwa' and added 'Nazwa firmy' input field.
- Modified main-view template to reflect the new naming conventions for clients.
- Enhanced finances main-view to display a list of clients with revenue details.
- Added client selection dropdown in operation-edit template.
- Improved work-time template by adding keyboard shortcut for task confirmation.
- Introduced CrmController for handling client-related actions.
- Created FinancesController to manage finance operations and categories.
- Implemented ClientRepository for client data management.
- Developed FinanceRepository for finance operations and data handling.
This commit is contained in:
2026-02-14 21:30:02 +01:00
parent c9795ca866
commit f3be8e1025
16 changed files with 939 additions and 626 deletions

View File

@@ -3,12 +3,19 @@ global $db;
ob_start();
?>
<?= \Html::input( [
'label' => 'Firma',
'label' => 'Nazwa',
'name' => 'firm',
'id' => 'firm',
'value' => $this -> client -> firm,
'inline' => true
] );?>
<?= \Html::input( [
'label' => 'Nazwa firmy',
'name' => 'firm_name',
'id' => 'firm_name',
'value' => $this -> client -> firm_name,
'inline' => true
] );?>
<?= \Html::input( [
'label' => 'Emaile',
'name' => 'emails',

View File

@@ -9,7 +9,7 @@ $grid = new \grid( 'crm_client' );
$grid -> debug = true;
$grid -> gdb_opt = $gdb;
$grid -> search = [
[ 'name' => 'Firma', 'db' => 'firm', 'type' => 'text' ],
[ 'name' => 'Nazwa', 'db' => 'firm', 'type' => 'text' ],
[ 'name' => 'Status', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => \factory\Crm::$status ] ],
];
$grid -> order = [ 'column' => 'firm', 'type' => 'ASC' ];
@@ -27,8 +27,11 @@ $grid -> columns_view = [
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_update]" ) );',
'sort' => true
], [
'name' => 'Firma',
'name' => 'Nazwa',
'db' => 'firm',
], [
'name' => 'Nazwa firmy',
'db' => 'firm_name',
], [
'name' => 'Telefony',
'db' => 'phones',

View File

@@ -49,40 +49,28 @@
<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 = is_array( $this -> tags ) ? $this -> tags[ count( $this -> tags ) - 1 ]['count'] : 0;
if ( is_array( $thi -> tags ) and 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 class="finance-clients">
<a href="/finances/main_view/client_clear=true" class="btn btn-sm btn-success mb10" style="display:block;"><i class="fa fa-bars"></i> wszyscy klienci</a>
<? if ( is_array( $this -> clients ) and count( $this -> clients ) ):?>
<table class="table table-sm table-hover mb0" style="background: #FFF; font-size: 12px;">
<thead>
<tr>
<th>Klient</th>
<th class="text-right" style="width: 90px;">Dochód</th>
</tr>
</thead>
<tbody>
<? foreach ( $this -> clients as $client ):?>
<tr class="<?= ( $client['id'] == $this -> client_id ) ? 'table-primary' : '';?>" style="cursor: pointer;" onclick="document.location.href='/finances/main_view/client_id=<?= $client['id'];?>'">
<td><?= $client['firm'];?></td>
<td class="text-right <?= $client['total'] > 0 ? 'text-success' : 'text-danger';?>"><?= \S::number_display( $client['total'] );?></td>
</tr>
<? endforeach;?>
</tbody>
</table>
<? else:?>
<small class="text-muted">Brak operacji z przypisanymi klientami w wybranym okresie.</small>
<? endif;?>
</div>
</div>
</div>

View File

@@ -31,6 +31,18 @@ ob_start();
'inline' => true
] );
$clients_values = [ '' => '--- brak ---' ];
if ( is_array( $this -> clients ) ) foreach ( $this -> clients as $client )
$clients_values[ $client['id'] ] = $client['firm'];
echo \Html::select( [
'label' => 'Klient',
'name' => 'client_id',
'id' => 'client_id',
'values' => $clients_values,
'value' => $this -> operation['client_id'],
] );
foreach ( $this -> operation['tags'] as $tag )
{
$tags_value .= $tag['tag'];
@@ -110,4 +122,4 @@ echo $grid -> draw();
}
});
});
</script>
</script>

View File

@@ -236,6 +236,7 @@ usort( $billing_clients, function( $a, $b ) {
confirm: {
text: 'Zamknij zadanie',
btnClass: 'btn-orange',
keys: ['enter'],
action: function() {
onConfirm();
}