CSV Export

  • kaatt
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 16
  • Thank you received: 0

kaatt created the topic: CSV Export

I have a form that clients fill out in depth for registration with the organization but the same information has to be sent to the head office in a different layout as they don't require all of the information we do.

Thusly, I'm trying to figure out a way to export my records as a CSV but I do not want all of the fields to export so I am trying to narrow down the ones I wish to still export.

I saw another support post stating to comment out several lines of code

crosstec.org/en/forums/51-breezingforms-...mize-csv-export.html

but commenting them out only removed the headers, not the fields, nor was I able to pick and choose the form fields to be exported in this fashion.

Any support would be greatly appreciated.

Running:
BreezingForms 1.9.0
Joomla 3.9.1
#233008
  • Posts: 1573
  • Karma: 48
  • Thank you received: 201

mihaela replied the topic: CSV Export

Hello,

Sorry for the late response, Crosstec Support staff was on collective holiday vacation, as noted in the forum.

First, if you want to remove 'SUBMITTED', 'USER_ID' and other metadata from the csv go to joomla/administrator/components/com_breezingforms/admin and in the recordmanagment.class.php file around line 2571 you need to comment out the following code as stated in the link you've sent:
		$fields['ID'] = true;
		$fields['SUBMITTED'] = true;
		$fields['USER_ID'] = true;
		$fields['USERNAME'] = true;
		$fields['USER_FULL_NAME'] = true;
		$fields['TITLE'] = true;
		$fields['IP'] = true;
		$fields['BROWSER'] = true;
		$fields['OPSYS'] = true;
		$fields['TRANSACTION_ID'] = true;
		$fields['DATE'] = true;
		$fields['TEST_ACCOUNT'] = true;
		$fields['DOWNLOAD_TRIES'] = true;

This will only remove the header as you wrote, so to remove the values as well, around line 2617 comment out this piece of code as well:
$lines[$lineNum]['ID'][] = $rec->id;
			$lines[$lineNum]['SUBMITTED'][] = $rec->submitted;
			$lines[$lineNum]['USER_ID'][] = $rec->user_id;
			$lines[$lineNum]['USERNAME'][] = $rec->username;
			$lines[$lineNum]['USER_FULL_NAME'][] = $rec->user_full_name;
			$lines[$lineNum]['TITLE'][] = $rec->title;
			$lines[$lineNum]['IP'][] = $rec->ip;
			$lines[$lineNum]['BROWSER'][] = $rec->browser;
			$lines[$lineNum]['OPSYS'][] = $rec->opsys;
			$lines[$lineNum]['TRANSACTION_ID'][] = $rec->paypal_tx_id;
			$lines[$lineNum]['DATE'][] = $rec->paypal_payment_date;
			$lines[$lineNum]['TEST_ACCOUNT'][] = $rec->paypal_testaccount;
			$lines[$lineNum]['DOWNLOAD_TRIES'][] = $rec->paypal_download_tries;

Furthermore, since you want to exclude some form fields, here is how you can achieve that.
Around line 2587 in this piece of code:
		foreach ($element_fields As $element_field) {
			if (!isset($fields[strip_tags($element_field->name)])) {				 
				$field_key = md5(strip_tags($element_field->name));
				$fields[$field_key] = true;
				$head_keys[$field_key] = strip_tags($element_field->name);  
			}
		}
you need to add an if statement like this:
		foreach ($element_fields As $element_field) {
			if (!isset($fields[strip_tags($element_field->name)])) {				 
				$field_key = md5(strip_tags($element_field->name));
				if(strip_tags($element_field->name) != 'field1' && strip_tags($element_field->name) != 'field2') {
				$fields[$field_key] = true;
				$head_keys[$field_key] = strip_tags($element_field->name);  }
			}
		}
This is an example code, if you do not wish to include fields from your form named 'field1' and 'field2'. Replace those values with the names of your form elements that you DO NOT want to have in the csv export.
That will remove the headers.

To remove the values from this fields as well around line 2665 in this if statement:
if ($sub->name != 'bfFakeName' && $sub->name != 'bfFakeName2' && $sub->name != 'bfFakeName3' && $sub->name != 'bfFakeName4')
add more conditions like this:
if ($sub->name != 'bfFakeName' && $sub->name != 'bfFakeName2' && $sub->name != 'bfFakeName3' && $sub->name != 'bfFakeName4' && $sub->name != 'field1' && $sub->name != 'field2')
NOTE: This will affect all exports from all your forms. The fields with that names won't be included in any export in Manage Records.
This is a sort of custom solution so managing this to work only for one wanted export would require additional coding which is out of scope of our support.
I hope that this will help.

Please before doing the changes backup the recordmanagment.class.phpfile, for example save it as OLD_recordmanagment.class.php.

Let me know whether you've managed to achieve what you wanted and apply this to your form.

Regards,

Mihaela
#233199
Moderators: ForumSupporttomeperica
Time to create page: 0.056 seconds

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99€

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here