noalyss Version-9
prepared_query.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * Copyright (C) 2019 Dany De Bontridder <dany@alchimerys.be>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program 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 this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21
22/**
23 * @file
24 * @brief contains prepared query used in different classes of the application
25 *
26 *
27 */
28
29/**
30 * @class Prepared_Query
31 * @brief contains prepared query used in different classes of the application
32 *
33 *
34 */
36 private $db; //!< Database connection
37
39 {
40 $this->db=$cn;
41 }
42
43 public function get_db()
44 {
45 return $this->db;
46 }
47
48 public function set_db($db)
49 {
50 $this->db=$db;
51 return $this;
52 }
53
54 /**
55 *@brief Prepare the query for fetching the linked operation. ONE paramete is needed : jrn.jr_id , returns all columns
56 * from the table PUBLIC.JRN, column qcode_bank (default card for fin ledger) of the operation concerning
57 * to the payment
58 *
59 * @see export_ledger_pdf.php
60 * @see Acc_Ledger_History
61 *
62 */
63 public function prepare_reconcile_date()
64 {
65 $prepare=$this->db->is_prepare("reconcile_date");
66 if ($prepare==FALSE)
67 {
68 $this->db->prepare('reconcile_date',
69 'select *
70 , (select ad_value from fiche_detail where ad_id=23 and f_id=jrn_def.jrn_def_bank ) as qcode_bank
71 , (select ad_value from fiche_detail where ad_id=1 and f_id=jrn_def.jrn_def_bank ) as qcode_name
72 from
73 jrn
74 join jrn_def on (jrn.jr_def_id=jrn_def.jrn_def_id)
75 where
76 jr_id in
77 (select
78 jra_concerned
79 from
80 jrn_rapt
81 where jr_id = $1
82 union all
83 select
84 jr_id
85 from jrn_rapt
86 where jra_concerned=$1)');
87 }
88 }
89 /**
90 * @brief Prepare the query for find the amount in currency
91 */
92 public function prepare_currency()
93 {
94 $prepare=$this->db->is_prepare("amount_cur");
95 if ($prepare==FALSE)
96 {
97
98 $this->db->prepare("amount_cur",
99 "select jrn2.jr_id ,
100 sum(coalesce(oc_amount,0)) as sum_ocamount
101 from operation_currency
102 join jrnx using (j_id)
103 join jrn as jrn2 on (j_grpt=jrn2.jr_grpt_Id)
104 where
105 j_id in (select j_id from jrnx where j_grpt=jrn2.jr_grpt_id )
106 and jr_id=$1
107 group by jr_id"
108 );
109 }
110 }
111
112}
contains the class for connecting to Noalyss
contains prepared query used in different classes of the application
__construct(Database $cn)
prepare_reconcile_date()
Prepare the query for fetching the linked operation.
$db
Database connection.
prepare_currency()
Prepare the query for find the amount in currency.
$SecUser db