Nouveau fichier

This commit is contained in:
Rodolphe Quiedeville 2004-12-07 10:15:42 +00:00
parent d8861e146b
commit 3722721e10
5 changed files with 482 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 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
* 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$
*
*/
/*!
\file htdocs/compta/index.php
\ingroup compta
\brief Page accueil zone comptabilité
\version $Revision$
*/
require("./pre.inc.php");
llxHeader();
print "Export Comptable";
if ($_GET["action"] == 'export')
{
include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.class.php';
$exc = new ComptaExport($db, $user, 'Poivre');
$exc->Export();
}
print '<a href="index.php?action=export">Export</a>';
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -0,0 +1,103 @@
<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
*/
class ComptaExport
{
function ComptaExport ($DB, $USER, $classe)
{
$this->db = $DB;
$this->user = $USER;
$this->classe_export = $classe;
}
function ReadLines()
{
$sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef";
$sql .= " , f.total_ttc, f.tva ";
$sql .= " ,s.nom, s.code_client";
$sql .= " , l.price, l.tva_taux";
$sql .= " , c.numero";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c";
$sql .= " WHERE f.rowid = l.fk_facture ";
$sql .= " AND s.idp = f.fk_soc";
$sql .= " AND f.fk_statut = 1 ";
$sql .= " AND l.fk_code_ventilation <> 0 ";
$sql .= " AND c.rowid = l.fk_code_ventilation";
$sql .= " ORDER BY f.rowid ASC, l.rowid ASC";
print $sql;
if ($this->db->query($sql))
{
$num = $this->db->num_rows();
$i = 0;
$this->linec = array();
while ($i < $num)
{
$obj = $this->db->fetch_object();
$this->linec[$i][0] = $obj->datef;
$this->linec[$i][1] = $obj->facnumber;
$this->linec[$i][2] = $obj->code_client;
$this->linec[$i][3] = $obj->nom;
$this->linec[$i][4] = $obj->numero;
$this->linec[$i][5] = $obj->facnumber;
$this->linec[$i][6] = $obj->tva;
$this->linec[$i][7] = $obj->total_ttc;
$this->linec[$i][8] = $obj->price;
$i++;
}
}
}
function Export()
{
$this->ReadLines();
if (sizeof($this->linec) > 0 )
{
include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.'.strtolower($this->classe_export).'.class.php';
$objexport_name = "ComptaExport".$this->classe_export;
$objexport = new $objexport_name();
$objexport->Export($this->linec);
}
}
}

View File

@ -0,0 +1,146 @@
<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
*/
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";
class ComptaExportPoivre
{
function ComptaExportPoivre ()
{
}
function Create()
{
$this->date = time();
$this->datef = "commande-".strftime("%d%b%y-%HH%M", $this->date);
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->datef.".xls";
if (strlen(trim($this->fournisseur->email_commande)) == 0)
{
return -3;
}
if (file_exists($fname))
{
return 2;
}
else
{
$res = $this->CreateFile($fname);
$res = $res + $this->LogSql();
$res = $res + $this->MailFile($fname);
return $res;
}
}
function Export($linec)
{
$fname = "/tmp/exportcompta";
$fp = fopen($fname,'w');
// Pour les factures
// Date Opération 040604 pour 4 juin 2004
// VE -> ventilation
// code Compte général
// code client
// Intitulé
// Numéro de pièce
// Montant
// Type opération D pour Débit ou C pour Crédit
// Date d'échéance, = à la date d'opération si pas d'échéance
// EUR pour Monnaie en Euros
// Pour les paiements
$i = 0;
$j = 0;
$n = sizeof($linec);
$oldfacture = 0;
for ( $i = 0 ; $i < $n ; $i++)
{
if ( $oldfacture <> $linec[$i][1])
{
// Ligne client
fputs($fp, strftime("%d%m%y",$linec[$i][0]) . "\t");
fputs($fp, "VE" ."\t");
fputs($fp, "\t");
fputs($fp, '411000000' ."\t");
fputs($fp, $linec[$i][3]." Facture" ."\t");
fputs($fp, $linec[$i][5] . "\t"); // Numéro de facture
fputs($fp, ereg_replace(",",".",$linec[$i][7]) ."\t"); // Montant total TTC de la facture
fputs($fp, 'D' . "\t"); // D pour débit
fputs($fp, strftime("%d%m%y",$linec[$i][0]) . "\t"); // Date d'échéance
fputs($fp, "EUR"); // Monnaie
fputs($fp, "\n");
// Ligne TVA
fputs($fp, strftime("%d%m%y",$linec[$i][0]) . "\t");
fputs($fp, "VE" ."\t");
fputs($fp, "\t");
fputs($fp, '4457119' ."\t");
fputs($fp, $linec[$i][3]." Facture" ."\t");
fputs($fp, $linec[$i][5] . "\t"); // Numéro de facture
fputs($fp, ereg_replace(",",".",$linec[$i][6]) ."\t"); // Montant de TVA
fputs($fp, 'C' . "\t"); // C pour crédit
fputs($fp, strftime("%d%m%y",$linec[$i][0]) . "\t"); // Date d'échéance
fputs($fp, "EUR"); // Monnaie
fputs($fp, "\n");
$oldfacture = $linec[$i][1];
$j++;
}
fputs($fp, strftime("%d%m%y",$linec[$i][0]) ."\t");
fputs($fp, 'VE' ."\t");
fputs($fp, $linec[$i][4]."\t"); // Code Comptable
fputs($fp, "\t");
fputs($fp, $linec[$i][3]." Facture" ."\t");
fputs($fp, $linec[$i][5]."\t"); // Numéro de facture
fputs($fp, ereg_replace(",",".",round($linec[$i][8], 2)) ."\t"); // Montant de la ligne
fputs($fp, 'C' . "\t"); // C pour crédit
fputs($fp, strftime("%d%m%y",$linec[$i][0]) . "\t"); // Date d'échéance
fputs($fp, "EUR"); // Monnaie
fputs($fp, "\n");
$j++;
}
fclose($fp);
return 0;
}
}

