';
//-----------------------------------------------------
// If print is asked
// First time in html
// after in pdf or cvs
//-----------------------------------------------------
if (isset($_REQUEST['bt_html']))
{
require_once("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 '';
if ($_GET['p_simple'] == 0 || $_GET['p_simple'] == 1)
{
echo ' | ";
echo ' | ";
echo ' | ";
}
echo '';
echo HtmlInput::print_window();
echo ' | ';
echo "
";
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 "| " . $op['j_date'] . " | ";
echo "" . $op['jr_pj_number'] . " | ";
if ($op['internal'] != '')
echo "" . HtmlInput::detail_op($op['jr_id'], $op['internal']) . " | ";
else
echo td();
echo "" . $op['poste'] . " | " .
"" . $op['description'] . " | " .
"" . nbm($op['deb_montant']) . " | " .
"" . nbm($op['cred_montant']) . " | " .
"
";
}// end loop
echo "
";
// 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)
{
// Simple printing
//---
echo '
';
echo "" .
"| operation " .
" | Date | " .
" n° de pièce | " .
"internal | " .
th('Tiers') .
"Commentaire | " .
"Total opération | " .
"
";
// set a filter for the FIN
$i = 0;
foreach ($Row as $line)
{
$i++;
$class = ($i % 2 == 0) ? ' class="even" ' : ' class="odd" ';
echo "";
echo "| " . $line['num'] . " | ";
echo "" . $line['date'] . " | ";
echo "" . h($line['jr_pj_number']) . " | ";
echo "" . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . " | ";
$tiers = $Jrn->get_tiers($line['jrn_def_type'], $line['jr_id']);
echo td($tiers);
echo "" . h($line['comment']) . " | ";
// echo "".$line['pj']." | ";
// 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 "";
echo ( $positive == 0 ) ? " - " . nbm($line['montant']) . "" : nbm($line['montant']);
echo " | ";
}
else
{
echo "" . nbm($line['montant']) . " | ";
}
echo "
";
}
echo "
";
}
/////////////////////////////////////////////////////////////////////////////////////
// Détaillé
/////////////////////////////////////////////////////////////////////////////////////
elseif ($_GET['p_simple'] == 2)
{
foreach ($Row as $line)
{
echo '
';
$class = ' class="odd" style="font-stretch: expanded;font-size:12px;"';
echo '
';
echo "";
echo '| ' . $line['date'] . " | ";
echo '' . h($line['jr_pj_number']) . " | ";
echo '' . HtmlInput::detail_op($line['jr_id'], $line['jr_internal']) . " | ";
$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 '' . h($ledger_name) . ' | ';
echo '' . h($tiers) . ' | ';
echo '' . h($line['comment']) . " | ";
echo '';
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
{
echo nbm($line['montant']) ;
}
echo " | ";
echo "
";
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 "