Plugins  LAST
 All Data Structures Files Functions Variables Pages
ajax.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 require_once NOALYSS_INCLUDE.'/lib/class_database.php';
20 require_once('class_ext_tva.php');
21 require_once NOALYSS_INCLUDE.'/lib/class_ibutton.php';
22 require_once ('class_ext_list_intra.php');
23 require_once ('class_ext_list_assujetti.php');
24 require_once NOALYSS_INCLUDE.'/class/class_acc_ledger.php';
25 
26 extract($_GET);
28 
29 $html='';$extra='';$ctl='';
30 switch($act) {
31 case 'dsp_decl':
32  /* the hide button */
33  $button=new IButton('hide');
34  $button->label=_('Retour');
35  $button->javascript="$('detail').hide();$('main').show();";
36  if ( $type == 1) {
37  /* display the declaration of amount */
38  $decl=new Ext_Tva($cn);
39  $decl->set_parameter('id',$id);
40  $decl->load();
41  $r=$button->input();
42  $r.=$decl->display();
43  $r.=$button->input();
44  }
45  if ( $type == 3) {
46  /* display the declaration for INTRACOM */
48  $decl->set_parameter('id',$id);
49  $decl->load();
50  $r=$button->input();
51  $r.=$decl->display();
52  $r.=$button->input();
53  }
54  if ( $type == 2) {
55  /* display the declaration of customer */
57  $decl->set_parameter('id',$id);
58  $decl->load();
59  $r=$button->input();
60  $r.=$decl->display();
61  $r.=$button->input();
62  }
63 
64  break;
65  /**
66  * generate writing
67  */
68 case 'rw':
69  require_once NOALYSS_INCLUDE.'/class/class_acc_ledger.php';
70  $count=$cn->get_value('select count(*) from tva_belge.declaration_amount where da_id=$1',array($_REQUEST['p_id']));
71  if ( $count == 1 )
72  {
73  $ctl='record_write';
74  $ledger=new Acc_ledger($cn,0);
75  $sel_ledger=$ledger->select_ledger('ODS',1);
76  $r=HtmlInput::title_box('Génération écriture','record_write');
77  if ($sel_ledger != null)
78  {
79  $r.='<form onsubmit="save_write(this);return false;">';
80  $decl=new Ext_Tva($cn);
81  $decl->set_parameter('id',$_GET['p_id']);
82  $decl->load();
83  $date=new IDate('pdate');
84  $r.="Date :".$date->input().'<br>';
85  $r.="Choix du journal : ".$sel_ledger->input();
86  $r.=$decl->propose_form();
87  $r.=HtmlInput::hidden('mt',microtime(true));
88  $r.=HtmlInput::extension();
89  $r.=dossier::hidden();
90  $r.=HtmlInput::submit('save','Sauver','onclick="return confirm(\'Vous confirmez ? \')"');
91  $r.='</form>';
92  } else {
93  $r.='<h2 class="error"> Aucun journal accessible</h2>';
94  }
95  }
96  else
97  {
98  $ctl='record_write';
99  $r=HtmlInput::anchor_close($ctl);
100  $r.="<h2 class=\"info\">Désolé cette opération n'existe pas </h2>";
101  $r.='<span class="notice">Il se peut que l\'information aie été effacée</span>';
102  $r.=HtmlInput::button_close($ctl);
103  }
104  break;
105 
106 case 'sw':
107  $ctl='record_write';
108  ob_start();
109  echo '<div style="float:right"><a class="mtitle" href="javascript:void(0)" onclick="removeDiv(\'record_write\')">fermer</a></div>';
110  extract($_GET);
111  try {
112  $array=array();
113  $array['e_date']=$pdate;
114  /* give automatically the periode */
115  $periode=new Periode($cn);
116  $periode->find_periode($pdate);
117  $array['period']=$periode->p_id;
118  $nb_item=count($account);
119  for ($i=0;$i<count($account);$i++) {
120  $array['amount'.$i]=$amount[$i];
121  $array['poste'.$i]=$account[$i];
122  $array['ld'.$i]='';
123  if ( isset($deb[$i])) $array['ck'.$i]=1;
124  }
125  /* ATVA */
126  if ( isset($atva)) {
127  $array['poste'.$i]=$atva;
128  $array['amount'.$i]=$atva_amount;
129  $array['ld'.$i]='';
130  if ( isset($atva_ic)) $array['ck'.$i]=1;
131  $i++;
132  $nb_item++;
133  }
134  /* CRED */
135  if ( isset($crtva)) {
136  $array['poste'.$i]=$crtva;
137  $array['amount'.$i]=$crtva_amount;
138  $array['ld'.$i]='';
139  if ( isset($crtva_ic)) $array['ck'.$i]=1;
140  $i++;
141  $nb_item++;
142  }
143  /* DET */
144  if ( isset($dttva)) {
145  $array['poste'.$i]=$dttva;
146  $array['amount'.$i]=$dttva_amount;
147  $array['ld'.$i]='';
148  if ( isset($dttva_ic)) $array['ck'.$i]=1;
149  $i++;
150  $nb_item++;
151  }
152  /* solde */
153  if ( isset($solde)) {
154  $array['poste'.$i]=$solde;
155  $array['amount'.$i]=$solde_amount;
156  $array['ld'.$i]='';
157  if ( isset($solde_ic)) $array['ck'.$i]=1;
158  $i++;
159  $nb_item++;
160  }
161  $array['nb_item']=$nb_item;
162  $array['e_pj']='';
163  $array['e_pj_suggest']='NONE';
164 
165  $array['p_jrn']=$p_jrn;
166  $array['mt']=$mt;
167 
168  $array['desc']='Extension TVA : écriture générée';
169  $ods=new Acc_Ledger($cn,$p_jrn);
170  $ods->save($array);
171  echo h2info("Sauvée : ajoutez le numéro de pièce");
172  echo HtmlInput::detail_op($ods->jr_id,'détail opération : '.$ods->internal);
173  $ods->with_concerned=false;
174  echo $ods->confirm($array,true);
175  } catch(Exception $e) {
176  echo alert($e->getMessage());
177  }
178  $r=ob_get_contents();
179  ob_end_clean();
180  break;
181 case 'rm_form':
182  switch($type)
183  {
184  case 'da':
185  $sql="delete from tva_belge.declaration_amount where da_id=$1";
186  break;
187  case 'li':
188  $sql="delete from tva_belge.intracomm where i_id=$1";
189  break;
190  case 'lc':
191  $sql="delete from tva_belge.assujetti where a_id=$1";
192  break;
193  }
194  $ctl='remove_form';
195  $cn->exec_sql($sql,array($_REQUEST['p_id']));
196  $r=HtmlInput::anchor_close($ctl);
197  $r.='<h2 class="info"> Information </h2>';
198  $r.='<h2 class="notice">Opération effacée</h2>';
199  $r.=HtmlInput::button_close($ctl);
200  $html=escape_xml($r);
201  break;
202 case 'add_param':
203  $ctl="paramadd_id";
204  $r=HtmlInput::title_box("Ajout paramètre",$ctl);
205  $r.='<h3>'._('Pour la grille ').$pcode.'</h3>';
206  // TVA input
207  $text = new ITva_Popup('tva_id');
208  $text->add_label('tva_label');
209  $text->js = 'onchange="set_tva_label(this);"';
210  $text->with_button(true);
211 
212  // Accounting
213  $iposte=new IPoste('paccount');
214  $iposte->set_attribute('gDossier',Dossier::id());
215  $iposte->set_attribute('jrn',0);
216  $iposte->set_attribute('account','paccount');
217  $iposte->set_attribute('label','paccount_label');
218 
219 
220  $r.='<form method="POST" id="faddparm"onsubmit="return confirm(\'Vous confirmez ?\');" style="margin-left:15px">';
221  $r.=HtmlInput::request_to_hidden(array("tab","gDossier","plugin_code","ac","pcode"));
222  $r.=_(" Code TVA ");
223  $r.=$text->input();
224  $r.='<span id="tva_label" style="display:block"></span>';
225  $r.=" Poste comptable (utilisez le % pour inclure les postes qui en dépendent)";
226  $r.=$iposte->input();
227 
228  $r.='<span id="paccount_label" style="display:inline"></span>';
229  $r.='<span style="display:block"></span>';
230  $r.=HtmlInput::submit("save_addparam","Sauver");
231  $r.=HtmlInput::button_close($ctl);
232  $r.='</form>';
233  break;
234 default:
235  $r=var_export($_REQUEST,true);
236 }
237 
238 $html=escape_xml($r);
239 
240 header('Content-type: text/xml; charset=UTF-8');
241 echo <<<EOF
242 <?xml version="1.0" encoding="UTF-8"?>
243 <data>
244 <ctl>$ctl</ctl>
245 <code>$html</code>
246 <extra>$extra</extra>
247 </data>
248 EOF;
249 ?>
if(isset($_POST['ftvaadd'])) if(isset($_POST['mod'])) $atva
get data from database
$select_type id
$act
Definition: ajax.php:5
$html
Definition: ajax.php:32
$r
Definition: ajax.php:28
$button
$categorie_appel extra
$periode
global $cn
Definition: ajax.php:27
$type
Retrouve le type de row si == 3.
$ctl
Definition: ajax.php:31
global $g_parameter
Definition: ajax.php:27
if(isset($_POST['remove'])) $array
$extra
Definition: ajax.php:33
$_REQUEST['sb']
Definition: am_print.php:39
$sql