Admin() == 0 && $g_user->is_local_admin() == 0) { $sql = "select jrn_def_id,jrn_def_name from jrn_def join jrn_type on jrn_def_type=jrn_type_id join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='$g_user->login' and uj_priv in ('R','W') order by jrn_def_name "; $ret = $cn->make_array($sql); } else { $ret = $cn->make_array("select jrn_def_id,jrn_def_name from jrn_def join jrn_type on jrn_def_type=jrn_type_id order by jrn_def_name "); } // Count the forbidden journaux $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, jrn_deb_max_line,jrn_cred_max_line from jrn_def join jrn_type on jrn_def_type=jrn_type_id join user_sec_jrn on uj_jrn_id=jrn_def_id where uj_login='$g_user->id' and uj_priv ='X' "); /* * Show all the available ledgers */ $a = count($ret); $all = array('value' => 0, 'label' => 'Tous les journaux disponibles'); $ret[$a] = $all; if (count($ret) < 1) NoAccess(); $exercice = (isset($_GET['exercice'])) ? $_GET['exercice'] : $g_user->get_exercice(); //----------------------------------------------------- // Form //----------------------------------------------------- echo '
'; /* * Let you change the exercice */ echo '
'; echo '
' . _('Exercice') . ''; ; echo _('Choisissez un autre exercice').' :'; $ex = new Exercice($cn); $wex = $ex->select('exercice', $exercice, ' onchange="submit(this)"'); echo $wex->input(); echo dossier::hidden(); echo HtmlInput::get_to_hidden(array('ac', 'type')); echo '
'; echo '
'; ?> ' . dossier::hidden(); echo HtmlInput::get_to_hidden(array('ac', 'type')); echo HtmlInput::hidden('type', 'jrn'); echo HtmlInput::get_to_hidden(array('exercice')); echo ''; $w = new ISelect(); $w->table = 1; $label = "Choisissez le journal"; $w->selected = (isset($_GET['jrn_id'])) ? $_GET['jrn_id'] : ''; print td($label) . $w->input("jrn_id", $ret); print ''; print ''; // filter on the current year $filter_year = " where p_exercice='" . sql_string($exercice) . "'"; $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"); $w->selected = (isset($_GET['from_periode'])) ? $_GET['from_periode'] : ''; print td('Depuis') . $w->input('from_periode', $periode_start); print ''; print ''; $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"); $w->selected = (isset($_GET['to_periode'])) ? $_GET['to_periode'] : ''; print td('Jusque ') . $w->input('to_periode', $periode_end); print ""; $a = array( array('value' => 0, 'label' => 'Ecriture comptable'), array('value' => 1, 'label' => 'Liste opérations'), array('value' => 2, 'label' => 'Avec Détails opérations ') ); $w->selected = 1; print ''; print ''; $w->selected = (isset($_GET['p_simple'])) ? $_GET['p_simple'] : ''; echo '' . $w->input('p_simple', $a); print ""; echo '
Style d\'impression '.HtmlInput::infobulle(32).'
'; print HtmlInput::submit('bt_html', 'Visualisation'); echo ''; echo '
'; //----------------------------------------------------- // If print is asked // First time in html // after in pdf or cvs //----------------------------------------------------- if (isset($_REQUEST['bt_html'])) { require_once NOALYSS_INCLUDE.'/class_acc_ledger.php'; $d = var_export($_GET, true); $Jrn = new Acc_Ledger($cn, $_GET['jrn_id']); $Jrn->get_name(); switch ($_GET['p_simple']) { case "0": $Row = $Jrn->get_row($_GET['from_periode'], $_GET['to_periode']); break; case "1": $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']); break; case "2": $Row = $Jrn->get_rowSimple($_GET['from_periode'], $_GET['to_periode']); break; default: var_dump($_GET['p_simple']); die(__FILE__ . ":" . __LINE__ . " error unknown style "); } $rep = ""; $hid = new IHidden(); echo '
'; echo '

' . h($Jrn->name) . '

