Skip to content
Snippets Groups Projects
Commit cb35c552 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Rename script with better name and fix it.

parent 11bb4512
No related branches found
No related tags found
No related merge requests found
<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -14,12 +15,35 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
*
* Export simple des contacts
*/
/**
* \file scripts/company/export-contacts-xls-example.php
* \ingroup company
* \brief Export third parties' contacts with emails
* \version $Id$
*/
$sapi_type = php_sapi_name();
$script_file = basename(__FILE__);
$path=str_replace($script_file,'',$_SERVER["PHP_SELF"]);
$path=preg_replace('@[\\\/]+$@','',$path).'/';
// Test if batch mode
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Error: You ar usingr PH for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n";
exit;
}
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";
exit;
}
$now=$argv[1];
// Recupere env dolibarr
$version='$Revision$';
require_once("../../htdocs/master.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
......@@ -27,7 +51,7 @@ require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
$error = 0;
$fname = '/tmp/export-client.xls';
$fname = DOL_DATA_ROOT.'/export-contacts.xls';
$workbook = &new writeexcel_workbook($fname);
......@@ -39,7 +63,6 @@ $sql = "SELECT distinct(c.email),c.name, c.firstname, s.nom ";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " WHERE s.rowid = c.fk_soc";
$sql .= " AND s.client = 1";
$sql .= " AND c.email IS NOT NULL";
$sql .= " ORDER BY c.email ASC";
......@@ -47,15 +70,15 @@ if ($db->query($sql))
{
$num = $db->num_rows();
print "Lignes trait�es $num\n";
print "Lines ".$num."\n";
$i = 0;
$j = 1;
$page->write_string(0, 0, "Soci�t�");
$page->write_string(0, 1, "Pr�nom");
$page->write_string(0, 2, "Nom");
$page->write_string(0, 3, "Email");
$page->write_string(0, 0, $langs->trans("ThirdParty"));
$page->write_string(0, 1, $langs->trans("Firstname"));
$page->write_string(0, 2, $langs->trans("Lastname"));
$page->write_string(0, 3, $langs->trans("Email"));
$oldemail = "";
......@@ -78,6 +101,8 @@ if ($db->query($sql))
$i++;
}
print 'File '.$fname.' was generated.'."\n";
}
$workbook->close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment