Topic: reminders in 2.4

in 2.3 I had a plugin, I believe it was part of the dashboard extension, called reminders.  I could configure it to schedule and display reminders under sales/purchases/etc.  I still have a table in the database called dashboard_reminders, but I don't find an option in 2.4 for it anymore, nor do I find any reference to it in the code.  Is there any way to get that back?
Also in 2.3 using the dashboard extension with the exclusive_db theme, one could configure the layout and some options of the various widgets, but that also seems to be missing in 2.4.

Re: reminders in 2.4

The dashboard theme must be installed
and then the dashboard extension as well
and then activated too.
Backup before installing them.

If you are upgrading,
take a backup,
then de-activate the dashboard extension,
choose a normal standard theme and
uninstall the dashboard theme and extension.
Now upgrade the FA, install the dashboard theme and extension and activate and choose them. Import your reminders selectively from your backup.

Re: reminders in 2.4

Hi Apmuthu,

Thanks for your response.  The upgrade already happened, and I have already made entries.  I also have my server running php7 now, which means if I were to roll back to 2.3 I would not be able to log in and upgrade that way.  I have already tried uninstalling and reinstalling the extension and the theme, but the configuration options never showed up.  I will see if there are some other ways to do that and report back with what happens...

4 (edited by apmuthu 09/16/2016 05:53:28 pm)

Re: reminders in 2.4

Make sure that the said extension's features are enabled for the System Administrator Role.

You might want to try a fresh installation of FA 2.4 and then update the database with the relevant tables' data from your current upgraded backup.

Re: reminders in 2.4

Hi Apmuthu,

Your help is, as always, truly appreciated.

my upgrade path went like this: upgrade server, find can't log in to FA. back everything up.  Unpack 2.4 over existing installation, get logged in, to to setup=>software upgrade, see option to upgrade to 2.4, do it and get no error.  mess around and find lots of oddness, like enable new theme, log out and in, and find new theme not enabled, but selectable in preferences.  Moved entire installation out of the way, and used just the 2.4 files as downloaded from sourceforge.  copied over the company/0/files, setup config_db.php.  still saw odd things, so found a file you posted with fixes, checked that out and found the CHANGELOG was more current than the download from sourceforge, so unpacked that over the new 2.4 install.

I say this because it seems I will have more questions in the near future, because I still have a number of errors that show up, Only variables should be passed by reference in file: $WEBROOT/frontaccounting.php at line 79 for example, and the occasional unexpected logout, and other odd things here and there.

When should I just make a bug report in mantis vs asking here first?  should I be putting this and the above errors in mantis because it is something that didn't work as expected, or should I generally ask here first and then put something in mantis after it has been identified as a bug and not a user/computer problem?

Since your last post, I have removed all themes and extensions from the web interface, and gone in and scrubbed out the themes and modules directories, leaving only the default theme.  This makes it so the web interface has a dashboard link beside preferences, and I believe this is builtin and thus expected as per a post I found at kvcodes.com

After that I installed the dashboard extension and activated it, then installed the dashboard theme.  I then went under setup=>access setup, and now I find I can enable dashboard setup and reminders.  After logging out and logging in again, I can now find and click on the links under setup=>Miscillaneous, but the reminders link gives me a blank page with error:

Cannot redeclare text_input() (previously declared in$WEBROOT /includes/ui/ui_input.inc:507) in $WEBROOT/modules/dashboard/includes/dashboard_ui.inc on line 28

clicking the dashboard setup link gives the same error, but not on a blank page, just in the main frame of the window.

Is there something else I need to do?

6 (edited by apmuthu 09/17/2016 04:22:19 am)

Re: reminders in 2.4

The function text_input() is declared in FA 2.4RC1 only once in includes/ui_input.inc. If the said file gets included more than once, then any such include / require should be made include_once / require_once. Removal of such seemingly redundant include / require should be done with caution as it may not always be redundant.

Dashboard extension v2.4.0.1 and dashboard_theme v2.4.0.1 are available to be installed via the official FA 2.4 extensions repo. Dashboard hooks are already present in FA 2.4 and as the said function above gets re-declared when using these plugins, they must be fixed.

Alternatively, using disposable functions / a check and unload if present can be attempted before re-defining the said function or naming it differently and using this new name in all dashboard functions (will need to be cascaded into all the dashboard type themes). Lets avoid namespaces.....and PECL runkit / APD's rename_function....

@joe: your thoughts?

Re: reminders in 2.4

Still think something is broken here, but was working out a bank transfer so I could make a journal entry from a different bank account, when I figured out I could accomplish the same GL entries using a bank payment.  So good now, thanks.

Re: reminders in 2.4

The Bank Payment is the correct way to go since it also labels it as a different voucher type used by FA in it's processing of payments allocations.

9 (edited by toHZLjGk 07/01/2017 06:15:34 pm)

Re: reminders in 2.4

Hi Apmuthu, hi bobloblian, dear all,

I also have the error "Cannot redeclare text_input()..."/ white screen (FA 2.4.1 with a prolonging update history) in Dashboard and Reminder Setup. As described here, I uninstalled, re-installed, deactivated, activated,disabled, enabled, choose default and dashboard themes, logged in and out, without result. Please advise.

Regards,

Peter

Re: reminders in 2.4

