Example #1
0
 /**
  * show history of all the stock movement
  * @param $p_array usually contains $_GET
  */
 function history($p_array)
 {
     $sql = $this->create_query_histo($p_array);
     require_once NOALYSS_INCLUDE . '/class_sort_table.php';
     $p_url = HtmlInput::get_to_string(array("gDossier", "ac", "wcard", "wdate_start", "wdate_end", "wrepo", "wamount_start", "wamount_end", "wcode_stock", "wdirection"));
     $tb = new Sort_Table();
     $tb->add("Date", $p_url, " order by real_date asc", "order by real_date desc", "da", "dd");
     $tb->add("Code Stock", $p_url, " order by sg_code asc", "order by sg_code desc", "sa", "sd");
     $tb->add("Dépôt", $p_url, " order by r_name asc", "order by r_name desc", "ra", "rd");
     $tb->add("Fiche", $p_url, " order by 2 asc", "order by 2 desc", "fa", "fd");
     $tb->add("Commentaire", $p_url, " order by coalesce(sg_comment,jr_comment)  asc", "order by coalesce(sg_comment,jr_comment)  desc", "ca", "cd");
     $tb->add("Montant", $p_url, " order by j_montant asc", "order by j_montant desc", "ja", "jd");
     $tb->add("Quantité", $p_url, " order by sg_quantity asc", "order by sg_quantity  desc", "qa", "qd");
     $tb->add("IN/OUT", $p_url, " order by (case when sg_type='c' then 'OUT' when sg_type='c' then 'IN' end ) asc", "order by (case when sg_type='c' then 'OUT' when sg_type='c' then 'IN' end ) desc", "ta", "td");
     $order = isset($p_array['ord']) ? $p_array['ord'] : 'da';
     $sql .= $tb->get_sql_order($order);
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
     $res = $this->cn->exec_sql($sql);
     $max_row = Database::num_row($res);
     $nav_bar = navigation_bar($offset, $max_row, 0, $page);
     if ($step != -1) {
         $res = $this->cn->exec_sql($sql . " , sg_id asc limit " . $step . " offset " . $offset);
     }
     $max_row = Database::num_row($res);
     $this->search_box_button();
     $this->search_box($p_array);
     require_once NOALYSS_INCLUDE . '/template/stock_histo.php';
     $this->export_stock_histo_form();
     echo HtmlInput::print_window();
 }
