noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compta_ach.inc.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  *   This file is part of NOALYSS.
00005  *
00006  *   NOALYSS is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   NOALYSS is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with NOALYSS; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00022 
00023 /**
00024  *\file
00025  * \brief file included to manage all the sold operation
00026  */
00027 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00028 require_once("class_icheckbox.php");
00029 require_once("class_acc_ledger_purchase.php");
00030 require_once ('class_pre_op_ach.php');
00031 require_once('class_ipopup.php');
00032 $gDossier = dossier::id();
00033 global $g_parameter;
00034 $cn = new Database(dossier::id());
00035 //menu = show a list of ledger
00036 $str_dossier = dossier::get();
00037 $ac = "ac=" . $_REQUEST['ac'];
00038 
00039 // Check privilege
00040 if (isset($_REQUEST['p_jrn']))
00041         if ($g_user->check_jrn($_REQUEST['p_jrn']) != 'W')
00042         {
00043                 NoAccess();
00044                 exit - 1;
00045         }
00046 
00047 /* if a new invoice is encoded, we display a form for confirmation */
00048 if (isset($_POST['view_invoice']))
00049 {
00050         $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00051         try
00052         {
00053                 $Ledger->verify($_POST);
00054         }
00055         catch (Exception $e)
00056         {
00057                 alert($e->getMessage());
00058                 $correct = 1;
00059         }
00060         // if correct is not set it means it is correct
00061         if (!isset($correct))
00062         {
00063                 echo '<div class="content">';
00064                  echo h1('Confirmation','');
00065                 echo_warning("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer");
00066 
00067 
00068                 echo '<form enctype="multipart/form-data" method="post" class="print">';
00069                 echo dossier::hidden();
00070 
00071                 echo $Ledger->confirm($_POST);
00072                 echo HtmlInput::hidden('ac', $_REQUEST['ac']);
00073                 echo '<div style="clear:both">';
00074 
00075                 echo Pre_operation::save_propose();
00076                 echo '</div>';
00077                 echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
00078                 echo HtmlInput::submit('correct', _("Corriger"));
00079                 echo '</form>';
00080                 echo '</div>';
00081                 echo '</div>';
00082 
00083                 exit();
00084         }
00085 }
00086 //------------------------------
00087 /* Record the invoice */
00088 //------------------------------
00089 
00090 if (isset($_POST['record']))
00091 {
00092         $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00093         try
00094         {
00095                 $Ledger->verify($_POST);
00096         }
00097         catch (Exception $e)
00098         {
00099                 alert($e->getMessage());
00100                 $correct = 1;
00101         }
00102         // record the invoice
00103         if (!isset($correct))
00104         {
00105                 echo '<div class="content">';
00106 
00107                 $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00108                 $internal = $Ledger->insert($_POST);
00109 
00110 
00111                 /* Save the predefined operation */
00112                 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
00113                 {
00114                         $opd = new Pre_op_ach($cn);
00115                         $opd->get_post();
00116                         $opd->save();
00117                 }
00118 
00119                 /* Show button  */
00120                 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
00121 
00122                 echo '<h1> Enregistrement </h1>';
00123                 // echo "<h2 >" . _('Opération sauvée') . " $internal ";
00124                 // if ($Ledger->pj != '')
00125                 //      echo ' Piece : ' . h($Ledger->pj);
00126                 // echo "</h2>";
00127                 // if (strcmp($Ledger->pj, $_POST['e_pj']) != 0)
00128                 // {
00129                 //      echo '<h3 class="notice"> ' . _('Attention numéro pièce existante, elle a du être adaptée') . '</h3>';
00130                 // }
00131                 /* Save the additional information into jrn_info */
00132                 $obj = new Acc_Ledger_Info($cn);
00133                 $obj->save_extra($Ledger->jr_id, $_POST);
00134                 //printf('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>', $jr_id, dossier::id(), $internal);
00135                 // Feedback
00136                 echo $Ledger->confirm($_POST, true);
00137                 if (isset($Ledger->doc))
00138                 {
00139                      echo '<h2>Document</h2>';
00140                      echo $Ledger->doc;
00141                 }
00142 
00143                 echo '</div>';
00144                 exit();
00145         }
00146 }
00147 //  ------------------------------
00148 /* Display a blank form or a form with predef operation */
00149 /* or a form for correcting */
00150 //  ------------------------------
00151 
00152 echo '<div class="content">';
00153 //
00154 
00155 
00156 $array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
00157 $Ledger = new Acc_Ledger_Purchase($cn, 0);
00158 
00159 
00160 if (!isset($_REQUEST ['p_jrn']))
00161 {
00162         $def_ledger = $Ledger->get_first('ach',2);
00163         if ( empty ($def_ledger))
00164         {
00165                 exit('Pas de journal disponible');
00166         }
00167         $Ledger->id = $def_ledger['jrn_def_id'];
00168 }
00169 else
00170         $Ledger->id = $_REQUEST ['p_jrn'];
00171 
00172 if (isset ($_REQUEST['p_jrn_predef'])){
00173         $Ledger->id=$_REQUEST['p_jrn_predef'];
00174 }
00175 // pre defined operation
00176 //
00177 echo '<div id="predef_form">';
00178 echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
00179 $op = new Pre_op_ach($cn);
00180 $op->set('ledger', $Ledger->id);
00181 $op->set('ledger_type', "ACH");
00182 $op->set('direct', 'f');
00183 $url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
00184 echo $op->form_get('do.php?'.$url);
00185 echo '</div>';
00186 echo '</div>';
00187 
00188 echo '<div class="content">';
00189 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
00190 /* request for a predefined operation */
00191 if ( isset($_REQUEST['pre_def']) && !isset($_POST['correct']))
00192 {
00193         // used a predefined operation
00194         //
00195         $op = new Pre_op_ach($cn);
00196         $op->set_od_id($_REQUEST['pre_def']);
00197         $p_post = $op->compute_array();
00198         $Ledger->id = $_REQUEST ['p_jrn_predef'];
00199         $p_post['p_jrn'] = $Ledger->id;
00200         echo $Ledger->input($p_post);
00201         echo '<div class="content">';
00202         echo $Ledger->input_paid();
00203         echo '</div>';
00204         echo '<script>';
00205         echo 'compute_all_ledger();';
00206         echo '</script>';
00207 }
00208 else
00209 {
00210         echo $Ledger->input($array);
00211         echo HtmlInput::hidden("p_action", "ach");
00212         echo HtmlInput::hidden("sa", "p");
00213         echo '<div class="content">';
00214         echo $Ledger->input_paid();
00215         echo '</div>';
00216         echo '<script>';
00217         echo 'compute_all_ledger();';
00218         echo '</script>';
00219 }
00220 echo '<div class="content">';
00221 echo HtmlInput::button('act', _('Actualiser'), 'onClick="compute_all_ledger();"');
00222 echo HtmlInput::submit("view_invoice", _("Enregistrer"));
00223 echo HtmlInput::reset(_('Effacer '));
00224 echo '</div>';
00225 echo "</FORM>";
00226 
00227 if (!isset($_POST['e_date']) && $g_parameter->MY_DATE_SUGGEST=='Y')
00228         echo create_script(" get_last_date()");
00229 echo create_script(" update_name()");
00230 echo '</div>';
00231 
00232 
00233 exit();
00234 // end record invoice
00235 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations