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
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
00036 $str_dossier = dossier::get();
00037 $ac = "ac=" . $_REQUEST['ac'];
00038
00039
00040 if (isset($_REQUEST['p_jrn']))
00041 if ($g_user->check_jrn($_REQUEST['p_jrn']) != 'W')
00042 {
00043 NoAccess();
00044 exit - 1;
00045 }
00046
00047
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 $correct = 1;
00059 }
00060
00061 if (!isset($correct))
00062 {
00063 echo '<div class="content">';
00064 echo h1('Confirmation','');
00065 echo_warning("Attention, cette opération n'est pas encore sauvée : vous devez encore confirmer");
00066
00067
00068 echo '<form enctype="multipart/form-data" method="post" class="print">';
00069 echo dossier::hidden();
00070
00071 echo $Ledger->confirm($_POST);
00072 echo HtmlInput::hidden('ac', $_REQUEST['ac']);
00073 echo '<div style="clear:both">';
00074
00075 echo Pre_operation::save_propose();
00076 echo '</div>';
00077 echo HtmlInput::submit("record", _("Enregistrement"), 'onClick="return verify_ca(\'\');"');
00078 echo HtmlInput::submit('correct', _("Corriger"));
00079 echo '</form>';
00080 echo '</div>';
00081 echo '</div>';
00082
00083 exit();
00084 }
00085 }
00086
00087
00088
00089
00090 if (isset($_POST['record']))
00091 {
00092 $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00093 try
00094 {
00095 $Ledger->verify($_POST);
00096 }
00097 catch (Exception $e)
00098 {
00099 alert($e->getMessage());
00100 $correct = 1;
00101 }
00102
00103 if (!isset($correct))
00104 {
00105 echo '<div class="content">';
00106
00107 $Ledger = new Acc_Ledger_Purchase($cn, $_POST['p_jrn']);
00108 $internal = $Ledger->insert($_POST);
00109
00110
00111
00112 if ( isset($_POST['opd_name']) && trim($_POST['opd_name']) != "" )
00113 {
00114 $opd = new Pre_op_ach($cn);
00115 $opd->get_post();
00116 $opd->save();
00117 }
00118
00119
00120 $jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($internal));
00121
00122 echo '<h1> Enregistrement </h1>';
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 $obj = new Acc_Ledger_Info($cn);
00133 $obj->save_extra($Ledger->jr_id, $_POST);
00134
00135
00136 echo $Ledger->confirm($_POST, true);
00137 if (isset($Ledger->doc))
00138 {
00139 echo '<h2>Document</h2>';
00140 echo $Ledger->doc;
00141 }
00142
00143 echo '</div>';
00144 exit();
00145 }
00146 }
00147
00148
00149
00150
00151
00152 echo '<div class="content">';
00153
00154
00155
00156 $array = (isset($_POST['correct']) || isset($correct)) ? $_POST : null;
00157 $Ledger = new Acc_Ledger_Purchase($cn, 0);
00158
00159
00160 if (!isset($_REQUEST ['p_jrn']))
00161 {
00162 $def_ledger = $Ledger->get_first('ach',2);
00163 if ( empty ($def_ledger))
00164 {
00165 exit('Pas de journal disponible');
00166 }
00167 $Ledger->id = $def_ledger['jrn_def_id'];
00168 }
00169 else
00170 $Ledger->id = $_REQUEST ['p_jrn'];
00171
00172 if (isset ($_REQUEST['p_jrn_predef'])){
00173 $Ledger->id=$_REQUEST['p_jrn_predef'];
00174 }
00175
00176
00177 echo '<div id="predef_form">';
00178 echo HtmlInput::hidden('p_jrn_predef', $Ledger->id);
00179 $op = new Pre_op_ach($cn);
00180 $op->set('ledger', $Ledger->id);
00181 $op->set('ledger_type', "ACH");
00182 $op->set('direct', 'f');
00183 $url=http_build_query(array('p_jrn_predef'=>$Ledger->id,'ac'=>$_REQUEST['ac'],'gDossier'=>dossier::id()));
00184 echo $op->form_get('do.php?'.$url);
00185 echo '</div>';
00186 echo '</div>';
00187
00188 echo '<div class="content">';
00189 echo "<FORM class=\"print\"NAME=\"form_detail\" METHOD=\"POST\" >";
00190
00191 if ( isset($_REQUEST['pre_def']) && !isset($_POST['correct']))
00192 {
00193
00194
00195 $op = new Pre_op_ach($cn);
00196 $op->set_od_id($_REQUEST['pre_def']);
00197 $p_post = $op->compute_array();
00198 $Ledger->id = $_REQUEST ['p_jrn_predef'];
00199 $p_post['p_jrn'] = $Ledger->id;
00200 echo $Ledger->input($p_post);
00201 echo '<div class="content">';
00202 echo $Ledger->input_paid();
00203 echo '</div>';
00204 echo '<script>';
00205 echo 'compute_all_ledger();';
00206 echo '</script>';
00207 }
00208 else
00209 {
00210 echo $Ledger->input($array);
00211 echo HtmlInput::hidden("p_action", "ach");
00212 echo HtmlInput::hidden("sa", "p");
00213 echo '<div class="content">';
00214 echo $Ledger->input_paid();
00215 echo '</div>';
00216 echo '<script>';
00217 echo 'compute_all_ledger();';
00218 echo '</script>';
00219 }
00220 echo '<div class="content">';
00221 echo HtmlInput::button('act', _('Actualiser'), 'onClick="compute_all_ledger();"');
00222 echo HtmlInput::submit("view_invoice", _("Enregistrer"));
00223 echo HtmlInput::reset(_('Effacer '));
00224 echo '</div>';
00225 echo "</FORM>";
00226
00227 if (!isset($_POST['e_date']) && $g_parameter->MY_DATE_SUGGEST=='Y')
00228 echo create_script(" get_last_date()");
00229 echo create_script(" update_name()");
00230 echo '</div>';
00231
00232
00233 exit();
00234
00235 ?>