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 ? $date : date( 'Y-m-d' ),
'class' => 'datetime 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
] );
$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'];
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 operacji';
$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();
?>