noalyss  Version-9
anc_account_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 if (!defined('ALLOWED'))
23  die('Appel direct ne sont pas permis');
24 
25 /**
26  * @file
27  * @brief Add , delete and update Poste_Analytic
28  *
29  */
30 /**
31  * @class Anc_Account_Table
32  * @brief derived from Manage_Table_SQL ,
33  */
34 require_once NOALYSS_INCLUDE.'/database/poste_analytique_sql.class.php';
35 
37 {
38  function __construct(Data_SQL $p_table)
39  {
40  parent::__construct($p_table);
42  $this->set_property_updatable("po_id", FALSE);
43  $this->set_property_updatable("pa_id", FALSE);
44  $this->set_property_visible("pa_id", FALSE);
45  $this->set_property_visible("po_id", FALSE);
46  $this->set_property_visible("po_amount", FALSE);
47  $this->set_col_label("po_name", _("Label"));
48  $this->set_col_label("po_description", _("Description"));
49  $this->set_col_label("ga_id", _("Groupe"));
50  $this->set_col_label("po_state", _("Etat"));
51  $this->set_col_type("ga_id", "select");
52  $this->set_object_name("anc_accounting");
53  $this->set_col_sort(1);
54  $this->a_select["ga_id"]=$cn->make_array("select '-','-' union all select ga_id,ga_id||' '||ga_description
55  from groupe_analytique
56  where
57  pa_id=$1
58  order by 2",0,array($p_table->pa_id));
59  $this->set_col_type("po_state","select",array(
60  [ "value"=>"1","label"=>_("Actif")],
61  [ "value"=>"0",'label'=>_("Inactif")]
62  ));
63 
64  }
65  /**
66  * Check and change po_name values
67  * @return boolean
68  */
69  function check()
70  {
72  $table=$this->get_table();
73  $is_error=0;
74  $table->po_amount=0;
75  // po_name must contains only valid letter (remove < > and ')
76  $table->po_name=str_replace("'", '', $table->po_name);
77  $table->po_name=str_replace("<", '', $table->po_name);
78  $table->po_name=str_replace(">", '', $table->po_name);
79 
80  // po_name must be uniq in the Analytic Plan
81  if ( $cn->get_value("select count(*) from poste_analytique where pa_id=$1 and po_name=upper($2) and po_id != $3",
82  array($table->pa_id,$table->po_name,$table->po_id)) > 0)
83  {
84  $is_error++;
85  $this->set_error("po_name", _("Le nom doit être unique dans un plan analytique"));
86 
87  }
88  // po_name cannot be empty
89  if (trim($table->po_name)=="") {
90  $is_error++;
91  $this->set_error("po_name", _("Le nom ne peut être vide"));
92  }
93  $table->ga_id=($table->ga_id=="-")?null:$table->ga_id;
94  if ($is_error==0)return TRUE;
95  return FALSE;
96  }
97 
98  /**
99  * @brief display a data row in the table, with the order defined
100  * in a_order and depending of the visibility of the column
101  */
102  function display_row($p_row)
103  {
105  $count=$cn->get_value("select count(*) from public.operation_analytique where po_id=$1",[$p_row["po_id"]]);
106  $p_row["po_name"]=sprintf("%s (%d)",$p_row['po_name'],$count);
107  parent::display_row($p_row);
108  }
109 
110  /**
111  * Before deleting , we check that nothing is in a closed periode
112  */
113  function delete() {
115  $count_closed=$cn->get_value(" select count(*)
116  from jrnx as jx1
117  join jrn jn1 on (jx1.j_grpt = jn1.jr_grpt_id )
118  join jrn_def as jf1 on (jn1.jr_def_id =jf1.jrn_def_id )
119  join jrn_periode as je1 on (jf1.jrn_def_id =je1.jrn_def_id )
120  join operation_analytique as oa on (oa.j_id =jx1.j_id )
121  where
122  je1.status = 'CL' and oa.po_id=$1 ",[$this->table->po_id]);
123  if ( $count_closed > 0 ) {
124  throw new \Exception(_("Effacement impossible : le poste est utilisé dans une période fermée"));
125  }
126 
127  }
128 
129 }
Anc_Account_Table\check
check()
Check and change po_name values.
Definition: anc_account_table.class.php:69
Manage_Table_SQL\set_col_type
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
Definition: manage_table_sql.class.php:425
Manage_Table_SQL\get_table
get_table()
Definition: manage_table_sql.class.php:264
Manage_Table_SQL\set_property_updatable
set_property_updatable($p_key, $p_value)
set a column of the data row updatable or not
Definition: manage_table_sql.class.php:553
Manage_Table_SQL\set_object_name
set_object_name($p_object_name)
Set the object_name.
Definition: manage_table_sql.class.php:543
Manage_Table_SQL
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
Definition: manage_table_sql.class.php:65
Dossier\connect
static connect()
Definition: dossier.class.php:282
Manage_Table_SQL\set_property_visible
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
Definition: manage_table_sql.class.php:663
Anc_Account_Table\display_row
display_row($p_row)
display a data row in the table, with the order defined in a_order and depending of the visibility of...
Definition: anc_account_table.class.php:102
Manage_Table_SQL\set_error
set_error($p_col, $p_message)
set the error message for a wrong input
Definition: manage_table_sql.class.php:289
Manage_Table_SQL\set_col_sort
set_col_sort($p_num)
When adding an element ,we place it thanks the DOM Attribute sort_value set it to -1 if you want one ...
Definition: manage_table_sql.class.php:253
Anc_Account_Table\__construct
__construct(Data_SQL $p_table)
Definition: anc_account_table.class.php:38
$cn
$cn
Definition: ajax_anc_accounting.php:30
Manage_Table_SQL\set_col_label
set_col_label($p_key, $p_display)
set the name to display for a column
Definition: manage_table_sql.class.php:696
$count
$count
Definition: modele.inc.php:251
table
$all table
Definition: company.inc.php:138
Manage_Table_SQL\$table
$table
Object Data_SQL.
Definition: manage_table_sql.class.php:68
Anc_Account_Table
derived from Manage_Table_SQL ,
Definition: anc_account_table.class.php:36
Data_SQL
this an abstract class , all the SQL class, like noalyss_sql (table), Acc_Plan_SQL (based on a SQL no...
Definition: data_sql.class.php:71
if
if(! defined('ALLOWED')) if(! defined( 'ALLOWED_ADMIN'))
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
Definition: admin_repo.inc.php:25