I’ve created these short snippet, CSV Exporter to place over the file:
applications/modules/clients/views/index.php
PLACE AT THE TOP OF THE FILE:
<?php
if (isset($_GET['exportcsv'])){
$fields = array('First Name', 'Last Name', 'E-mail', 'Phone', 'Address', 'Website');
// CSV column headings
$delimiter = ",";
$separator = " ";
//You might want to put a prefix to differenciate from other contacts
$clientprefix = "IPClient"." ";
// set the default timezone to use.
date_default_timezone_set('UTC');
$today = date("Ymd");
$filename = "IPClients-".$today.".csv";
$f = fopen("php://output", "w");
$campos = array_map('trim', $fields);
fputcsv($f, $fields, $delimiter,$separator,$separator);
//get clients from DB
foreach ($records as $client) :
$CI = &get_instance();
$CI->load->model('custom_fields/mdl_custom_fields');
$custom_fields = array('client' => $CI->mdl_custom_fields->get_values_for_fields('mdl_client_custom', $client->client_id),);
$array = array(
array("First Name"=>$clientprefix.$client->client_name, "Last Name"=>$client->client_surname, "E-mail"=>$client->client_email,"Phone"=>$client->client_mobile, "Address"=>$client->client_address_1." ".$client->client_address_2." ".$client->client_city." ".$client->client_state." ".$client->client_zip." ".$client->client_country, "Website"=>$client->client_web));
foreach($array as $row){
// Adding data into CSV
$row_data = array($row['First Name'], $row['Last Name'],$row['E-mail'],$row['Phone'],$row['Address'], $row['Website']);
fputcsv($f, $row_data, $delimiter,$separator,$separator);
}
endforeach;
fclose($f);
// Telling browser to download file as CSV
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="'.$filename.'";');
exit();
}
?>
Around LINE 39 NOW REPLACE
<h1 class="headerbar-title"><?php _trans('clients'); ?></h1>
WITH THIS:
<h1 class="headerbar-title"><?php _trans('clients'); ?> » <a href="<?php echo $_SERVER['PHP_SELF'].'?exportcsv'; ?>" class="btn btn-success">CSV Export Clients</a></h1>
UPLOAD THE FILE.
Now you should be able to see a green button beside the work “Clients” that once push will export these basic fields from your InvoicePlane DB.
Enjoy!