476

(9 replies, posted in Setup)

@dz After you close fiscal year and then delete it than it will purge the data. But you won't be able to see previous year's transactions. But I think that is not ideal for any organization. (:

Am I correct @apmuthu

Earlier we had this Layout in Customer Transaction Inquiry that was very helpful but this has been changed in FA24. No Upper section appears now if we select any customer.

Can any one share whats the logic behind that?

Line 153, 154 shall be replaced with this

elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())
echo "          <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a></li>\n";

Here is the final renderer.php code

<?php
/**********************************************************************
    Copyright (C) FrontAccounting, LLC.
    Released under the terms of the GNU General Public License, GPL,
    as published by the Free Software Foundation, either version 3
    of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
// Author: Joe Hunt, 17/11/2015. Upgraded to release 2.4. 10/11/2015.

    class renderer
    {
        function wa_get_apps($title, $applications, $sel_app)
        {
            foreach($applications as $app)
            {
                foreach ($app->modules as $module)
                {
                    $apps = array();
                    foreach ($module->lappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    foreach ($module->rappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    $application = array();
                    foreach ($apps as $application)
                    {
                        $lnk = $_SERVER['REQUEST_URI'];
                        $pos = strpos($application->link, "/");
                        if ($pos > 0)
                        {
                            $app_lnk = substr($application->link, $pos + 1);
                            $pos = strpos($app_lnk, "?");
                            if ($pos == false)
                                $pos = strlen($app_lnk);
                            $app_lnk = substr($app_lnk, 0, $pos);
                            $pos = strrpos($lnk, "/");
                            $lnk = substr($lnk, $pos + 1);
                            $pos = strpos($lnk, "?");
                            if ($pos == false)
                                $pos = strlen($lnk);
                            $lnk = substr($lnk, 0, $pos);
                            if ($app_lnk == $lnk)
                            {
                                $acc = access_string($app->name);
                                return array($acc[0], $module->name, $application->label, $app->id);
                            }
                        }
                    }
                }
            }
            return array("", "", "", $sel_app);
        }

        function wa_header()
        {
            page(_($help_context = "Main Menu"), false, true);
        }

        function wa_footer()
        {
            end_page(false, true);
        }
        function shortcut($url, $label)
        {
            echo "<li>";
            echo menu_link($url, $label);
            echo "</li>";
        }
        function menu_header($title, $no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version, $db_connections, $installed_extensions;

            $sel_app = $_SESSION['sel_app'];
            echo "<div class='fa-main'>\n";
            if (!$no_menu)
            {
                echo "<script type='text/javascript' src='$path_to_root/themes/dynamic/ddmenu/ddlevelsmenu.js'></script>\n";
                $applications = $_SESSION['App']->applications;
                $local_path_to_root = $path_to_root;
                $img = "<img src='$local_path_to_root/themes/dynamic/images/login.gif' width='14' height='14' border='0' alt='"._('Logout')."'>&nbsp;&nbsp;";
                $himg = "<img src='$local_path_to_root/themes/dynamic/images/help.gif' width='14' height='14' border='0' alt='"._('Help')."'>&nbsp;&nbsp;";
                echo "<div id='header'>\n";
                echo "<ul>\n";
                echo "  <li><a href='$local_path_to_root/admin/display_prefs.php?'>" . _("Preferences") . "</a></li>\n";
                echo "  <li><a href='$local_path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>" . _("Change password") . "</a></li>\n";
                if ($SysPrefs->help_base_url != null)
                    echo "  <li><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='".
                        help_url()."'>$himg" . _("Help") . "</a></li>";
                echo "  <li><a href='$path_to_root/access/logout.php?'>$img" . _("Logout") . "</a></li>";
                echo "</ul>\n";
                $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
                echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
                echo "</div>\n"; // header

                echo "<div id='cssmenu'>\n";
                echo "<ul>\n";
                $account = $this->wa_get_apps($title, $applications, $sel_app);
                if (!$no_menu)
        {
                    add_access_extensions();
                
                foreach($applications as $app)
                {
                    if ($this->check_application_access($app))
                    {
                        if ($account[3] == $app->id)
                            $sel_application = $app;
                        $acc = access_string($app->name);
                        $class = ($account[3] == $app->id ? "active" : "");
                        $n = count($app->modules);
                        if ($n)
                            $class .= " has-sub";
                        echo "  <li class ='$class'><a href='$local_path_to_root/index.php?application=" . $app->id
                            ."'$acc[1]'><span>" . $acc[0] . "</span></a>\n";
                        if (!$n)
                        {
                            echo "  </li>\n";
                            continue;
                        }
                        echo "    <ul>\n";
                        foreach ($app->modules as $module)
                        {
                            if (!$this->check_module_access($module))
                                continue;
                             echo "      <li class='has-sub'><a href='#'><span>$module->name</span></a>\n";
                             $apps2 = array();
                             foreach ($module->lappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            foreach ($module->rappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            $application = array();
                               $n = count($apps2);
                            if ($n)
                                echo "        <ul>\n";
                            else
                            {
                                echo "      </li>\n";
                                continue;
                            }
                            foreach ($apps2 as $application)
                            {
                                $lnk = access_string($application->label);
                                if ($_SESSION["wa_current_user"]->can_access_page($application->access))
                                {
                                    if ($application->label != "")
                                    {
                                        echo "          <li><a href='$path_to_root/$application->link'><span>$lnk[0]</span></a></li>\n";
                                    }
                                }
                                elseif (!$this->hide_inaccessible_menu_items())
                                    echo "          <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a>/li>\n";
                            }
                            if ($n)
                                echo "        </ul>\n";
                            echo "      </li>\n";
                        }
                        echo "    </ul>\n"; // menu
                    }
                    echo"  </li>\n";
                }
                echo "</ul>\n";
                echo "</div>\n"; // menu
            }
            echo "<div class='fa-body'>\n";
            echo "<div class='fa-content'>\n";
        }
            if ($no_menu)
                echo "<br>";
            elseif ($title && !$no_menu && !$is_index)
            {
                echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
                ."<td align=right>"
                .(user_hints() ? "<span id='hints'></span>" : '')
                ."</td>"
                ."</tr></table></center>";
            }
        }

        function menu_footer($no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version, $db_connections;
            include_once($path_to_root . "/includes/date_functions.inc");

            if (!$no_menu)
                echo "</div>\n"; // fa-content
            echo "</div>\n"; // fa-body
            if (!$no_menu)
            {
                echo "<div class='fa-footer'>\n";
                if (isset($_SESSION['wa_current_user']))
                {
                    echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
                    echo "<span class='date'>".Today() . "&nbsp;" . Now()."</span>\n";
                    echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
                    echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
                    echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
                    echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
                    echo "<span class='date'>".show_users_online()."</span>\n";
                }
                echo "</div>\n"; // footer
            }
            echo "</div>\n"; // fa-main
        }

        function display_applications(&$waapp)
        {
            global $path_to_root, $SysPrefs;
            include_once("$path_to_root/includes/ui.inc");
            include_once($path_to_root . "/reporting/includes/class.graphic.inc");
            include($path_to_root . "/includes/system_tests.inc");

            if ($SysPrefs->use_popup_windows)
            {
                $js = get_js_open_window(900, 500);
                  add_js_source($js);
            }
            if (!defined('FLOAT_COMP_DELTA'))
                define('FLOAT_COMP_DELTA', 0.004);

            $selected_app = $waapp->get_selected_application();
            if (!$this->check_application_access($selected_app))
                return;
            // first have a look through the directory,
            // and remove old temporary pdfs and pngs
            $dir = company_path(). '/pdf_files';

            if ($d = @opendir($dir)) {
                while (($file = readdir($d)) !== false) {
                    if (!is_file($dir.'/'.$file) || $file == 'index.php') continue;
                // then check to see if this one is too old
                    $ftime = filemtime($dir.'/'.$file);
                 // seems 3 min is enough for any report download, isn't it?
                    if (time()-$ftime > 180){
                        unlink($dir.'/'.$file);
                    }
                }
                closedir($d);
            }

            //check_for_overdue_recurrent_invoices();
            if ($selected_app->id == "orders")
                display_customer_topten();
            elseif ($selected_app->id == "AP")
                display_supplier_topten();
            elseif ($selected_app->id == "stock")
                display_stock_topten();
            elseif ($selected_app->id == "manuf")
                display_stock_topten(true);
            elseif ($selected_app->id == "proj")
                display_dimension_topten();
            elseif ($selected_app->id == "GL")
                display_gl_info();
            else
                display_all();
        }

        function check_application_access($waapp)
        {
            if (!$this->hide_inaccessible_menu_items())
            {
                return true;
            }

            foreach ($waapp->modules as $module)
            {
                if ($this->check_module_access($module))
                {
                    return true;
                }
            }

            return false;

        }

        function check_module_access($module)
        {

            if (!$this->hide_inaccessible_menu_items())
            {
                return true;
            }

            if (sizeof($module->lappfunctions) > 0)
            {
                foreach ($module->lappfunctions as $appfunction)
                {
                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
                    {
                        return true;
                    }
                }
            }

            if (sizeof($module->rappfunctions) > 0)
            {
                foreach ($module->rappfunctions as $appfunction)
                {
                    if ($appfunction->label != "" && $_SESSION["wa_current_user"]->can_access_page($appfunction->access))
                    {
                        return true;
                    }
                }
            }

            return false;

        }

        function hide_inaccessible_menu_items()
        {
            global $hide_inaccessible_menu_items;

            if (!isset($hide_inaccessible_menu_items) || $hide_inaccessible_menu_items == 0)
            {
                return false;
            }

            else
            {
                return true;
            }
        }
    }

    function display_customer_topten()
    {
        global $path_to_root;;

        $pg = new graph();

        $today = Today();
        $title = customer_top($today, 10, 33, $pg);
        source_graphic($today, $title, _("Customer"), $pg);
        customer_trans($today);
        customer_recurrent_invoices($today);
    }

    function display_supplier_topten()
    {
        global $path_to_root;

        $pg = new graph();

        $today = Today();
        $title = supplier_top($today, 10, 33, $pg);
        source_graphic($today, $title, _("Supplier"), $pg);
        supplier_trans($today);
    }

    function display_stock_topten($manuf=false)
    {
        global $path_to_root;

        $pg = new graph();

        $today = Today();
        $title = stock_top($today, 10, 33, $manuf, $pg);
        $source = ($manuf) ? _("Manufacturing") : _("Items");
        source_graphic($today, $title, $source, $pg);
    }

    function display_dimension_topten()
    {
        global $path_to_root;

        $pg = new graph();

        $today = Today();
        $title = dimension_top($today, 10, 33, $pg);
        source_graphic($today, $title, _("Dimension"), $pg, 5);
    }

    function display_gl_info()
    {
        global $path_to_root;

        $pg = new graph();

        $today = Today();
        $title = gl_top($today, 33, $pg);
        source_graphic($today, $title, _("Class"), $pg, 5);
    }

    function display_all()
    {
        $today = Today();

        $pg = new graph();

        echo "<table width='100%'>";
        echo "<tr valign=top><td style='width:50%'>\n"; // outer table

        $title = customer_top($today, 3, 66, $pg);
        source_graphic($today, $title, _("Customer"), $pg);
        $title = supplier_top($today, 3, 66, $pg);
        source_graphic($today, $title, _("Supplier"), $pg);
        $title = stock_top($today, 3, 66, false, $pg);
        source_graphic($today, $title, _("Stock"), $pg);

        echo "</td><td style='width:50%'>\n";

        dimension_top($today, 3, 66);
        $title = gl_top($today, 66, $pg);
        source_graphic($today, $title, _("Class"), $pg, 5);
        stock_top($today, 3, 66, true);

        echo "</td></tr></table>\n";
    }

    function display_title($title, $colspan=2)
    {
        br();
        echo "<tr><td colspan=$colspan class='headingtext' style='text-align:center;border:0;height:40px;'>$title</td></tr>\n";
    }

    function customer_top($today, $limit=10, $width="33", &$pg=null)
    {
        $begin = begin_fiscalyear();
        $begin1 = date2sql($begin);
        $today1 = date2sql($today);
        $sql = "SELECT SUM((ov_amount + ov_discount) * rate * IF(trans.type = ".ST_CUSTCREDIT.", -1, 1)) AS total,d.debtor_no, d.name FROM
            ".TB_PREF."debtor_trans AS trans, ".TB_PREF."debtors_master AS d WHERE trans.debtor_no=d.debtor_no
            AND (trans.type = ".ST_SALESINVOICE." OR trans.type = ".ST_CUSTCREDIT.")
            AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no
            LIMIT $limit";
        $result = db_query($sql);
        $title = _("Top $limit customers in fiscal year");
        $th = array(_("Customer"), _("Amount"));
        start_table(TABLESTYLE, "width='$width%'");
        display_title($title, count($th));
        table_header($th);
        $k = 0; //row colour counter
        $i = 0;
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            $name = $myrow["debtor_no"]." ".$myrow["name"];
            label_cell($name);
            amount_cell($myrow['total']);
            if ($pg != null)
            {
                $pg->x[$i] = $name;
                $pg->y[$i] = $myrow['total'];
            }
            $i++;
            end_row();
        }
        end_table(2);
        return $title;
    }

    function supplier_top($today, $limit=10, $width="33", &$pg=null)
    {
        $begin = begin_fiscalyear();
        $begin1 = date2sql($begin);
        $today1 = date2sql($today);
        $sql = "SELECT SUM((trans.ov_amount + trans.ov_discount) * rate) AS total, s.supplier_id, s.supp_name FROM
            ".TB_PREF."supp_trans AS trans, ".TB_PREF."suppliers AS s WHERE trans.supplier_id=s.supplier_id
            AND (trans.type = ".ST_SUPPINVOICE." OR trans.type = ".ST_SUPPCREDIT.")
            AND tran_date >= '$begin1' AND tran_date <= '$today1' GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id
            LIMIT $limit";
        $result = db_query($sql);
        $title = _("Top $limit suppliers in fiscal year");
        $th = array(_("Supplier"), _("Amount"));
        start_table(TABLESTYLE, "width='$width%'");
        display_title($title, count($th));
        table_header($th);
        $k = 0; //row colour counter
        $i = 0;
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            $name = $myrow["supplier_id"]." ".$myrow["supp_name"];
            label_cell($name);
            amount_cell($myrow['total']);
            if ($pg != null)
            {
                $pg->x[$i] = $name;
                $pg->y[$i] = $myrow['total'];
            }
            $i++;
            end_row();
        }
        end_table(2);
        return $title;
    }

    function stock_top($today, $limit=10, $width="33", $manuf=false, &$pg=null)
    {
        $begin = begin_fiscalyear();
        $begin1 = date2sql($begin);
        $today1 = date2sql($today);
        $sql = "SELECT SUM((trans.unit_price * trans.quantity) * d.rate) AS total, s.stock_id, s.description,
            SUM(trans.quantity) AS qty FROM
            ".TB_PREF."debtor_trans_details AS trans, ".TB_PREF."stock_master AS s, ".TB_PREF."debtor_trans AS d
            WHERE trans.stock_id=s.stock_id AND trans.debtor_trans_type=d.type AND trans.debtor_trans_no=d.trans_no
            AND (d.type = ".ST_SALESINVOICE." OR d.type = ".ST_CUSTCREDIT.") ";
        if ($manuf)
            $sql .= "AND s.mb_flag='M' ";
        $sql .= "AND d.tran_date >= '$begin1' AND d.tran_date <= '$today1' GROUP by s.stock_id ORDER BY total DESC, s.stock_id
            LIMIT $limit";
        $result = db_query($sql);
        if ($manuf)
            $title = _("Top $limit Manufactured Items in fiscal year");
        else
            $title = _("Top $limit Sold Items in fiscal year");
        $th = array(_("Item"), _("Amount"), _("Quantity"));
        start_table(TABLESTYLE, "width='$width%'");
        display_title($title, count($th));
        table_header($th);
        $k = 0; //row colour counter
        $i = 0;
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            $name = $myrow["description"];
            label_cell($name);
            amount_cell($myrow['total']);
            qty_cell($myrow['qty']);
            if ($pg != NULL)
            {
                $pg->x[$i] = $name;
                $pg->y[$i] = $myrow['total'];
            }
            $i++;
            end_row();
        }
        end_table(2);
    }

    function dimension_top($today, $limit=10, $width="33", &$pg=null)
    {

        $begin = begin_fiscalyear();
        $begin1 = date2sql($begin);
        $today1 = date2sql($today);
        $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM
            ".TB_PREF."gl_trans AS t,".TB_PREF."dimensions AS d WHERE
            (t.dimension_id = d.id OR t.dimension2_id = d.id) AND
            t.tran_date >= '$begin1' AND t.tran_date <= '$today1' GROUP BY d.id ORDER BY total DESC LIMIT $limit";
        $result = db_query($sql, "Transactions could not be calculated");
        $title = _("Top $limit Dimensions in fiscal year");
        $th = array(_("Dimension"), _("Amount"));
        start_table(TABLESTYLE, "width='$width%'");
        display_title($title, count($th));
        table_header($th);
        $k = 0; //row colour counter
        $i = 0;
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            $name = $myrow['reference']." ".$myrow["name"];
            label_cell($name);
            amount_cell($myrow['total']);
            if ($pg != null)
            {
                $pg->x[$i] = $name;
                $pg->y[$i] = abs($myrow['total']);
            }
            $i++;
            end_row();
        }
        end_table(2);
    }

    function gl_top($today, $width="33", &$pg=null)
    {
        $begin = begin_fiscalyear();
        $begin1 = date2sql($begin);
        $today1 = date2sql($today);
        $sql = "SELECT SUM(amount) AS total, c.class_name, c.ctype FROM
            ".TB_PREF."gl_trans,".TB_PREF."chart_master AS a, ".TB_PREF."chart_types AS t,
            ".TB_PREF."chart_class AS c WHERE
            account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid
            AND IF(c.ctype > 3, tran_date >= '$begin1', tran_date >= '0000-00-00')
            AND tran_date <= '$today1' GROUP BY c.cid ORDER BY c.cid";
        $result = db_query($sql, "Transactions could not be calculated");
        $title = _("Class Balances");
        start_table(TABLESTYLE2, "width='$width%'");
        display_title($title);
        $i = 0;
        $total = 0;
        while ($myrow = db_fetch($result))
        {
            if ($myrow['ctype'] > 3)
            {
                $total += $myrow['total'];
                $myrow['total'] = -$myrow['total'];
                if ($pg != null)
                {
                    $pg->x[$i] = $myrow['class_name'];
                    $pg->y[$i] = abs($myrow['total']);
                }
                $i++;
            }
            label_row($myrow['class_name'], number_format2($myrow['total'], user_price_dec()),
                "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
        }
        $calculated = _("Calculated Return");
        label_row("&nbsp;", "");
        label_row($calculated, number_format2(-$total, user_price_dec()),
            "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
        if ($pg != null)
        {
            $pg->x[$i] = $calculated;
            $pg->y[$i] = -$total;
        }
        end_table(2);
    }

    function source_graphic($today, $title, $source, $pg, $type=2)
    {
        $pg->title     = $title;
        $pg->axis_x    = $source;
        $pg->axis_y    = _("Amount");
        $pg->graphic_1 = $today;
        $pg->type      = $type;
        $pg->skin      = 1;
        $pg->built_in  = false;
        $filename = company_path(). "/pdf_files/". uniqid("").".png";
        $pg->display($filename, true);
        start_table(TABLESTYLE);
        start_row();
        echo "<td>";
        echo "<img src='$filename' border='0' alt='$title'>";
        echo "</td>";
        end_row();
        end_table(1);
    }

    function customer_trans($today)
    {
        $today = date2sql($today);

        $sql = "SELECT trans.trans_no, trans.reference,    trans.tran_date, trans.due_date, debtor.debtor_no,
            debtor.name, branch.br_name, debtor.curr_code,
            (trans.ov_amount + trans.ov_gst + trans.ov_freight
                + trans.ov_freight_tax + trans.ov_discount)    AS total,
            (trans.ov_amount + trans.ov_gst + trans.ov_freight
                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) AS remainder,
            DATEDIFF('$today', trans.due_date) AS days
            FROM ".TB_PREF."debtor_trans as trans, ".TB_PREF."debtors_master as debtor,
                ".TB_PREF."cust_branch as branch
            WHERE debtor.debtor_no = trans.debtor_no AND trans.branch_code = branch.branch_code
                AND trans.type = ".ST_SALESINVOICE." AND (trans.ov_amount + trans.ov_gst + trans.ov_freight
                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) > ".FLOAT_COMP_DELTA."
                AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC";
        $result = db_query($sql);
        $title = db_num_rows($result) . _(" overdue Sales Invoices");
        br(1);
        display_heading($title);
        br();
        $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Customer"), _("Branch"), _("Currency"),
            _("Total"), _("Remainder"),    _("Days"));
        start_table(TABLESTYLE);
        table_header($th);
        $k = 0; //row colour counter
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            label_cell(get_trans_view_str(ST_SALESINVOICE, $myrow["trans_no"]));
            label_cell($myrow['reference']);
            label_cell(sql2date($myrow['tran_date']));
            label_cell(sql2date($myrow['due_date']));
            $name = $myrow["debtor_no"]." ".$myrow["name"];
            label_cell($name);
            label_cell($myrow['br_name']);
            label_cell($myrow['curr_code']);
            amount_cell($myrow['total']);
            amount_cell($myrow['remainder']);
            label_cell($myrow['days'], "align='right'");
            end_row();
        }
        end_table(2);
    }

    function calculate_next_invoice($myrow)
    {
        if ($myrow["last_sent"] == '0000-00-00')
            $next = sql2date($myrow["begin"]);
        else
            $next = sql2date($myrow["last_sent"]);
        $next = add_months($next, $myrow['monthly']);
        $next = add_days($next, $myrow['days']);
        return add_days($next,-1);
    }

    function customer_recurrent_invoices($today)
    {
        $result = get_recurrent_invoices($today);
        $title = _("Overdue Recurrent Invoices");
        br(1);
        display_heading($title);
        br();
        $th = array(_("Description"), _("Template No"),_("Customer"),_("Branch")."/"._("Group"),_("Next invoice"));
        start_table(TABLESTYLE, "width=70%");
        table_header($th);
        $k = 0;
        while ($myrow = db_fetch($result))
        {
            if (!$myrow['overdue'])
                continue;
            alt_table_row_color($k);

            label_cell($myrow["description"]);
            label_cell(get_customer_trans_view_str(ST_SALESORDER, $myrow["order_no"]));
            if ($myrow["debtor_no"] == 0)
            {
                label_cell("");

                label_cell(get_sales_group_name($myrow["group_no"]));
            }
            else
            {
                label_cell(get_customer_name($myrow["debtor_no"]));
                label_cell(get_branch_name($myrow['group_no']));
            }
            label_cell(calculate_next_invoice($myrow),  "align='center'");
            end_row();
        }
        end_table(2);
    }

    function supplier_trans($today)
    {
        $today = date2sql($today);
        $sql = "SELECT trans.trans_no, trans.reference, trans.tran_date, trans.due_date, s.supplier_id,
            s.supp_name, s.curr_code,
            (trans.ov_amount + trans.ov_gst + trans.ov_discount) AS total,
            (trans.ov_amount + trans.ov_gst + trans.ov_discount - trans.alloc) AS remainder,
            DATEDIFF('$today', trans.due_date) AS days
            FROM ".TB_PREF."supp_trans as trans, ".TB_PREF."suppliers as s
            WHERE s.supplier_id = trans.supplier_id
                AND trans.type = ".ST_SUPPINVOICE." AND (ABS(trans.ov_amount + trans.ov_gst +
                    trans.ov_discount) - trans.alloc) > ".FLOAT_COMP_DELTA."
                AND DATEDIFF('$today', trans.due_date) > 0 ORDER BY days DESC";
        $result = db_query($sql);
        $title = db_num_rows($result) . _(" overdue Purchase Invoices");
        br(1);
        display_heading($title);
        br();
        $th = array("#", _("Ref."), _("Date"), _("Due Date"), _("Supplier"), _("Currency"), _("Total"),
            _("Remainder"),    _("Days"));
        start_table(TABLESTYLE);
        table_header($th);
        $k = 0; //row colour counter
        while ($myrow = db_fetch($result))
        {
            alt_table_row_color($k);
            label_cell(get_trans_view_str(ST_SUPPINVOICE, $myrow["trans_no"]));
            label_cell($myrow['reference']);
            label_cell(sql2date($myrow['tran_date']));
            label_cell(sql2date($myrow['due_date']));
            $name = $myrow["supplier_id"]." ".$myrow["supp_name"];
            label_cell($name);
            label_cell($myrow['curr_code']);
            amount_cell($myrow['total']);
            amount_cell($myrow['remainder']);
            label_cell($myrow['days'], "align='right'");
            end_row();
        }
        end_table(2);
    }

Get it updated in Repo also. Thanks alot

Thanks @apmuthu and @notrinos for your help. I compared @apmuthu's suggestion with Dynamic theme and finally got the solution.

Add following lines at Line: 101

    if (!$no_menu)
        {
                    add_access_extensions();

Close the If statement at Line: 169

After applying apmuthus fix the error code appears on Line 142

Undefined index: SA_CSVIMPORT in file: C:\xampp\htdocs\bx242\includes\current_user.inc at line 192
C:\xampp\htdocs\bx242\includes\current_user.inc:201:    (current_user Object)->can_access('SA_CSVIMPORT')
C:\xampp\htdocs\bx242\themes\dropdown-new\renderer.php:142:    (current_user Object)->can_access_page('SA_CSVIMPORT')
C:\xampp\htdocs\bx242\includes\page\header.inc:164:    (renderer Object)->menu_header('Display Setup','','')
C:\xampp\htdocs\bx242\includes\main.inc:44:    page_header('Display Setup','','','','','')
C:\xampp\htdocs\bx242\admin\display_prefs.php:16:    page('Display Setup')

Seems @apmuthu's fixs working.

really

@apmuthu I have applied your code but still problem exists.

If Dynamic theme is latest than Dropdown then in Download package instead of Dropdown, Dynamic must have been added.

its on Line 154

<?php
/**********************************************************************
    Copyright (C) FrontAccounting, LLC.
    Released under the terms of the GNU General Public License, GPL, 
    as published by the Free Software Foundation, either version 3 
    of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
// Author: Joe Hunt, 17/11/2015. Upgraded to release 2.4. 10/11/2015.

    class renderer
    {
        function wa_get_apps($title, $applications, $sel_app)
        {
            foreach($applications as $app)
            {
                foreach ($app->modules as $module)
                {
                    $apps = array();
                    foreach ($module->lappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    foreach ($module->rappfunctions as $appfunction)
                        $apps[] = $appfunction;
                    $application = array();    
                    foreach ($apps as $application)    
                    {
                        $url = explode('?', $application->link);
                        $app_lnk = $url[0];                    
                        $pos = strrpos($app_lnk, "/");
                        if ($pos > 0)
                        {
                            $app_lnk = substr($app_lnk, $pos + 1);
                            $lnk = $_SERVER['REQUEST_URI'];
                            $url = explode('?', $lnk);
                            $asset = false;
                            if (isset($url[1]))
                                $asset = strstr($url[1], "FixedAsset");
                            $lnk = $url[0];                    
                            $pos = strrpos($lnk, "/");
                            $lnk = substr($lnk, $pos + 1);
                            if ($app_lnk == $lnk)  
                            {
                                $acc = access_string($app->name);
                                $app_id = ($asset != false ? "assets" : $app->id);
                                return array($acc[0], $module->name, $application->label, $app_id);
                            }    
                        }    
                    }
                }
            }
            return array("", "", "", $sel_app);
        }
        
        function wa_header()
        {
            page(_($help_context = "Main Menu"), false, true);
        }

        function wa_footer()
        {
            end_page(false, true);
        }
        function shortcut($url, $label) 
        {
            echo "<li>";
            echo menu_link($url, $label);
            echo "</li>";
        }
        function menu_header($title, $no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version;

            $sel_app = $_SESSION['sel_app'];
            echo "<div class='fa-main'>\n";
            if (!$no_menu)
            {
                $applications = $_SESSION['App']->applications;
                $local_path_to_root = $path_to_root;
                $pimg = "<img src='$local_path_to_root/themes/".user_theme()."/images/preferences.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Preferences')."'>&nbsp;&nbsp;";
                $limg = "<img src='$local_path_to_root/themes/".user_theme()."/images/lock.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Change Password')."'>&nbsp;&nbsp;";
                $img = "<img src='$local_path_to_root/themes/".user_theme()."/images/on_off.png' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Logout')."'>&nbsp;&nbsp;";
                $himg = "<img src='$local_path_to_root/themes/".user_theme()."/images/help.gif' style='width:14px;height:14px;border:0;vertical-align:middle;padding-bottom:3px;' alt='"._('Help')."'>&nbsp;&nbsp;";
                echo "<div id='header'>\n";
                echo "<ul>\n";
                echo "  <li><a href='$local_path_to_root/admin/display_prefs.php?'>$pimg" . _("Preferences") . "</a></li>\n";
                echo "  <li><a href='$local_path_to_root/admin/change_current_user_password.php?selected_id=" . $_SESSION["wa_current_user"]->username . "'>$limg" . _("Change password") . "</a></li>\n";
                if ($SysPrefs->help_base_url != null)
                    echo "  <li><a target = '_blank' onclick=" .'"'."javascript:openWindow(this.href,this.target); return false;".'" '. "href='". 
                        help_url()."'>$himg" . _("Help") . "</a></li>";
                echo "  <li><a href='$path_to_root/access/logout.php?'>$img" . _("Logout") . "</a></li>";
                echo "</ul>\n";
                $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif";
                echo "<h1>$SysPrefs->power_by $version<span style='padding-left:300px;'><img id='ajaxmark' src='$indicator' align='center' style='visibility:hidden;'></span></h1>\n";
                echo "</div>\n"; // header
                                
                echo "<div id='cssmenu'>\n";
                echo "<ul>\n";
                $i = 0;
                $account = $this->wa_get_apps($title, $applications, $sel_app);
                foreach($applications as $app)
                {
                    if ($_SESSION["wa_current_user"]->check_application_access($app))
                    {
                        $acc = access_string($app->name);
                        $class = ($account[3] == $app->id ? "active" : "");
                        $n = count($app->modules);
                        if ($n)
                            $class .= " has-sub";
                        $dashboard = "";    
                        $u_agent = $_SERVER['HTTP_USER_AGENT']; 
                        if (preg_match('/android/i', $u_agent) && preg_match('/mobile/i', $u_agent)) {
                            $link = "#'";
                            $dashboard = "$local_path_to_root/index.php?application=$app->id";
                        }
                        else
                            $link = "$local_path_to_root/index.php?application=$app->id '$acc[1]";
                        echo "  <li class ='$class'><a href='$link><span>" . $acc[0] . "</span></a>\n";
                        if (!$n)
                        {
                            echo "  </li>\n";
                            continue;
                        }    
                        echo "    <ul>\n";
                           if ($dashboard !="")
                            echo "      <li><a href='$dashboard'><span><font color='red'>"._("Dashboard")."</font></span></a></li>\n";
                        foreach ($app->modules as $module)
                        {
                            if (!$_SESSION["wa_current_user"]->check_module_access($module))
                                continue;
                             echo "      <li class='has-sub'><a href='#'><span>$module->name</span></a>\n"; 
                             $apps2 = array();
                             foreach ($module->lappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            foreach ($module->rappfunctions as $appfunction)
                                $apps2[] = $appfunction;
                            $application = array();    
                               $n = count($apps2);
                               $class = "";
                               if ($i > 5)
                                   $class = "class='align_right'";
                            if ($n)
                                echo "        <ul $class>\n";
                            else
                            {
                                echo "      </li>\n";
                                continue;
                            }    
                            foreach ($apps2 as $application)    
                            {
                                $lnk = access_string($application->label);
                                if ($_SESSION["wa_current_user"]->can_access_page($application->access))
                                {
                                    if ($application->label != "")
                                    {
                                        echo "          <li><a href='$path_to_root/$application->link'><span>$lnk[0]</span></a></li>\n";
                                    }
                                }
                                elseif (!$_SESSION["wa_current_user"]->hide_inaccessible_menu_items())    
                                    echo "          <li><a href='#'><span><font color='gray'>$lnk[0]</font></span></a></li>\n";
                            }
                            if ($n)
                                echo "        </ul>\n";    
                            echo "      </li>\n";
                        }
                        echo "    </ul>\n"; // menu
                    }
                    echo"  </li>\n";
                    $i++;
                }    
                echo "</ul>\n"; 
                echo "</div>\n"; // menu
            }
            echo "<div class='fa-body'>\n";
            if ($no_menu)
                echo "<br>";
            elseif ($title && !$no_menu && !$is_index)
            {
                echo "<div class='fa-content'>\n";
                echo "<center><table id='title'><tr><td width='100%' class='titletext'>$title</td>"
                ."<td align=right>"
                .(user_hints() ? "<span id='hints'></span>" : '')
                ."</td>"
                ."</tr></table></center>";
            }
        }

        function menu_footer($no_menu, $is_index)
        {
            global $path_to_root, $SysPrefs, $version, $db_connections;
            include_once($path_to_root . "/includes/date_functions.inc");

            if (!$no_menu && !$is_index)
                echo "</div>\n"; // fa-content
            echo "</div>\n"; // fa-body
            if (!$no_menu)
            {
                   echo "<script type='text/javascript'>if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
                          {document.getElementById('cssmenu').style.position = 'fixed';}</script>\n";
                echo "<div class='fa-footer'>\n";
                if (isset($_SESSION['wa_current_user']))
                {
                    echo "<span class='power'><a target='_blank' href='$SysPrefs->power_url'>$SysPrefs->power_by $version</a></span>\n";
                    echo "<span class='date'>".Today() . "&nbsp;" . Now()."</span>\n";
                    echo "<span class='date'>" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . "</span>\n";
                    echo "<span class='date'>" . $_SERVER['SERVER_NAME'] . "</span>\n";
                    echo "<span class='date'>" . $_SESSION["wa_current_user"]->name . "</span>\n";
                    echo "<span class='date'>" . _("Theme:") . " " . user_theme() . "</span>\n";
                    echo "<span class='date'>".show_users_online()."</span>\n";
                }
                echo "</div>\n"; // footer
            }
            echo "</div>\n"; // fa-main
        }

        function display_applications(&$waapp)
        {
            global $path_to_root;

            $sel = $waapp->get_selected_application();
            meta_forward("$path_to_root/admin/dashboard.php", "sel_app=$sel->id");    
            end_page();
            exit;
        }    
    }
    

Below is the Error Code from the Core renderer.php without any customization

Undefined index: SA_CSVIMPORT in file: C:\xampp\htdocs\FA242ORG\includes\current_user.inc at line 192
C:\xampp\htdocs\FA242ORG\includes\current_user.inc:201:    (current_user Object)->can_access('SA_CSVIMPORT')
C:\xampp\htdocs\FA242ORG\themes\dropdown\renderer.php:154:    (current_user Object)->can_access_page('SA_CSVIMPORT')
C:\xampp\htdocs\FA242ORG\includes\page\header.inc:158:    (renderer Object)->menu_header('Search Outstanding Purchase Orders','','')
C:\xampp\htdocs\FA242ORG\includes\main.inc:44:    page_header('Search Outstanding Purchase Orders','','','','function openWindow(url, title) { var left = (screen.width - 900) / 2; var top = (screen.height - 500) / 2; return window.open(url, title, 'width=900,height=500,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes'); } function lookupWindow(url, title) { var u = url.split('#'); if (u.length == 2) { var element = document.getElementById(u[1]); var options = element.options; url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value; } openWindow(url, title); }','')
C:\xampp\htdocs\FA242ORG\purchasing\inquiry\po_search.php:25:    page('Search Outstanding Purchase Orders','','','','function openWindow(url, title) { var left = (screen.width - 900) / 2; var top = (screen.height - 500) / 2; return window.open(url, title, 'width=900,height=500,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes'); } function lookupWindow(url, title) { var u = url.split('#'); if (u.length == 2) { var element = document.getElementById(u[1]); var options = element.options; url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value; } openWindow(url, title); }')
    

485

(9 replies, posted in Setup)

For a permanent solution I have tried dropmysite.com and its very fast to backup and restore database in case of any failure.

The issue still exists

Undefined index: SA_CSVIMPORT in file: C:\xampp\htdocs\bx242\includes\current_user.inc at line 192
C:\xampp\htdocs\bx242\includes\current_user.inc:201:    (current_user Object)->can_access('SA_CSVIMPORT')
C:\xampp\htdocs\bx242\themes\default\renderer.php:198:    (current_user Object)->can_access_page('SA_CSVIMPORT')
C:\xampp\htdocs\bx242\includes\page\header.inc:164:    (renderer Object)->menu_header('Dashboard','','')
C:\xampp\htdocs\bx242\includes\main.inc:44:    page_header('Dashboard','','','','function openWindow(url, title) { var left = (screen.width - 800) / 2; var top = (screen.height - 500) / 2; return window.open(url, title, 'width=800,height=500,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes'); } function lookupWindow(url, title) { var u = url.split('#'); if (u.length == 2) { var element = document.getElementById(u[1]); var options = element.options; url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value; } openWindow(url, title); }','')
C:\xampp\htdocs\bx242\admin\dashboard.php:27:    page('Dashboard','','','','function openWindow(url, title) { var left = (screen.width - 800) / 2; var top = (screen.height - 500) / 2; return window.open(url, title, 'width=800,height=500,left='+left+',top='+top+',screenX='+left+',screenY='+top+',status=no,scrollbars=yes'); } function lookupWindow(url, title) { var u = url.split('#'); if (u.length == 2) { var element = document.getElementById(u[1]); var options = element.options; url = u[0] + '&' + u[1] + '=' + options[element.selectedIndex].value; } openWindow(url, title); }')

This issue is for all external extensions and only for this theme Dropdown

Both themes have same core function calls but why this theme showing error about all custom modules' SECURITY AREAS if debug mode is on and not showing up custom modules?

These errors can be ignored if debug mode is set to off but problem is that the link of custom modules are not showing up.

This theme is now added to the default repo so its need to be fixed. I tried but unable to find the exact reason. @joe may help us here!!

488

(9 replies, posted in Setup)

One of my database size has grown upto 240 MB. and now I am unable to take its backup. The script breaks on the way. What is the solution to it?

Hello,

Dropdown theme is showing error as below in can_access_page function as below

Undefined index: SA_CSVIMPORT in file: /home/boxygenb/public_html/fa/fa24/includes/current_user.inc at line 192
/home/boxygenb/public_html/fa/fa24/includes/current_user.inc:201:    (current_user Object)->can_access('SA_CSVIMPORT')
/home/boxygenb/public_html/fa/fa24/themes/dropdown/renderer.php:142:    (current_user Object)->can_access_page('SA_CSVIMPORT')
/home/boxygenb/public_html/fa/fa24/includes/page/header.inc:158:    (renderer Object)->menu_header('Users','','')
/home/boxygenb/public_html/fa/fa24/includes/main.inc:44:    page_header('Users','','','','','')
/home/boxygenb/public_html/fa/fa24/admin/users.php:16:    page('Users')

And the extension is also not appearing. While in Default theme no such errors and extensions are shown.

Please check it.

You can reproduce error at Here

id: admin
pass: Pakistan1947

Yes please have a look into this. Also sometimes it happens that auto increment of the reference gets stopped without any reason. Unless you manually go to the Forms Setup and increase it.

The next reference number routine shall check the reference table as well as the transaction table and If any reference in transactions table is higher than the reference in reference table than it shall automatically takes the next reference from the Transaction table and update the next reference in reference table.

491

(18 replies, posted in Report Bugs here)

@dz I am not getting any error if I select more than one customer/suppliers (each should be different) and it is reflecting in each parties ledger, balances, aging etc.

At some places the view is distorted just like in Journal Inquiry View but technically the transaction is OK.

You may call locally at my number to discuss further if you want that I am going to PM you.

Hello, There is a change in behaviour while adding Items on the Fly while creating invoices in FA24.

When we press F4 the dialog opens. When a New Item is created and then selected to be added as a Line Item in Invoice, the Select Button doesn't appear at the bottom. This is unlike in FA23.

Please do the whole process to reproduce the behavior. Because when you will press F4, you will see the select button, then if you select any other item you will see the select button, but when you create new item and then select it the Select button will disappear.

Thanks

493

(4 replies, posted in Reporting)

You mean to hide Reports Tabs?

I defined like this but it didn't work

class hooks_masjid extends hooks {
    var $module_name = 'masjid';
    var $extn_systypes_array ;

    /*
        Install additonal menu options provided by module
    */
    function install_options($app) {
        global $path_to_root, $systypes_array;

        $extn_systypes_array = $systypes_array;
        $extn_systypes_array[ST_SALESINVOICE] = _('Donations');

@cambell are you using this module currently? Because I have faced a very strange behaviour from this module. I entered almost 10 recurring invoices of 10 different customers. ON due date I selected the Check All Check Box and Clicked the Generate Invoice BUtton to send invoices to all.

Invoices were created but each customer has received invoice ten times in email. It has simply multiplied the number of times each email with number of recurring invoices. sad

496

(18 replies, posted in Report Bugs here)

@dz are you using latest version of FA?

In FA2.4+ if you select Accounts REceiveable Code in Account Description in Journal Entry It creates another column automatically to enter CounterParty. This works same for Accounts Payable also.

Is it possible to change the $systypes_array headings from any given extension without changing the Core?

For example for ST_SALESINVOICE I want the heading to be displayed as 'Donations' so can I change it from the extension?

Regards.

498

(4 replies, posted in Reporting)

I got it

unset ($reports->ar_reports [RC_CUSTOMER][102]);

will do this.

499

(4 replies, posted in Reporting)

Through any extension we can add reports to the Report Class using

$reports->addReport() function.

My question is that is it possible to remove reports from the report class through any given extension. The idea is that sometimes all reports are not important for every one so while creating extension can we hide unwanted reports from the Report Class?

Thanks in advance.

500

(18 replies, posted in Report Bugs here)

It happens only when counterparty is used and it multiplies the number of times the counterpaties are added to voucher.