'; //----------------------------------------------------- if (!isset($_GET['cat_display'])) exit(); $fd_id = $_GET['cat']; $array = Fiche::get_fiche_def($cn, $_GET['cat'], 'name_asc'); $h_add_card_b = new IButton('add_card'); $h_add_card_b->label = _('Créer une nouvelle fiche'); $h_add_card_b->javascript = "dis_blank_card({gDossier:$gDossier,fd_id:$fd_id,ref:2})"; $str_add_card = ($g_user->check_action(FICADD) == 1) ? $h_add_card_b->input() : ""; /* * You show now the result */ if ($array == null) { echo '
Aucune fiche trouvée
'; echo $str_add_card; exit(); } $allcard = (isset($_GET['allcard'])) ? 1 : 0; if ( $allcard == 0 ){ $fiche_def=new Fiche_Def($cn,$_GET['cat']); $fiche_def->Get(); echo h1($fiche_def->label,""); echo h2($fiche_def->fd_description,""); } /* * ********************************************************************************************************************************* * Liste * * ******************************************************************************************************************************** */ if ($_GET['histo'] == -1) { $write = $g_user->check_action(FICADD); /** * If ask for move or delete */ if (isset($_POST['action'])) { if ($write == 1) { $ack = $_POST['f_id']; /** * Move */ if (isset($_POST['move'])) { for ($i = 0; $i < count($ack); $i++) { $fiche = new Fiche($cn, $ack[$i]); $fiche->move_to($_POST['move_to']); } } /** * Delete */ if (isset($_POST['delete'])) { $msg=""; for ($i = 0; $i < count($ack); $i++) { $fiche = new Fiche($cn, $ack[$i]); if ( $fiche->remove(true) == 1 ) { $msg.="\n ".$fiche->strAttribut(ATTR_DEF_QUICKCODE); } } if ($msg != "") { echo h2(_("Fiche non effacées"), ' class="error" '); echo ''._(" Ces fiches n'ont pas été effacées ").$msg; } } } else { echo NoAccess(); } } $sql = "select f_id from fiche "; if ($allcard == 1) { $cond = ""; } else { $cond = " where f.fd_id = " . sql_string($_GET['cat']); } // Create nav bar $max = $cn->get_value("select count(*) from fiche as f " . $cond); $step = $_SESSION['g_pagesize']; $page = (isset($_GET['offset'])) ? $_GET['page'] : 1; $offset = (isset($_GET['offset'])) ? $_GET['offset'] : 0; $bar = navigation_bar($offset, $max, $step, $page); $limit = ($step == -1 ) ? "" : " limit " . $step; $res = $cn->exec_sql(" select f_id, (select ad_value from fiche_detail as fd1 where ad_id=1 and fd1.f_id=f.f_id) as name, (select ad_value from fiche_detail as fd1 where ad_id=23 and fd1.f_id=f.f_id) as qcode, fd_label, (select ad_value from fiche_detail as fd1 where ad_id=5 and fd1.f_id=f.f_id) as poste from fiche as f join fiche_def as fd on (fd.fd_id=f.fd_id) $cond order by 2,4 offset $offset $limit "); $nb_line = Database::num_row($res); if ($write != 1 || $allcard != 0 ) $str_add_card=""; require_once 'template/fiche_list.php'; echo '
'.$bar; exit(); } /* * ********************************************************************************************************************************* * Summary * * ******************************************************************************************************************************** */ if ($_GET['histo'] == 3) { $cat_card = new Fiche_Def($cn); $cat_card->id = $_GET['cat']; $aHeading = $cat_card->getAttribut(); if ( $allcard == 0) echo $str_add_card; require_once('template/result_cat_card_summary.php'); $hid = new IHidden(); echo '"; exit(); } $export_pdf = ''; $export_print = HtmlInput::print_window(); $export_csv = ''; /******************************************************************************************************************************** * Balance * **********************************************************************************************************************************/ if ($_GET['histo'] == 4 || $_GET['histo'] == 5) { if (isDate($_REQUEST['start']) == null || isDate($_REQUEST['end']) == null) { echo h2('Date invalide !', 'class="error"'); alert('Date invalide !'); exit; } if ( $allcard == 0 ) echo $str_add_card; echo $export_pdf; echo $export_csv; echo $export_print; $fd = new Fiche_Def($cn, $_REQUEST['cat']); if ($allcard == 0 && $fd->hasAttribute(ATTR_DEF_ACCOUNT) == false) { echo alert("Cette catégorie n'ayant pas de poste comptable n'a pas de balance"); exit; } // all card if ($allcard == 1) { $afiche = $cn->get_array("select fd_id from vw_fiche_def where ad_id=" . ATTR_DEF_ACCOUNT . " order by fd_label asc"); } else { $afiche[0] = array('fd_id' => $_REQUEST['cat']); } for ($e = 0; $e < count($afiche); $e++) { $ret = $cn->exec_sql("select f_id,ad_value from fiche join fiche_detail using(f_id) where fd_id=$1 and ad_id=1 order by 2 ", array($afiche[$e]['fd_id'])); if ($cn->count() == 0) { if ($allcard == 0) { echo _("Aucune fiche trouvée"); exit; } else continue; } echo '
' . $cn->get_value("select fd_label from fiche_def where fd_id=$1", array($afiche[$e]['fd_id'])) . '
'; echo '| Poste'.HtmlInput::infobulle(27).' | '. th('Débit', 'style="text-align:right"') . th('Crédit', 'style="text-align:right"') . th('Solde', 'style="text-align:right"') . th('D/C', 'style="text-align:right"') ); $idx = 0;$sum_deb=0;$sum_cred=0;$sum_solde=0;bcscale(4); for ($i = 0; $i < Database::num_row($ret); $i++) { $filter = " (j_date >= to_date('" . $_REQUEST['start'] . "','DD.MM.YYYY') " . " and j_date <= to_date('" . $_REQUEST['end'] . "','DD.MM.YYYY')) "; $aCard = Database::fetch_array($ret, $i); $oCard = new Fiche($cn, $aCard['f_id']); $solde = $oCard->get_solde_detail($filter); if ($solde['debit'] == 0 && $solde['credit'] == 0) continue; /* only not purged card */ if ($_GET['histo'] == 5 && $solde['debit'] == $solde['credit']) continue; $class = ''; if ($idx % 2 == 0) $class = 'class="odd"'; $idx++; $sum_cred=bcadd($sum_cred,$solde['credit']); $sum_deb=bcadd($sum_deb,$solde['debit']); $sum_solde=bcsub($sum_deb,$sum_cred); echo tr( td(HtmlInput::history_card($oCard->id, $oCard->strAttribut(ATTR_DEF_QUICKCODE))) . td($oCard->strAttribut(ATTR_DEF_NAME)) . td($oCard->strAttribut(ATTR_DEF_ACCOUNT)). td(nbm($solde['debit']), 'style="text-align:right"') . td(nbm($solde['credit']), 'style="text-align:right"') . td(nbm(abs($solde['solde'])), 'style="text-align:right"') . td((($solde['debit'] < $solde['credit']) ? 'CRED' : 'DEB'), 'style="text-align:right"'), $class ); } echo tr( td(''). td(_('Totaux')). td(''). td(nbm($sum_deb), 'style="text-align:right"'). td(nbm($sum_cred), 'style="text-align:right"'). td(nbm(abs($sum_solde)), 'style="text-align:right"'). td((($sum_deb < $sum_cred) ? 'CRED' : 'DEB'), 'style="text-align:right"'),""); echo '
|---|