Select columns for CSV output

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

Select columns for CSV output

Post by omackeytech » 2018-11-13 14:18

I use Appgini to track employees hours, they enter the start and stop time and the totals are calculated for each day. I customized the administrators' table view so they only see the total hours and jobs worked on.
When they save the csv though it saves all columns, they only need the totals.

My question is where does Appgini select the columns for the csv and can I change that?

Thank you

Appgini 5.72 -1038

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Select columns for CSV output

Post by pbottcher » 2018-11-13 16:10

Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

Re: Select columns for CSV output

Post by omackeytech » 2018-11-14 04:50

I assume $query also contains the filter information entered in spm, how do I pass that thru if I limit or rewrite the select statement?

Thanks for the help.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Select columns for CSV output

Post by pbottcher » 2018-11-14 07:35

Sorry, I do not have the spm. But you could dump the $query content and have a look what is stored in there to see if the filter information is there.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

omackeytech
Veteran Member
Posts: 35
Joined: 2014-06-04 13:18

Re: Select columns for CSV output

Post by omackeytech » 2018-11-14 14:12

I found in tablename_view a section called "Fields that can be displayed in the csv file" it starts with "$x->QueryFieldsCSV = array(".

I found I can modify the array and get the results I was looking for. I just commented out the fields I did not need.

It can be done dynamically by user if needed, but I don't have to for my needs.

The $query is a select statement with a where clause, I guess I could pass the filter info through the $arg if I can find where the call is made.

Thanks for the help.

Brian

Code: Select all

$x->QueryFieldsCSV = array(   
		"`time_entry`.`id`" => "id",
		"if(`time_entry`.`Day`,date_format(`time_entry`.`Day`,'%m/%d/%Y'),'')" => "Day",
		"`time_entry`.`Period`" => "Period",
		// "TIME_FORMAT(`time_entry`.`StTime`, '%r')" => "StTime",
		// "TIME_FORMAT(`time_entry`.`LnchStart`, '%r')" => "LnchStart",
		// "TIME_FORMAT(`time_entry`.`LnchEnd`, '%r')" => "LnchEnd",
		// "TIME_FORMAT(`time_entry`.`EndTime`, '%r')" => "EndTime",
		"TIME_FORMAT(`time_entry`.`Hours`, '%h:%i')" => "Hours",
		"`time_entry`.`Mileage`" => "Mileage",
		"IF(    CHAR_LENGTH(`vehicles1`.`Vehicle`), CONCAT_WS('',   `vehicles1`.`Vehicle`), '') /* Vehicle */" => "Vehicle",
		"`time_entry`.`Expenses`" => "Expenses",
		"IF(    CHAR_LENGTH(`projects1`.`Name`), CONCAT_WS('',   `projects1`.`Name`), '') /* Project */" => "Project",
		"`time_entry`.`Pay_Type`" => "Pay_Type",
		"`time_entry`.`E_Name`" => "E_Name",
		// "`time_entry`.`Memo`" => "Memo",
		// "`time_entry`.`Job`" => "Job",
		// "`time_entry`.`Recorded`" => "Recorded"
	);

Post Reply