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 $p_msg="";
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                 $p_msg=$e->getMessage();
00059                 $correct = 1;
00060         }
00061         // if correct is not set it means it is correct
00062         if (!isset($correct))
00063         {
00064                 echo '<div class="content">';
00065                 echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
00066                 echo h1(_("Confirmation"));
00067                 echo '</div>';
00068 
00069                 echo '<div id="warning_ven_id" class="notice" style="width: 50%; margin-left: 0px; float: right;">';
00070                 echo h2(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"),' class="notice"');
00071                 echo '</div>';
00072 
00073                 echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
00074                 echo '<form enctype="multipart/form-data" method="post" class="print">';
00075                 echo dossier::hidden();
00076 
00077                 echo $Ledger->confirm($_POST);
00078                 echo HtmlInput::hidden('ac', $_REQUEST['ac']);
00079                             ?>
00080 <div id="tab_id" >
00081 <ul class="tabs">
00082     <li class="tabs_selected"><a href="javascript:void(0)" title="<?php echo _("Générer une facture ou charger un document")?>"  onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('repo_div_id').hide();$('facturation_div_id').show();"><?php echo _('Facture')?></a></li>
00083     <li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Choix du dépôt")?>"  onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('modele_div_id').hide();$('facturation_div_id').hide();$('repo_div_id').show();"> <?php echo _('Dépôt')?> </a></li>
00084     <li class="tabs"> <a href="javascript:void(0)" title="<?php echo _("Modèle à sauver")?>"  onclick="unselect_other_tab(this.parentNode.parentNode);this.parentNode.className='tabs_selected';$('facturation_div_id').hide();$('repo_div_id').hide();$('modele_div_id').show()"> <?php echo _('Modèle')?> </a></li>
00085 </ul>
00086 <?php
00087                 echo $Ledger->select_depot(false, -1);
00088                 echo $Ledger->extra_info();
00089                 
00090                 echo '<div id="modele_div_id" style="display:none;height:185px;height:10rem">';
00091                 echo Pre_operation::save_propose();
00092                 echo '</div>';
00093 
00094                 echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
00095                 echo HtmlInput::submit('correct', _("Corriger"));
00096                 echo '</form>';
00097                 echo '</div>'; /* tab_id */
00098                 echo '</div>';
00099                 ?>
00100 <script>
00101     $('repo_div_id').hide();
00102     $('modele_div_id').hide();
00103 </script>
00104 <?php
00105             echo '</div>';
00106             return;
00107 
00108                 return;
00109         }
00110 }
00111 //------------------------------
00112 /* Record the invoice */
00113 //------------------------------
00114 
00115 if (isset($_POST['record']))
00116 {
00117         $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00118         try
00119         {
00120                 $Ledger->verify($_POST);
00121         }
00122         catch (Exception $e)
00123         {
00124                 alert($e->getMessage());
00125                 $p_msg=$e->getMessage();
00126                 $correct = 1;
00127         }
00128         // record the invoice
00129         if (!isset($correct))
00130         {
00131                 echo '<div class="content">';
00132 
00133                 $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00134                 $internal = $Ledger->insert($_POST);
00135 
00136 
00137                 /* Save the predefined operation */
00138                 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
00139                 {
00140                         $opd = new Pre_op_ach($cn);
00141                         $opd->get_post();
00142                         $opd->save();
00143                 }
00144 
00145                 /* Show button  */
00146                 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
00147 
00148                 echo '<h1> '._('Enregistrement').' </h1>';
00149                 /* Save the additional information into jrn_info */
00150                 $obj = new Acc_Ledger_Info($cn);
00151                 $obj->save_extra($Ledger->jr_id, $_POST);
00152                 //printf('<a class="line" style="display:inline" href="javascript:modifyOperation(%d,%d)">%s</a><hr>', $jr_id, dossier::id(), $internal);
00153                 // Feedback
00154                 echo $Ledger->confirm($_POST, true);
00155                 if (isset($Ledger->doc))
00156                 {
00157                      echo '<h2>'._('Document').'</h2>';
00158                      echo $Ledger->doc;
00159                 }
00160                 echo $Ledger->button_new_operation();
00161                 echo '</div>';
00162                 return;
00163         }
00164 }
00165 //  ------------------------------
00166 /* Display a blank form or a form with predef operation */
00167 /* or a form for correcting */
00168 //  ------------------------------
00169 
00170 echo '<div class="content">';
00171 //
00172 
00173 
00174 $array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
00175 $Ledger = new Acc_Ledger_Purchase($cn, 0);
00176 
00177 
00178 if (!isset($_REQUEST ['p_jrn']))
00179 {
00180         $def_ledger = $Ledger->get_first('ach',2);
00181         if ( empty ($def_ledger))
00182         {
00183                 exit('Pas de journal disponible');
00184         }
00185         $Ledger->id = $def_ledger['jrn_def_id'];
00186 }
00187 else
00188         $Ledger->id = $_REQUEST ['p_jrn'];
00189 
00190 if (isset ($_REQUEST['p_jrn_predef'])){
00191         $Ledger->id=$_REQUEST['p_jrn_predef'];
00192 }
00193 // pre defined operation
00194 //
00195 echo '<div id="predef_form">';
00196 echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
00197 $op = new Pre_op_ach($cn);
00198 $op->set('ledger', $Ledger->id);
00199 $op->set('ledger_type', "ACH");
00200 $op->set('direct', 'f');
00201 $url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
00202 echo $op->form_get('do.php?'.$url);
00203 echo '</div>';
00204 echo '</div>';
00205 
00206 if ( is_msie() == 0 ) 
00207     echo '<div style="position:absolute"  class="content">';
00208 else
00209     echo '<div class="content">';
00210 
00211 echo '<p class="notice">'.$p_msg.'</p>';
00212 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
00213 /* request for a predefined operation */
00214 if ( isset($_REQUEST['pre_def']) && !isset($_POST['correct']))
00215 {
00216         // used a predefined operation
00217         //
00218         $op = new Pre_op_ach($cn);
00219         $op->set_od_id($_REQUEST['pre_def']);
00220         $p_post = $op->compute_array();
00221         $Ledger->id = $_REQUEST ['p_jrn_predef'];
00222         $p_post['p_jrn'] = $Ledger->id;
00223         echo $Ledger->input($p_post);
00224         echo '<div class="content">';
00225         echo $Ledger->input_paid();
00226         echo '</div>';
00227         echo '<script>';
00228         echo 'compute_all_ledger();';
00229         echo '</script>';
00230 }
00231 else
00232 {
00233         echo $Ledger->input($array);
00234         echo HtmlInput::hidden("p_action", "ach");
00235         echo HtmlInput::hidden("sa", "p");
00236         echo '<div class="content">';
00237         echo $Ledger->input_paid();
00238         echo '</div>';
00239         echo '<script>';
00240         echo 'compute_all_ledger();';
00241         echo '</script>';
00242 }
00243 echo '<div class="content">';
00244 echo HtmlInput::button('act', _('Actualiser'), 'onClick="compute_all_ledger();"');
00245 echo HtmlInput::submit("view_invoice", _("Enregistrer"));
00246 echo HtmlInput::reset(_('Effacer '));
00247 echo '</div>';
00248 echo "</FORM>";
00249 
00250 if (!isset($_POST['e_date']) && $g_parameter->MY_DATE_SUGGEST=='Y')
00251         echo create_script(" get_last_date()");
00252 echo create_script(" update_name()");
00253 echo '</div>';
00254 
00255 
00256 return;
00257 // end record invoice
00258 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations