feat(05-finances-fakturownia-import): complete Fakturownia mapping corrections
Phase 5 complete: - add category mapping edit from operation edit for Fakturownia operations - update current operation category immediately after mapping change - support optional bulk update for matching imported operations - close 05-05 and 05-06 PAUL summaries Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
@@ -59,6 +59,50 @@ ob_start();
|
||||
'inline' => true
|
||||
] );
|
||||
|
||||
$fakturowniaOperationContext = $this -> fakturownia_operation_context;
|
||||
if ( ( !is_array( $fakturowniaOperationContext ) || empty( $fakturowniaOperationContext ) ) && !empty( $this -> operation['id'] ) )
|
||||
{
|
||||
$financeRepository = new \Domain\Finances\FinanceRepository();
|
||||
$fakturowniaOperationContext = $financeRepository -> fakturowniaOperationContext( (int)$this -> operation['id'] );
|
||||
}
|
||||
|
||||
if ( is_array( $fakturowniaOperationContext ) && !empty( $fakturowniaOperationContext ) )
|
||||
{
|
||||
$currentCategoryId = (int)( $fakturowniaOperationContext['finance_category_id'] ?? 0 );
|
||||
?>
|
||||
<div class="alert alert-info" style="margin-top: 20px;">
|
||||
<strong>Edycja dopasowania Fakturownia</strong><br>
|
||||
Pozycja: <?= htmlspecialchars( (string)$fakturowniaOperationContext['external_name'] ); ?>
|
||||
</div>
|
||||
<div class="form-inline" style="margin-bottom: 20px;">
|
||||
<div class="form-group" style="margin-right: 10px;">
|
||||
<label style="margin-right: 8px;">Nowa kategoria:</label>
|
||||
<select id="fakturownia-finance-category-id" class="form-control" required>
|
||||
<option value="">-- wybierz --</option>
|
||||
<? foreach ( $this -> fakturownia_categories as $category ): ?>
|
||||
<option value="<?= (int)$category['id']; ?>" <?= (int)$category['id'] === $currentCategoryId ? 'selected' : ''; ?>>
|
||||
<?= htmlspecialchars( (string)$category['name'] ); ?>
|
||||
</option>
|
||||
<? endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="checkbox-inline" style="margin-right: 10px;">
|
||||
<input type="checkbox" id="fakturownia-apply-to-all" value="1"> Przepnij wszystkie pasujace operacje z Fakturowni
|
||||
</label>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-warning"
|
||||
id="fakturownia-mapping-save"
|
||||
data-operation-id="<?= (int)$this -> operation['id']; ?>"
|
||||
data-return-category-id="<?= (int)$this -> category_id; ?>"
|
||||
data-csrf-token="<?= \S::csrf_token(); ?>"
|
||||
>Zmien dopasowanie</button>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
@@ -121,5 +165,28 @@ echo $grid -> draw();
|
||||
source: tags_data.ttAdapter()
|
||||
}
|
||||
});
|
||||
|
||||
$( '#fakturownia-mapping-save' ).on( 'click', function() {
|
||||
var categoryId = $( '#fakturownia-finance-category-id' ).val();
|
||||
if ( !categoryId ) {
|
||||
alert( 'Wybierz nowa kategorie.' );
|
||||
return false;
|
||||
}
|
||||
|
||||
var form = $( '<form>', {
|
||||
method: 'post',
|
||||
action: '/finances/fakturownia_operation_mapping_save/'
|
||||
} );
|
||||
|
||||
form.append( $( '<input>', { type: 'hidden', name: 'csrf_token', value: $( this ).data( 'csrf-token' ) } ) );
|
||||
form.append( $( '<input>', { type: 'hidden', name: 'operation_id', value: $( this ).data( 'operation-id' ) } ) );
|
||||
form.append( $( '<input>', { type: 'hidden', name: 'return_category_id', value: $( this ).data( 'return-category-id' ) } ) );
|
||||
form.append( $( '<input>', { type: 'hidden', name: 'finance_category_id', value: categoryId } ) );
|
||||
form.append( $( '<input>', { type: 'hidden', name: 'apply_to_all', value: $( '#fakturownia-apply-to-all' ).is( ':checked' ) ? 1 : 0 } ) );
|
||||
|
||||
$( 'body' ).append( form );
|
||||
form.submit();
|
||||
return false;
|
||||
} );
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user