Example #2
0
if (isset($_GET['viewsearch'])) {
    // Navigation bar
    $step = $_SESSION['g_pagesize'];
    $page = isset($_GET['offset']) ? $_GET['page'] : 1;
    $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
    if (count($_GET) == 0) {
        $array = null;
    } else {
        $array = $_GET;
    }
    $array['p_action'] = 'ALL';
    list($sql, $where) = $ledger->build_search_sql($array);
    // Count nb of line
    $max_line = $cn->count_sql($sql);
    list($count, $a) = $ledger->list_operation($sql, $offset, 0);
    $bar = navigation_bar($offset, $max_line, $step, $page);
    echo $bar;
    echo $a;
    echo $bar;
    /*
     * Export to csv
     */
    $r = HtmlInput::get_to_hidden(array('l', 'date_start', 'date_end', 'desc', 'amount_min', 'amount_max', 'qcode', 'accounting', 'unpaid', 'gDossier', 'ledger_type'));
    if (isset($_GET['r_jrn'])) {
        foreach ($_GET['r_jrn'] as $k => $v) {
            $r .= HtmlInput::hidden('r_jrn[' . $k . ']', $v);
        }
    }
    echo '<form action="export.php" method="get">';
    echo $r;
    echo HtmlInput::hidden('act', 'CSV:histo');
 function html_table($p_from)
 {
     if ($p_from == "") {
         $from = "";
         $to = "";
     } else {
         $p = new Periode($this->db);
         list($from, $to) = $p->get_date_limit($p_from);
     }
     $array = $this->get_list($from, $to);
     if (empty($array)) {
         return "Pas d'enregistrement trouv&eacute;";
     }
     // navigation_bar
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
     $bar = navigation_bar($offset + 1, count($array), $step, $page);
     if ($step != -1) {
         $view = array_splice($array, $offset, $step);
     } else {
         $view = $array;
     }
     $gDossier = dossier::id();
     $ret = "";
     $ret .= $bar;
     $count = 0;
     $group = 0;
     $oldgroup = 0;
     $oldjrid = 0;
     foreach ($view as $row) {
         $group = $row['oa_group'];
         if ($group != $oldgroup) {
             if ($oldgroup != 0) {
                 $efface = new IButton();
                 $efface->javascript = "anc_remove_operation(" . $gDossier . "," . $oldgroup . ")";
                 $efface->name = "Efface";
                 $efface->label = "Efface";
                 $ret .= "<td>" . $efface->input() . "</td>";
                 $this->oa_group = $oldgroup;
                 $jr_id = $this->get_jrid();
                 if ($jr_id != 0) {
                     // get the old jr_id
                     $detail = new IButton();
                     $detail->javascript = "viewOperation({$jr_id},{$gDossier})";
                     $detail->name = "Detail";
                     $detail->label = "Detail";
                     $ret .= "<td>" . $detail->input() . "</td>";
                 }
                 $ret .= '</table>';
             }
             $ret .= '<table id="' . $row['oa_group'] . '" class="result">';
             $ret .= "<tr class=\"highlight\">" . td($row['oa_date']) . "<td>" . HtmlInput::detail_op($row['jr_id'], h($row['oa_description'] . " " . $row['jr_pj_number'])) . "</td>" . td();
             $ret .= "<td>" . "Groupe id : " . $row['oa_group'] . "</td>" . ($oldgroup = $group);
         }
         $class = $count % 2 == 0 ? "odd" : "even";
         $count++;
         $cred = $row['oa_debit'] == 'f' ? "CREDIT" : "DEBIT";
         $ret .= "<tr class=\"{$class}\">";
         $ret .= "<td>" . h($row['po_name']) . "</td>";
         $ret .= td(h($row['po_description']));
         $ret .= '<td class="num">' . nbm($row['oa_amount']) . "</td>" . "<td>" . $cred . "</td>" . "</tr>";
     }
     $efface = new IButton();
     $efface->javascript = "anc_remove_operation(" . "{$gDossier}," . $oldgroup . ")";
     $efface->name = "Efface";
     $efface->label = "Efface";
     $ret .= "<td>" . $efface->input() . "</td>";
     // get the old jr_id
     $this->oa_group = $oldgroup;
     $jr_id = $this->get_jrid();
     if ($jr_id != 0) {
         $detail = new IButton();
         $detail->javascript = "modifyOperation({$jr_id},'" . $gDossier . "')";
         $detail->name = "Detail";
         $detail->label = "Detail";
         $ret .= "<td>" . $detail->input() . "</td>";
     }
     $ret .= '</table>';
     $ret .= $bar;
     return $ret;
 }
Example #4
0
 function myList()
 {
     $this->get();
     echo '<H2 class="info">' . $this->id . " " . $this->label . '</H2>';
     $step = $_SESSION['g_pagesize'];
     $sql_limit = "";
     $sql_offset = "";
     $bar = "";
     if ($step != -1) {
         $page = isset($_GET['page']) ? $_GET['page'] : 1;
         $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
         $max_line = $this->cn->count_sql("select f_id,ad_value  from\n                                           fiche join fiche_detail using (f_id)\n                                           where fd_id='" . $this->id . "' and ad_id=" . ATTR_DEF_NAME . " order by f_id");
         $sql_limit = " limit " . $step;
         $sql_offset = " offset " . $offset;
         $bar = navigation_bar($offset, $max_line, $step, $page);
     }
     // Get all name the cards of the select category
     // 1 for attr_def.ad_id is always the name
     $Res = $this->cn->exec_sql("select f_id,vw_name,quick_code  from " . " vw_fiche_attr " . " where fd_id='" . $this->id . "' order by f_id {$sql_offset} {$sql_limit} ");
     $Max = Database::num_row($Res);
     echo $bar;
     $str = "";
     // save the url
     // with offet &offset=15&step=15&page=2&size=15
     if ($_SESSION['g_pagesize'] != -1) {
         $str = sprintf("&offset=%s&step=%s&page=%s&size=%s", $offset, $step, $page, $max_line);
     }
     echo '<FORM METHOD="POST" action="?p_action=fiche&action=vue' . $str . '">';
     echo HtmlInput::hidden('ac', $_REQUEST['ac']);
     echo dossier::hidden();
     echo HtmlInput::hidden("fiche", $this->id);
     echo HtmlInput::submit('add', 'Ajout fiche');
     echo '</FORM>';
     $str_dossier = dossier::get();
     echo '<table>';
     for ($i = 0; $i < $Max; $i++) {
         $l_line = Database::fetch_array($Res, $i);
         if ($i % 2 == 0) {
             echo '<TR class="odd">';
         } else {
             echo '<TR class="even">';
         }
         $span_mod = '<TD><A href="?p_action=fiche&' . $str_dossier . '&action=detail&fiche_id=' . $l_line['f_id'] . $str . '&fiche=' . $_REQUEST['fiche'] . '&ac=' . $_REQUEST['ac'] . '">' . $l_line['quick_code'] . '</A></TD>';
         echo $span_mod . '<TD>' . h($l_line['vw_name']) . "</TD>";
         echo '</tr>';
     }
     echo '</table>';
     echo '<FORM METHOD="POST" action="?p_action=fiche&action=vue' . $str . '">';
     echo HtmlInput::hidden('ac', $_REQUEST['ac']);
     echo dossier::hidden();
     echo HtmlInput::hidden("fiche", $this->id);
     echo HtmlInput::submit('add', 'Ajout fiche');
     echo '</FORM>';
     echo $bar;
 }
Example #5
0
    function Summary($p_search = "", $p_action = "", $p_sql = "", $p_nothing = false)
    {
        $p_search = sql_string($p_search);
        $extra_sql = "";
        if ($this->company != "") {
            $extra_sql = "and f_id in (select f_id from fiche_detail\n                       where ad_value=upper('" . $this->company . "') and ad_id=" . ATTR_DEF_COMPANY . ") ";
        }
        $url = urlencode($_SERVER['REQUEST_URI']);
        $script = $_SERVER['PHP_SELF'];
        // Creation of the nav bar
        // Get the max numberRow
        $all_contact = $this->count_by_modele($this->fiche_def_ref, $p_search, $extra_sql);
        // Get offset and page variable
        $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
        $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
        $bar = navigation_bar($offset, $all_contact, $_SESSION['g_pagesize'], $page);
        // set a filter ?
        $search = "";
        if (trim($p_search) != "") {
            $search = " and f_id in\n                    (select f_id from fiche_Detail\n                    where\n                    ad_id=1 and ad_value ~* '{$p_search}') ";
        }
        // Get The result Array
        $step_contact = $this->get_by_category($offset, $search . $extra_sql . $p_sql);
        if ($all_contact == 0) {
            return "";
        }
        $r = $bar;
        $r .= '<table id="contact_tb" class="sortable">
            <TR>
            <th>Quick Code</th>
            <th>Nom</th>
            <th>Prénom</th>
			<th>Société</th>
            <th>Téléphone</th>
            <th>email</th>
            <th>Fax</th>
            </TR>';
        $base = $_SERVER['PHP_SELF'];
        // Compute the url
        $url = "";
        $and = "?";
        $get = $_GET;
        if (isset($get)) {
            foreach ($get as $name => $value) {
                // we clean the parameter offset, step, page and size
                if (!in_array($name, array('f_id', 'detail'))) {
                    $url .= $and . $name . "=" . $value;
                    $and = "&";
                }
                // if
            }
            //foreach
        }
        // if
        $back_url = urlencode($_SERVER['REQUEST_URI']);
        if (sizeof($step_contact) == 0) {
            return $r;
        }
        $idx = 0;
        foreach ($step_contact as $contact) {
            $l_company = new Fiche($this->cn);
            $l_company->get_by_qcode($contact->strAttribut(ATTR_DEF_COMPANY), false);
            $l_company_name = $l_company->strAttribut(ATTR_DEF_NAME);
            if ($l_company_name == NOTFOUND) {
                $l_company_name = "";
            }
            // add popup for detail
            if ($l_company_name != "") {
                $l_company_name = HtmlInput::card_detail($contact->strAttribut(ATTR_DEF_COMPANY), $l_company_name, 'style="text-decoration:underline;"');
            }
            $tr = $idx % 2 == 0 ? ' <tr class="odd">' : '<tr class="even">';
            $idx++;
            $r .= $tr;
            $qcode = $contact->strAttribut(ATTR_DEF_QUICKCODE);
            $r .= '<TD>' . HtmlInput::card_detail($qcode) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_NAME) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_FIRST_NAME) . "</TD>";
            $r .= "<TD>" . $l_company_name . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_TEL) . "</TD>";
            $r .= "<TD>" . $contact->strAttribut(ATTR_DEF_EMAIL) . "</TD>" . "<TD> " . $contact->strAttribut(ATTR_DEF_FAX) . "</TD>";
            $r .= "</TR>";
        }
        $r .= "</TABLE>";
        $r .= $bar;
        return $r;
    }