'; echo ""; echo ''; echo '"; echo '"; echo '"; echo ''; echo ""; echo "
' . dossier::hidden() . $hid->input("type", "jrn") . $hid->input('p_action', 'impress') . "
' . dossier::hidden() . HtmlInput::submit('bt_pdf', "Export PDF") . HtmlInput::hidden('act', 'PDF:ledger') . $hid->input("type", "jrn") . $hid->input("jrn_id", $Jrn->id) . $hid->input("from_periode", $_GET['from_periode']) . $hid->input("to_periode", $_GET['to_periode']); echo $hid->input("p_simple", $_GET['p_simple']); echo HtmlInput::get_to_hidden(array('ac', 'type')); echo "
' . dossier::hidden() . HtmlInput::submit('bt_csv', "Export CSV") . HtmlInput::hidden('act', 'CSV:ledger') . $hid->input("type", "jrn") . $hid->input("jrn_id", $Jrn->id) . $hid->input("from_periode", $_GET['from_periode']) . $hid->input("to_periode", $_GET['to_periode']); echo $hid->input("p_simple", $_GET['p_simple']); echo HtmlInput::get_to_hidden(array('ac', 'type')); echo "
'; echo HtmlInput::print_window(); echo '
"; if (count($Jrn->row) == 0 && $Row == null) exit; ///////////////////////////////////////////////////////////////////////////////////// // Ecriture comptable ///////////////////////////////////////////////////////////////////////////////////// if ($_GET['p_simple'] == 0) { echo ''; // detailled printing //--- foreach ($Jrn->row as $op) { $class = ""; if ($op['j_date'] != '') { $class = "odd"; } echo ""; echo ""; echo ""; if ($op['internal'] != '') echo ""; else echo td(); echo "" . "" . "" . "" . ""; }// end loop echo "
" . $op['j_date'] . "" . $op['jr_pj_number'] . "" . HtmlInput::detail_op($op['jr_id'], $op['internal']) . "" . $op['poste'] . "" . $op['description'] . "" . nbm($op['deb_montant']) . "" . nbm($op['cred_montant']) . "
"; // show the saldo $solde = $Jrn->get_solde($_GET['from_periode'], $_GET['to_periode']); echo "solde débiteur:" . $solde[0] . "
"; echo "solde créditeur:" . $solde[1]; } // if ///////////////////////////////////////////////////////////////////////////////////// // Liste opérations ///////////////////////////////////////////////////////////////////////////////////// elseif ($_GET['p_simple'] == 1) { if ( $Jrn->get_type() != 'ACH' && $Jrn->get_type() != 'VEN') { // Simple printing //--- echo ''; echo "" . "" . "" . "" . th('Tiers') . "" . "" . ""; // set a filter for the FIN $i = 0;$tot_amount=0; bcscale(2); foreach ($Row as $line) { $i++; $class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" '; echo ""; echo ""; echo ""; echo ""; echo ""; $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']); echo td($tiers); echo ""; // echo ""; // If the ledger is financial : // the credit must be negative and written in red // Get the jrn type if ($line['jrn_def_type'] == 'FIN') { $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id'])); if ($cn->count() == 0) $positive = 1; else $positive = ($positive > 0) ? 1 : 0; echo ""; if ( $positive == 1 ) { $tot_amount=bcadd($tot_amount,$line['montant']); } else { $tot_amount=bcsub($tot_amount,$line['montant']); } } else { echo ""; $tot_amount=bcadd($tot_amount,$line['montant']); } echo ""; } echo ''; echo ''; echo td().td().td().td().td(); echo ''; echo ''; echo "
operation " . "Date n° de pièce internalCommentaireTotal opération
" . $line['num'] . "" . $line['date'] . "" . h($line['jr_pj_number']) . "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "" . h($line['comment']) . "".$line['pj'].""; echo ( $positive == 0 ) ? " - " . nbm($line['montant']) . "" : nbm($line['montant']); echo "" . nbm($line['montant']) . "
'._('Totaux').''.nbm($tot_amount).'
"; } else { /* * Ledger ACH or VEN */ $own=new Own($cn); require_once NOALYSS_INCLUDE.'/template/print_ledger_simple.php'; } } ///////////////////////////////////////////////////////////////////////////////////// // Détaillé ///////////////////////////////////////////////////////////////////////////////////// elseif ($_GET['p_simple'] == 2) { foreach ($Row as $line) { echo '
'; $class = ' class="odd" style="font-stretch: expanded;font-size:1em;"'; echo ''; echo ""; echo '"; echo '"; echo '"; $tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']); $ledger_name = $cn->get_value("select jrn_def_name from jrn_def where jrn_def_id=$1", array($line['jr_def_id'])); echo ''; echo ''; echo '"; echo '"; echo ""; echo '
' . $line['date'] . "' . h($line['jr_pj_number']) . "' . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . "' . h($ledger_name) . ' ' . h($tiers) . ' ' . h($line['comment']) . "'; if ($line['jrn_def_type'] == 'FIN') { $positive = $cn->get_value("select qf_amount from quant_fin where jr_id=$1", array($line['jr_id'])); if ($cn->count() == 0) $positive = 1; else $positive = ($positive > 0) ? 1 : 0; echo ( $positive == 0 ) ? " - " . nbm($line['montant']) . "" : nbm($line['montant']); } else { if ( isset ($line['TVAC'])) { echo ( nbm($line['TVAC']) < 0 ) ? " - " . nbm($line['TVAC']) . "" : nbm($line['TVAC']); } else { echo nbm($line['montant']) ; } } echo "
'; ////////////////////////////////////////////////////////////////////////////////////////////////////// // Add detail for each operation ////////////////////////////////////////////////////////////////////////////////////////////////////// $op = new Acc_Operation($cn); $op->jr_id = $line['jr_id']; $op->get(); $obj = $op->get_quant(); switch ($obj->signature) { case 'FIN': require 'template/operation_detail_fin.php'; break; case 'ACH': require 'template/operation_detail_ach.php'; break; case 'VEN': require 'template/operation_detail_ven.php'; break; case 'ODS': require 'template/operation_detail_misc.php'; break; default: die("unknown type of ledger"); break; } echo '
'; //echo '
'; } // end loop } echo "
"; exit; } echo '
'; ?>