Overview
Comment:Visualisation d'écriture
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: fed857312c7c27c4553478ece5faa74f6734172a
User & Date: bohwaz on 2020-09-16 01:34:52
Other Links: branch diff | manifest | tags
Context
2020-09-16
01:53
Not used anymore check-in: 5e35f1ac90 user: bohwaz tags: dev
01:34
Visualisation d'écriture check-in: fed857312c user: bohwaz tags: dev
01:27
Try to be coherent with PHP typehinting: use int and bool, not integer and boolean check-in: 81f1561f12 user: bohwaz tags: dev
Changes

Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [27e8f56d39] to [8c80beee08].

1
2
3
4

5
6
7
8
9
10
11
..
43
44
45
46
47
48
49
50
51






52
53
54
55
56
57
58
59
60
61
...
210
211
212
213
214
215
216
217






<?php

namespace Garradin\Entities\Accounting;


use Garradin\Entity;
use Garradin\Accounting\Accounts;
use Garradin\ValidationException;
use Garradin\DB;
use Garradin\Config;

class Transaction extends Entity
................................................................................
		'notes'     => 'string|max:20000',
		'reference' => 'string|max:200',
		'date'      => 'required|date_format:Y-m-d',
	];

	protected $_lines;

	public function getLines()
	{






		if (null === $this->_lines && $this->exists()) {
			$db = DB::getInstance();
			$this->_lines = $db->toObject($db->get('SELECT * FROM ' . Line::TABLE . ' WHERE id_transaction = ? ORDER BY id;', $this->id), Ligne::class);
		}
		elseif (null === $this->_lines) {
			$this->_lines = [];
		}

		return $this->_lines;
	}
................................................................................
				}

				$line = (new Line)->import($line);
				$this->add($line);
			}
		}
	}
}










>







 







|

>
>
>
>
>
>

|
|







 







|
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php

namespace Garradin\Entities\Accounting;

use KD2\DB\EntityManager;
use Garradin\Entity;
use Garradin\Accounting\Accounts;
use Garradin\ValidationException;
use Garradin\DB;
use Garradin\Config;

class Transaction extends Entity
................................................................................
		'notes'     => 'string|max:20000',
		'reference' => 'string|max:200',
		'date'      => 'required|date_format:Y-m-d',
	];

	protected $_lines;

	public function getLinesWithAccounts()
	{
		$em = EntityManager::getInstance(Line::class);
		return $em->DB()->get('SELECT a.*, b.label AS account_name, b.code AS account_code FROM ' . Line::TABLE  .' a INNER JOIN ' . Account::TABLE . ' b ON b.id = a.id_account WHERE a.id_transaction = ? ORDER BY a.id;', $this->id);
	}

	public function getLines($with_accounts = false)
	{
		if (null === $this->_lines && $this->exists()) {
			$em = EntityManager::getInstance(Line::class);
			$this->_lines = $em->all('SELECT * FROM @TABLE WHERE id_transaction = ? ORDER BY id;', $this->id);
		}
		elseif (null === $this->_lines) {
			$this->_lines = [];
		}

		return $this->_lines;
	}
................................................................................
				}

				$line = (new Line)->import($line);
				$this->add($line);
			}
		}
	}

	public function year()
	{
		return EntityManager::findOneById(Year::class, $this->id_year);
	}

}

Added src/templates/acc/transactions/details.tpl version [0439690d86].





























































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{include file="admin/_head.tpl" title="Écriture n°%d"|args:$transaction.id current="acc"}

{if $session->canAccess('compta', Membres::DROIT_ADMIN)}
<ul class="actions">
	<li class="edit"><a href="edit.php?id={$transaction.id}">Modifier cette écriture</a></li>
	<li class="delete"><a href="delete.php?id={$transaction.id}">Supprimer cette écriture</a></li>
</ul>
{/if}

