Plugins  LAST
 All Data Structures Files Functions Variables Pages
amortize_javascript.js
Go to the documentation of this file.
1 content[400]="Filtrer sur quick-code, nom, date d'acquisition ou Année d'achat";
2 /* This file is part of NOALYSS and is under GPL see licence.txt */
3 /**
4  *javascript
5  */
6 function add_material(dossier_id,plugin_code,target)
7 {
8  var qs="gDossier="+dossier_id+'&plugin_code='+plugin_code+'&op=add_mat&t='+target;
9 
10  var action=new Ajax.Request ( 'ajax.php',
11  {
12  method:'get',
13  parameters:qs,
14  onFailure:error_ajax,
15  onSuccess:success_add_material
16  }
17  );
18  if ( $(target))
19  {
20  removeDiv(target);
21  }
22 
23  var sx=0;
24  if ( window.scrollY)
25  {
26  sx=window.scrollY+120;
27  }
28  else
29  {
30  sx=document.body.scrollTop+120;
31  }
32  var str_style="top:"+sx+"px;width:80%;height:70%";
33 
34  var div={id:target, cssclass:'inner_box',style:str_style,html:loading(),drag:1};
35 
36  add_div(div);
37 
38 }
39 function display_material(dossier_id,f_id,plugin_code,target)
40 {
41  var qs="gDossier="+dossier_id+'&plugin_code='+plugin_code+'&op=display_modify&t='+target+'&f='+f_id;
42 
43  var action=new Ajax.Request ( 'ajax.php',
44  {
45  method:'get',
46  parameters:qs,
47  onFailure:error_ajax,
48  onSuccess:success_add_material
49  }
50  );
51  if ( $(target))
52  {
53  removeDiv(target);
54  }
55 
56  var sx=0;
57  if ( window.scrollY)
58  {
59  sx=window.scrollY+120;
60  }
61  else
62  {
63  sx=document.body.scrollTop+120;
64  }
65  var str_style="top:"+sx+"px;width:auto;height:auto";
66 
67  var div={id:target, cssclass:'inner_box',style:str_style,html:loading(),drag:1};
68 
69  add_div(div);
70 
71 }
72 function success_add_material(req)
73 {
74  fill_box(req);
75 
76 }
77 function error_ajax() {
78  alert_box('Erreur ajax AMORTIS');
79 }
80 function confirm_new_material(obj) {
81  smoke.confirm('Confirmez ?',function(e) { if ( e ) {save_new_material(obj);return false;} });
82  return false;
83 }
84 /**
85  * Check the values
86  * - amrt_date date
87  * - p_card
88  * - p_number
89  * - p_year
90  * - p_amount
91  * - select_type_id
92  * @returns 0 if no error , otherwise number of error
93  */
94 function check_material()
95 {
96  var error=0;
97  // check date
98  if ( check_date ($('amrt_date').value) == false ) {
99  $('amrt_date').addClassName('error');
100  error++;
101  } else {
102  $('amrt_date').removeClassName('error');
103  }
104  // check card is given
105  if ( String.trim($('p_card').value) == "") {
106  $('p_card').addClassName('error');
107  error++;
108  } else {
109  $('p_card').removeClassName('error');
110  }
111  // check amount of year
112  if ( String.trim($('p_number').value) == "") {
113  $('p_number').addClassName('error');
114  error++;
115  } else {
116  $('p_number').removeClassName('error');
117  }
118  // check year of buy
119  if ( String.trim($('p_year').value) == "" || parseFloat(String.trim($('p_year').value)) < 1970 || parseFloat(String.trim($('p_year').value)) > 2100 )
120  {
121  $('p_year').addClassName('error');
122  error++;
123  } else {
124  $('p_year').removeClassName('error');
125  }
126  // check year of buy
127  if ( String.trim($('p_amount').value) == "" ) {
128  $('p_amount').addClassName('error');
129  error++;
130  } else {
131  $('p_amount').removeClassName('error');
132  }
133  // check card or accounting
134  if ( $('select_type_id').value == -1) {
135  $('select_type_id').addClassName('error');
136  error++;
137  } else {
138  $('select_type_id').removeClassName('error');
139  }
140  return error;
141 }
142 
143 /**
144 *Answer to a post (or get) in ajax
145 */
146 function save_new_material(obj)
147 {
148 
149  /*********************************************************************/
150  /* Check that all fields are properly set*/
151  /*********************************************************************/
152 
153 
154  if ( check_material() != 0 ) {
155  return false;
156  }
157  var querystring=$(obj).serialize()+'&op=save_new_material&t=bxmat';
158 
159  // Create a ajax request to get all the person
160  var action = new Ajax.Request ('ajax.php',
161  {
162  method: 'post',
163  parameters: querystring,
164  onFailure: error_ajax,
165  onSuccess: success_save_new_material
166  }
167  );
168 
169  return false;
170 }
171 
173 {
174  fill_box(req);
175  $('bxmat').style.height='auto';
176  $('bxmat').width='80%';
177 }
178 
179 function confirm_save_modify(obj) {
180  smoke.confirm('Confirmez ?',function(e) { if ( e ) {save_modify(obj);return false;} });
181  return false;
182 }
183 function save_modify(obj)
184 {
185  if ( check_material() != 0 ) { return false;}
186  var querystring=$(obj).serialize()+'&op=save_modify&t=bxmat';
187 
188  // Create a ajax request to get all the person
189  var action = new Ajax.Request ('ajax.php',
190  {
191  method: 'post',
192  parameters: querystring,
193  onFailure: error_ajax,
194  onSuccess: success_save_modify
195  }
196  );
197 
198  return false;
199 
200 }
201 function success_save_modify(req)
202 {
203  fill_box(req);
204 
205 }
206 function remove_mat(g_dossier,plugin_code,a_id)
207 {
208  confirm_box(null,'Vous confirmez EFFACEMENT',function() {
209  var qs="gDossier="+g_dossier+"&plugin_code="+plugin_code+"&a_id="+a_id+"&op=rm&t=bxmat";
210  var action=new Ajax.Request ( 'ajax.php',
211  {
212  method:'get',
213  parameters:qs,
214  onFailure:error_ajax,
215  onSuccess:function (req) {
217  $('bxmat').style.width='80%';
218  }
219  }
220  )
221  }
222  );
223 
224 
225 
226 }
227 
228 function list_csv(obj)
229 {
230  alert_box ("dossier = "+obj.dossier+" plugin :"+obj.plugin+" year "+obj.year);
231  var qs="gDossier="+obj.dossier+"&plugin_code="+obj.plugin+"&list_year=1"+"&year="+obj.year;
232  var action=new Ajax.Request ( 'extension.raw.php',
233  {
234  method:'get',
235  parameters:qs,
236  onFailure:null,
237  onSuccess:null
238  }
239  );
240 
241 
242 }
243 
245 {
246  if ( obj.value==0) { $('cred_use_account_tr_id').show();$('deb_use_account_tr_id').show();
247  $('cred_use_card_tr_id').hide();$('deb_use_card_tr_id').hide() }
248  if ( obj.value==1) { $('cred_use_account_tr_id').hide();$('deb_use_account_tr_id').hide()
249  $('cred_use_card_tr_id').show();$('deb_use_card_tr_id').show()}
250  if ( obj.value==-1) { $('cred_use_account_tr_id').hide();$('deb_use_account_tr_id').hide() ;
251  $('cred_use_card_tr_id').hide();$('deb_use_card_tr_id').hide()}
252 }
function save_modify(obj)
$note style
function save_new_material(obj)
Answer to a post (or get) in ajax.
function confirm_save_modify(obj)
function display_material(dossier_id, f_id, plugin_code, target)
function confirm_new_material(obj)
$p_year value
function success_save_modify(req)
function success_save_new_material(req)
function remove_mat(g_dossier, plugin_code, a_id)
function error_ajax()
show($p_code, $p_desc)
function success_add_material(req)
function add_material(dossier_id, plugin_code, target)
javascript
function check_material()
Check the values.
content[400]
function show_selected_material(obj)
function list_csv(obj)
if($p_number->value==0) l les annuités seront recalculées et l pct[] ad_year[] select h_amount from amortissement amortissement_histo where a_id