noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compta_fin.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  * \brief this file is to be included to handle the financial ledger
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 require_once ('class_acc_ledger_fin.php');
00027 require_once('class_ipopup.php');
00028 global $g_user,$g_parameter;
00029 
00030 $gDossier=dossier::id();
00031 
00032 
00033 $cn=new Database(dossier::id());
00034 $menu_action="?ledger_type=fin&ac=".$_REQUEST['ac']."&".dossier::get();
00035 
00036 $Ledger=new Acc_Ledger_Fin($cn,0);
00037 
00038 //--------------------------------------------------------------------------------
00039 // Encode a new financial operation
00040 //--------------------------------------------------------------------------------
00041 
00042 if ( isset($_REQUEST['p_jrn']))
00043         $Ledger->id=$_REQUEST['p_jrn'];
00044 else
00045 {
00046         $def_ledger=$Ledger->get_first('fin');
00047         if ( empty ($def_ledger))
00048         {
00049                 exit('Pas de journal disponible');
00050         }
00051         $Ledger->id=$def_ledger['jrn_def_id'];
00052 }
00053 $jrn_priv=$g_user->get_ledger_access($Ledger->id);
00054 // Check privilege
00055 if ( isset($_REQUEST['p_jrn']) && ( $jrn_priv == 'X'))
00056 {
00057         NoAccess();
00058         exit -1;
00059 }
00060 
00061 //----------------------------------------
00062 // Confirm the operations
00063 //----------------------------------------
00064 if ( isset($_POST['save']))
00065 {
00066         try
00067         {
00068                 $Ledger->verify($_POST);
00069         }
00070         catch (Exception $e)
00071         {
00072                 alert($e->getMessage());
00073                 $correct=1;
00074         }
00075         if ( ! isset ($correct ))
00076         {
00077                 echo '<div class="content">';
00078                 echo h1('Confirmation','');
00079                 echo_warning("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer");
00080                 echo '<form name="form_detail" class="print" enctype="multipart/form-data" class="print" METHOD="POST">';
00081                 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00082                 echo $Ledger->confirm($_POST);
00083                 echo HtmlInput::submit('confirm',_('Confirmer'));
00084                 echo HtmlInput::submit('correct',_('Corriger'));
00085 
00086                 echo '</form>';
00087                 echo '</div>';
00088                 exit();
00089         }
00090 }
00091 //----------------------------------------
00092 // Confirm and save  the operations
00093 // into the database
00094 //----------------------------------------
00095 if ( isset($_POST['confirm']))
00096 {
00097         try
00098         {
00099                 $Ledger->verify($_POST);
00100         }
00101         catch (Exception $e)
00102         {
00103                 alert($e->getMessage());
00104                 $correct=1;
00105         }
00106         if ( !isset($correct))
00107         {
00108                 echo '<div id="jrn_name_div">';
00109                 echo '<h2 id="jrn_name" style="display:inline">' . $Ledger->get_name() . '</h2>';
00110                 echo '</div>';
00111 
00112                 echo '<div class="content">';
00113                 $a= $Ledger->insert($_POST);
00114                 echo '<h1>'._('Enregistrement').' </h1>';
00115                 echo '<div class="content">';
00116                 echo $a;
00117                 echo '</div>';
00118                 echo '</div>';
00119                 exit();
00120         }
00121 }
00122 //----------------------------------------
00123 // Correct the operations
00124 //----------------------------------------
00125 if ( isset($_POST['correct']))
00126 {
00127         $correct=1;
00128 }
00129 //----------------------------------------
00130 // Blank form
00131 //----------------------------------------
00132 echo '<div class="content">';
00133 
00134 
00135 echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
00136 echo HtmlInput::hidden('ledger_type','fin');
00137 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00138 $array=( isset($correct))?$_POST:null;
00139 
00140 // show select ledger
00141 echo $Ledger->input($array);
00142 echo HtmlInput::button('add_item',_('Ajout article'),   ' onClick="ledger_fin_add_row()"');
00143 echo HtmlInput::submit('save',_('Sauve'));
00144 echo HtmlInput::reset(_('Effacer'));
00145 
00146 if ( ! isset ($_POST['e_date'])&& $g_parameter->MY_DATE_SUGGEST=='Y')
00147 {
00148         echo create_script(" get_last_date();ajax_saldo('first_sold');");
00149 }else {
00150         echo create_script(" ajax_saldo('first_sold');");
00151 }
00152 echo create_script(" update_name()");
00153 exit();
 All Data Structures Namespaces Files Functions Variables Enumerations