Index: src/include/lib/Paheko/Accounting/AdvancedSearch.php ================================================================== --- src/include/lib/Paheko/Accounting/AdvancedSearch.php +++ src/include/lib/Paheko/Accounting/AdvancedSearch.php @@ -29,10 +29,16 @@ } $types .= 'END'; return [ + 'line_id' => [ + 'label' => null, + 'type' => 'integer', + 'null' => true, + 'select' => 'l.id', + ], 'id' => [ 'label' => 'Numéro écriture', 'type' => 'integer', 'null' => false, 'select' => 't.id', @@ -273,11 +279,11 @@ $tables = 'acc_transactions AS t INNER JOIN acc_transactions_lines AS l ON l.id_transaction = t.id INNER JOIN acc_accounts AS a ON l.id_account = a.id INNER JOIN acc_years AS y ON t.id_year = y.id LEFT JOIN acc_projects AS p ON l.id_project = p.id'; - return $this->makeList($query, $tables, 'id', true, ['id', 'account_code', 'debit', 'credit']); + return $this->makeList($query, $tables, 'id', true, ['id', 'account_code', 'line_id', 'debit', 'credit']); } public function defaults(): \stdClass { $group = [ Index: src/include/lib/Paheko/AdvancedSearch.php ================================================================== --- src/include/lib/Paheko/AdvancedSearch.php +++ src/include/lib/Paheko/AdvancedSearch.php Index: src/templates/acc/accounts/journal.tpl ================================================================== --- src/templates/acc/accounts/journal.tpl +++ src/templates/acc/accounts/journal.tpl @@ -81,11 +81,11 @@ {foreach from=$list->iterate() item="line"} {if $can_edit} - {input type="checkbox" name="check[%s]"|args:$line.id_line value=$line.id default=0} + {input type="checkbox" name="selected[%s]"|args:$line.id_line value=$line.id default=0} {/if} #{$line.id} {$line.date|date_short} {if $simple} Index: src/templates/acc/search.tpl ================================================================== --- src/templates/acc/search.tpl +++ src/templates/acc/search.tpl @@ -27,12 +27,13 @@ $credit = null; ?> {foreach from=$list->iterate() item="row"} - {if $is_admin}{input type="checkbox" name="selected[]" value=$row.id}{/if} + {if $is_admin}{input type="checkbox" name="selected[%s]"|args:$row.line_id value=$row.id}{/if} {foreach from=$row key="key" item="value"} + {if $prev_id == $row.id && !in_array($key, ['debit', 'credit', 'account_code', 'line_label', 'line_reference', 'project_code'])} @@ -73,11 +74,11 @@ {/foreach} {if $debit !== null || $credit !== null} $v) { if ($key == 'credit' || $key == 'debit') { break; } $span1++; @@ -96,10 +97,23 @@ {/if} {/foreach} + {if $is_admin} + + + Pour les écritures cochées : + + {csrf_field key="projects_action"} + + {* As it needs a second formaction for this, and as submit is handled by automatic onchange event selecting ".actions select", the simplest (having only one action here), is to use a button instead of a + {/if} + {else} + {$column} + {/if} {/foreach} {foreach from=$results item="row"} {foreach from=$row key="key" item="value"} - {if $id_column === $key} + {if $line_id_column === $key} + {if $is_admin} + {input type="checkbox" name="selected[%s]"|args:$row[$line_id_column] value=$row[$id_column]} + {/if} + {elseif $id_column === $key} {link href="!acc/transactions/details.php?id=%d"|args:$value label="#%d"|args:$value} {else} {$value} {/if} {/foreach} {/foreach} + {if $is_admin} + + + + + Pour les écritures cochées : + + {csrf_field key="projects_action"} + {button type="submit" formaction="%sacc/transactions/actions.php"|args:$admin_url name="action" value="change_project" shape="plus" label="Ajouter/enlever d'un projet"} + + + + {/if} {elseif $count === 0}

Aucun résultat trouvé pour cette recherche.

Index: src/www/admin/acc/transactions/actions.php ================================================================== --- src/www/admin/acc/transactions/actions.php +++ src/www/admin/acc/transactions/actions.php @@ -8,18 +8,18 @@ require_once __DIR__ . '/../_inc.php'; $session->requireAccess($session::SECTION_ACCOUNTING, $session::ACCESS_ADMIN); -$check = f('check'); +$selected = f('selected'); -if (!$check || !is_array($check)) { +if (!$selected || !is_array($selected)) { throw new UserException('Aucune écriture n\'a été sélectionnée.'); } -$transactions = array_unique(array_values($check)); -$lines = array_keys($check); +$transactions = array_unique(array_values($selected)); +$lines = array_keys($selected); if (f('action') === 'payoff') { Utils::redirect('!acc/transactions/new.php?payoff=' . implode(',', $transactions)); } @@ -51,13 +51,13 @@ Transactions::setProject($id, $transactions, $lines); }, $csrf_key, f('from') ?: ADMIN_URL); $from = f('from'); -$count = count($check); -$extra = compact('check', 'from'); -$tpl->assign(compact('csrf_key', 'check', 'count', 'extra')); +$count = count($selected); +$extra = compact('selected', 'from'); +$tpl->assign(compact('csrf_key', 'selected', 'count', 'extra')); if (f('action') == 'delete') { $tpl->display('acc/transactions/actions_delete.tpl'); }