Parsing CSV File to display on a WFB...

User 2836110 Photo


Registered User
109 posts

I suppose i could adjust the script for the clients actual TZ which is probably what your leading to.
Would you like to send me the script/form for the parsing and i will have a play.
Your help is invaluable and it makes using WFB a dream, just saying.
User 187934 Photo


Senior Advisor
20,193 posts

Add this code to your 004WZ.php form page above the <!DOCTYPE HTML>.
I enterd the time zone for your area.
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$f = fopen("storage/csv/WZ.csv", "r");
date_default_timezone_set('Australia/Melbourne');
$sumTrailerA = array();
$sumTrailerB = array();
$sumTrailerC = array();
$sumTrailerD = array();
$sumTrailerTotal = array();
while (($line = fgetcsv($f)) !== false) {
$submitted_date = $line[0];
$current_date_formatted = date("d/m/Y");
if( $submitted_date == $current_date_formatted){
$Trailer=preg_replace('/\s+/', '', $line[7]);
if($Trailer == "TrailerA"){
array_push($sumTrailerA,$line[11]);
}else if($Trailer == "TrailerB"){
array_push($sumTrailerB,$line[11]);
}else if($Trailer == "TrailerC"){
array_push($sumTrailerC,$line[11]);
}else if($Trailer == "TrailerD"){
array_push($sumTrailerD,$line[11]);
}
array_push($sumTrailerTotal,$line[11]);
}
}
fclose($f);
?>

Here's how your inputs should each look.
Trailer A
<input name="TrailerA" disabled id="item80_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerA)) ? array_sum($sumTrailerA) : '');?>" />

Trailer B
<input name="TrailerB" disabled id="item81_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerB)) ? array_sum($sumTrailerB) : '');?>" />

Trailer C
<input name="TrailerC" disabled id="item82_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerC)) ? array_sum($sumTrailerC) : '');?>" />

Trailer D
<input name="TrailerD" disabled id="item83_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerD)) ? array_sum($sumTrailerD) : '');?>" />

Cumulative Totals
<input name="TrailerTotals" disabled id="item84_text_1" type="text" maxlength="254"
data-hint="" autocomplete="off" value="<?php echo (!empty(array_sum($sumTrailerTotal)) ? array_sum($sumTrailerTotal) : '');?>" />

This code relys on the datepicker still. You could leave it and hide it, or I could adjust to your needs after you have tested and we have tweaked everything to your liking.
Let me know.;)
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

I will give it a whirl, thanks again Eric.
Will let you know how it all works out.
User 2836110 Photo


Registered User
109 posts

Looking at script, is there an allocation to delete the values in the Trailer Fields on the form at midnight ready for the next days entries ??
User 187934 Photo


Senior Advisor
20,193 posts

I have built several forms that I use for data collection and one is a huge app that I use at work. The hardest part is making the forms user proof. If you don't want users to enter of select the wrong values you need to set it up to be fail proof. Your form is very straight forward so with a few tweaks you'll be very successful.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

A little confused on how you placed the script on the form ?
I assumed just use the HTML Element.
Could you send me the WZ.fb form back so i can view how it was done.
Is that possible ?
Thanks
User 187934 Photo


Senior Advisor
20,193 posts

You do it after manual export.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

I couldn't find the <!DOCTYPE HTML>
Entry in the PHP File.

<?php

$scriptpath = substr( $_SERVER['SCRIPT_FILENAME'], 0, -4 );
$paths = explode ( DIRECTORY_SEPARATOR , $scriptpath );
$myName = end($paths);
require $scriptpath . '/fbapp/php/config.inc.php';


if( strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) {

$ctl = new FormController();
$ctl->Dispatch();

} else {

if( ! isset( $_GET['action'] ) ) $myPage->ReportStats( 'NotifyFormView' );
}

ob_start();

$myPage->Show();
ob_end_flush();

?>
User 187934 Photo


Senior Advisor
20,193 posts

The actual form.
myformname.html will need to be changed to myformname.php
So in your case 004WZ.html to 004WZ.php
It's in the 004WZ directory.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2836110 Photo


Registered User
109 posts

Pardon my ignorance Eric,
Do i place the Trailer Inputs in the same file or do they go on the form via a HTML Element ?
Sorry about my vagueness.

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.