Page 1 of 1

Select columns for CSV output

Posted: 2018-11-13 14:18
by omackeytech
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

Re: Select columns for CSV output

Posted: 2018-11-13 16:10
by pbottcher

Re: Select columns for CSV output

Posted: 2018-11-14 04:50
by omackeytech
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.

Re: Select columns for CSV output

Posted: 2018-11-14 07:35
by pbottcher
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.

Re: Select columns for CSV output

Posted: 2018-11-14 14:12
by omackeytech
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"
	);