Plugins  LAST
 All Data Structures Files Functions Variables Pages
appel_fond.inc.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS 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 NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 /* $Revision$ */
21 
22 // Copyright (c) 2002 Author Dany De Bontridder dany@alchimerys.be
23 
24 /**
25  * @file
26  * @brief génére écriture comptable pour appel de fond
27  *
28  */
30 require_once 'class_coprop_appel_fond.php';
31 extract($_GET);
32 $error = 0;
33 
34 // Demande génération
35 if (isset($calc))
36 {
37  try
38  {
39 
40 // Génére écriture comptable dans journal choisi
41  switch ($aft)
42  {
43  case -1:
44  throw new Exception("Choisissez le type de calcul");
45  break;
46  case 1:
47  $appel_fond = new Coprop_Appel_Fond();
48  $appel_fond->compute_budget($_GET);
49  break;
50  case 2:
51  $appel_fond = new Coprop_Appel_Fond();
52  $appel_fond->compute_amount($_GET);
53  break;
54  }
55 
56  $appel_fond->display_ledger();
57 
58 
59  return;
60  }
61  catch (Exception $e)
62  {
63  alert($e->getMessage());
64  }
65 }
66 // correct
67 
68 if (isset($_POST['correct']))
69 {
70  $appel_fond = new Coprop_Appel_Fond();
71  $appel_fond->id = $_POST['af_id'];
72  $ledger = new Acc_Ledger($cn, $_POST['p_jrn']);
73 
74  echo '<FORM METHOD="GET" class="print">';
75  echo $ledger->input($_POST, 0);
76  echo HtmlInput::request_to_hidden(array('amount', 'key', 'w_categorie_appel', 'b_id', 'aft', 'bud_pct', 'p_date', 'ac', 'plugin_code', 'sa'));
77  echo HtmlInput::extension() . dossier::hidden();
78  echo HtmlInput::hidden('action', 'confirm');
79  echo HtmlInput::hidden('af_id', $appel_fond->id);
80  echo HtmlInput::submit('save', 'Sauve');
81 
82  echo HtmlInput::button('add', _('Ajout d\'une ligne'), 'onClick="quick_writing_add_row()"');
83  echo '</form>';
84  echo '<div class="info">' .
85  _('Débit') . ' = <span id="totalDeb"></span> ' .
86  _('Crédit') . ' = <span id="totalCred"></span> ' .
87  _('Difference') . ' = <span id="totalDiff"></span></div> ';
88  echo "<script>checkTotalDirect();</script>";
89  echo '</div>';
90 
91  return;
92 }
93 // save
94 if (isset($_POST['confirm']))
95 {
96  try
97  {
98 
99  $ledger = new Acc_Ledger($cn, $_POST['p_jrn']);
100  $ledger->with_concerned = false;
101  $ledger->save($_POST);
102  echo "<h2>Opération sauvée</h2>";
103  echo HtmlInput::detail_op($ledger->jr_id, $ledger->internal);
104  echo $ledger->confirm($_POST, true);
105  $appel_fond = new Coprop_Appel_Fond();
106  $appel_fond->id = $_POST['af_id'];
107  $appel_fond->jr_internal=$ledger->internal;
108  $appel_fond->confirm();
109  return;
110  }
111  catch (Exception $e)
112  {
113  alert($e->getMessage());
114 
115  return;
116  }
117 }
118 // Montre écran confirmation
119 if (isset($_GET['save']))
120 {
121  try
122  {
123  $ledger = new Acc_Ledger($cn, $_GET['p_jrn']);
124  $ledger->with_concerned = false;
125  $res = $ledger->input($_GET, 1);
126  echo '<form method="POST">';
127 
128  echo HtmlInput::hidden('af_id', $_GET['af_id']);
129 
130  echo $res;
131  echo HtmlInput::submit('confirm', 'Confirmer');
132  echo HtmlInput::submit('correct', 'Corriger');
133  echo '</form>';
134  return;
135  }
136  catch (Exception $e)
137  {
138  alert($e->getMessage());
139  $appel_fond = new Coprop_Appel_Fond();
140  $appel_fond->id = $_GET['af_id'];
141  $ledger = new Acc_Ledger($cn, $_GET['p_jrn']);
142 
143  echo '<FORM METHOD="GET" class="print">';
144  echo $ledger->input($_GET, 0);
145  echo HtmlInput::get_to_hidden(array('amount', 'key', 'w_categorie_appel', 'b_id', 'aft', 'bud_pct', 'p_date', 'ac', 'plugin_code', 'sa'));
146  echo HtmlInput::extension() . dossier::hidden();
147  echo HtmlInput::hidden('action', 'confirm');
148  echo HtmlInput::hidden('af_id', $appel_fond->id);
149  echo HtmlInput::submit('save', 'Sauve');
150 
151  echo HtmlInput::button('add', _('Ajout d\'une ligne'), 'onClick="quick_writing_add_row()"');
152  echo '</form>';
153  echo '<div class="info">' .
154  _('Débit') . ' = <span id="totalDeb"></span> ' .
155  _('Crédit') . ' = <span id="totalCred"></span> ' .
156  _('Difference') . ' = <span id="totalDiff"></span></div> ';
157  echo "<script>checkTotalDirect();</script>";
158  echo '</div>';
159  return;
160  }
161 }
162 
163 
164 
165 // Detail : propose de faire un appel de fond
166 $date = new IDate('p_date');
167 $date->value = HtmlInput::default_value('p_date', "", $_GET);
168 
169 $amount = new INum('amount');
170 $amount->value = HtmlInput::default_value('amount', 0, $_GET);
171 
172 $ledger = new Acc_Ledger($cn, 0);
173 $led_appel_fond = $ledger->select_ledger('ODS', 3);
174 $led_appel_fond->selected = (isset($_GET['p_jrn'])) ? $_GET['p_jrn'] : $g_copro_parameter->journal_appel;
175 
176 $copro = new ICard();
177 $categorie_appel = new ICard();
178 $categorie_appel->label = " Appel de fond : " . HtmlInput::infobulle(0);
179 $categorie_appel->name = "w_categorie_appel";
180 $categorie_appel->tabindex = 1;
181 $categorie_appel->value = isset($_GET['w_categorie_appel']) ? $_GET['w_categorie_appel'] : "";
182 $categorie_appel->table = 0;
183 $categorie_appel->selected = (isset($_GET['key'])) ? $_GET['key'] : -1;
184 
185 // name of the field to update with the name of the card
186 $categorie_appel->set_attribute('label', 'w_categorie_appel_label');
187 // Type of card : deb, cred,
188 $categorie_appel->set_attribute('typecard', $g_copro_parameter->categorie_appel);
189 
190 $categorie_appel->extra = $g_copro_parameter->categorie_appel;
191 
192 // Add the callback function to filter the card on the jrn
193 $categorie_appel->set_callback('filter_card');
194 $categorie_appel->set_attribute('ipopup', 'ipopcard');
195 // when value selected in the autcomplete
196 $categorie_appel->set_function('fill_data');
197 
198 // when the data change
199 $categorie_appel->javascript = sprintf(' onchange="fill_data_onchange(\'%s\');" ', $categorie_appel->name);
200 $categorie_appel->set_dblclick("fill_ipopcard(this);");
201 
203 $categorie_appel_label->table = 0;
204 $f_categorie_appel_label = $categorie_appel_label->input("w_categorie_appel_label", "");
205 
206 // Search button for card
208 
209 $key = new ISelect("key");
210 $key->value = $cn->make_array("select cr_id,cr_name from coprop.clef_repartition order by cr_name");
211 $key->selected = HtmlInput::default_value('key', -1, $_GET);
212 
213 $f_add_button = new IButton('add_card');
214 $f_add_button->label = _('Nouvelle fiche ');
215 $f_add_button->set_attribute('ipopup', 'ipop_newcard');
216 $f_add_button->set_attribute('jrn', -1);
217 $filter = $g_copro_parameter->categorie_appel;
218 $f_add_button->javascript = " this.filter='$filter';this.jrn=-1;select_card_type(this);";
220 
221 // Budget
222 $budget_sel = new ISelect("b_id");
223 $budget_sel->value = $cn->make_array("select b_id,b_name from coprop.budget order by b_name");
224 $budget_sel->selected = HtmlInput::default_value('b_id', -1, $_GET);
225 
226 // pourcentage
227 $budget_pct = new INum("bud_pct", 0);
228 $budget_pct->value = HtmlInput::default_value('bud_pct', 0, $_GET);
229 
230 // select between budget or amount
231 $appel_fond_type = new ISelect("aft");
232 $appel_fond_type->value = array(
233  array("value" => -1, 'label' => 'Faites votre choix'),
234  array("value" => 1, 'label' => 'Appel de fond par budget'),
235  array("value" => 2, 'label' => 'Appel de fond par montant')
236 );
237 $onchange = " onchange=\"appel_fond_show() \"";
238 $appel_fond_type->javascript = $onchange;
239 $appel_fond_type->selected = HtmlInput::default_value('aft', -1, $_GET);
240 
241 echo '<form method="get">';
242 echo HtmlInput::request_to_hidden(array('ac', 'plugin_code', 'sa', 'gDossier'));
243 require_once 'template/appel_fond.php';
244 echo HtmlInput::submit('calc', "Calculer");
245 echo '</form>';
246 ?>
$categorie_appel
$str_add_appel
$f_categorie_appel_bt
$led_appel_fond
$categorie_appel_label
$f_categorie_appel_label
global $cn
$budget_sel
$budget_pct
if(isset($calc)) if(isset($_POST['correct'])) if(isset($_POST['confirm'])) if(isset($_GET['save'])) $date
$f_add_button
$onchange
global $g_copro_parameter
$res
calcul appel de fond
$error
$appel_fond_type