<dl class="describe">
	<dt>Libellé</dt>
	<dd><h2>{$transaction.label}</h2></dd>
	<dt>Date</dt>
	<dd>{$transaction.date|date_fr:'l j F Y (d/m/Y)'}</dd>
	<dt>Numéro pièce comptable</dt>
	<dd>{if trim($transaction.numero_piece)}{$transaction.numero_piece}{else}<em>Non renseigné</em>{/if}</dd>

	<dt>Exercice</dt>
	<dd>
		<a href="{$admin_url}acc/years/year.php?id={$transaction.id_year}">{$tr_year.label}</a>
		| Du {$tr_year.start_date|date_fr:'d/m/Y'} au {$tr_year.end_date|date_fr:'d/m/Y'}
		| <strong>{if $tr_year.closed}Clôturé{else}En cours{/if}</strong>
	</dd>

	{if $transaction.id_projet}
		<dt>Projet</dt>
		<dd>
			<a href="{$admin_url}compta/projets/">{$projet.libelle}</a>
		</dd>
	{/if}

	<dt>Opération créée par</dt>
	<dd>
		{if $transaction.id_auteur}
			{if $session->canAccess('compta', Membres::DROIT_ACCES)}
				<a href="{$admin_url}membres/fiche.php?id={$transaction.id_auteur}">{$nom_auteur}</a>
			{else}
				{$nom_auteur}
			{/if}
		{else}
			<em>membre supprimé</em>
		{/if}
	</dd>

	<dt>Opération liée à</dt>
	<dd>
		{if empty($related_members)}
			Aucun membre n'est lié à cette opération.
		{else}
			{foreach from=$related_members item="membre"}
				<a href="{$admin_url}membres/{if $membre.id_cotisation}cotisations{else}fiche{/if}.php?id={$membre.id_membre}">{if $membre.id_cotisation}Cotisation pour {/if}{$membre.identite}</a>
			{/foreach}
		{/if}
	</dd>

	<dt>Remarques</dt>
	<dd>{if trim($transaction.notes)}{$transaction.notes}{else}<em>Non renseigné</em>{/if}</dd>

	<dt>Fichiers joints</dt>
	{foreach from=$files item="file"}
	<dd>
		<aside class="file">
			<a href="{$file.url}">{$file.nom}</a>
			<small>({$file.type}, {$file.taille|format_bytes})</small>
		</aside>
	</dd>
	{/foreach}
</dl>

<table class="list multi">
	<thead>
		<tr>
			<th colspan="2">Comptes</th>
			<td>Débit</td>
			<td>Crédit</td>
			<td>Libellé</td>
			<td>Référence</td>
		</tr>
	</thead>
	<tbody>
		{foreach from=$transaction->getLinesWithAccounts() item="line"}
		<tr>
			<td><a href="{$admin_url}acc/accounts/journal.php?id={$line.id_account}">{$line.account_code}</a></td>
			<td>{$line.account_name}</td>
			<td>{$line.debit|escape|html_money}&nbsp;{$config.monnaie}</td>
			<td>{$line.credit|escape|html_money}&nbsp;{$config.monnaie}</td>
			<td>{$line.label}</td>
			<td>{$line.reference}</td>
		</tr>
		{/foreach}
	</tbody>
</table>

{include file="admin/_foot.tpl"}

Added src/www/admin/acc/transactions/details.php version [a4e3c44122].







































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
namespace Garradin;

use Garradin\Entities\Accounting\Transaction;
use KD2\DB\EntityManager as EM;

require_once __DIR__ . '/../_inc.php';

$transaction = EM::findOneById(Transaction::class, (int) qg('id'));

if (!$transaction) {
    throw new UserException('Cette écriture n\'existe pas');
}

$tpl->assign('files', Fichiers::listLinkedFiles(Fichiers::LIEN_COMPTA, $transaction->id()));
$tpl->assign('transaction', $transaction);
$tpl->assign('tr_year', $transaction->year());

$tpl->display('acc/transactions/details.tpl');

Modified src/www/admin/acc/transactions/new.php from [66c5f5f141] to [e263e7bf24].

11
12
13
14
15
16
17

18

19
20
21
22
23
24
25
..
42
43
44
45
46
47
48

49
50
51
52
53
54
55
$accounts = $chart->accounts();

$transaction = new Transaction;
$lines = [[], []];

if (f('save') && $form->check('acc_transaction_new')) {
    try {

        if (f('type') == 'advanced' && $lines = f('lines')) {

            $max = count($lines['label']);

            if ($max != count($lines['debit'])
                || $max != count($lines['credit'])
                || $max != count($lines['reference'])
                || $max != count($lines['account']))
            {
................................................................................
            $_POST['lines'] = $lines = $out;
        }

        $transaction->id_year = $year->id();
        $transaction->importFromSimpleForm($chart->id());
        $transaction->save();


        if (!empty($_FILES['file']['name'])) {
            $file = Fichiers::upload($_FILES['file']);
            $file->linkTo(Fichiers::LIEN_COMPTA, $transaction->id());
        }

        Utils::redirect(Utils::getSelfURL(false) . '?ok=' . $transaction->id());
    }







>
|
>







 







>







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
..
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
$accounts = $chart->accounts();

$transaction = new Transaction;
$lines = [[], []];

if (f('save') && $form->check('acc_transaction_new')) {
    try {
        // Advanced transaction: handle lines
        if (f('type') == 'advanced' && $lines = f('lines'))
        {
            $max = count($lines['label']);

            if ($max != count($lines['debit'])
                || $max != count($lines['credit'])
                || $max != count($lines['reference'])
                || $max != count($lines['account']))
            {
................................................................................
            $_POST['lines'] = $lines = $out;
        }

        $transaction->id_year = $year->id();
        $transaction->importFromSimpleForm($chart->id());
        $transaction->save();

        // Append file
        if (!empty($_FILES['file']['name'])) {
            $file = Fichiers::upload($_FILES['file']);
            $file->linkTo(Fichiers::LIEN_COMPTA, $transaction->id());
        }

        Utils::redirect(Utils::getSelfURL(false) . '?ok=' . $transaction->id());
    }