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 $p_msg="";
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             $p_msg=$e->getMessage();
00068             $correct=1;
00069         }
00070         // if correct is not set it means it is correct
00071         if ( ! isset($correct))
00072         {
00073             echo '<div class="content">';
00074 
00075             echo '<div id="confirm_div_id" style="width: 47%; float: left;">';
00076             echo h1(_("Confirmation"));
00077             echo '</div>';
00078 
00079             echo '<div id="warning_ven_id" class="notice" style="width: 50%; margin-left: 0px; float: right;">';
00080             echo h2(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"),' class="notice"');
00081             echo '</div>';
00082             
00083             echo '<div id="confirm_div_id" style="width: 100%; float: left;">';
00084             echo '<form class="print" enctype="multipart/form-data" method="post">';
00085             echo dossier::hidden();
00086             echo $Ledger->confirm($_POST );
00087             echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00088             ?>
00089 <div id="tab_id" >
00090 <ul class="tabs">
00091     <li class="tabs_selected"><a href="javascript:void(0)" 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>
00092     <li class="tabs"> <a href="javascript:void(0)" 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>
00093     <li class="tabs"> <a href="javascript:void(0)" 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>
00094 </ul>
00095 <?php
00096             echo $Ledger->select_depot(false, -1);
00097             echo $Ledger->extra_info();
00098             echo '<div id="modele_div_id" style="display:none;height:185px;height:10rem">';
00099             echo Pre_operation::save_propose();
00100             echo '</div>';
00101             
00102             echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00103             echo HtmlInput::submit("record",_("Enregistrement"),'onClick="return verify_ca(\'\');"');
00104             echo HtmlInput::submit('correct',_("Corriger"));
00105             echo '</form>';
00106             echo '</div>';
00107             echo '</div>'; /* tab_id */
00108 ?>
00109 <script>
00110     $('repo_div_id').hide();
00111     $('modele_div_id').hide();
00112 </script>
00113 <?php
00114             echo '</div>';
00115             return;
00116         }
00117     }
00118     //------------------------------
00119     /* Record the invoice */
00120     //------------------------------
00121 
00122     if ( isset($_POST['record']) )
00123     {
00124 // Check privilege
00125         if ( $g_user->check_jrn($_REQUEST['p_jrn']) != 'W' )
00126         {
00127 
00128             NoAccess();
00129             exit -1;
00130         }
00131 
00132         $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
00133         try
00134         {
00135             $Ledger->verify($_POST);
00136         }
00137         catch (Exception $e)
00138         {
00139             alert($e->getMessage());
00140             $correct=1;
00141         }
00142 
00143         if ( ! isset($correct))
00144         {
00145             if ( is_msie() == 0 ) 
00146                 echo '<div style="position:absolute"  class="content">';
00147              else
00148                 echo '<div class="content">';
00149 
00150             $Ledger=new Acc_Ledger_Sold($cn,$_POST['p_jrn']);
00151             $internal=$Ledger->insert($_POST);
00152 
00153             /* Save the predefined operation */
00154             if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
00155             {
00156                 $opd=new Pre_op_ven($cn);
00157                 $opd->get_post();
00158                 $opd->save();
00159             }
00160 
00161             /* Show button  */
00162             echo '<h1 style="float:right;margin-right:20%"> Enregistrement </h1>';
00163 
00164             echo $Ledger->confirm($_POST,true);
00165             /* Show link for Invoice */
00166             if (isset ($Ledger->doc) )
00167             {
00168                 echo '<h2>Document </h2>';
00169                 echo $Ledger->doc;
00170             }
00171 
00172 
00173             /* Save the additional information into jrn_info */
00174             $obj=new Acc_Ledger_Info($cn);
00175             $obj->save_extra($Ledger->jr_id,$_POST);
00176 
00177             echo $Ledger->button_new_operation();
00178 
00179             echo '</div>';
00180             return;
00181         }
00182     }
00183     //  ------------------------------
00184     /* Display a blank form or a form with predef operation */
00185     //  ------------------------------
00186 
00187     $array=(isset($_POST['correct'])||isset ($correct))?$_POST:null;
00188     $Ledger=new Acc_Ledger_Sold($cn,0);
00189 //
00190 // pre defined operation
00191 //
00192 if ( is_msie() == 0 ) 
00193     echo '<div style="position:absolute"  class="content">';
00194 else
00195     echo '<div class="content">';
00196 
00197     if ( !isset($_REQUEST ['p_jrn']) )
00198     {
00199         $def_ledger=$Ledger->get_first('ven',2);
00200                 if (empty($def_ledger))
00201         {
00202                 exit('Pas de journal disponible');
00203         }
00204         $Ledger->id=$def_ledger['jrn_def_id'];
00205     }
00206     else
00207         $Ledger->id=$_REQUEST ['p_jrn'];
00208         if (isset ($_REQUEST['p_jrn_predef'])){
00209                 $Ledger->id=$_REQUEST['p_jrn_predef'];
00210         }
00211 
00212     echo '<div id="predef_form">';
00213     echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
00214     $op=new Pre_op_ven($cn);
00215     $op->set('ledger',$Ledger->id);
00216     $op->set('ledger_type',"VEN");
00217     $op->set('direct','f');
00218     $url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
00219     echo $op->form_get('do.php?'.$url);
00220     echo '</div>';
00221 
00222    echo '<div class="content">';
00223    echo '<p class="notice">'.$p_msg.'</p>';
00224  echo "<FORM class=\"print\" NAME=\"form_detail\" METHOD=\"POST\" >";
00225     /* request for a predefined operation */
00226     if (  isset($_REQUEST['pre_def']) && ! isset($_POST['correct']) )
00227     {
00228         // used a predefined operation
00229         //
00230         $op=new Pre_op_ven($cn);
00231         $op->set_od_id($_REQUEST['pre_def']);
00232         $p_post=$op->compute_array();
00233         $Ledger->id=$_REQUEST ['p_jrn_predef'];
00234 
00235         echo $Ledger->input($p_post);
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     else if ( isset ($_GET['create_invoice']))
00244     {
00245         $array=$Ledger->convert_from_follow($_GET ['ag_id']);
00246         echo HtmlInput::hidden("ledger_type","VEN");
00247         echo HtmlInput::hidden("ac",$_REQUEST['ac']);
00248         echo HtmlInput::hidden("sa","p");
00249         echo $Ledger->input($array);
00250         echo '<div class="content">';
00251         echo $Ledger->input_paid();
00252         echo '</div>';
00253         echo '<script>';
00254         echo 'compute_all_ledger();';
00255         echo '</script>';
00256     }
00257     else
00258     {
00259         echo HtmlInput::hidden("ledger_type","VEN");
00260           echo HtmlInput::hidden("ac",$_REQUEST['ac']);
00261         echo HtmlInput::hidden("sa","p");
00262         echo $Ledger->input($array);
00263         echo '<div class="content">';
00264         echo $Ledger->input_paid();
00265         echo '</div>';
00266         echo '<script>';
00267         echo 'compute_all_ledger();';
00268         echo '</script>';
00269     }
00270     echo '<div class="content">';
00271 
00272 
00273     echo HtmlInput::button('act',_('Actualiser'),'onClick="compute_all_ledger();"');
00274     echo HtmlInput::submit("view_invoice",_("Enregistrer"));
00275     echo HtmlInput::reset(_('Effacer '));
00276     echo '</div>';
00277     echo "</FORM>";
00278 
00279     /* if we suggest the pj n# the run the script */
00280     if ( $g_parameter->MY_PJ_SUGGEST=='Y')
00281     {
00282                 echo '<script> update_pj()</script>';
00283     }
00284         if (!isset($_POST['e_date']) && $g_parameter->MY_DATE_SUGGEST=='Y')
00285         {
00286                 echo create_script(" get_last_date()");
00287         }
00288 echo create_script(" update_name()");   
00289 return;
00290 ?>
 All Data Structures Namespaces Files Functions Variables Enumerations