Clear browser cache. State versions of PHP/MySQL and OS and make sure you have the latest GitMaster version of FA.

Re: reminders in 2.4

Cache cleared, no avail. Php 5.6.28, MySQL 5.5.38, Linux, FA 2.4.1 (downloaded from SourceForge, modified 2017-05-22). Dashboard & Reminders used to work in FA 2.3.x.

Re: reminders in 2.4

Take latest Git Master or take the changed files from this post.

Dashboard is included in the FA 2.4.1. You may at best need the extension and make sure that the includes/dashboard.inc does not get overwritten or superseded. You can try to remove the old dashboard theme and extension first before upgrading and then install them afresh aferwards.

Do not forget to activate the dashboard for your specific company when logged in on the default company. When in the target company, make sure to enable ti for the access roles and permissions, logout, clear cache, close all browser instances and login again.

Re: reminders in 2.4

Hi Apmuthu,

Thank you for your help! Yet something must be terribly wrong here. I meticulously followed your instructions and I still get these "Cannot redeclare text_input()"/ blank screen errors, even in an completely new instance, freshly installed from your Git Master link, and looked up in a cacheless browser...

Any further suggestions?

Regards,

Peter

Re: reminders in 2.4

The function text_input() is available in modules/dashboard/includes/dashboard_ui.inc and is executed first. Therefore when the same function defined in includes/ui/ui_input.inc gets executed later, the said error arises. Hence we need to modify the function in the latter file to be executed only if the said function is not defined as yet when it is executed. The code in the latter file at line 507 onwards:

function text_input($name, $value=null, $size='', $max='', $title='', $params='')
{
    if ($value === null)
        $value = get_post($name);

    return "<input $params type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" value=\"$value\""
        .($title ? " title='$title'" : '')
        .">";
}

should be wrapped like:

if (!function_exists('text_input')) {
function text_input($name, $value=null, $size='', $max='', $title='', $params='')
{
    if ($value === null)
        $value = get_post($name);

    return "<input $params type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" value=\"$value\""
        .($title ? " title='$title'" : '')
        .">";
}
}

15 (edited by toHZLjGk 07/04/2017 09:48:21 pm)

Re: reminders in 2.4

Hi apmuthu,

I wrapped up lines 507-515 from ui_input.inc as you suggested, which resulted in a shift of the error code from line 507 to 508. Then I unwrapped these code lines again and wrapped up lines 28-47 in dashboard_ui.inc.

if (!function_exists('text_input')) {
function text_input($label, $name, $value=null, $size="", $max="", $title=false,
    $labparams="", $post_label="", $inparams="")
{
    global $Ajax;

    default_focus($name);
    if ($label != null)
        label_cell($label, $labparams);

    if ($value === null)
        $value = get_post($name);
    echo "<input $inparams type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" value=\"$value\""
        .($title ? " title='$title'" : '')
        .">";

    if ($post_label != "")
        echo " " . $post_label;

    $Ajax->addUpdate($name, $name, $value);
}
}

This resulted in an errorless Dashboard setup screen and a non functioning Reminder setup screen with error code "Undefined variable: use_date_picker in file: /X/X/X/X/public_html/fa/modules/dashboard/reminder_setup.php at line 20". So function text_input() seems to be executed in dashboard_ui.inc later... Do you agree, can I leave it this way?

After I exchanged line 20 of reminder_setup.php

if ($use_date_picker)
$js .= get_js_date_picker();

with

if (user_use_date_picker ()){
    $js .= get_js_date_picker();
 }

everthing seems to work fine. Is this the way to go or should the variable "$use_date_picker" be used somehow. Please advice on both edits.

Regards,

Peter

Re: reminders in 2.4

Did you just swap the last part without wrapping any of the functions? If so we may need it to be as you described. There is no $use_date_picker at all in FA 2.4.1 as it is only a property in the user_prefs class.

Actually, the said function text_input is just defined in the extension with extra parameters and different order as well since a new parameter is at the beginning. It is not used anywhere in the extension. It is also not used in the dashboard_theme as well. We may consider removing this function in the extension. If this function gets used anywhere then the parameters and their order will affect such usage.

All instances in the core use the following construct:

$js = "";
if (user_use_date_picker())
    $js = get_js_date_picker();

@joe?

The original function in the core is used in the standard functions text_cells() and editor_view().

Committed in my FA24Extensions Repo.

Re: reminders in 2.4

In 2.4 all the global defined variables in config.php is assembled into the global $SysPrefs variable, so the name of the global variables is now $SysPrefs->use_date_picker. Then we only need to declare the $SysPrefs variable as global.
However if you are using the old $use_date_picker in an extension and you declare this as global in your routines is should work adequate.
For simplicity we have surrounded the new global members by macros, like user_use_date_picker();

There should be no occurrencies of the old $use_date_picker in the core, besides the one in config.php.

/Joe

Re: reminders in 2.4

The variable $use_date_picker is not in the config.default.php file in FA 2.4.1+.

Re: reminders in 2.4

Ok, sorry my mistake. Then it is per default set to 1 in the sys_pref class. That is to say that the $SysPref->use_date_picker is set to 1 per default.

/Joe

Re: reminders in 2.4

Hence using the wrapper function user_use_date_picker() obviates the need to globalise $SysPrefs here.
Thanks.

Please update the extensions for FA 2.4.1.