noalyss Version-9
compta_ods.inc.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/**
23 * \file
24 *
25 *
26 * \brief to write directly into the ledgers,the stock and the tables
27 * quant_purchase and quant_sold are not changed by this
28 *
29 */
30if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
31require_once NOALYSS_INCLUDE . '/lib/ac_common.php';
32require_once NOALYSS_INCLUDE . '/lib/function_javascript.php';
33
34global $g_user, $http;
35
37
38
39$id_predef = $http->request('p_jrn_predef', 'number', -1);
40$id_ledger = $http->request('p_jrn', 'number', $id_predef);
41
43$first_ledger = $ledger->get_first('ODS');
44if (empty ($first_ledger)) {
45 exit('<span class="warning">' .
46 _('Pas de journal disponible') .
47 '</span>');
48}
49$ledger->id = ($ledger->id == -1) ? $first_ledger['jrn_def_id'] : $id_ledger;
50
51/**\brief show a form for quick_writing */
52$def = -1;
53$ledger->with_concerned = true;
54
55
56if ($g_user->check_jrn($ledger->id) == 'X') {
57 NoAccess();
58 exit - 1;
59}
60$p_msg = "";
61if (!isset($_POST['summary']) && !isset($_POST['save'])) {
62 require NOALYSS_INCLUDE . '/operation_ods_new.inc.php';
63 return;
64} elseif (isset($_POST['summary'])) {
65 try {
66 $ledger->verify_operation($_POST);
67 require_once NOALYSS_INCLUDE . '/operation_ods_confirm.inc.php';
68 } catch (Exception $e) {
69 echo alert($e->getMessage());
70 $p_msg = $e->getMessage();
71 require_once NOALYSS_INCLUDE . '/operation_ods_new.inc.php';
72
73 }
74 return;
75} elseif (isset($_POST['save'])) {
76 $array = $_POST;
77 echo '<div class="content">';
78 try {
79 $ledger->save($array);
80 $jr_id = $ledger->jr_id;
81
82 /* save followup */
83 $ledger->save_followup($http->request("action_gestion", "string", ""));
84
85
86 echo '<h2>' . _("Opération enregistrée") ." ". _("Piece") ." ". h($ledger->pj) . '</h2>';
87 if (strcmp($ledger->pj, $_POST['e_pj']) != 0) {
88 echo '<h3 class="notice">' . _('Attention numéro pièce existante, elle a du être adaptée') .
89 '</h3>';
90 }
91 echo '<div style="margin-left:3rem">';
92 echo _("Détail opération");
93 echo " ";
94 printf('<a class="detail" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>',
95 $jr_id, dossier::id(), $ledger->internal);
96 echo '</div>';
97
98 // show feedback
99 echo '<div id="jrn_name_div">';
100 echo '<h1 id="jrn_name" style="display:inline">' .
101 $ledger->get_name() . '</h1>';
102 echo '</div>';
103 echo $ledger->confirm($_POST, true);
104 // extourne
105 if (isset($_POST['reverse_ck'])) {
106 $p_date = $http->post('reverse_date', "string", '');
107 $p_msg = $http->post("ext_label");
108 if (isDate($p_date) == $p_date) {
109 // reverse the operation
110 try {
111 $ledger->reverse($p_date, $p_msg);
112 echo '<p>';
113 echo _('Extourné au ') . $p_date;
114 echo '</p>';
115 } catch (Exception $e) {
116 echo '<span class="warning">' . _('Opération non extournée') .
117 $e->getMessage() .
118 '</span>';
119
120 }
121 } else {
122 // warning because date is invalid
123 echo '<span class="warning">' . _('Date invalide, opération non extournée') . '</span>';
124 }
125 }
126 echo '<ul class="aligned-block">';
127 echo "<li>";
128 echo $ledger->button_new_operation();
129 echo "</li>";
130 echo "<li>";
131 echo $ledger->button_copy_operation();
132 echo "</li>";
133 echo "</ul>";
134 } catch (Exception $e) {
135 require NOALYSS_INCLUDE . '/operation_ods_new.inc.php';
136 alert($e->getMessage());
137 $p_msg = $e->getMessage();
138 }
139 echo '</div>';
140 return;
141}
142return;
143
isDate($p_date)
Definition: ac_common.php:236
NoAccess($js=1)
Echo no access and stop.
Definition: ac_common.php:480
alert($p_msg, $buffer=false)
alert in javascript
Definition: ac_common.php:738
h( $row[ 'oa_description'])
$jr_id
Definition: ajax_ledger.php:44
static connect()
$id_ledger
if(empty($first_ledger)) $ledger id
$ledger
$first_ledger
global $http
global $g_user
if($g_user->check_jrn($ledger->id)=='X') $p_msg
$id_predef
$def
show a form for quick_writing
$_POST['ac']
Definition: do.php:310
for($e=0; $e< count($afiche); $e++) exit
if( $delta< 0) elseif( $delta==0)