From 868c4e1324d557d4c81c0f944b8639cf99e7aeb1 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 31 Dec 2004 15:16:39 +0000 Subject: [PATCH] Nouveau fichier --- scripts/export-mailing.php | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 scripts/export-mailing.php diff --git a/scripts/export-mailing.php b/scripts/export-mailing.php new file mode 100644 index 00000000000..f63b1e092d2 --- /dev/null +++ b/scripts/export-mailing.php @@ -0,0 +1,88 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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$ + * $Source$ + * + * + * Export simple des contacts + * + */ + +require ("../htdocs/master.inc.php"); + +require_once (DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php"); +require_once (DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php"); + +$error = 0; + + +$fname = '/tmp/export-client.xls'; + +$workbook = &new writeexcel_workbook($fname); + +$page = &$workbook->addworksheet('Export Dolibarr'); + +$page->set_column(0,4,18); // A + +$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.idp = c.fk_soc"; +$sql .= " AND s.client = 1"; +$sql .= " AND c.email IS NOT NULL"; +$sql .= " ORDER BY c.email ASC"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + + print "Lignes traitées $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"); + + $oldemail = ""; + + while ($i < $num) + { + $obj = $db->fetch_object(); + + if ($obj->email <> $oldemail) + { + + $page->write_string($j, 0, $obj->nom); + $page->write_string($j, 1, $obj->firstname); + $page->write_string($j, 2, $obj->name); + $page->write_string($j, 3, $obj->email); + $j++; + + $oldemail = $obj->email; + } + + $i++; + + } +} + +$workbook->close(); +?>