Example #6
0
 function Summary($p_search = "", $p_action = "", $p_sql = "", $p_amount = false)
 {
     global $g_user;
     $bank = new Acc_Parm_Code($this->cn, 'BANQUE');
     $cash = new Acc_Parm_Code($this->cn, 'CAISSE');
     $cc = new Acc_Parm_Code($this->cn, 'COMPTE_COURANT');
     bcscale(4);
     $gDossier = dossier::id();
     $p_search = sql_string($p_search);
     $script = $_SERVER['PHP_SELF'];
     // Creation of the nav bar
     // Get the max numberRow
     $filter_amount = '';
     global $g_user;
     $filter_year = "  j_tech_per in (select p_id from parm_periode " . "where p_exercice='" . $g_user->get_exercice() . "')";
     if ($p_amount) {
         $filter_amount = ' and f_id in (select f_id from jrnx where  ' . $filter_year . ')';
     }
     $all_tiers = $this->count_by_modele($this->fiche_def_ref, "", $p_sql . $filter_amount);
     // Get offset and page variable
     $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
     $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
     $bar = navigation_bar($offset, $all_tiers, $_SESSION['g_pagesize'], $page);
     // set a filter ?
     $search = $p_sql;
     $exercice = $g_user->get_exercice();
     $tPeriode = new Periode($this->cn);
     list($max, $min) = $tPeriode->get_limit($exercice);
     if (trim($p_search) != "") {
         $search .= " and f_id in\n                     (select distinct f_id from fiche_detail\n                     where\n                     ad_id in (1,32,30,23,18,13) and ad_value ~* '{$p_search}')";
     }
     // Get The result Array
     $step_tiers = $this->get_by_category($offset, $search . $filter_amount, 'name');
     if ($all_tiers == 0 || count($step_tiers) == 0) {
         return "";
     }
     $r = "";
     $r .= _("Filtre rapide ") . HtmlInput::filter_table("tiers_tb", '0,1,2', 1);
     $r .= $bar;
     $r .= '<table  id="tiers_tb" class="sortable"  style="width:90%;margin-left:5%">
         <TR >
         <TH>' . _('Quick Code') . HtmlInput::infobulle(17) . '</TH>' . '<th>' . _('Poste comptable') . '</th>' . '<th  class="sorttable_sorted_reverse">' . _('Nom') . '<span id="sorttable_sortrevind">&nbsp;&blacktriangle;</span>' . '</th>
         <th>' . _('Adresse') . '</th>
         <th style="text-align:right">' . _('Total débit') . '</th>
         <th style="text-align:right">' . _('Total crédit') . '</th>
         <th style="text-align:right">' . _('Solde') . '</th>';
     $r .= '</TR>';
     if (sizeof($step_tiers) == 0) {
         return $r;
     }
     $i = 0;
     $deb = 0;
     $cred = 0;
     foreach ($step_tiers as $tiers) {
         $i++;
         /* Filter on the default year */
         $amount = $tiers->get_solde_detail($filter_year);
         /* skip the tiers without operation */
         if ($p_amount && $amount['debit'] == 0 && $amount['credit'] == 0 && $amount['solde'] == 0) {
             continue;
         }
         $odd = "";
         $odd = $i % 2 == 0 ? ' odd ' : ' even ';
         $accounting = $tiers->strAttribut(ATTR_DEF_ACCOUNT);
         if ($p_action == 'bank' && $amount['debit'] < $amount['credit']) {
             if (strpos($accounting, $bank->p_value) === 0 || strpos($accounting, $cash->p_value) === 0 || strpos($accounting, $cc->p_value) === 0) {
                 //put in red if c>d
                 $odd .= " notice ";
             }
         }
         $odd = ' class="' . $odd . '"';
         $r .= "<TR {$odd}>";
         $url_detail = $script . '?' . http_build_query(array('sb' => 'detail', 'sc' => 'sv', 'ac' => $_REQUEST['ac'], 'f_id' => $tiers->id, 'gDossier' => $gDossier));
         $e = sprintf('<A HREF="%s" title="Détail" class="line"> ', $url_detail);
         $r .= "<TD> {$e}" . $tiers->strAttribut(ATTR_DEF_QUICKCODE) . "</A></TD>";
         $r .= "<TD> {$e}" . $accounting . "</TD>";
         $r .= "<TD>" . h($tiers->strAttribut(ATTR_DEF_NAME)) . "</TD>";
         $r .= "<TD>" . h($tiers->strAttribut(ATTR_DEF_ADRESS) . " " . $tiers->strAttribut(ATTR_DEF_CP) . " " . $tiers->strAttribut(ATTR_DEF_PAYS)) . "</TD>";
         $str_deb = $amount['debit'] == 0 ? 0 : nbm($amount['debit']);
         $str_cred = $amount['credit'] == 0 ? 0 : nbm($amount['credit']);
         $str_solde = nbm($amount['solde']);
         $r .= '<TD sorttable_customkey="' . $amount['debit'] . '" align="right"> ' . $str_deb . '</TD>';
         $r .= '<TD sorttable_customkey="' . $amount['credit'] . '" align="right"> ' . $str_cred . '</TD>';
         $side = $amount['debit'] > $amount['credit'] ? 'D' : 'C';
         $side = $amount['debit'] == $amount['credit'] ? '=' : $side;
         $red = "";
         if ($p_action == 'customer' && $amount['debit'] < $amount['credit']) {
             //put in red if d>c
             $red = " notice ";
         }
         if ($p_action == 'supplier' && $amount['debit'] > $amount['credit']) {
             //put in red if c>d
             $red = " notice ";
         }
         $r .= '<TD class="' . $red . '" sorttable_customkey="' . $amount['solde'] . '" align="right"> ' . $str_solde . "{$side} </TD>";
         $deb = bcadd($deb, $amount['debit']);
         $cred = bcadd($cred, $amount['credit']);
         $r .= "</TR>";
     }
     $r .= "<tfoot >";
     $solde = abs(bcsub($deb, $cred));
     $side = $deb > $cred ? 'Débit' : 'Crédit';
     $r .= '<tr class="highlight">';
     $r .= td("") . td("") . td("") . td("Totaux") . td(nbm($deb), 'class="num"') . td(nbm($cred), 'class="num"') . td(" {$side} " . nbm($solde), 'class="num"');
     $r .= '</tr>';
     $r .= "</tfoot>";
     $r .= "</TABLE>";
     $r .= $bar;
     return $r;
 }
