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 $p_msg="";
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 $p_msg=$e->getMessage();
00074 $correct=1;
00075 }
00076 if ( ! isset ($correct ))
00077 {
00078 echo '<div class="content">';
00079 echo h1(_('Confirmation'),'');
00080 echo_warning(_("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer"));
00081 echo '<form name="form_detail" class="print" enctype="multipart/form-data" class="print" METHOD="POST">';
00082 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00083 echo $Ledger->confirm($_POST);
00084 echo HtmlInput::submit('confirm',_('Confirmer'));
00085 echo HtmlInput::submit('correct',_('Corriger'));
00086
00087 echo '</form>';
00088 echo '</div>';
00089 return;
00090 }
00091 }
00092
00093
00094
00095
00096 if ( isset($_POST['confirm']))
00097 {
00098 try
00099 {
00100 $Ledger->verify($_POST);
00101 }
00102 catch (Exception $e)
00103 {
00104 alert($e->getMessage());
00105 $p_msg=$e->getMessage();
00106 $correct=1;
00107 }
00108 if ( !isset($correct))
00109 {
00110 echo '<div id="jrn_name_div">';
00111 echo '<h2 id="jrn_name" style="display:inline">' . $Ledger->get_name() . '</h2>';
00112 echo '</div>';
00113
00114 echo '<div class="content">';
00115 $a= $Ledger->insert($_POST);
00116 echo '<h1>'._('Enregistrement').' </h1>';
00117 echo '<div class="content">';
00118 echo $a;
00119 echo '</div>';
00120
00121 echo '</div>';
00122 echo $Ledger->button_new_operation();
00123 return;
00124 }
00125 }
00126
00127
00128
00129 if ( isset($_POST['correct']))
00130 {
00131 $correct=1;
00132 }
00133
00134
00135
00136 echo '<div style="position:absolute" class="content">';
00137
00138 echo '<p class="notice">'.$p_msg.'</p>';
00139
00140 echo '<form class="print" name="form_detail" enctype="multipart/form-data" class="print" METHOD="POST">';
00141 echo HtmlInput::hidden('ledger_type','fin');
00142 echo HtmlInput::hidden('ac',$_REQUEST['ac']);
00143 $array=( isset($correct))?$_POST:null;
00144
00145
00146 echo $Ledger->input($array);
00147 echo HtmlInput::button('add_item',_('Ajout article'), ' onClick="ledger_fin_add_row()"');
00148 echo HtmlInput::submit('save',_('Sauve'));
00149 echo HtmlInput::reset(_('Effacer'));
00150
00151 if ( ! isset ($_POST['e_date'])&& $g_parameter->MY_DATE_SUGGEST=='Y')
00152 {
00153 echo create_script(" get_last_date();ajax_saldo('first_sold');");
00154 }else {
00155 echo create_script(" ajax_saldo('first_sold');");
00156 }
00157 echo create_script(" update_name()");
00158 return;