noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compta_ods.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  *
00025  * \brief to write directly into the ledgers,the stock and the tables
00026  * quant_purchase and quant_sold are not changed by this
00027  *
00028  */
00029 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00030 require_once("class_icheckbox.php");
00031 require_once ('class_acc_ledger.php');
00032 require_once ('class_acc_reconciliation.php');
00033 require_once('ac_common.php');
00034 require_once('class_periode.php');
00035 require_once('function_javascript.php');
00036 require_once('class_ipopup.php');
00037 
00038 global $g_user;
00039 
00040 $cn = new Database(dossier::id());
00041 
00042 $id_predef = (isset($_REQUEST['p_jrn_predef'])) ? $_REQUEST['p_jrn_predef'] : -1;
00043 $id_ledger = (isset($_REQUEST['p_jrn'])) ? $_REQUEST['p_jrn'] : $id_predef;
00044 $ledger = new Acc_Ledger($cn, $id_ledger);
00045 $first_ledger = $ledger->get_first('ODS');
00046 if ( empty ($first_ledger))
00047 {
00048         exit('Pas de journal disponible');
00049 }
00050 $ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id_ledger;
00051 
00052 /**\brief show a form for quick_writing */
00053 $def = -1;
00054 $ledger->with_concerned = true;
00055 
00056 
00057 
00058 
00059 if ($g_user->check_jrn($ledger->id) == 'X')
00060 {
00061         NoAccess();
00062         exit - 1;
00063 }
00064 $p_msg="";
00065 if (!isset($_POST['summary']) && !isset($_POST['save']))
00066 {
00067         require('operation_ods_new.inc.php');
00068         return;
00069 }
00070 elseif (isset($_POST['summary']))
00071 {
00072         try {
00073                         $ledger->verify($_POST);
00074                         require_once 'operation_ods_confirm.inc.php';
00075         } catch (Exception $e)
00076         {
00077                 echo alert($e->getMessage());
00078                 $p_msg=$e->getMessage();
00079                 require('operation_ods_new.inc.php');
00080 
00081         }
00082         return;
00083 }
00084 elseif (isset($_POST['save']))
00085 {
00086         $array = $_POST;
00087         echo '<div class="content">';
00088         try
00089         {
00090                 $ledger->save($array);
00091                 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal));
00092 
00093                 echo '<h2> Op&eacute;ration enregistr&eacute;e  Piece ' . h($ledger->pj) . '</h2>';
00094                 if (strcmp($ledger->pj, $_POST['e_pj']) != 0)
00095                 {
00096                         echo '<h3 class="notice">' . _('Attention numéro pièce existante, elle a du être adaptée') . '</h3>';
00097                 }
00098                 printf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>', $jr_id, dossier::id(), $ledger->internal);
00099 
00100                 // show feedback
00101                 echo '<div id="jrn_name_div">'; echo '<h2 id="jrn_name"  style="display:inline">' . $ledger->get_name() . '</h2>'; echo '</div>';
00102                 echo $ledger->confirm($_POST, true);
00103                 echo $ledger->button_new_operation();
00104 
00105         }
00106         catch (Exception $e)
00107         {
00108                 require('operation_ods_new.inc.php');
00109                 alert($e->getMessage());
00110                 $p_msg=$e->getMessage();
00111         }
00112         echo '</div>';
00113         return;
00114 }
00115 return;
00116 
 All Data Structures Namespaces Files Functions Variables Enumerations