Example #7
0
 /**
  * myList($p_base, $p_filter = "", $p_search = "") 
  * Show list of action by default if sorted on date
  * @param $p_base base url with ac...
  * @param $p_filter filters on the document_type
  * @param $p_search must a valid sql command ( ex 'and  ag_title like upper('%hjkh%'))
  * @return string containing html code
  */
 function myList($p_base, $p_filter = "", $p_search = "")
 {
     // for the sort
     $url = HtmlInput::get_to_string(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag")) . '&' . $p_base;
     $table = new Sort_Table();
     $table->add('Date Doc.', $url, 'order by ag_timestamp asc', 'order by ag_timestamp desc', 'da', 'dd');
     $table->add('Date Comm.', $url, 'order by last_comment', 'order by last_comment desc', 'dca', 'dcd');
     $table->add('Date Limite', $url, 'order by ag_remind_date asc', 'order by ag_remind_date  desc', 'ra', 'rd');
     $table->add('Tag', $url, 'order by tags asc', 'order by tags desc', 'taa', 'tad');
     $table->add('Réf.', $url, 'order by ag_ref asc', 'order by ag_ref desc', 'ra', 'rd');
     $table->add('Groupe', $url, "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe')", "order by coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') desc", 'dea', 'ded');
     $table->add('Dest/Exp', $url, 'order by name asc', 'order by name desc', 'ea', 'ed');
     $table->add('Titre', $url, 'order by ag_title asc', 'order by ag_title desc', 'ta', 'td');
     $ord = !isset($_GET['ord']) ? "dcd" : $_GET['ord'];
     $sort = $table->get_sql_order($ord);
     if (strlen(trim($p_filter)) != 0) {
         $p_filter_doc = " dt_id in ( {$p_filter} )";
     } else {
         $p_filter_doc = " 1=1 ";
     }
     $sql = "\n             select ag_id,to_char(ag_timestamp,'DD.MM.YYYY') as my_date,\n                to_char(ag_remind_date,'DD.MM.YYYY') as my_remind,\n                to_char(coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp),'DD.MM.YY') as str_last_comment,\n                coalesce((select max(agc_date) from action_gestion_comment as agc where agc.ag_id=ag.ag_id),ag_timestamp) as last_comment,\n                f_id_dest,\n                s_value,\n                ag_title,dt_value,ag_ref, ag_priority,ag_state,\n                coalesce((select p_name from profile where p_id=ag_dest),'Aucun groupe') as dest,\n                (select ad_value from fiche_Detail where f_id=ag.f_id_dest and ad_id=1) as name,\n                array_to_string((select array_agg(t1.t_tag) from action_tags as a1 join tags as t1 on (a1.t_id=t1.t_id) where a1.ag_id=ag.ag_id ),',') as tags\n            from action_gestion as ag\n                join document_type on (ag_type=dt_id)\n                join document_state on (ag_state=s_id)\n             where {$p_filter_doc} {$p_search} {$sort}";
     $max_line = $this->db->count_sql($sql);
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? Database::escape_string($_GET['offset']) : 0;
     if ($step != -1) {
         $limit = " LIMIT {$step} OFFSET {$offset} ";
     } else {
         $limit = '';
     }
     $bar = navigation_bar($offset, $max_line, $step, $page);
     $Res = $this->db->exec_sql($sql . $limit);
     $a_row = Database::fetch_all($Res);
     $r = "";
     $r .= '<p>' . $bar . '</p>';
     $r .= '<table class="document">';
     $r .= "<tr>";
     $r .= '<th name="ag_id_td" style="display:none" >' . ICheckBox::toggle_checkbox('ag', 'list_ag_frm') . '</th>';
     $r .= '<th>' . $table->get_header(0) . '</th>';
     $r .= '<th>' . $table->get_header(1) . '</th>';
     $r .= '<th>' . $table->get_header(2) . '</th>';
     $r .= '<th>' . $table->get_header(3) . '</th>';
     $r .= '<th>' . $table->get_header(4) . '</th>';
     $r .= '<th>' . $table->get_header(5) . '</th>';
     $r .= '<th>' . $table->get_header(6) . '</th>';
     $r .= '<th>' . $table->get_header(7) . '</th>';
     $r .= th('Priorité');
     $r .= "</tr>";
     // if there are no records return a message
     if (sizeof($a_row) == 0 or $a_row == false) {
         $r = '<div style="clear:both">';
         $r .= '<hr>Aucun enregistrement trouvé';
         $r .= "</div>";
         return $r;
     }
     $today = date('d.m.Y');
     $i = 0;
     $checkbox = new ICheckBox("mag_id[]");
     //show the sub_action
     foreach ($a_row as $row) {
         $href = '<A class="document" HREF="do.php?' . $p_base . HtmlInput::get_to_string(array("closed_action", "remind_date_end", "remind_date", "sag_ref", "only_internal", "state", "gDossier", "qcode", "ag_dest_query", "action_query", "tdoc", "date_start", "date_end", "hsstate", "searchtag", "ac"), "&") . '&sa=detail&ag_id=' . $row['ag_id'] . '">';
         $i++;
         $tr = $i % 2 == 0 ? 'even' : 'odd';
         if ($row['ag_priority'] < 2) {
             $tr = 'priority1';
         }
         $st = '';
         if ($row['my_date'] == $today) {
             $st = ' style="font-weight:bold; border:2px solid orange;"';
         }
         $date_remind = format_date($row['my_remind'], 'DD.MM.YYYY', 'YYYYMMDD');
         $date_today = date('Ymd');
         if ($date_remind != "" && $date_remind == $date_today && $row['ag_state'] != 1 && $row['ag_state'] != 3) {
             $st = ' style="font-weight:bold;background:orange"';
         }
         if ($date_remind != "" && $date_remind < $date_today && $row['ag_state'] != 1 && $row['ag_state'] != 3) {
             $st = ' style="font-weight:bold;background:#FF0000;color:white;"';
         }
         $r .= "<tr class=\"{$tr}\" {$st}>";
         $checkbox->value = $row['ag_id'];
         $r .= '<td name="ag_id_td" style="display:none">' . $checkbox->input() . '</td>';
         $r .= "<td>" . $href . smaller_date($row['my_date']) . '</a>' . "</td>";
         $r .= "<td>" . $href . $row['str_last_comment'] . '</a>' . "</td>";
         $r .= "<td>" . $href . smaller_date($row['my_remind']) . '</a>' . "</td>";
         $r .= "<td>" . $href . h($row['tags']) . '</a>' . "</td>";
         $r .= "<td>" . $href . $row['ag_ref'] . '</a>' . "</td>";
         $r .= "<td>" . $href . h($row['dest']) . '</a>' . "</td>";
         // Expediteur
         $fexp = new Fiche($this->db);
         $fexp->id = $row['f_id_dest'];
         $qcode_dest = $fexp->strAttribut(ATTR_DEF_QUICKCODE);
         $qexp = $qcode_dest == NOTFOUND ? "Interne" : $qcode_dest;
         $jsexp = sprintf("javascript:showfiche('%s')", $qexp);
         if ($qexp != 'Interne') {
             $r .= "<td>{$href}" . $qexp . " : " . $fexp->getName() . '</a></td>';
         } else {
             $r .= "<td>{$href} Interne </a></td>";
         }
         $ref = "";
         $r .= '<td>' . $href . h($row['ag_title']) . "</A></td>";
         /*
          * State
          */
         switch ($row['ag_priority']) {
             case 1:
                 $priority = 'Haute';
                 break;
             case 2:
                 $priority = "Moyenne";
                 break;
             case 3:
                 $priority = "Important";
                 break;
         }
         $r .= td($priority);
         $r .= "<td>" . $ref . "</td>";
         $r .= "</tr>";
     }
     $r .= "</table>";
     $r .= '<p>' . $bar . '</p>';
     return $r;
 }
 /**
  * @brief update the payment
  * @deprecated
  * 
  */
 function show_unpaid()
 {
     // Show list of unpaid sell
     // Date - date of payment - Customer - amount
     // Nav. bar
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
     $sql = SQL_LIST_UNPAID_INVOICE_DATE_LIMIT . " and jr_def_id=" . $this->id;
     list($max_line, $list) = ListJrn($this->db, $sql, null, $offset, 1);
     $sql = SQL_LIST_UNPAID_INVOICE . " and jr_def_id=" . $this->id;
     list($max_line2, $list2) = ListJrn($this->db, $sql, null, $offset, 1);
     // Get the max line
     $m = $max_line2 > $max_line ? $max_line2 : $max_line;
     $bar2 = navigation_bar($offset, $m, $step, $page);
     echo $bar2;
     echo '<h2 class="info"> ' . _('Echeance dépassée') . ' </h2>';
     echo $list;
     echo '<h2 class="info"> ' . _('Non Payée') . ' </h2>';
     echo $list2;
     echo $bar2;
     // Add hidden parameter
     $hid = new IHidden();
     echo '<hr>';
     if ($m != 0) {
         echo HtmlInput::submit('paid', _('Mise à jour paiement'));
     }
 }
 function show_ledger()
 {
     global $g_user;
     echo dossier::hidden();
     $hid = new IHidden();
     $hid->name = "p_action";
     $hid->value = "bank";
     echo $hid->input();
     $hid->name = "sa";
     $hid->value = "l";
     echo $hid->input();
     $w = new ISelect();
     // filter on the current year
     $filter_year = " where p_exercice='" . $g_user->get_exercice() . "'";
     $periode_start = $this->db->make_array("select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode {$filter_year} order by p_start,p_end", 1);
     // User is already set User=new User($this->db);
     $current = isset($_GET['p_periode']) ? $_GET['p_periode'] : -1;
     $w->selected = $current;
     echo '<form>';
     echo 'Période  ' . $w->input("p_periode", $periode_start);
     $wLedger = $this->select_ledger('fin', 3);
     if ($wLedger == null) {
         throw new Exception(_('Pas de journal disponible'));
     }
     if (count($wLedger->value) > 1) {
         $aValue = $wLedger->value;
         $wLedger->value[0] = array('value' => -1, 'label' => _('Tous les journaux financiers'));
         $idx = 1;
         foreach ($aValue as $a) {
             $wLedger->value[$idx] = $a;
             $idx++;
         }
     }
     echo 'Journal ' . $wLedger->input();
     $w = new ICard();
     $w->noadd = 'no';
     $w->jrn = $this->id;
     $qcode = isset($_GET['qcode']) ? $_GET['qcode'] : "";
     echo dossier::hidden();
     echo HtmlInput::hidden('p_action', 'bank');
     echo HtmlInput::hidden('sa', 'l');
     $w->name = 'qcode';
     $w->value = $qcode;
     $w->label = '';
     $this->type = 'FIN';
     $all = $this->get_all_fiche_def();
     $w->extra = $all;
     $w->extra2 = 'QuickCode';
     $sp = new ISpan();
     echo $sp->input("qcode_label", "", $qcode);
     echo $w->input();
     echo HtmlInput::submit('gl_submit', _('Rechercher'));
     echo '</form>';
     // Show list of sell
     // Date - date of payment - Customer - amount
     if ($current != -1) {
         $filter_per = " and jr_tech_per=" . $current;
     } else {
         $filter_per = " and jr_tech_per in (select p_id from parm_periode where p_exercice::integer=" . $g_user->get_exercice() . ")";
     }
     /* security  */
     if ($this->id != -1) {
         $available_ledger = " and jr_def_id= " . $this->id . " and " . $g_user->get_ledger_sql();
     } else {
         $available_ledger = " and " . $g_user->get_ledger_sql();
     }
     // Show list of sell
     // Date - date of payment - Customer - amount
     $sql = SQL_LIST_ALL_INVOICE . $filter_per . " and jr_def_type='FIN'" . " {$available_ledger}";
     $step = $_SESSION['g_pagesize'];
     $page = isset($_GET['offset']) ? $_GET['page'] : 1;
     $offset = isset($_GET['offset']) ? $_GET['offset'] : 0;
     $l = "";
     // check if qcode contains something
     if ($qcode != "") {
         // add a condition to filter on the quick code
         $l = " and jr_grpt_id in (select j_grpt from jrnx where j_qcode=upper('{$qcode}')) ";
     }
     list($max_line, $list) = ListJrn($this->db, "where jrn_def_type='FIN' {$filter_per} {$l} {$available_ledger} ", null, $offset, 0);
     $bar = navigation_bar($offset, $max_line, $step, $page);
     echo "<hr> {$bar}";
     echo $list;
     echo "{$bar} <hr>";
 }