Overview
Comment:Nouveaux graphs
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 736a2f9b0ce79e00357491c449fa1e27fbf1084a
User & Date: bohwaz on 2012-10-17 05:49:30
Other Links: manifest | tags
Context
2012-10-22
04:24
Fix suppression de membre check-in: aa118db042 user: bohwaz tags: trunk
2012-10-17
05:49
Nouveaux graphs check-in: 736a2f9b0c user: bohwaz tags: trunk
04:58
Import/export de CSV check-in: 095e880cbe user: bohwaz tags: trunk
Changes

Modified include/class.compta_stats.php from [973311ee4b] to [72fec75275].

18
19
20
21
22
23
24






































25
26
27
28
29
30
31
		return $this->_byType(-1);
	}

	public function depenses()
	{
		return $this->_byType(1);
	}







































	public function getStats($query)
	{
		$db = Garradin_DB::getInstance();

		$data = $db->simpleStatementFetchAssoc($query);








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
		return $this->_byType(-1);
	}

	public function depenses()
	{
		return $this->_byType(1);
	}

	public function soldeCompte($compte, $augmente = 'debit', $diminue = 'credit')
	{
		$db = Garradin_DB::getInstance();

		if (strpos($compte, '%') !== false)
		{
			$compte = 'LIKE \''. $db->escapeString($compte) . '\'';
		}
		else
		{
			$compte = '= \''. $db->escapeString($compte) . '\'';
		}

		$stats = $this->getStats('SELECT strftime(\'%Y%m\', date) AS date,
			(COALESCE((SELECT SUM(montant) FROM compta_journal
				WHERE compte_'.$augmente.' '.$compte.' AND id_exercice = cj.id_exercice
				AND date >= strftime(\'%Y-%m-01\', cj.date)
				AND date <= strftime(\'%Y-%m-31\', cj.date)), 0)
			- COALESCE((SELECT SUM(montant) FROM compta_journal
				WHERE compte_'.$diminue.' '.$compte.' AND id_exercice = cj.id_exercice
				AND date >= strftime(\'%Y-%m-01\', cj.date)
				AND date <= strftime(\'%Y-%m-31\', cj.date)), 0)
			) AS solde
			FROM compta_journal AS cj
			WHERE (compte_debit '.$compte.' OR compte_credit '.$compte.')
			AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0)
			GROUP BY strftime(\'%Y-%m\', date) ORDER BY date;');

		$c = 0;
		foreach ($stats as $k=>$v)
		{
			$c += $v;
			$stats[$k] = $c;
		}

		return $stats;
	}

	public function getStats($query)
	{
		$db = Garradin_DB::getInstance();

		$data = $db->simpleStatementFetchAssoc($query);

Modified templates/admin/compta/index.tpl from [0e2400fdd1] to [c78e6d3fcf].

13
14
15
16
17
18
19


20
21
22
<ul class="actions">
    <li><a href="{$www_url}admin/compta/import.php">Import / export</a></li>
</ul>
{/if}

<p>
    <img src="{$www_url}admin/compta/graph.php?g=recettes_depenses" />


</p>

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







>
>



13
14
15
16
17
18
19
20
21
22
23
24
<ul class="actions">
    <li><a href="{$www_url}admin/compta/import.php">Import / export</a></li>
</ul>
{/if}

<p>
    <img src="{$www_url}admin/compta/graph.php?g=recettes_depenses" />
    <img src="{$www_url}admin/compta/graph.php?g=banques_caisses" />
    <img src="{$www_url}admin/compta/graph.php?g=dettes" />
</p>

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

Modified www/admin/compta/graph.php from [58f4ec54c7] to [621195ae37].

26
27
28
29
30
31
32

33


































34
35









36

37
38
39
40
41
42



43
44
45
46
47
48
	foreach ($r->get() as $k=>$v)
	{
		$labels[] = utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) .'-01'));
	}

	$plot->setLabels($labels);
}




































if (!empty($data))
{









	$i = 0;


	foreach ($data as $line)
	{
		$line->color = ($i++ % 2) ? '#fa4' : '#9c4f15';
		$line->width = 2;
		$plot->add($line);



	}
}

$plot->display();

?>







>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>

>



|


>
>
>






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
95
96
	foreach ($r->get() as $k=>$v)
	{
		$labels[] = utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) .'-01'));
	}

	$plot->setLabels($labels);
}
elseif (utils::get('g') == 'banques_caisses')
{
	require_once GARRADIN_ROOT . '/include/class.compta_comptes_bancaires.php';
	$banques = new Garradin_Compta_Comptes_Bancaires;

	$data = array();

	$r = new SVGPlot_Data($stats->soldeCompte(Garradin_Compta_Comptes::CAISSE));
	$r->title = 'Caisse';

	$data[] = $r;

	foreach ($banques->getList() as $banque)
	{
		$r = new SVGPlot_Data($stats->soldeCompte($banque['id']));
		$r->title = $banque['libelle'];
		$data[] = $r;
	}

	$plot->setTitle('Solde des comptes et caisses');
}
elseif (utils::get('g') == 'dettes')
{
	$data = array();

	$r = new SVGPlot_Data($stats->soldeCompte('401%', 'credit', 'debit'));
	$r->title = 'Dettes fournisseurs';
	$data[] = $r;

	$r = new SVGPlot_Data($stats->soldeCompte('411%', 'credit', 'debit'));
	$r->title = 'Dettes usagers';
	$data[] = $r;

	$plot->setTitle('Dettes');
}

if (!empty($data))
{
	$labels = array();

	foreach ($data[0]->get() as $k=>$v)
	{
		$labels[] = utils::date_fr('M y', strtotime(substr($k, 0, 4) . '-' . substr($k, 4, 2) .'-01'));
	}

	$plot->setLabels($labels);

	$i = 0;
	$colors = array('#fa4', '#941', '#af4', '#4af', '#a4f');

	foreach ($data as $line)
	{
		$line->color = $colors[$i++];
		$line->width = 2;
		$plot->add($line);

		if ($i > count($colors))
			$i = 0;
	}
}

$plot->display();

?>