Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00028 require_once("class_anc_plan.php");
00029 require_once("class_anc_account.php");
00030 $ret="";
00031 $str_dossier=Dossier::get();
00032
00033
00034
00035
00036 if ( isset($_REQUEST['sa']))
00037 {
00038 $sa=$_REQUEST['sa'];
00039
00040
00041 if ( $sa == "add_pa")
00042 {
00043 $new=new Anc_Plan($cn);
00044 if ( $new->isAppend() == true)
00045 {
00046 $ret.= '<div class="redcontent">';
00047 $ret.= '<h2 class="info">'._("Nouveau plan").'</h2>';
00048 $ret.= '<form method="post">';
00049 $ret.=dossier::hidden();
00050 $ret.= $new->form();
00051 $ret.= HtmlInput::hidden("sa","pa_write");
00052 $ret.=HtmlInput::submit("submit",_("Enregistre"));
00053 $ret.= '</form>';
00054 $ret.= '</div>';
00055 }
00056 else
00057 {
00058 $ret.= '<div class="redcontent">'.
00059 '<h2 class="info">'.
00060 _("Maximum de plan analytique est atteint").
00061 "</h2></div>";
00062 }
00063 }
00064
00065 if ( $sa == "pa_write")
00066 {
00067 $new=new Anc_Plan($cn);
00068
00069
00070 if ( $new->isAppend() == false)
00071 {
00072 $ret.= '<h2 class="info">'.
00073 _("Maximum de plan analytique est atteint").
00074 "</h2>";
00075 }
00076 else
00077 {
00078 $new=new Anc_Plan($cn);
00079 $new->name=$_POST['pa_name'];
00080 $new->description=$_POST['pa_description'];
00081 $new->add();
00082 }
00083 }
00084
00085 if ( $sa == "pa_detail" )
00086 {
00087 $new=new Anc_Plan($cn,$_GET['pa_id']);
00088 $wSa=HtmlInput::hidden("sa","pa_update");
00089
00090 $new->get();
00091
00092 $ret.= '<div class="redcontent">';
00093 $ret.= '<h2 class="info">'._("Mise à jour").'</h2>';
00094 $ret.= '<form method="post">';
00095 $ret.=dossier::hidden();
00096
00097 $ret.= $new->form();
00098 $ret.= $wSa;
00099 $ret.=HtmlInput::submit("submit",_("Enregistre"));
00100 $ret.=HtmlInput::button_anchor(_('Efface'),"?ac=".$_REQUEST['ac']."&pa_id=".$_GET['pa_id']."&sa=pa_delete&$str_dossier",'Efface','onclick="return confirm(\'Effacer ?\')"');
00101 $ret.= '</form>';
00102 $ret.= '</div>';
00103
00104 }
00105
00106 if ( $sa == "pa_update" )
00107 {
00108 $new=new Anc_Plan($cn,$_GET['pa_id']);
00109 $new->name=$_POST['pa_name'];
00110 $new->description=$_POST['pa_description'];
00111 $new->update();
00112 $ret='<div class="redcontent">';
00113 $ret.='<h2 class="info">Mis à jour</h2>';
00114 $ret.="</div>";
00115 }
00116
00117 if ( $sa=='po_add')
00118 {
00119 $po=new Anc_Account($cn);
00120 $po->pa_id=$_REQUEST['pa_id'];
00121 $wSa=HtmlInput::hidden("sa","po_write");
00122 $ret.='<div class="redcontent">';
00123 $ret.='<form method="post">';
00124 $ret.=dossier::hidden();
00125 $ret.=$po->form();
00126 $ret.=$wSa;
00127 $ret.=HtmlInput::submit("add",_("Ajout"));
00128 $ret.="</form>";
00129 $ret.="</div>";
00130 }
00131
00132 if ( $sa=="po_write")
00133 {
00134
00135 $po=new Anc_Account($cn);
00136 $po->get_from_array($_POST);
00137 $po->add();
00138 $sa="list";
00139
00140 }
00141
00142 if ( $sa == "pa_delete")
00143 {
00144 $delete=new Anc_Plan($cn,$_GET['pa_id']);
00145 $delete->delete();
00146 }
00147
00148
00149
00150 if ( $sa=="po_detail")
00151 {
00152 $po=new Anc_Account($cn,$_GET['po_id']);
00153 $po->get_by_id();
00154 $ret.='<div class="redcontent">';
00155 $ret.='<form method="post">';
00156 $ret.=dossier::hidden();
00157
00158 $ret.=$po->form();
00159 $ret.=HtmlInput::hidden('sa','po_update');
00160 $ret.=HtmlInput::submit('Correction','Correction');
00161 $ret.=sprintf('<A class="mtitle" HREF="?ac='.$_REQUEST['ac'].'&sa=po_delete&po_id=%s&pa_id=%s&'.$str_dossier.'">'.
00162 '<input type="button" class="button" value="Efface" onClick="return confirm(\' Voulez-vous vraiment effacer cette activité\');"></A>',
00163 $po->id,
00164 $_REQUEST['pa_id']
00165 );
00166
00167 $ret.='</form>';
00168 $ret.='</div>';
00169 }
00170 if ( $sa=="po_update")
00171 {
00172 $po=new Anc_Account($cn);
00173 $po->get_from_array($_POST);
00174 $po->update();
00175 $sa="list";
00176 }
00177 if ( $sa=="po_delete")
00178 {
00179 $po=new Anc_Account($cn,$_REQUEST['po_id']);
00180 $po->delete();
00181 $sa="list";
00182 }
00183
00184 if ( $sa == "list" )
00185 {
00186 $count=0;
00187
00188 $new=new Anc_Plan($cn,$_REQUEST['pa_id']);
00189 $new->get();
00190 $array=$new->get_poste_analytique(" order by po_name");
00191 $ret.='<div class="redcontent">';
00192 $ret.='<table class="table_large">';
00193 $ret.="<tr>";
00194 $ret.="<th>"._("Nom")." </td>";
00195 $ret.="<th>"._("Montant")." </td>";
00196 $ret.="<th>"._("Description")." </td>";
00197 $ret.="<th>"._("Groupe")."</th>";
00198 $ret.="<th>"._("Plan A")." </td>";
00199 $ret.="</tr>";
00200 $class="";
00201 foreach ($array as $obj)
00202 {
00203 $count++;
00204 if ( $count %2 == 0 )
00205 $class="even";
00206 else
00207 $class="odd";
00208
00209 $ret.="<TR class=\"$class\">";
00210 $ret.="<TD >".
00211 '<a style="text-decoration:underline;" href="?ac='.$_REQUEST['ac'].'&sa=po_detail&po_id='.$obj->id.'&pa_id='.$_REQUEST['pa_id'].'&'.
00212 $str_dossier.'">'.
00213 h($obj->name).
00214 '</a>';
00215 "</td>"
00216 ;
00217 $ret.="<TD align=\"right\">".$obj->amount."</td>";
00218 $ret.="<TD>".h($obj->description)."</td>";
00219 $ret.="<td>".$obj->ga_id."</td>";
00220 $ret.="<TD>".h($new->name)."</td>";
00221 $ret.="</tr>";
00222
00223 }
00224 $ret.="</table>";
00225 $ret.=HtmlInput::button_anchor(_('Ajout'),"?ac=".$_REQUEST['ac']."&sa=po_add&pa_id=".$_GET['pa_id']."&".$str_dossier);
00226 $ret.='</div>';
00227
00228 }
00229
00230 }
00231
00232
00233
00234
00235
00236
00237 $obj=new Anc_Plan($cn);
00238 $list=$obj->get_list();
00239
00240
00241
00242
00243 if ( empty($list) )
00244 {
00245 echo '<div class="lmenu">';
00246 echo '<TABLE>';
00247 echo '<TR><TD class="mtitle">';
00248 echo '<a class="mtitle" href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan comptable").'</a>';
00249 echo '</TD></TR>';
00250 echo '</TABLE>';
00251
00252 echo '</div>';
00253 if ( ! isset ( $_REQUEST['sa']))
00254 echo '<div class="notice">'.
00255 _("Aucun plan analytique n'est défini").
00256 '</div>';
00257
00258 }
00259 else
00260 {
00261 echo '<div class="lmenu">';
00262
00263 echo '<table>';
00264 foreach ($list as $line)
00265 {
00266 echo '<TR>';
00267 echo '<TD >'.
00268 '<a class="mtitle" href="?ac='.$_REQUEST['ac'].'&sa=pa_detail&pa_id='.$line['id'].'&'.$str_dossier.'">'.
00269 h($line['name']).
00270 '</TD>';
00271 echo '<td class="mtitle">'.
00272 '<a class="mtitle" href="?ac='.$_REQUEST['ac'].'&sa=list&pa_id='.$line['id'].'&'.$str_dossier.'">'.
00273 "Activités".
00274 "</a>";
00275
00276 echo '</TR>';
00277 }
00278 echo '</table>';
00279 if ($obj->isAppend()==true )
00280 {
00281 echo '<TABLE>';
00282 echo '<TR><TD class="mtitle">';
00283 echo '<a class="mtitle" href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan comptable").'</a>';
00284 echo '</TD></TR>';
00285 echo '</TABLE>';
00286 }
00287
00288
00289 echo '</div>';
00290 }
00291
00292
00293
00294
00295
00296
00297 echo $ret;