noalyss Version-9
pre_op_ods.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief definition of the class Pre_op_ods
24 */
25
26/*---------------------------------------------------------------------- */
27/*!\brief concerns the predefined operation for ODS ledger
28*/
30{
31 var $op;
32 function __construct($cn)
33 {
34 parent::__construct($cn);
35 }
36
37 /***
38 * @brief retrieve data from $_POST
39 */
40 function get_post()
41 {
42 $http=new \HttpInput();
43 $nb=$http->post("nb_item","number");
44 for ($i=0;$i< $nb ;$i++)
45 {
46 $this->{"e_account".$i}=$http->post("e_account'.$i");
47 $this->{"e_account".$i."_amount"}=$http->post("e_account".$i."_amount","number",0);
48 $this->{"e_account".$i."_type"}=$http->post('e_account'.$i."_type");
49
50 }
51 }
52 /*!
53 * \brief save the detail and op in the database
54 *
55 */
56 function save($p_od_id,$p_nbitem)
57 {
58 try
59 {
60 // save the selling
61 for ($i=0;$i< $p_nbitem ;$i++)
62 {
63 $sql='insert into op_predef_detail (opd_poste,opd_amount,'.
64 'opd_debit,od_id)'.
65 ' values ($1,$2,$3,$4)';
66
67 $this->db->exec_sql($sql,array($this->{"e_account".$i},
68 $this->{"e_account".$i."_amount"},
69 ($this->{"e_account".$i."_type"}=='d')?'t':'f',
70 $p_od_id)
71 );
72 }
73 }
74 catch (Exception $e)
75 {
77 echo ($e->getMessage());
78 throw $e;
79 }
80
81 }
82 /*!\brief compute an array accordingly with the FormVenView function
83 */
84 function compute_array($p_od_id)
85 {
86 $count=0;
87 $p_array=$this->load($p_od_id);
88 foreach ($p_array as $row)
89 {
90 $c=($row['opd_debit']=='t')?'d':'c';
91 $array+=array("e_account".$count=>$row['opd_poste'],
92 "e_account".$count."_amount"=>$row['opd_amount'],
93 "e_account".$count."_type"=>$c
94 );
95 $count++;
96
97 }
98 return $array;
99 }
100 /*!\brief load the data from the database and return an array
101 * \return an array
102 */
103 function load($p_od_id)
104 {
105 $sql="select opd_id,opd_poste,opd_amount,opd_debit".
106 " from op_predef_detail where od_id= $1 ".
107 " order by opd_debit, opd_id,opd_amount";
108 $res=$this->db->exec_sql($sql,array($p_od_id));
110 return $array;
111 }
112}
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342
static fetch_all($ret)
wrapper for the function pg_fetch_all
concerns the predefined operation for ODS ledger
save($p_od_id, $p_nbitem)
save the detail and op in the database
load($p_od_id)
load the data from the database and return an array
compute_array($p_od_id)
compute an array accordingly with the FormVenView function
mother of the pre_op_XXX, it contains only one data : an object Pre_Operation. The child class contai...
$count
$SecUser db