noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
periode.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 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00020 /*! \file
00021  * \brief add, modify, close or delete a period
00022  */
00023 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00024 $gDossier=dossier::id();
00025 require_once("class_iselect.php");
00026 require_once ('class_periode.php');
00027 echo '<div class="content">';
00028 $cn=new Database($gDossier);
00029 //-----------------------------------------------------
00030 // Periode
00031 //-----------------------------------------------------
00032 $action="";
00033 if ( isset($_REQUEST['action']))
00034     $action=$_REQUEST['action'];
00035 $choose=(isset ($_GET['choose']))?$_GET['choose']:"no";
00036 
00037 if ($choose=='Valider') $choose='yes';
00038 
00039 if ( isset ($_POST["add_per"] ))
00040 {
00041     extract($_POST);
00042     $obj=new Periode($cn);
00043     if ( $obj->insert($p_date_start,$p_date_end,$p_exercice) == 1 )
00044     {
00045         alert(_('Valeurs invalides'));
00046     }
00047     $choose="yes";
00048 
00049 }
00050 if (isset($_POST['add_exercice']))
00051   {
00052     $obj=new Periode($cn);
00053     $exercice=$cn->get_value('select max(p_exercice::float)+1 from parm_periode');
00054     if ( $obj->insert_exercice($exercice,$_POST['nb_exercice']) == 1 )
00055     {
00056         alert(_('Valeurs invalides'));
00057     }
00058 
00059     $choose="yes";
00060   }
00061 /*
00062  * Close selected periode
00063  */  
00064 if ( isset($_POST['close_per']) )
00065 {
00066         if (isset($_POST['sel_per_close'] ) ) {
00067                 $a_per_to_close=$_POST['sel_per_close'];
00068                 for ($i=0;$i < count($a_per_to_close);$i++) {
00069                         $per=new Periode($cn);
00070                          $jrn_def_id=(isset($_GET['jrn_def_id']))?$_GET['jrn_def_id']:0;
00071                          $per->jrn_def_id=$jrn_def_id;
00072                          $per->set_periode($a_per_to_close[$i]);
00073                         $per->close();
00074                 
00075                 }
00076         }
00077         $choose="yes";
00078 }
00079 
00080 
00081 if ( $action== "delete_per" )
00082 {
00083     $p_per=$_GET["p_per"];
00084 // Check if the periode is not used
00085     if ( $cn->count_sql("select * from jrnx where j_tech_per=$p_per") != 0 )
00086     {
00087         alert(' Désolé mais cette période est utilisée');
00088     }
00089     else
00090     {
00091         $count=$cn->get_value("select count(*) from parm_periode;");
00092         if ( $count > 1 ) {
00093             $Res=$cn->exec_sql("delete from parm_periode where p_id=$p_per");
00094         }
00095         {
00096             alert(' Désolé mais vous devez avoir au moins une période');
00097         }
00098     }
00099     $choose="yes";
00100 }
00101 if ( $action == 'reopen')
00102   {
00103     $jrn_def_id=(isset($_GET['jrn_def_id']))?$_GET['jrn_def_id']:0;
00104     $per=new Periode($cn);
00105     $jrn_def_id=(isset($_GET['jrn_def_id']))?$_GET['jrn_def_id']:0;
00106     $per->set_jrn($jrn_def_id);
00107     $per->set_periode($_GET['p_per']);
00108     $per->reopen();
00109 
00110     $choose="yes";
00111   }
00112 if ( $choose=="yes" )
00113 {
00114     echo '<p>';
00115     echo HtmlInput::button_anchor('Autre Journal ?','?choose=no&ac='.$_REQUEST['ac'].'&gDossier='.dossier::id());
00116     echo '</p>';
00117     $per=new Periode($cn);
00118     $jrn=(isset($_GET['jrn_def_id']))?$_GET['jrn_def_id']:0;
00119     $per->set_jrn($jrn);
00120 
00121     $per->display_form_periode();
00122     $nb_exercice=new ISelect("nb_exercice");
00123     $nb_exercice->value=array(
00124                               array('value'=>12,'label'=>"12 périodes"),
00125                               array('value'=>13,'label'=>"13 périodes")
00126                               );
00127 
00128     require_once('template/periode_add_exercice.php');
00129 }
00130 else
00131 {
00132     echo '<form method="GET" >';
00133     echo dossier::hidden();
00134     $sel_jrn=$cn->make_array("select jrn_def_id, jrn_def_name from ".
00135                              " jrn_def order by jrn_def_name");
00136     $sel_jrn[]=array('value'=>0,'label'=>'Global : periode pour tous les journaux');
00137     $wSel=new ISelect();
00138     $wSel->value=$sel_jrn;
00139     $wSel->name='jrn_def_id';
00140     echo "Choississez global ou uniquement le journal à fermer".$wSel->input();
00141     echo   HtmlInput::submit('choose','Valider');
00142     echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00143     echo "</form>";
00144     echo '<p class="info"> Pour ajouter, effacer ou modifier une p&eacute;riode, il faut choisir global</p>';
00145 }
00146 echo '</div>';
00147 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations