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 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
00025 require_once("class_ihidden.php");
00026 require_once("class_iselect.php");
00027 require_once("class_icheckbox.php");
00028 require_once('class_exercice.php');
00029 require_once('class_dossier.php');
00030 load_all_script();
00031 $gDossier = dossier::id();
00032 global $g_user;
00033
00034
00035
00036 require_once('class_database.php');
00037
00038 if ($g_user->Admin() == 0 && $g_user->is_local_admin() == 0)
00039 {
00040 $sql = "select jrn_def_id,jrn_def_name
00041 from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00042 join user_sec_jrn on uj_jrn_id=jrn_def_id
00043 where
00044 uj_login='$g_user->login'
00045 and uj_priv in ('R','W')
00046 order by jrn_def_name
00047 ";
00048 $ret = $cn->make_array($sql);
00049 }
00050 else
00051 {
00052 $ret = $cn->make_array("select jrn_def_id,jrn_def_name
00053 from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00054 order by jrn_def_name
00055 ");
00056 }
00057
00058 $NoPriv = $cn->count_sql("select jrn_def_id,jrn_def_name,jrn_def_class_deb,jrn_def_class_cred,jrn_type_id,jrn_desc,uj_priv,
00059 jrn_deb_max_line,jrn_cred_max_line
00060 from jrn_def join jrn_type on jrn_def_type=jrn_type_id
00061 join user_sec_jrn on uj_jrn_id=jrn_def_id
00062 where
00063 uj_login='$g_user->id'
00064 and uj_priv ='X'
00065 ");
00066
00067
00068
00069 $a = count($ret);
00070 $all = array('value' => 0, 'label' => 'Tous les journaux disponibles');
00071 $ret[$a] = $all;
00072 if (count($ret) < 1)
00073 NoAccess();
00074 $exercice = (isset($_GET['exercice'])) ? $_GET['exercice'] : $g_user->get_exercice();
00075
00076
00077
00078
00079 echo '<div class="content">';
00080
00081
00082
00083 echo '<form method="GET">';
00084 echo '<fieldset><legend>' . _('Choississez un autre exercice') . '</legend>';
00085 ;
00086 echo 'Choississez un autre exercice :';
00087 $ex = new Exercice($cn);
00088 $wex = $ex->select('exercice', $exercice, ' onchange="submit(this)"');
00089 echo $wex->input();
00090 echo dossier::hidden();
00091 echo HtmlInput::get_to_hidden(array('ac', 'type'));
00092 echo '</fieldset>';
00093 echo '</form>';
00094 ?>
00095 <?php
00096
00097
00098 echo '<FORM METHOD="GET">' . dossier::hidden();
00099 echo HtmlInput::get_to_hidden(array('ac', 'type'));
00100 echo HtmlInput::hidden('type', 'jrn');
00101 echo HtmlInput::get_to_hidden(array('exercice'));
00102 echo '<TABLE ><TR>';
00103 $w = new ISelect();
00104 $w->table = 1;
00105 $label = "Choississez le journal";
00106 $w->selected = (isset($_GET['jrn_id'])) ? $_GET['jrn_id'] : '';
00107 print td($label) . $w->input("jrn_id", $ret);
00108 print '</TR>';
00109 print '<TR>';
00110
00111 $filter_year = " where p_exercice='" . sql_string($exercice) . "'";
00112
00113 $periode_start = $cn->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
00114 $w->selected = (isset($_GET['from_periode'])) ? $_GET['from_periode'] : '';
00115 print td('Depuis') . $w->input('from_periode', $periode_start);
00116 print '</TR>';
00117 print '<TR>';
00118
00119 $periode_end = $cn->make_array("select p_id,to_char(p_end,'DD-MM-YYYY') from parm_periode $filter_year order by p_start,p_end");
00120 $w->selected = (isset($_GET['to_periode'])) ? $_GET['to_periode'] : '';
00121 print td('Jusque ') . $w->input('to_periode', $periode_end);
00122 print "</TR><TR>";
00123 $a = array(
00124 array('value' => 0, 'label' => 'Ecriture comptable'),
00125 array('value' => 1, 'label' => 'Liste opérations'),
00126 array('value' => 2, 'label' => 'Avec Détails opérations ')
00127 );
00128 $w->selected = 1;
00129 print '</TR>';
00130 print '<TR>';
00131 $w->selected = (isset($_GET['p_simple'])) ? $_GET['p_simple'] : '';
00132 echo '<td>Style d\'impression '.HtmlInput::infobulle(32).'</td>' . $w->input('p_simple', $a);
00133 print "</TR>";
00134 echo '</TABLE>';
00135 print HtmlInput::submit('bt_html', 'Visualisation');
00136
00137 echo '</FORM>';
00138
00139
00140
00141
00142
00143
00144
00145
00146 if (isset($_REQUEST['bt_html']))
00147 {
00148 require_once("class_acc_ledger.php");
00149
00150 $d = var_export($_GET, true);
00151 $Jrn = new Acc_Ledger($cn, $_GET['jrn_id']);
00152 $Jrn->get_name();
00153 switch ($_GET['p_simple'])
00154 {
00155 case "0":
00156 $Row = $Jrn->get_row($_GET['from_periode'], $_GET['to_periode']);
00157 break;
00158 case "1":
00159 $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']);
00160 break;
00161 case "2":
00162 $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']);
00163 break;
00164 default:
00165 var_dump($_GET['p_simple']);
00166 die(__FILE__ . ":" . __LINE__ . " error unknown style ");
00167 }
00168 $rep = "";
00169 $hid = new IHidden();
00170 echo '<div class="content">';
00171 echo '<h2 class="info">' . h($Jrn->name) . '</h2>';
00172 echo "<table>";
00173 echo '<TR>';
00174 echo '<TD><form method="GET" ACTION="?">' . dossier::hidden() .
00175 $hid->input("type", "jrn") . $hid->input('p_action', 'impress') . "</form></TD>";
00176
00177 echo '<TD><form method="GET" ACTION="export.php">' . dossier::hidden() .
00178 HtmlInput::submit('bt_pdf', "Export PDF") .
00179 HtmlInput::hidden('act', 'PDF:ledger') .
00180 $hid->input("type", "jrn") .
00181 $hid->input("jrn_id", $Jrn->id) .
00182 $hid->input("from_periode", $_GET['from_periode']) .
00183 $hid->input("to_periode", $_GET['to_periode']);
00184 echo $hid->input("p_simple", $_GET['p_simple']);
00185 echo HtmlInput::get_to_hidden(array('ac', 'type'));
00186 echo "</form></TD>";
00187
00188 echo '<TD><form method="GET" ACTION="export.php">' . dossier::hidden() .
00189 HtmlInput::submit('bt_csv', "Export CSV") .
00190 HtmlInput::hidden('act', 'CSV:ledger') .
00191 $hid->input("type", "jrn") .
00192 $hid->input("jrn_id", $Jrn->id) .
00193 $hid->input("from_periode", $_GET['from_periode']) .
00194 $hid->input("to_periode", $_GET['to_periode']);
00195 echo $hid->input("p_simple", $_GET['p_simple']);
00196 echo HtmlInput::get_to_hidden(array('ac', 'type'));
00197 echo "</form></TD>";
00198
00199 echo '<td style="vertical-align:top">';
00200 echo HtmlInput::print_window();
00201 echo '</td>';
00202 echo "</TR>";
00203
00204 echo "</table>";
00205 if (count($Jrn->row) == 0
00206 && $Row == null)
00207 exit;
00208
00209
00210
00211
00212
00213 if ($_GET['p_simple'] == 0)
00214 {
00215 echo '<TABLE class="result">';
00216
00217
00218 foreach ($Jrn->row as $op)
00219 {
00220 $class = "";
00221 if ($op['j_date'] != '')
00222 {
00223 $class = "odd";
00224 }
00225
00226 echo "<TR class=\"$class\">";
00227
00228 echo "<TD>" . $op['j_date'] . "</TD>";
00229 echo "<TD >" . $op['jr_pj_number'] . "</TD>";
00230
00231
00232 if ($op['internal'] != '')
00233 echo "<TD>" . HtmlInput::detail_op($op['jr_id'], $op['internal']) . "</TD>";
00234 else
00235 echo td();
00236
00237 echo "<TD >" . $op['poste'] . "</TD>" .
00238 "<TD >" . $op['description'] . "</TD>" .
00239 "<TD style=\"text-align:right\">" . nbm($op['deb_montant']) . "</TD>" .
00240 "<TD style=\"text-align:right\">" . nbm($op['cred_montant']) . "</TD>" .
00241 "</TR>";
00242 }
00243 echo "</table>";
00244
00245
00246 $solde = $Jrn->get_solde($_GET['from_periode'], $_GET['to_periode']);
00247 echo "solde débiteur:" . $solde[0] . "<br>";
00248 echo "solde créditeur:" . $solde[1];
00249 }
00250
00251
00252
00253 elseif ($_GET['p_simple'] == 1)
00254 {
00255 if ( $Jrn->get_type() != 'ACH' && $Jrn->get_type() != 'VEN')
00256 {
00257
00258
00259 echo '<TABLE class="result">';
00260 echo "<TR>" .
00261 "<th> operation </td>" .
00262 "<th>Date</th>" .
00263 "<th> n° de pièce </th>" .
00264 "<th>internal</th>" .
00265 th('Tiers') .
00266 "<th>Commentaire</th>" .
00267 "<th>Total opération</th>" .
00268 "</TR>";
00269
00270 $i = 0;
00271 foreach ($Row as $line)
00272 {
00273 $i++;
00274 $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" ';
00275 echo "<tr $class>";
00276 echo "<TD>" . $line['num'] . "</TD>";
00277 echo "<TD>" . $line['date'] . "</TD>";
00278 echo "<TD>" . h($line['jr_pj_number']) . "</TD>";
00279 echo "<TD>" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "</TD>";
00280 $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']);
00281 echo td($tiers);
00282 echo "<TD>" . h($line['comment']) . "</TD>";
00283
00284
00285
00286
00287
00288
00289 if ($line['jrn_def_type'] == 'FIN')
00290 {
00291 $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id']));
00292 if ($cn->count() == 0)
00293 $positive = 1;
00294 else
00295 $positive = ($positive > 0) ? 1 : 0;
00296
00297 echo "<TD align=\"right\">";
00298 echo ( $positive == 0 ) ? "<font color=\"red\"> - " . nbm($line['montant']) . "</font>" : nbm($line['montant']);
00299 echo "</TD>";
00300 }
00301 else
00302 {
00303 echo "<TD align=\"right\">" . nbm($line['montant']) . "</TD>";
00304 }
00305
00306 echo "</tr>";
00307 }
00308 echo "</table>";
00309 } else {
00310
00311
00312
00313 $own=new Own($cn);
00314 require_once 'template/print_ledger_simple.php';
00315
00316 }
00317 }
00318
00319
00320
00321 elseif ($_GET['p_simple'] == 2)
00322 {
00323 foreach ($Row as $line)
00324 {
00325 echo '<div style="margin-top:2px;margin-bottom:10px;border:solid 1px black">';
00326 $class = ' class="odd" style="font-stretch: expanded;font-size:1em;"';
00327 echo '<table class="result" style="font-weight: bolder;font-variant: small-caps;width:100%;">';
00328 echo "<tr $class>";
00329 echo '<TD style="width:5%">' . $line['date'] . "</TD>";
00330 echo '<TD style="width:10%">' . h($line['jr_pj_number']) . "</TD>";
00331 echo '<TD style="width:5%">' . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "</TD>";
00332 $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']);
00333 $ledger_name = $cn->get_value("select jrn_def_name from jrn_def where jrn_def_id=$1", array($line['jr_def_id']));
00334 echo '<TD style="width:20%">' . h($ledger_name) . ' </td>';
00335 echo '<TD style="width:20%">' . h($tiers) . ' </td>';
00336 echo '<TD style="width:30%">' . h($line['comment']) . "</TD>";
00337 echo '<TD style="text-align:right">';
00338 if ($line['jrn_def_type'] == 'FIN')
00339 {
00340 $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id']));
00341 if ($cn->count() == 0)
00342 $positive = 1;
00343 else
00344 $positive = ($positive > 0) ? 1 : 0;
00345
00346 echo ( $positive == 0 ) ? "<font color=\"red\"> - " . nbm($line['montant']) . "</font>" : nbm($line['montant']);
00347 }
00348 else
00349 {
00350 if ( isset ($line['TVAC'])) {
00351 echo ( nbm($line['TVAC']) < 0 ) ? "<font color=\"red\"> - " . nbm($line['TVAC']) . "</font>" : nbm($line['TVAC']);
00352 } else
00353 {
00354 echo nbm($line['montant']) ;
00355 }
00356 }
00357 echo "</TD>";
00358 echo "</tr>";
00359 echo '</table>';
00360
00361
00362
00363 $op = new Acc_Operation($cn);
00364 $op->jr_id = $line['jr_id'];
00365 $op->get();
00366 $obj = $op->get_quant();
00367 switch ($obj->signature)
00368 {
00369 case 'FIN':
00370 require 'template/operation_detail_fin.php';
00371 break;
00372 case 'ACH':
00373 require 'template/operation_detail_ach.php';
00374 break;
00375 case 'VEN':
00376 require 'template/operation_detail_ven.php';
00377 break;
00378 case 'ODS':
00379 require 'template/operation_detail_misc.php';
00380 break;
00381 default:
00382 die("unknown type of ledger");
00383 break;
00384 }
00385 echo '</div>';
00386
00387 }
00388 }
00389
00390 echo "</div>";
00391 exit;
00392 }
00393
00394 echo '</div>';
00395 ?>