noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
anc_pa.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  *
00024  * \brief Plan Analytique
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 // action
00034 // Compute the redcontent div
00035 //---------------------------------------------------------------------------
00036 if ( isset($_REQUEST['sa']))
00037 {
00038     $sa=$_REQUEST['sa'];
00039 
00040     // show the form for adding a pa
00041     if ( $sa == "add_pa")
00042     {
00043         $new=new Anc_Plan($cn);
00044         if ( $new->isAppend() == true)
00045         {
00046             $ret.= '<div style="position:absolute;top:25%" class="inner_box">';
00047             $ret.=HtmlInput::title_box(_('Nouveau plan'),'','none');
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="content">'.
00059                    '<h2 class="notice">'.
00060                    _("Maximum de plan analytique est atteint").
00061                    "</h2></div>";
00062         }
00063         $sa="anc_menu";
00064     }
00065     // Add
00066     if ( $sa == "pa_write")
00067     {
00068         $new=new Anc_Plan($cn);
00069 
00070 
00071         if ( $new->isAppend() == false)
00072         {
00073             $ret.= '<h2 class="notice">'.
00074                    _("Maximum de plan analytique est atteint").
00075                    "</h2>";
00076         }
00077         else
00078         {
00079             $new=new Anc_Plan($cn);
00080             $new->name=$_POST['pa_name'];
00081             $new->description=$_POST['pa_description'];
00082             $new->add();
00083         }
00084         $sa="anc_menu";
00085     }
00086     
00087     // Update the PA
00088     if ( $sa == "pa_update" )
00089     {
00090         $new=new Anc_Plan($cn,$_GET['pa_id']);
00091         $new->name=$_POST['pa_name'];
00092         $new->description=$_POST['pa_description'];
00093         $new->update();
00094         $ret='<div class="content">';
00095         $ret.='<h2 class="info">'._('Mis à jour').'</h2>';
00096         $ret.="</div>";
00097         $sa="anc_menu";
00098     }
00099     // show the form for add a poste
00100     if ( $sa=='po_add')
00101     {
00102         $po=new Anc_Account($cn);
00103         $po->pa_id=$_REQUEST['pa_id'];
00104         $wSa=HtmlInput::hidden("sa","po_write");
00105         $ret.='<div class="content">';
00106         $ret.=h2(_("Ajout d'un poste analytique"));
00107         $ret.='<form method="post">';
00108         $ret.=dossier::hidden();
00109         $ret.=$po->form();
00110         $ret.=$wSa;
00111         $ret.=HtmlInput::submit("add",_("Ajout"));
00112         $ret.="</form>";
00113         $ret.="</div>";
00114         
00115     }
00116     // record the poste
00117     if ( $sa=="po_write")
00118     {
00119         //              var_dump($_POST);
00120         $po=new Anc_Account($cn);
00121         $po->get_from_array($_POST);
00122         $po->add();
00123         $sa="pa_detail";
00124         
00125 
00126     }
00127     /* delete pa */
00128     if ( $sa == "pa_delete")
00129     {
00130         $delete=new Anc_Plan($cn,$_GET['pa_id']);
00131         $delete->delete();
00132         $sa="anc_menu";
00133     }
00134     /* po detail
00135      *---> in ajax : montre detail d'un poste analytique
00136      * 
00137      */
00138     if ( $sa=="po_detail")
00139     {
00140         $ret.=h2(_('Modification'));
00141         $po=new Anc_Account($cn,$_GET['po_id']);
00142         $po->get_by_id();
00143         $ret.='<div class="content">';
00144         $ret.='<form method="post">';
00145         $ret.=dossier::hidden();
00146 
00147         $ret.=$po->form();
00148         $ret.=HtmlInput::hidden('sa','po_update');
00149         $ret.=HtmlInput::submit('Correction','Correction');
00150         $ret.=sprintf('<A class="mtitle" HREF="?ac='.$_REQUEST['ac'].'&sa=po_delete&po_id=%s&pa_id=%s&'.$str_dossier.'">'.
00151                       '<input type="button" class="smallbutton" value="Efface" onClick="return confirm(\' Voulez-vous vraiment effacer cette activité\');"></A>',
00152                       $po->id,
00153                       $_REQUEST['pa_id']
00154                      );
00155 
00156         $ret.='</form>';
00157         $ret.='</div>';
00158         $sa="";
00159     }
00160     /**
00161      * mise à jour po 
00162      */
00163     if ( $sa=="po_update")
00164     {
00165         $po=new Anc_Account($cn);
00166         $po->get_from_array($_POST);
00167         $po->update();
00168         $sa="pa_detail";
00169     }
00170     /**
00171      * Efface po
00172      */
00173     if ( $sa=="po_delete")
00174     {
00175         $po=new Anc_Account($cn,$_REQUEST['po_id']);
00176         $po->delete();
00177         $sa="pa_detail";
00178     }
00179     // show the detail
00180     if ( $sa == "pa_detail" )
00181     {
00182         $new=new Anc_Plan($cn,$_GET['pa_id']);
00183         $wSa=HtmlInput::hidden("sa","pa_update");
00184 
00185         $new->get();
00186 
00187         $ret.= '<div class="content">';
00188         $ret.= '<h2 class="info">'._("Mise à jour").'</h2>';
00189         $ret.= '<form method="post">';
00190         $ret.=dossier::hidden();
00191 
00192         $ret.= $new->form();
00193         $ret.= $wSa;
00194         $ret.=HtmlInput::submit("submit",_("Enregistre"));
00195         $ret.=HtmlInput::button_anchor(_('Efface'),"?ac=".$_REQUEST['ac']."&pa_id=".$_GET['pa_id']."&sa=pa_delete&$str_dossier",_('Efface'),'onclick="return confirm(\'Effacer ?\')"','smallbutton');
00196         $ret.= '</form>';
00197         /**
00198          * Detail now
00199          */
00200             $count=0;
00201 
00202         $new=new Anc_Plan($cn,$_REQUEST['pa_id']);
00203         $new->get();
00204         $array=$new->get_poste_analytique(" order by po_name");
00205         $ret.='<div class="content">';
00206         $ret.='<table class="table_large">';
00207         $ret.="<tr>";
00208         $ret.="<th>"._("Nom")." </td>";
00209         $ret.="<th>"._("Montant")." </td>";
00210         $ret.="<th>"._("Description")." </td>";
00211         $ret.="<th>"._("Groupe")."</th>";
00212         $ret.="<th>"._("Plan A")." </td>";
00213         $ret.="</tr>";
00214         $class="";
00215         foreach ($array as $obj)
00216         {
00217             $count++;
00218             if ( $count %2 == 0 )
00219                 $class="even";
00220             else
00221                 $class="odd";
00222 
00223             $ret.="<TR class=\"$class\">";
00224             $ret.="<TD class=\"vert_mtitle\">".
00225                   '<a style="text-decoration:underline;" href="?ac='.$_REQUEST['ac'].'&sa=po_detail&po_id='.$obj->id.'&pa_id='.$_REQUEST['pa_id'].'&'.
00226                   $str_dossier.'">'.
00227                   h($obj->name).
00228                   '</a>';
00229             "</td>"
00230             ;
00231             $ret.="<TD align=\"right\">".$obj->amount."</td>";
00232             $ret.="<TD>".h($obj->description)."</td>";
00233             $ret.="<td>".$obj->ga_id."</td>";
00234             $ret.="<TD>".h($new->name)."</td>";
00235             $ret.="</tr>";
00236 
00237         }
00238         $ret.="</table>";
00239         // ---> montre form pour ajouter po
00240         $ret.=HtmlInput::button_anchor(_('Ajout'),"?ac=".$_REQUEST['ac']."&sa=po_add&pa_id=".$_GET['pa_id']."&".$str_dossier,'','','smallbutton');
00241         $href=http_build_query(array('ac'=>$_REQUEST['ac'],'gDossier'=>$_REQUEST['gDossier']));
00242         $ret.= '<a style="display:inline" class="smallbutton" href="do.php?'.$href.'">'._('Retour').'</a>';
00243         $ret.= '</div>';
00244         
00245     }
00246 }
00247 else {
00248     $sa="anc_menu";
00249 }
00250 
00251 //---------------------------------------------------------------------------
00252 // Show lmenu
00253 //
00254 //---------------------------------------------------------------------------
00255 if ($sa=='anc_menu')
00256 {
00257 
00258     $obj=new Anc_Plan($cn);
00259     $list=$obj->get_list();
00260 
00261 
00262 
00263 
00264     if (empty($list))
00265     {
00266         echo '<div class="content">';
00267         echo '<TABLE>';
00268         echo '<TR><TD class="vert_mtitle">';
00269         echo '<a href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan comptable").'</a>';
00270         echo '</TD></TR>';
00271         echo '</TABLE>';
00272 
00273         echo '</div>';
00274         if (!isset($_REQUEST['sa']))
00275             echo '<div class="notice">'.
00276             _("Aucun plan analytique n'est défini").
00277             '</div>';
00278     }
00279     else
00280     {
00281         echo '<div class="content">';
00282 
00283         echo '<table class="vert_mtitle">';
00284         if ($obj->isAppend()==true)
00285         {
00286             echo '<TR><TD class="first">';
00287             echo '<a href="?ac='.$_REQUEST['ac'].'&sa=add_pa&'.$str_dossier.'">'._("Ajout d'un plan comptable").'</a>';
00288             echo '</TD></TR>';
00289         }
00290         foreach ($list as $line)
00291         {
00292             echo '<TR>';
00293             echo '<TD>'.
00294             '<a href="?ac='.$_REQUEST['ac'].'&sa=pa_detail&pa_id='.$line['id'].'&'.$str_dossier.'">'.
00295             h($line['name']);
00296 
00297             echo $line['description']."</a>";
00298             echo "</td>";
00299             echo "</TR>\n";
00300         }
00301         echo '</TABLE>';
00302 
00303 
00304         echo '</div>';
00305     }
00306 }
00307 //---------------------------------------------------------------------------
00308 // show the content part
00309 //
00310 //
00311 //---------------------------------------------------------------------------
00312 
00313 echo $ret;
 All Data Structures Namespaces Files Functions Variables Enumerations