View File

@ -0,0 +1,127 @@
<?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
*/
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";
class ComptaExportTableur extends ComptaExport
{
function ComptaExportTableur ()
{
}
function Create()
{
$this->date = time();
$this->datef = "commande-".strftime("%d%b%y-%HH%M", $this->date);
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->datef.".xls";
if (strlen(trim($this->fournisseur->email_commande)) == 0)
{
return -3;
}
if (file_exists($fname))
{
return 2;
}
else
{
$res = $this->CreateFile($fname);
$res = $res + $this->LogSql();
$res = $res + $this->MailFile($fname);
return $res;
}
}
function Export($linec)
{
$fname = "/tmp/toto.xls";
$workbook = &new writeexcel_workbook($fname);
$worksheet = &$workbook->addworksheet();
// Pour les factures
// Date Opération 040604 pour 4 juin 2004
// VE -> ventilation
// code Compte général
// code client
// Intitulé
// Numéro de pièce
// Montant
// Type opération D pour Débit ou C pour Crédit
// Date d'échéance, = à la date d'opération si pas d'échéance
// EUR pour Monnaie en Euros
// Pour les paiements
$worksheet->set_column('A:A', 20);
$worksheet->set_column('B:B', 20);
$worksheet->set_column('C:C', 15);
$worksheet->set_column('D:D', 9);
$worksheet->set_column('E:E', 16);
$worksheet->set_column('F:F', 18);
$worksheet->set_column('G:G', 20);
$i = 0;
$j = 0;
$n = sizeof($linec);
$oldfacture = 0;
for ( $i = 0 ; $i < $n ; $i++)
{
if ( $oldfacture <> $linec[$i][1])
{
$worksheet->write_string($j, 0, strftime("%d%m%y",$linec[$i][0]));
$worksheet->write_string($j, 1, 'VE');
$worksheet->write_string($j, 3, '411000000');
$worksheet->write_string($j, 4, $linec[$i][3]." Facture");
$oldfacture = $linec[$i][1];
$j++;
}
$worksheet->write_string($j, 0, strftime("%d%m%y",$linec[$i][0]));
$worksheet->write_string($j, 1, 'VE');
$worksheet->write_string($j, 2, $linec[$i][4]);
$worksheet->write_string($j, 4, $linec[$i][3]." Facture");
$j++;
}
$workbook->close();
return 0;
}
}

View File

@ -0,0 +1,58 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 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
* 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$
*
*/
/*!
\file htdocs/compta/pre.inc.php
\ingroup compta
\brief Fichier gestionnaire du menu compta
*/
require("../../main.inc.php");
$user->getrights('');
function llxHeader($head = "", $title="", $help_url='')
{
global $user, $conf, $langs;
top_menu($head, $title);
$menu = new Menu();
// Les recettes
$menu->add(DOL_URL_ROOT."/compta/clients.php", $langs->trans("Customers"));
$menu->add(DOL_URL_ROOT."/compta/ventilation/",$langs->trans("Ventilation"));
$menu->add(DOL_URL_ROOT."/compta/export/",$langs->trans("Export"));
if (! $user->compta)
{
$menu->clear();
$menu->add(DOL_URL_ROOT."/",$langs->trans("Home"));
}
left_menu($menu->liste, $help_url);
}
?>