This commit is contained in:
2026-04-02 12:00:38 +02:00
parent 46dae22a71
commit e743245cee
21 changed files with 2105 additions and 196 deletions

View File

@@ -0,0 +1,148 @@
<?php
$esc = function( $value )
{
return htmlspecialchars( (string)$value, ENT_QUOTES, 'UTF-8' );
};
?>
<style>
.fakturownia-panel {
border-radius: 6px;
overflow: hidden;
}
.fakturownia-panel .panel-heading {
padding: 12px 14px;
}
.fakturownia-panel .panel-title {
margin: 0;
line-height: 1.3;
}
.fakturownia-panel .panel-body {
padding-bottom: 10px;
}
.fakturownia-panel .panel-body > :last-child {
margin-bottom: 0;
}
.fakturownia-panel .select2-container {
min-width: 320px !important;
}
</style>
<div class="panel panel-default fakturownia-panel">
<div class="panel-heading">
<h4 class="panel-title">Import faktur z Fakturowni</h4>
</div>
<div class="panel-body">
<? if ( is_array( $this -> fakturownia_last_summary ) && isset( $this -> fakturownia_last_summary['summary'] ) ): ?>
<div class="alert alert-info mb15">
Ostatni import: <?= $esc( $this -> fakturownia_last_summary['at'] ?? '-' ); ?><br>
Zaimportowano: <strong><?= (int)( $this -> fakturownia_last_summary['summary']['imported'] ?? 0 ); ?></strong>,
pominieto: <strong><?= (int)( $this -> fakturownia_last_summary['summary']['skipped'] ?? 0 ); ?></strong>,
brak mapowan: <strong><?= (int)( $this -> fakturownia_last_summary['summary']['unmapped'] ?? 0 ); ?></strong>,
bledy: <strong><?= (int)( $this -> fakturownia_last_summary['summary']['errors'] ?? 0 ); ?></strong>
</div>
<? endif; ?>
<? if ( is_array( $this -> fakturownia_pending_clients ) && count( $this -> fakturownia_pending_clients ) ): ?>
<h5>Brakujace mapowania klientow</h5>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Klient z Fakturowni</th>
<th>CRM klient</th>
<th style="width: 130px;">Akcja</th>
</tr>
</thead>
<tbody>
<? foreach ( $this -> fakturownia_pending_clients as $row ): ?>
<tr>
<td>
<?= $esc( $row['external_name'] ); ?><br>
<small class="text-muted">Klucz: <?= $esc( $row['external_key'] ); ?> | wystapienia: <?= (int)$row['hits']; ?></small>
</td>
<td>
<form method="post" action="/finances/fakturownia_client_mapping_save/" class="form-inline">
<input type="hidden" name="csrf_token" value="<?= \S::csrf_token(); ?>">
<input type="hidden" name="external_key" value="<?= $esc( $row['external_key'] ); ?>">
<input type="hidden" name="external_name" value="<?= $esc( $row['external_name'] ); ?>">
<select name="crm_client_id" class="form-control input-sm js-fakturownia-client-select" required>
<option value="">Wybierz klienta</option>
<? foreach ( $this -> fakturownia_crm_clients as $client ): ?>
<option value="<?= (int)$client['id']; ?>"><?= $esc( $client['firm'] ); ?></option>
<? endforeach; ?>
</select>
</td>
<td>
<button type="submit" class="btn btn-success btn-sm">Zapisz</button>
</form>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
<? endif; ?>
<? if ( is_array( $this -> fakturownia_pending_items ) && count( $this -> fakturownia_pending_items ) ): ?>
<h5 class="mt20">Brakujace mapowania produktow/uslug</h5>
<table class="table table-sm table-bordered">
<thead>
<tr>
<th>Pozycja z faktury</th>
<th>Kategoria finansowa</th>
<th style="width: 130px;">Akcja</th>
</tr>
</thead>
<tbody>
<? foreach ( $this -> fakturownia_pending_items as $row ): ?>
<tr>
<td>
<?= $esc( $row['external_name'] ); ?><br>
<small class="text-muted">Klucz: <?= $esc( $row['external_key'] ); ?> | wystapienia: <?= (int)$row['hits']; ?></small>
</td>
<td>
<form method="post" action="/finances/fakturownia_item_mapping_save/" class="form-inline">
<input type="hidden" name="csrf_token" value="<?= \S::csrf_token(); ?>">
<input type="hidden" name="external_key" value="<?= $esc( $row['external_key'] ); ?>">
<input type="hidden" name="external_name" value="<?= $esc( $row['external_name'] ); ?>">
<select name="finance_category_id" class="form-control input-sm" required>
<option value="">Wybierz kategorie</option>
<? foreach ( $this -> fakturownia_categories as $category ): ?>
<option value="<?= (int)$category['id']; ?>">
<?= $esc( $category['name'] ); ?> (grupa: <?= (int)$category['group_id']; ?>)
</option>
<? endforeach; ?>
</select>
</td>
<td>
<button type="submit" class="btn btn-success btn-sm">Zapisz</button>
</form>
</td>
</tr>
<? endforeach; ?>
</tbody>
</table>
<? endif; ?>
</div>
</div>
<script type="text/javascript">
(function() {
if ( typeof jQuery === 'undefined' || !jQuery.fn.select2 )
return;
var selects = jQuery( '.js-fakturownia-client-select' );
if ( !selects.length )
return;
selects.select2({
theme: 'bootstrap-5',
width: '100%',
placeholder: 'Wyszukaj klienta CRM'
});
selects.on( 'select2:open', function() {
setTimeout( function() {
var searchField = document.querySelector( '.select2-container--open .select2-search__field' );
if ( searchField )
searchField.focus();
}, 0 );
} );
})();
</script>

View File

@@ -46,6 +46,9 @@
</div>
</div>
</div>
<div class="finance-import-panel" style="clear: both; margin-top: 15px;">
<? include 'fakturownia-import-panel.php'; ?>
</div>
<div class="finance-manager">
<div class="column-left">
<div class="clients-list-container">
@@ -307,4 +310,4 @@ $(function() {
$(this).parents('.input-group').children('input').trigger('click');
});
});
</script>
</script>