noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
compta_ven.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  * \brief file included to manage all the sold operation
00024  */
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 require_once("class_icheckbox.php");
00027 require_once("class_acc_ledger_sold.php");
00028 require_once ('class_pre_op_ven.php');
00029 require_once ('class_document.php');
00030 require_once ('class_acc_ledger_info.php');
00031 require_once('class_ipopup.php');
00032 
00033 $gDossier=dossier::id();
00034 $cn=new Database(dossier::id());
00035 //menu = show a list of ledger
00036 $str_dossier=dossier::get();
00037 $ac="ac=".$_REQUEST['ac'];
00038 global $g_parameter;
00039 
00040 //----------------------------------------------------------------------
00041 // Encode a new invoice
00042 // empty form for encoding
00043 //----------------------------------------------------------------------
00044 
00045     $Ledger=new Acc_Ledger_Sold($cn,0);
00046 
00047     // Check privilege
00048     if ( isset($_REQUEST['p_jrn']) &&
00049             $g_user->check_jrn($_REQUEST['p_jrn']) != 'W' )
00050     {
00051 
00052         NoAccess();
00053         exit -1;
00054     }
00055 
00056     /* if a new invoice is encoded, we display a form for confirmation */
00057     if ( isset ($_POST['view_invoice'] ) )
00058     {
00059         $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
00060         try
00061         {
00062             $Ledger->verify($_POST);
00063         }
00064         catch (Exception $e)
00065         {
00066             alert($e->getMessage());
00067             $correct=1;
00068         }
00069         // if correct is not set it means it is correct
00070         if ( ! isset($correct))
00071         {
00072             echo '<div class="content">';
00073             echo h1('Confirmation','');
00074             echo_warning("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer");
00075 
00076 
00077             echo '<form class="print" enctype="multipart/form-data" method="post">';
00078             echo dossier::hidden();
00079             echo $Ledger->confirm($_POST );
00080                         echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00081             echo '<div style="clear:both">';
00082             
00083             echo Pre_operation::save_propose();
00084             echo '</div>';
00085             echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00086             echo HtmlInput::submit("record",_("Enregistrement"),'onClick="return verify_ca(\'\');"');
00087             echo HtmlInput::submit('correct',_("Corriger"));
00088             echo '</form>';
00089 
00090             echo '</div>';
00091             exit();
00092         }
00093     }
00094     //------------------------------
00095     /* Record the invoice */
00096     //------------------------------
00097 
00098     if ( isset($_POST['record']) )
00099     {
00100 // Check privilege
00101         if ( $g_user->check_jrn($_REQUEST['p_jrn']) != 'W' )
00102         {
00103 
00104             NoAccess();
00105             exit -1;
00106         }
00107 
00108         $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
00109         try
00110         {
00111             $Ledger->verify($_POST);
00112         }
00113         catch (Exception $e)
00114         {
00115             alert($e->getMessage());
00116             $correct=1;
00117         }
00118 
00119         if ( ! isset($correct))
00120         {
00121             echo '<div class="content">';
00122             $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
00123             $internal=$Ledger->insert($_POST);
00124 
00125             /* Save the predefined operation */
00126             if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
00127             {
00128                 $opd=new Pre_op_ven($cn);
00129                 $opd->get_post();
00130                 $opd->save();
00131             }
00132 
00133             /* Show button  */
00134             echo '<h1 > Enregistrement </h1>';
00135 
00136             echo $Ledger->confirm($_POST,true);
00137             /* Show link for Invoice */
00138             if (isset ($Ledger->doc) )
00139             {
00140                 echo '<h2>Document </h2>';
00141                 echo $Ledger->doc;
00142             }
00143 
00144 
00145             /* Save the additional information into jrn_info */
00146             $obj=new Acc_Ledger_Info($cn);
00147             $obj->save_extra($Ledger->jr_id,$_POST);
00148 
00149 
00150             echo '</div>';
00151             exit();
00152         }
00153     }
00154     //  ------------------------------
00155     /* Display a blank form or a form with predef operation */
00156     //  ------------------------------
00157 
00158     $array=(isset($_POST['correct'])||isset ($correct))?$_POST:null;
00159     $Ledger=new Acc_Ledger_Sold($cn,0);
00160 //
00161 // pre defined operation
00162 //
00163 echo '<div class="content">';
00164     if ( !isset($_REQUEST ['p_jrn']) )
00165     {
00166         $def_ledger=$Ledger->get_first('ven',2);
00167                 if (empty($def_ledger))
00168         {
00169                 exit('Pas de journal disponible');
00170         }
00171         $Ledger->id=$def_ledger['jrn_def_id'];
00172     }
00173     else
00174         $Ledger->id=$_REQUEST ['p_jrn'];
00175         if (isset ($_REQUEST['p_jrn_predef'])){
00176                 $Ledger->id=$_REQUEST['p_jrn_predef'];
00177         }
00178 
00179     echo '<div id="predef_form">';
00180     echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
00181     $op=new Pre_op_ven($cn);
00182     $op->set('ledger',$Ledger->id);
00183     $op->set('ledger_type',"VEN");
00184     $op->set('direct','f');
00185     $url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
00186     echo $op->form_get('do.php?'.$url);
00187     echo '</div>';
00188 
00189    echo '<div class="content">';
00190  echo "<FORM class=\"print\" NAME=\"form_detail\" METHOD=\"POST\" >";
00191     /* request for a predefined operation */
00192     if (  isset($_REQUEST['pre_def']) && ! isset($_POST['correct']) )
00193     {
00194         // used a predefined operation
00195         //
00196         $op=new Pre_op_ven($cn);
00197         $op->set_od_id($_REQUEST['pre_def']);
00198         $p_post=$op->compute_array();
00199         $Ledger->id=$_REQUEST ['p_jrn_predef'];
00200 
00201         echo $Ledger->input($p_post);
00202         echo '<div class="content">';
00203         echo $Ledger->input_paid();
00204         echo '</div>';
00205         echo '<script>';
00206         echo 'compute_all_ledger();';
00207         echo '</script>';
00208     }
00209     else if ( isset ($_GET['create_invoice']))
00210     {
00211         $array=$Ledger->convert_from_follow($_GET ['ag_id']);
00212         echo HtmlInput::hidden("ledger_type","VEN");
00213         echo HtmlInput::hidden("ac",$_REQUEST['ac']);
00214         echo HtmlInput::hidden("sa","p");
00215         echo $Ledger->input($array);
00216         echo '<div class="content">';
00217         echo $Ledger->input_paid();
00218         echo '</div>';
00219         echo '<script>';
00220         echo 'compute_all_ledger();';
00221         echo '</script>';
00222     }
00223     else
00224     {
00225         echo HtmlInput::hidden("ledger_type","VEN");
00226           echo HtmlInput::hidden("ac",$_REQUEST['ac']);
00227         echo HtmlInput::hidden("sa","p");
00228         echo $Ledger->input($array);
00229         echo '<div class="content">';
00230         echo $Ledger->input_paid();
00231         echo '</div>';
00232         echo '<script>';
00233         echo 'compute_all_ledger();';
00234         echo '</script>';
00235     }
00236     echo '<div class="content">';
00237     echo HtmlInput::button('act',_('Actualiser'),'onClick="compute_all_ledger();"');
00238     echo HtmlInput::submit("view_invoice",_("Enregistrer"));
00239     echo HtmlInput::reset(_('Effacer '));
00240     echo '</div>';
00241     echo "</FORM>";
00242 
00243     /* if we suggest the pj n# the run the script */
00244     if ( $g_parameter->MY_PJ_SUGGEST=='Y')
00245     {
00246                 echo '<script> update_pj()</script>';
00247     }
00248         if (!isset($_POST['e_date']) && $g_parameter->MY_DATE_SUGGEST=='Y')
00249         {
00250                 echo create_script(" get_last_date()");
00251         }
00252 echo create_script(" update_name()");   
00253 exit();
00254 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations