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 if (!isset($_POST['summary']) && !isset($_POST['save']))
00065 {
00066         require('operation_ods_new.inc.php');
00067         exit();
00068 }
00069 elseif (isset($_POST['summary']))
00070 {
00071         try {
00072                         $ledger->verify($_POST);
00073                         require_once 'operation_ods_confirm.inc.php';
00074         } catch (Exception $e)
00075         {
00076                 echo alert($e->getMessage());
00077                 require('operation_ods_new.inc.php');
00078 
00079         }
00080         exit();
00081 }
00082 elseif (isset($_POST['save']))
00083 {
00084         $array = $_POST;
00085 
00086         try
00087         {
00088                 $ledger->save($array);
00089                 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal));
00090 
00091                 echo '<h2> Op&eacute;ration enregistr&eacute;e  Piece ' . h($ledger->pj) . '</h2>';
00092                 if (strcmp($ledger->pj, $_POST['e_pj']) != 0)
00093                 {
00094                         echo '<h3 class="notice">' . _('Attention numéro pièce existante, elle a du être adaptée') . '</h3>';
00095                 }
00096                 printf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>', $jr_id, dossier::id(), $ledger->internal);
00097 
00098                 // show feedback
00099                 echo '<div id="jrn_name_div">'; echo '<h2 id="jrn_name" class="title"  style="display:inline">' . $ledger->get_name() . '</h2>'; echo '</div>';
00100                 echo $ledger->confirm($_POST, true);
00101         }
00102         catch (Exception $e)
00103         {
00104                 require('operation_ods_new.inc.php');
00105                 alert($e->getMessage());
00106         }
00107         exit();
00108 }
00109 exit();
00110 
 All Data Structures Namespaces Files Functions Variables Enumerations