Overview
Comment:Saving the creator
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | dev
Files: files | file ages | folders
SHA1: 1c7ffa0c7d9c3ebb882d2e585b24dbdfcc01e2f4
User & Date: bohwaz on 2020-09-18 16:36:29
Other Links: branch diff | manifest | tags
Context
2020-09-25
11:46
Use grids for
columns
check-in: ee59447841 user: bohwaz tags: dev
2020-09-18
16:36
Saving the creator check-in: 1c7ffa0c7d user: bohwaz tags: dev
2020-09-16
16:39
Use nav.tabs instead of ul.actions for submenus check-in: 0e113c6a6a user: bohwaz tags: dev
Changes

Modified src/include/data/1.0.0_migration.sql from [96c4b53767] to [e268d29158].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- Bénévolat en nature
UPDATE acc_accounts SET type_parent = 7 WHERE code = '870';

-- Comptes de tiers
UPDATE acc_accounts SET type_parent = 4 WHERE code = '4';

-- Recopie des mouvements
INSERT INTO acc_transactions (id, label, notes, reference, date, id_year)
	SELECT id, libelle, remarques, numero_piece, date, id_exercice
	FROM compta_journal;

-- Création des lignes associées aux mouvements
INSERT INTO acc_transactions_lines (id_transaction, id_account, debit, credit, reference, id_analytical)
	SELECT id, (SELECT id FROM acc_accounts WHERE code = compte_credit), 0, CAST(montant * 100 AS INT), numero_cheque,
	CASE WHEN id_projet IS NOT NULL THEN (SELECT id FROM acc_accounts WHERE code = '99' || substr('0000' || id_projet, -4)) ELSE NULL END
	FROM compta_journal;







|
|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- Bénévolat en nature
UPDATE acc_accounts SET type_parent = 7 WHERE code = '870';

-- Comptes de tiers
UPDATE acc_accounts SET type_parent = 4 WHERE code = '4';

-- Recopie des mouvements
INSERT INTO acc_transactions (id, label, notes, reference, date, id_year, id_creator)
	SELECT id, libelle, remarques, numero_piece, date, id_exercice, id_auteur
	FROM compta_journal;

-- Création des lignes associées aux mouvements
INSERT INTO acc_transactions_lines (id_transaction, id_account, debit, credit, reference, id_analytical)
	SELECT id, (SELECT id FROM acc_accounts WHERE code = compte_credit), 0, CAST(montant * 100 AS INT), numero_cheque,
	CASE WHEN id_projet IS NOT NULL THEN (SELECT id FROM acc_accounts WHERE code = '99' || substr('0000' || id_projet, -4)) ELSE NULL END
	FROM compta_journal;

Modified src/include/data/1.0.0_schema.sql from [d98aa45b1a] to [442e7113d3].

236
237
238
239
240
241
242
243

244
245
246
247
248
249
250
    date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date),

    validated INTEGER NOT NULL DEFAULT 0, -- 1 = écriture validée, non modifiable

    hash TEXT NULL,
    prev_hash TEXT NULL,

    id_year INTEGER NOT NULL REFERENCES acc_years(id)

);

CREATE INDEX IF NOT EXISTS acc_transactions_year ON acc_transactions (id_year);
CREATE INDEX IF NOT EXISTS acc_transactions_date ON acc_transactions (date);

CREATE TABLE IF NOT EXISTS acc_transactions_lines
-- Lignes d'écritures d'une opération







|
>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
    date TEXT NOT NULL DEFAULT CURRENT_DATE CHECK (date(date) IS NOT NULL AND date(date) = date),

    validated INTEGER NOT NULL DEFAULT 0, -- 1 = écriture validée, non modifiable

    hash TEXT NULL,
    prev_hash TEXT NULL,

    id_year INTEGER NOT NULL REFERENCES acc_years(id),
    id_creator INTEGER NULL REFERENCES membres(id) ON DELETE SET NULL
);

CREATE INDEX IF NOT EXISTS acc_transactions_year ON acc_transactions (id_year);
CREATE INDEX IF NOT EXISTS acc_transactions_date ON acc_transactions (date);

CREATE TABLE IF NOT EXISTS acc_transactions_lines
-- Lignes d'écritures d'une opération

Modified src/include/lib/Garradin/Entities/Accounting/Transaction.php from [54f7b43ca3] to [162732cfbf].

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
...
238
239
240
241
242
243
244



245


	protected $validated = 0;

	protected $hash;
	protected $prev_hash;

	protected $id_year;


	protected $_types = [
		'id'        => 'int',
		'label'     => 'string',
		'notes'     => '?string',
		'reference' => '?string',
		'date'      => 'date',
		'validated' => 'bool',
		'hash'      => '?string',
		'prev_hash' => '?string',
		'id_year'   => 'int',

	];

	protected $_form_rules = [
		'label'     => 'required|string|max:200',
		'notes'     => 'string|max:20000',
		'reference' => 'string|max:200',
		'date'      => 'required|date_format:Y-m-d',
................................................................................
	}

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




}








>











>







 







>
>
>
|
>
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
...
240
241
242
243
244
245
246
247
248
249
250
251

	protected $validated = 0;

	protected $hash;
	protected $prev_hash;

	protected $id_year;
	protected $id_creator;

	protected $_types = [
		'id'        => 'int',
		'label'     => 'string',
		'notes'     => '?string',
		'reference' => '?string',
		'date'      => 'date',
		'validated' => 'bool',
		'hash'      => '?string',
		'prev_hash' => '?string',
		'id_year'   => 'int',
		'id_creator' => '?int',
	];

	protected $_form_rules = [
		'label'     => 'required|string|max:200',
		'notes'     => 'string|max:20000',
		'reference' => 'string|max:200',
		'date'      => 'required|date_format:Y-m-d',
................................................................................
	}

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

	public function listFiles()
	{
		return Fichiers::listLinkedFiles(Fichiers::LIEN_COMPTA, $this->id());
	}
}

Modified src/templates/acc/transactions/details.tpl from [510e989ff7] to [4d6df636eb].

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
		<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>







|

|

|







29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
		<dd>
			<a href="{$admin_url}compta/projets/">{$projet.libelle}</a>
		</dd>
	{/if}

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

	<dt>Opération liée à</dt>

Modified src/www/admin/acc/transactions/details.php from [ff2f396577] to [201118bacb].

7
8
9
10
11
12
13
14
15
16

17
18

$transaction = Transactions::get((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');







|


>


7
8
9
10
11
12
13
14
15
16
17
18
19

$transaction = Transactions::get((int) qg('id'));

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

$tpl->assign('files', $transaction->listFiles());
$tpl->assign('transaction', $transaction);
$tpl->assign('tr_year', $transaction->year());
$tpl->assign('creator_name', $transaction->id_creator ? (new Membres)->getNom($transaction->id_creator) : null);

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

Modified src/www/admin/acc/transactions/new.php from [e263e7bf24] to [4f163a9108].

42
43
44
45
46
47
48

49
50
51
52
53
54
55
            }

            $_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());
        }







>







42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
            }

            $_POST['lines'] = $lines = $out;
        }

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

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