noalyss Version-9
periode_ledger_table.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * NOALYSS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2016) Author Dany De Bontridder <dany@alchimerys.be>
21
22
23/**
24 * @file
25 * @brief Manage the periode per ledger, used the table jrn_periode
26 * @example periode-ledger-test.php
27 */
28require_once NOALYSS_INCLUDE.'/database/jrn_periode_sql.class.php';
29
30/**
31 * @brief Display the periode per ledger: close : reopen ...
32 * the close , open must be done thanks Periode
33 * @see Periode
34 */
36{
37
38 private $sql;
39 private $a_member;
40 private $cn;
41
43 {
44 $this->a_member["id"]=$p_id;
45 $this->sql="select id,p_id,status,p_id,p_start,p_end,p_closed,p_exercice,jrn_def_id
46 from
47 jrn_periode
48 join parm_periode using (p_id)";
49 $this->cn=Dossier::connect();
50 $this->a_member=$this->cn->get_row($this->sql." where id = $1",
51 [$this->a_member["id"]]);
52
53 }
54 public function get_a_member()
55 {
56 return $this->a_member;
57 }
58
59
60 function set_id($p_id)
61 {
62 $a_member['id']=$p_id;
63 }
64 /**
65 * Load a row and return it as an array
66 * @return type
67 */
68 function load()
69 {
70 $this->a_member=$this->cn->get_row($this->sql." where id = $1",
71 [$this->a_member["id"]]);
72 return $this->a_member;
73 }
75 {
76 $ret=$this->cn->exec_sql($this->sql." where jrn_def_id = $1 order by p_start asc",[$p_ledger_id]);
77 return $ret;
78 }
79 /**
80 * Display all the periode for a specific ledger
81 * the ledger is in m_jrn_periode_sql
82 *
83 * @param type $p_resource_psql resource SQL
84 * @param type $p_js
85 * @return type
86 * @see Periode_Ledger_Table::get_resource_periode_ledger
87 */
88 function display_table($p_resource_psql, $p_js)
89 {
90 $nb_periode=Database::num_row($p_resource_psql);
91
92 if ($nb_periode==0)
93 return;
94 echo '<table class="result" id="periode_tbl">';
95 echo "<thead>";
96 echo "<tr>";
97 echo th("");
98 echo th(_("Date Début"));
99 echo th(_("Date Fin"));
100 echo th(_("Exercice"));
101 echo th("");
102 echo "</tr>";
103 echo "</thead>";
104 echo '<tbody>';
105
106 for ($i=0; $i<$nb_periode; $i++)
107 {
108 $obj=Database::fetch_array($p_resource_psql, $i);
109 $this->display_row($obj, $i, $p_js);
110 }
111 echo '</tbody>';
112 echo '</table>';
113 }
114 /**
115 * Display one row from jrn_periode with supplemental info
116 *
117 * @param type $pa_row is an array corresponding to a_member
118 * @param type $p_num number of rows , for color
119 * @param type $p_js name of the js variable passed to ajax
120 */
121 function display_row($pa_row, $p_num, $p_js)
122 {
123 $class=($p_num%2==0)?"even":"odd";
124 printf('<tr id="row_per_%d" per_ledger="%s" per_exercice="%s" jrn_ledger_id="%s" class="%s"> ',
125 $pa_row["id"], $pa_row["jrn_def_id"], $pa_row["p_exercice"],
126 $pa_row["id"], $class
127 );
128 /**
129 * Display a checkbox to select several month to close
130 */
131 if ($pa_row["status"] == "OP") {
132 $checkbox=new ICheckBox("sel_per_close[]");
133 $checkbox->set_attribute("per_id", $pa_row['id']);
134 $checkbox->set_range("sel_per_close_ck");
135 $checkbox->value=$pa_row['id'];
136 echo "<td>".$checkbox->input()."</td>";
137 }else {
138 echo td("");
139 }
140 echo td(format_date($pa_row["p_start"], "YYYY-MM-DD", "DD.MM.YYYY"));
141 echo td(format_date($pa_row["p_end"], "YYYY-MM-DD", "DD.MM.YYYY"));
142 echo td($pa_row["p_exercice"]);
143 $status=($pa_row['p_closed']=='t')?_("Fermée"):_("Ouvert");
144 echo "<td>";
145 if ($pa_row["status"] == "OP") { echo _("Ouvert"); }
146 if ($pa_row["status"] == "CL") { echo _("Fermé"); }
147 echo "</td>";
148 /// Can close if open
149 echo "<td>";
150 if ($pa_row['status']=='OP')
151 {
152 $javascript=sprintf("%s.close_periode('%d')", $p_js, $pa_row['id']);
153 echo Icon_Action::iconon(uniqid(), $javascript);
154 }
155 elseif ($pa_row['status']=='CL')
156 {
157 $javascript=sprintf("%s.open_periode('%d')", $p_js, $pa_row['id']);
158 echo Icon_Action::iconoff(uniqid(), $javascript);
159 }
160 echo "</td>";
161 echo "</tr>";
162 }
163
164}
format_date($p_date, $p_from_format='YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
Definition: ac_common.php:852
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$input_from cn
Definition: balance.inc.php:66
$class
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
static connect()
Html Input.
static iconoff($p_id, $p_javascript, $p_style="")
Display a icon OFF.
static iconon($p_id, $p_javascript, $p_style="")
Display a icon ON.
Display the periode per ledger: close : reopen ... the close , open must be done thanks Periode.
load()
Load a row and return it as an array.
display_table($p_resource_psql, $p_js)
Display all the periode for a specific ledger the ledger is in m_jrn_periode_sql.
display_row($pa_row, $p_num, $p_js)
Display one row from jrn_periode with supplemental info.
if( $delta< 0) elseif( $delta==0)
$p_ledger_id
Definition: periode.inc.php:33