Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request : add export to CSV #5

Closed
nqb opened this issue Nov 2, 2017 · 15 comments
Closed

Feature request : add export to CSV #5

nqb opened this issue Nov 2, 2017 · 15 comments
Assignees
Milestone

Comments

@nqb
Copy link
Contributor

nqb commented Nov 2, 2017

Hello,

Could you add a feature to export a search result to CSV (in a row form) ?
My goal is to print an export for end users.

@coudot coudot added this to the 0.2 milestone Nov 2, 2017
@coudot
Copy link
Member

coudot commented Nov 2, 2017

Yes, interesting feature!

@coudot
Copy link
Member

coudot commented Nov 11, 2017

@coudot coudot self-assigned this Dec 15, 2017
coudot added a commit that referenced this issue Dec 15, 2017
@coudot
Copy link
Member

coudot commented Dec 18, 2017

@coudot coudot closed this as completed Dec 18, 2017
@nqb
Copy link
Contributor Author

nqb commented Dec 21, 2017

Hi,

At fd85544 commit, this feature doesn't work.

Steps to reproduce :

  • Go on advanced search page
  • Fill "Firstname" row
  • Click on "Download results as CSV"
    => Server doesn't return CSV file.

Apache access log :

[21/Dec/2017:12:15:55 +0100] "POST /index.php?page=advancedsearch HTTP/1.1" 500 185 "http://wp.example.com/index.php?page=advancedsearch"

Apache error log :

[Thu Dec 21 13:37:34.650501 2017] [:error] [pid 13854] [client X.X.X.X:55908] PHP Warning:  require_once(../lib/csv.inc.php): failed to open stream: No such file or directory in /usr/local/white-pages/htdocs/advancedsearch.php on line 88, referer: http://wp.example.com/index.php?page=advancedsearch

In /usr/local/white-pages/lib, there is no csv.inc.php file ! A forget ?

coudot added a commit that referenced this issue Dec 21, 2017
@coudot
Copy link
Member

coudot commented Dec 21, 2017

@nqb you are right, the file was missing. It has just been pushed.

@nqb
Copy link
Contributor Author

nqb commented Dec 21, 2017

Thanks @coudot. It works !

Two suggestions for this enhancement :

  • Export results as CSV after a search. Currently, export is possible before a search. Consequently, you don't know what you are exporting.
  • Use advanced search fields (First name, Last Name, Mail, etc.) as CSV columns (headers) in place of LDAP attributes.

Do you want an issue for each suggestion ?

@coudot
Copy link
Member

coudot commented Dec 21, 2017

Export results as CSV after a search. Currently, export is possible before a search. Consequently, you don't know what you are exporting.

Indeed, but this requires to repost the data from the form, so have an hidden form in results page. Not very clean in the code, but I understand the need. You can open a feature request for this, but I am not sure to do it for the moment.

Use advanced search fields (First name, Last Name, Mail, etc.) as CSV columns (headers) in place of LDAP attributes.

Are you talking about using the labels? Yes I think this could be done easily.

@nqb
Copy link
Contributor Author

nqb commented Dec 21, 2017

Are you talking about using the labels?

I don't understand what is labels.

I just think that when you use advanced search with fields like First Name, Last Name, Mail, Title, etc and click on "Download results as CSV", it will be more clear to have CSV file like this :

First Name,Last Name,Mail,Title,
Nicolas,Quiniou-Briand,mail@example.com,,

rather than

cn,mail,mobile,sn,telephonenumber
nqb,mail@example.com,Quiniou-Briand,6666

@coudot coudot reopened this Jan 16, 2018
coudot added a commit that referenced this issue Jan 22, 2018
@coudot coudot closed this as completed Jan 22, 2018
@nqb
Copy link
Contributor Author

nqb commented Jan 23, 2018

After 508f6f2, possible enhancements :

  • 8 fields in Advanced search, only 5 columns in CSV export
  • CSV's columns order don't match Advanced Search's fields order
    • First column in CSV : Mail
    • First field in Advanced Search : First Name
  • CSV's columns names don't match Advanced Search's fields names.

A example with a CSV export :

Mail;Phone;Mobile;Full name;Last name
mail@example.com;6666;;nqb;Quiniou-Briand

with First Name, Last Name, Mail, Title, Business Category, Employee Type, Created and Modified fields in Advanced Search.

@coudot
Copy link
Member

coudot commented Jan 23, 2018

CSV fields match $search_result_items fields.

We may create a new configuration settings for CSV fields.

@nqb
Copy link
Contributor Author

nqb commented Jan 24, 2018

@coudot,

Would you like a dedicated issue(s) for enhancements mentioned in my previous comment ?

CSV fields match $search_result_items fields.

Agree. I notice that two last columns of CSV export are : $search_result_title and $search_result_sortby. Expected behavior ?

@coudot
Copy link
Member

coudot commented Jan 24, 2018

I reopen the issue so we complete this feature

@coudot
Copy link
Member

coudot commented Jan 25, 2018

@nqb You can now configure CSV items: https://ltb-project.org/documentation/white-pages/0.2/config_csv

@nqb
Copy link
Contributor Author

nqb commented Jan 29, 2018

Hello @coudot

Great job ! It works for me. I notice that CSV file contains translated columns.

@nqb
Copy link
Contributor Author

nqb commented Jan 29, 2018

Tip : in my config file, I set $csv_items like that :

# sync with advanced search fields
$csv_items = $search_result_items;

@coudot coudot closed this as completed Feb 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants