Process records in a row

Questions related to using nuBuilder Forte.

Process records in a row

Postby toms » Thu Feb 01, 2018 1:47 pm

Hi,

I would like to edit records one after the other without going back to the browse form every time.

The workflow should work like this:

1. Fetch the next record (from a table, where a done_flag is not set. e.g. SELECT * FROM customers WHERE cust_done_done is null LIMIT 1;
2. The user inputs data in the edit form/updates some fields
3. The user saves the record (a js/php script would set a 'done' flag/datetime stamp. I know how to do that. Eg. Set cust_done_done = 1 or set it to now())
4. A next record is fetched (basically the same as in step 1)
5. The record is opened in the edit form

Now I'm not sure if there is an inbuilt way to open "any" next record that meets a criteria ( cust_done_done is null)

Looking at nuForm(), I can only pass a specific row id or open the browse form
Code: Select all
nuForm(nuGetProperty('form_id'), r, '', '', '0', '1');


Any advice would be greatly appreciated,

next_record.png
next_record.png (8.64 KiB) Viewed 575 times
toms
 

Re: Process records in a row

Postby admin » Thu Feb 01, 2018 3:14 pm

toms,

I have changed nuReturnNewRecord() to optionally take a primary key as a parameter.

So you'll need the latest from Github.

http://wiki.nubuilder.net/nubuilderforte/index.php/PHP#nuReturnNewRecord

That way you can return to any record you wish.

(in the example below, it will bring up payments that are due and not paid - if you set a record to Paid and save, it will return the next Outstanding payment that is due)


So in After Save it would look like this...

Code: Select all

$today  = Date('Y-m-d');
$s      = "
            SELECT payment_id
            FROM `payment` WHERE pay_due <= '$today' AND pay_paid = 'Outstanding'
            ORDER BY pay_due
        ";

$t      = nuRunQuery($s);
$r      = db_fetch_row($t)[0];

if(db_num_rows($t)== 0){           //-- new record if no criteria met.
   nuReturnNewRecord();
}else{
   nuReturnNewRecord($r);
}




next_primary_key.PNG
next_primary_key.PNG (24.67 KiB) Viewed 573 times


Hopefully, I have understood your question.


Steven
admin
Site Admin
 
Posts: 3157
Joined: Mon Jun 15, 2009 9:53 am

Re: Process records in a row

Postby toms » Thu Feb 01, 2018 5:33 pm

Steven,

Nice, it works just as I expected! Thanks a lot for the quick implementation!
toms
 

Re: Process records in a row

Postby admin » Thu Feb 01, 2018 6:23 pm

.
admin
Site Admin
 
Posts: 3157
Joined: Mon Jun 15, 2009 9:53 am


Return to General



cron