how to manage auxillary data

40 views
Skip to first unread message

tom wible

unread,
Dec 27, 2023, 9:06:02 AM12/27/23
to Xataface
i maintain a database of homeowner dues, and have a utility function to calculate late fees, based on a due date that i've hard-coded, as well as defaulting to the current date.

what would be the xataface way to handle this? simply a table of those values?
and happy holidays 2 all;-)

Steve Hannah

unread,
Dec 27, 2023, 11:03:44 AM12/27/23
to xata...@googlegroups.com
There are a few different ways you could handle this.  You could create a "calculated" field in the delegate class that produces this value, then make this field visible in the Xataface UI via the visibility:list or visibility:view

Alternatively you could create a table that actually stores this value, and run a cron script to recalculate these values daily.

--
You received this message because you are subscribed to the Google Groups "Xataface" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xataface+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xataface/0d10956a-b9c8-42d9-b070-7ba4fd41d815n%40googlegroups.com.


--
Steve Hannah
Web Lite Solutions Corp.

tom wible

unread,
Dec 27, 2023, 12:25:52 PM12/27/23
to Xataface
thanx, steve...i can easily edit my util func/config files to maintain the values, but i need to prepare for my understudy to take over if i get hit by a bus;-) 
is there a way to retrieve these values 1x & cache them  to make available to the util func, rather than retrieving each time the util func is called? 

tom wible

unread,
Jan 27, 2024, 8:57:36 AMJan 27
to Xataface
just getting back to this...how about url query parameters? i'm thinking "?-table=properties&-due_date=2024-03-15"
and where would i define those & use them? 
thx

tom wible

unread,
Jan 27, 2024, 9:05:05 AMJan 27
to Xataface
the manual also says "add your own configuration directives as well (which you access in your PHP and Action definitions)."
are there examples of this?

Steve Hannah

unread,
Jan 27, 2024, 9:17:28 AMJan 27
to xata...@googlegroups.com
> "?-table=properties&-due_date=2024-03-15"

What is the expected effect of adding `-due_date=2024-03-15` to the query string?  In what context would this be added?  In the list view, details view, edit form, etc...?

tom wible

unread,
Jan 28, 2024, 3:32:07 PMJan 28
to Xataface
i have added some calculated fields in my duesmailing table fields.ini for csv export->mailing:
    __sql__ = "select *, 0.0 as lateFee, 0.0 as totalDue, 0.0 as ppFee from duesMailing;"

and each field has its render func in duesMailing.php:
    function lateFee__csvValue( &$record ) // export
    {
        return cghoa_calc_lateFee($record->val('balance'));
    }

and utility funcs for each (used in more than 1 table==dry;-)

    function cghoa_calc_lateFee(
                        float $bal,
                        int   $
due_date   = "2023-05-16",  // d/b?
                        int   $cur_date    = "now",            // d/b?
                        float $penaltyrate = 0.08)        // d/b?
    {
        if ( $bal < 0 )
        {
            $due_date = strtotime($due_date);
            $cur_date = strtotime($cur_date);
            $daysl8 = floor(($cur_date - $due_date)/(60*60*24));
            if ( $daysl8 > 0 )
                return round(-$bal * $penaltyrate * $daysl8/365,2); // penalty always >= 0
        }
        return 0.0;
    }

so i want to be able to override the default values rather than editing the code every time;-) 
or if i just create a parameter table,  how do add those to the sql?

tom wible

unread,
Jan 31, 2024, 7:46:57 PMJan 31
to Xataface
i've decided to go with a singleton database table, leaving type checking to the d/b, and only allowing edit in
    function getPermissions(Dataface_Record $record = null)
    {
        $perms['view']=1;
        $perms['list']=1;
        $perms['edit']=1;
        $perms['new']=0;
        $perms['delete']=0;
        return $perms;
    }
but i'm still trying to figure out where to put the sql so my dues calc code can access it...

tom wible

unread,
Jan 31, 2024, 10:10:07 PMJan 31
to Xataface
so how do i get rid of these?

With Selected: 

tom wible

unread,
Jan 31, 2024, 10:16:28 PMJan 31
to Xataface
this seems to work in my my calc funcs:

static     $due_date         = -1;
static    $cur_date        = -1;
static    $penaltyrate    = -1;

        if (is_int($due_date) and $due_date == -1 )
        {
            $query = "select * from duesCalcParams";
            $res = xf_db_query($query, df_db());
            $row = xf_db_fetch_row($res) ;

            $due_date         = $row[1]; // '2023-05-16';
            $cur_date        = $row[2]; // 'now';
            $penaltyrate    = $row[3]; // 0.08;
           
            xf_db_free_result($res);
        }

tom wible

unread,
Feb 1, 2024, 10:50:20 AMFeb 1
to Xataface

so what's the diff between


   while ($row = xf_db_fetch_row($res) )

                            

and


   foreach ($res as $row) 


in looping thru resultset?


tom wible

unread,
Feb 1, 2024, 11:25:31 AMFeb 1
to Xataface
i'm getting these warnings when my duescalcparams table loads:


[01-Feb-2024 16:22:20 UTC] PHP Warning:  Illegal string offset 'list' in /home/cardin55/public_html/hoaDB/xataface22may23/Dataface/ResultList.php on line 73

[01-Feb-2024 16:22:42 UTC] PHP Warning:  Illegal string offset 'browse' in /home/cardin55/public_html/hoaDB/xataface22may23/Dataface/RecordView.php on line 140

[01-Feb-2024 16:22:42 UTC] PHP Warning:  Illegal string offset 'browse' in /home/cardin55/public_html/hoaDB/templates_c/dataface/%%C1^C17^C174B680%%Dataface_View_Record.html.php on line 314


Reply all
Reply to author
Forward
0 new messages