Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00026 require_once ('class_acc_ledger_fin.php');
00027 require_once('class_ipopup.php');
00028 global $g_user,$g_parameter;
00029
00030 $gDossier=dossier::id();
00031
00032
00033 $cn=new Database(dossier::id());
00034 $menu_action="?ledger_type=fin&ac=".$_REQUEST['ac']."&".dossier::get();
00035
00036 $Ledger=new Acc_Ledger_Fin($cn,0);
00037
00038
00039
00040
00041
00042 if ( isset($_REQUEST['p_jrn']))
00043 $Ledger->id=$_REQUEST['p_jrn'];
00044 else
00045 {
00046 $def_ledger=$Ledger->get_first('fin');
00047 if ( empty ($def_ledger))
00048 {
00049 exit('Pas de journal disponible');
00050 }
00051 $Ledger->id=$def_ledger['jrn_def_id'];
00052 }
00053 $jrn_priv=$g_user->get_ledger_access($Ledger->id);
00054
00055 if ( isset($_REQUEST['p_jrn']) && ( $jrn_priv == 'X'))
00056 {
00057 NoAccess();
00058 exit -1;
00059 }
00060
00061
00062
00063
00064 if ( isset($_POST['save']))
00065 {
00066 try
00067 {
00068 $Ledger->verify($_POST);
00069 }
00070 catch (Exception $e)
00071 {
00072 alert($e->getMessage());
00073 $correct=1;
00074 }
00075 if ( ! isset ($correct ))
00076 {
00077 echo '<div class="content">';
00078 echo h1('Confirmation','');
00079 echo_warning("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer");
00080 echo '<form name="form_detail" class="print" enctype="multipart/form-data" class="print" METHOD="POST">';
00081 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00082 echo $Ledger->confirm($_POST);
00083 echo HtmlInput::submit('confirm',_('Confirmer'));
00084 echo HtmlInput::submit('correct',_('Corriger'));
00085
00086 echo '</form>';
00087 echo '</div>';
00088 exit();
00089 }
00090 }
00091
00092
00093
00094
00095 if ( isset($_POST['confirm']))
00096 {
00097 try
00098 {
00099 $Ledger->verify($_POST);
00100 }
00101 catch (Exception $e)
00102 {
00103 alert($e->getMessage());
00104 $correct=1;
00105 }
00106 if ( !isset($correct))
00107 {
00108 echo '<div id="jrn_name_div">';
00109 echo '<h2 id="jrn_name" style="display:inline">' . $Ledger->get_name() . '</h2>';
00110 echo '</div>';
00111
00112 echo '<div class="content">';
00113 $a= $Ledger->insert($_POST);
00114 echo '<h1>'._('Enregistrement').' </h1>';
00115 echo '<div class="content">';
00116 echo $a;
00117 echo '</div>';
00118 echo '</div>';
00119 exit();
00120 }
00121 }
00122
00123
00124
00125 if ( isset($_POST['correct']))
00126 {
00127 $correct=1;
00128 }
00129
00130
00131
00132 echo '<div class="content">';
00133
00134
00135 echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
00136 echo HtmlInput::hidden('ledger_type','fin');
00137 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00138 $array=( isset($correct))?$_POST:null;
00139
00140
00141 echo $Ledger->input($array);
00142 echo HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_fin_add_row()"');
00143 echo HtmlInput::submit('save',_('Sauve'));
00144 echo HtmlInput::reset(_('Effacer'));
00145
00146 if ( ! isset ($_POST['e_date'])&& $g_parameter->MY_DATE_SUGGEST=='Y')
00147 {
00148 echo create_script(" get_last_date();ajax_saldo('first_sold');");
00149 }else {
00150 echo create_script(" ajax_saldo('first_sold');");
00151 }
00152 echo create_script(" update_name()");
00153 exit();