if (sizeof($a_poste) == 0) { die("Nothing here. Strange."); exit; } if (isDate($_REQUEST['from_periode']) == null || isDate($_REQUEST['to_periode']) == null) { echo alert('Date malformée, désolée'); return; } echo '<div class="content">'; echo '<table class="result">'; $l = isset($_REQUEST['letter']) ? 2 : 0; $s = isset($_REQUEST['solded']) ? 1 : 0; foreach ($a_poste as $poste_id) { $Poste = new Acc_Account_Ledger($cn, $poste_id['pcm_val']); $Poste->load(); $Poste->get_row_date($_GET['from_periode'], $_GET['to_periode'], $l, $s); if (empty($Poste->row)) { continue; } echo '<tr > <td colspan="8" style="width:auto"> <h2 class="info">' . $poste_id['pcm_val'] . ' ' . h($Poste->label) . '</h2> </td> </tr>'; echo '<tr> <td>Date</td> <td>Référence</td> <td>Libellé</td> <td>Pièce</td> <td align="right">Débit</td> <td align="right">Crédit</td>
foreach ($a_poste as $poste_id) { $Poste = new Acc_Account_Ledger($cn, $poste_id['pcm_val']); $Poste->HtmlTable(null, $_GET['ople']); } echo Acc_Account_Ledger::HtmlTableHeader(); echo "</div>"; } else { //---------------------------------------------------------------------- // Detail //---------------------------------------------------------------------- echo Acc_Account_Ledger::HtmlTableHeader(); echo '<table style="width:100%;margin-left:0%">'; foreach ($a_poste as $poste_id) { $Poste = new Acc_Account_Ledger($cn, $poste_id['pcm_val']); $Poste->load(); $Poste->get_row_date($_GET['from_periode'], $_GET['to_periode'], $_GET['ople']); if (empty($Poste->row)) { continue; } echo '<tr><td class="mtitle" style="width:auto" colspan="6"><h2 class="title">' . $poste_id['pcm_val'] . ' ' . h($Poste->label) . '</h2></td></tr>'; $detail = $Poste->row[0]; $old = array(); foreach ($Poste->row as $detail) { /* avoid duplicates */ if (in_array($detail['jr_id'], $old) == TRUE) { continue; } $old[] = $detail['jr_id']; echo tr(td("Journal :" . $detail['jrn_def_name'], ''), 'style="width:auto" colspan="6"'); echo '<tr><td class="mtitle" style="width:auto" colspan="6">' . $detail['j_date'] . ' ' . $detail['jr_internal'] . ' ' . hb($detail['description']) . ' ' . hi($detail['jr_pj_number']) . '</td></tr>'; $op = new Acc_Operation($cn);
} $sql = $sql . $cond_poste . ' order by pcm_val::text'; $a_poste = $cn->get_array($sql); } if (count($a_poste) == 0) { echo 'Rien à rapporter.'; printf("\n"); exit; } // Header $header = array("Date", "Référence", "Libellé", "Pièce", "Lettrage", "Débit", "Crédit", "Solde"); $l = isset($_GET['letter']) ? 2 : 0; $s = isset($_REQUEST['solded']) ? 1 : 0; foreach ($a_poste as $poste) { $Poste = new Acc_Account_Ledger($cn, $poste['pcm_val']); $array1 = $Poste->get_row_date($from_periode, $to_periode, $l, $s); // don't print empty account if (count($array1) == 0) { continue; } $array = $array1[0]; $tot_deb = $array1[1]; $tot_cred = $array1[2]; // don't print empty account if (count($array) == 0) { continue; } echo sprintf("%s - %s ", $Poste->id, $Poste->get_name()); printf("\n"); for ($i = 0; $i < count($header); $i++) { echo $header[$i] . ";";
echo '"' . $pos['pcm_val'] . '";' . '"' . $op['jr_pj_number'] . '"' . ";" . '"' . $op['jrn_def_code'] . '"' . ";" . '"' . $op['jrn_def_name'] . '"' . ";" . '"' . $name . '";' . '"' . $op['jr_internal'] . '"' . ";" . '"' . $op['j_date_fmt'] . '"' . ";" . '"' . $op['description'] . '";' . nb($op['deb_montant']) . ";" . nb($op['cred_montant']) . ";" . nb(abs($prog)) . ";" . ($op['letter'] != -1 ? strtoupper(base_convert($op['letter'], 10, 36)) : ""); printf("\n"); } $solde_type = $tot_deb > $tot_cred ? "solde débiteur" : "solde créditeur"; $diff = abs($tot_deb - $tot_cred); printf(";;;" . '"' . _('total') . '";' . '"' . $current_exercice . '";' . '"' . "{$solde_type}" . '"' . ";" . nb($tot_deb) . ";" . nb($tot_cred) . ";" . nb($diff) . ";" . "\n"); } } else { /* detail of all operation */ if (count($a_poste) == 0) { exit; } foreach ($a_poste as $pos) { $Poste = new Acc_Account_Ledger($cn, $pos['pcm_val']); $Poste->get_name(); list($array, $tot_deb, $tot_cred) = $Poste->get_row_date($_REQUEST['from_periode'], $_REQUEST['to_periode'], $_GET['ople']); if (count($Poste->row) == 0) { continue; } echo '"Poste";' . '"Lib.";' . '"QuickCode";' . "\"Code interne\";" . "\"Date\";" . "\"Description\";" . "\"Montant\";" . "\"D/C\""; printf("\n"); foreach ($Poste->row as $a) { $op = new Acc_Operation($cn); $op->jr_id = $a['jr_id']; $result = $op->get_jrnx_detail(); foreach ($result as $r) { printf('"%s";"%s";"%s";"%s";"%s";"%s";"%s";%12.2f;"%s"', $r['j_poste'], $r['pcm_lib'], $r['j_qcode'], $r['jr_internal'], $r['jr_date'], $a['description'], $a['jr_pj_number'], nb($r['j_montant']), $r['debit']); printf("\r\n"); } } }
$ret = ""; $pdf = new PDF($cn); $pdf->setDossierInfo(" Periode : " . $_GET['from_periode'] . " - " . $_GET['to_periode']); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetAuthor('NOALYSS'); $pdf->setTitle("Détail poste comptable", true); if (count($a_poste) == 0) { $pdf->Output('poste.pdf', 'D'); exit; } $size = array(13, 25, 13, 65, 12, 20, 20, 20); $align = array('L', 'C', 'C', 'L', 'R', 'R', 'R', 'R'); foreach ($a_poste as $poste) { $Poste = new Acc_Account_Ledger($cn, $poste['pcm_val']); list($array, $tot_deb, $tot_cred) = $Poste->get_row_date($from_periode, $to_periode, $_GET['ople']); // don't print empty account if (count($array) == 0) { continue; } $Libelle = sprintf("(%s) %s ", $Poste->id, $Poste->get_name()); $pdf->SetFont('DejaVuCond', '', 10); $pdf->Cell(0, 8, $Libelle, 1, 0, 'C'); $pdf->Ln(); $pdf->SetFont('DejaVuCond', '', 8); $l = 0; $pdf->Cell($size[$l], 6, 'Date', 0, 0, 'L'); $l++; $pdf->Cell($size[$l], 6, 'Ref', 0, 0, 'C'); $l++; $pdf->Cell($size[$l], 6, 'Journal', 0, 0, 'C');