Qual: Debuggage module compta simple

This commit is contained in:
Laurent Destailleur 2006-09-16 12:14:36 +00:00
parent ddcb333393
commit 5e822a1d71
15 changed files with 354 additions and 267 deletions

View File

@ -31,6 +31,9 @@ require("./pre.inc.php");
require_once("./ComptaJournalPaiement.class.php"); require_once("./ComptaJournalPaiement.class.php");
require_once("./ComptaJournalVente.class.php"); require_once("./ComptaJournalVente.class.php");
$langs->load("compta");
/* /*
* Actions * Actions
*/ */
@ -70,11 +73,11 @@ if ($_GET["action"] == 'export')
llxHeader('','Compta - Export'); llxHeader('','Compta - Export');
print_titre("Export Comptable"); print_fiche_titre($langs->trans("AccountancyExport"));
if ($exc->error_message); if ($exc->error_message)
{ {
print $exc->error_message; print '<div class="error">'.$exc->error_message.'</div>';
} }
@ -105,9 +108,11 @@ if ($resql)
} }
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>Type</td><td align="center">Nb</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Nb").'</td><td align="right">'.$langs->trans("Nb").'</td></tr>';
print '<tr><td>Factures à exporter</td><td align="center">'.$nbfac.'</td></tr>'; $var=false;
print '<tr><td>Paiements à exporter</td><td align="center">'.$nbp.'</td></tr>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("Invoices").'</td><td align="right">'.$nbfac.'</td></tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("Payments").'</td><td align="right">'.$nbp.'</td></tr>';
print "</table>\n"; print "</table>\n";
print '</td><td valign="top" width="70%">'; print '</td><td valign="top" width="70%">';
@ -116,7 +121,7 @@ $dir = DOL_DATA_ROOT."/compta/export/";
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>'; print '<td>'.$langs->trans("File").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
@ -137,5 +142,5 @@ print "</table>";
print '</td></tr></table>'; print '</td></tr></table>';
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -17,14 +17,14 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
llxHeader('','Compta - Export'); $langs->load("compta");
/*
* Sécurité accés client
*/ // Sécurité accés client
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action = ''; $action = '';
@ -32,6 +32,8 @@ if ($user->societe_id > 0)
} }
llxHeader('','Compta - Export');
/* /*
* *
* *
@ -48,8 +50,6 @@ if ($sortfield == "") $sortfield="ec.date_export";
/* /*
* Mode Liste * Mode Liste
* *
*
*
*/ */
$sql = "SELECT ec.rowid,".$db->pdate("ec.date_export")." as date_export, ec.ref"; $sql = "SELECT ec.rowid,".$db->pdate("ec.date_export")." as date_export, ec.ref";
@ -85,7 +85,7 @@ if ($result)
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
print '<td>'.stripslashes($obj->ref).'</td>'; print '<td>'.$obj->ref.'</td>';
print '<td>'.strftime("%a %e %b %Y %H:%M:%S",$obj->date_export).'</td>'; print '<td>'.strftime("%a %e %b %Y %H:%M:%S",$obj->date_export).'</td>';
print '<td><a href="index.php?action=export&amp;id='.$obj->rowid.'">Regénérer</a></td>'; print '<td><a href="index.php?action=export&amp;id='.$obj->rowid.'">Regénérer</a></td>';
print "</tr>\n"; print "</tr>\n";
@ -101,5 +101,5 @@ else
$db->close(); $db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>"); llxFooter('$Date$ - $Revision$');
?> ?>

View File

@ -1,5 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -34,94 +35,97 @@
class ComptaExport class ComptaExport
{ {
/**
/** \brief Constructeur de la class
\brief Constructeur de la class \param DB Object de base de données
\param DB Object de base de données \param USER Object utilisateur
\param USER Object utilisateur \param classe Nom de la classe utilisée pour formater les rapports
\param classe Nom de la classe utilisée pour formater les rapports */
*/ function ComptaExport ($DB, $USER, $classe)
function ComptaExport ($DB, $USER, $classe) {
{ $this->db = $DB;
$this->db = $DB; $this->user = $USER;
$this->user = $USER; $this->classe_export = $classe;
$this->classe_export = $classe; $this->error_message = '';
$this->error_message = ''; }
}
/** /**
\brief Lecture des factures dans la base \brief Lecture des factures dans la base
\param id Id ligne \param id Id ligne
*/ */
function ReadLines($id=0) function ReadLines($id=0)
{ {
dolibarr_syslog("ComptaExport::ReadLines id=".$id); global $langs;
$error = 0; dolibarr_syslog("ComptaExport::ReadLines id=".$id);
$sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef"; $error = 0;
$sql .= " , f.total_ttc, f.tva ";
$sql .= " ,s.nom, s.code_compta";
$sql .= " , l.price, l.tva_taux";
$sql .= " , c.numero, f.increment";
$sql .= " , l.rowid as lrowid";
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; $sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef";
$sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql .= " , f.total_ttc, f.tva ";
$sql .= " , ".MAIN_DB_PREFIX."societe as s"; $sql .= " ,s.nom, s.idp, s.code_compta";
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; $sql .= " , l.price, l.tva_taux";
$sql .= " , c.numero, f.increment";
$sql .= " , l.rowid as lrowid";
$sql .= " WHERE f.rowid = l.fk_facture "; $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
$sql .= " AND s.idp = f.fk_soc"; $sql .= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " AND f.fk_statut = 1 "; $sql .= " , ".MAIN_DB_PREFIX."societe as s";
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c";
$sql .= " AND l.fk_code_ventilation <> 0 "; $sql .= " WHERE f.rowid = l.fk_facture ";
$sql .= " AND s.idp = f.fk_soc";
$sql .= " AND f.fk_statut = 1 ";
$sql .= " AND l.fk_export_compta = ".$id; $sql .= " AND l.fk_code_ventilation <> 0 ";
$sql .= " AND c.rowid = l.fk_code_ventilation"; $sql .= " AND l.fk_export_compta = ".$id;
$sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC"; $sql .= " AND c.rowid = l.fk_code_ventilation";
$sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
$this->linec = array(); $this->linec = array();
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->linec[$i][0] = $obj->datef; $this->linec[$i][0] = $obj->datef;
$this->linec[$i][1] = $obj->facid; $this->linec[$i][1] = $obj->facid;
$this->linec[$i][2] = $obj->code_compta; $this->linec[$i][2] = $obj->code_compta;
$this->linec[$i][3] = $obj->nom; $this->linec[$i][3] = $obj->nom;
$this->linec[$i][4] = $obj->numero; $this->linec[$i][4] = $obj->numero;
$this->linec[$i][5] = $obj->facnumber; $this->linec[$i][5] = $obj->facnumber;
$this->linec[$i][6] = $obj->tva; $this->linec[$i][6] = $obj->tva;
$this->linec[$i][7] = $obj->total_ttc; $this->linec[$i][7] = $obj->total_ttc;
$this->linec[$i][8] = $obj->price; $this->linec[$i][8] = $obj->price;
$this->linec[$i][9] = $obj->increment; $this->linec[$i][9] = $obj->increment;
$this->linec[$i][10] = $obj->lrowid; $this->linec[$i][10] = $obj->lrowid;
if ($obj->code_compta == '') if ($obj->code_compta == '')
{ {
$this->error_message .= "Code compta non valide pour $obj->nom<br>"; $societe=new Societe($this->db);
$error++; $societe->fetch($obj->idp);
} $this->error_message.= $langs->transnoentities("ErrorWrongAccountancyCodeForCompany",$societe->getNomUrl(1));
$error++;
}
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
} }
return $error; return $error;
} }
/** /**
\brief Lecture des paiements dans la base \brief Lecture des paiements dans la base

View File

@ -1,5 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -19,9 +20,8 @@
* $Source$ * $Source$
*/ */
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php"; require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php"; require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
class ComptaExportPoivre extends ComptaExport class ComptaExportPoivre extends ComptaExport
@ -170,16 +170,16 @@ class ComptaExportPoivre extends ComptaExport
// Pour les factures // Pour les factures
//A 0 Date Opération 040604 pour 4 juin 2004 // A 0 Date Opération 040604 pour 4 juin 2004
//B 1 VE -> ventilation // B 1 VE -> ventilation
//C 2 code Compte général // C 2 code Compte général
//D 3 code client // D 3 code client
//E 4 Intitul // E 4 Intitul
//F 5 Numéro de pièce // F 5 Numéro de pièce
//G 6 Date d'échéance, = à la date d'opération si pas d'échéance // G 7 Montant
//H 7 Montant // H 8 Type opération D pour Débit ou C pour Crédit
//I 8 Type opération D pour Débit ou C pour Crédit // I Date d'échéance, = à la date d'opération si pas d'échéance
//J 9 EUR pour Monnaie en Euros // J EUR pour Monnaie en Euros
// Pour les paiements // Pour les paiements
@ -250,16 +250,16 @@ class ComptaExportPoivre extends ComptaExport
// Pour les paiements // Pour les paiements
// Date Opération 040604 pour 4 juin 2004 // A Date Opération 040604 pour 4 juin 2004
// CE -> caisse d'epargne // B CE -> caisse d'epargne
// code Compte général // C code Compte général
// code client // D code client
// Intitul // E Intitul
// Numéro de pièce // F Numéro de pièce
// Montant // G Montant
// Type opération D pour Débit ou C pour Crédit // H 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 // I Date d'échéance, = à la date d'opération si pas d'échéance
// EUR pour Monnaie en Euros // J EUR pour Monnaie en Euros
$i = 0; $i = 0;
//$j = 0; //$j = 0;

View File

@ -19,8 +19,8 @@
* $Source$ * $Source$
*/ */
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php"; require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php"; require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
class ComptaExportTableur extends ComptaExport class ComptaExportTableur extends ComptaExport

View File

@ -100,16 +100,16 @@ print '<tr><td valign="top" width="30%" class="notopnoleft">';
*/ */
if ($conf->facture->enabled) if ($conf->facture->enabled)
{ {
print '<form method="post" action="facture.php">'; print '<form method="post" action="facture.php">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>'; print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>';
print "<tr $bc[0]><td>".$langs->trans("Ref").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'; print "<tr $bc[0]><td>".$langs->trans("Ref").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>';
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>'; print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>';
print '</tr>'; print '</tr>';
print "</table></form><br>"; print "</table></form><br>";
} }

View File

@ -1,6 +1,6 @@
<?PHP <?PHP
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -28,14 +28,19 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
$langs->load("bills"); $langs->load("bills");
$mesg = ''; $mesg = '';
if (!$user->rights->compta->ventilation->creer) accessforbidden(); if (!$user->rights->compta->ventilation->creer) accessforbidden();
/*
* Actions
*/
if ($_POST["action"] == 'ventil' && $user->rights->compta->ventilation->creer) if ($_POST["action"] == 'ventil' && $user->rights->compta->ventilation->creer)
{ {
$sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet";
@ -79,6 +84,7 @@ if ($result)
* *
*/ */
$form = new Form($db); $form = new Form($db);
$facture_static=new Facture($db);
if($_GET["id"]) if($_GET["id"])
{ {
@ -110,14 +116,19 @@ if($_GET["id"])
} }
print_titre("Ventilation"); print_fiche_titre("Ventilation");
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans("Bill").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a></td></tr>'; // Ref facture
print '<tr><td>'.$langs->trans("Invoice").'</td>';
$facture_static->ref=$objp->facnumber;
$facture_static->id=$objp->facid;
print '<td>'.$facture_static->getNomUrl(1).'</td>';
print '</tr>';
print '<tr><td width="20%">Ligne</td>'; print '<tr><td width="20%">Ligne</td>';
print '<td>'.stripslashes(nl2br($objp->description)).'</td></tr>'; print '<td>'.nl2br($objp->description).'</td></tr>';
print '<tr><td width="20%">Ventiler dans le compte :</td><td>'; print '<tr><td width="20%">Ventiler dans le compte :</td><td>';
if($objp->fk_code_ventilation == 0) if($objp->fk_code_ventilation == 0)

View File

@ -29,6 +29,8 @@
require("./pre.inc.php"); require("./pre.inc.php");
$langs->load("compta");
llxHeader('','Compta - Ventilation'); llxHeader('','Compta - Ventilation');
@ -66,18 +68,18 @@ if ($result)
$var=true; $var=true;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">Lignes a ventiler</tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Lines").'</tr>';
print '<tr class="liste_titre"><td>Type</td><td align="center">Nb</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Type").'</td><td align="right">'.$langs->trans("Nb").'</td></tr>';
$var=!$var; $var=!$var;
print "<tr $bc[$var]>".'<td>Factures</td><td align="center">'.$nbfac.'</td></tr>'; print "<tr $bc[$var]>".'<td>'.$langs->trans("Invoices").'</td><td align="right">'.$nbfac.'</td></tr>';
$var=!$var; $var=!$var;
print "<tr $bc[$var]>".'<td>Paiements</td><td align="center">'.$nbp.'</td></tr>'; print "<tr $bc[$var]>".'<td>'.$langs->trans("Payments").'</td><td align="right">'.$nbp.'</td></tr>';
print "</table>\n"; print "</table>\n";
print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>Type</td><td align="center">Nb de lignes</td><td align="center">Numero</td><td align="center">ID</td></tr>'; print '<tr class="liste_titre"><td>Type</td><td align="center">'.$langs->trans("NbOfLines").'</td><td align="center">'.$langs->trans("AccountNumber").'</td><td align="center">'.$langs->trans("TransID").'</td></tr>';
$sql = "SELECT count(*), ccg.intitule, ccg.rowid,ccg.numero FROM ".MAIN_DB_PREFIX."facturedet as fd"; $sql = "SELECT count(*), ccg.intitule, ccg.rowid,ccg.numero FROM ".MAIN_DB_PREFIX."facturedet as fd";
$sql.= " ,".MAIN_DB_PREFIX."compta_compte_generaux as ccg"; $sql.= " ,".MAIN_DB_PREFIX."compta_compte_generaux as ccg";

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -20,48 +21,51 @@
*/ */
/** /**
\file htdocs/compta/ventilation/lignes.php \file htdocs/compta/ventilation/lignes.php
\ingroup facture \ingroup facture
\brief Page de detail des lignes de ventilation d'une facture \brief Page de detail des lignes de ventilation d'une facture
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("bills");
$langs->load("compta");
$user->getrights('facture'); $user->getrights('facture');
$user->getrights('banque'); $user->getrights('banque');
$langs->load("bills");
if (!$user->rights->facture->lire) accessforbidden(); if (!$user->rights->facture->lire) accessforbidden();
if (!$user->rights->compta->ventilation->creer) accessforbidden(); if (!$user->rights->compta->ventilation->creer) accessforbidden();
/*
* Sécurité accés client // Sécurité accés client
*/
if ($user->societe_id > 0) accessforbidden(); if ($user->societe_id > 0) accessforbidden();
llxHeader(''); llxHeader('');
/* /*
* Lignes de factures * Lignes de factures
* *
*/ */
$page = $_GET["page"]; $page = $_GET["page"];
if ($page < 0) $page = 0; if ($page < 0) $page = 0;
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.fk_code_ventilation, c.intitule, c.numero"; $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.fk_code_ventilation, c.intitule, c.numero,";
$sql .= ",p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
$sql .= " FROM (".MAIN_DB_PREFIX."facturedet as l"; $sql.= " FROM (".MAIN_DB_PREFIX."facturedet as l";
$sql .= " , ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."facture as f";
$sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c)"; $sql.= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)";
$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND l.fk_code_ventilation <> 0 "; $sql.= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND l.fk_code_ventilation <> 0 ";
$sql .= " AND c.rowid = l.fk_code_ventilation"; $sql.= " AND c.rowid = l.fk_code_ventilation";
if (strlen(trim($_GET["search_facture"]))) if (strlen(trim($_GET["search_facture"])))
{ {
$sql .= " AND f.facnumber like '%".$_GET["search_facture"]."%'"; $sql .= " AND f.facnumber like '%".$_GET["search_facture"]."%'";
} }
$sql .= " ORDER BY l.rowid DESC"; $sql .= " ORDER BY l.rowid DESC";
@ -71,54 +75,69 @@ $result = $db->query($sql);
if ($result) if ($result)
{ {
$num_lignes = $db->num_rows($result); $num_lignes = $db->num_rows($result);
$i = 0; $i = 0;
print_barre_liste("Lignes de facture ventilées",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); print_barre_liste("Lignes de facture ventilées",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes);
print '<form method="GET" action="lignes.php">'; print '<form method="GET" action="lignes.php">';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class=\"liste_titre\"><td>'.$langs->trans("Invoice").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Invoice").'</td>';
print '<td>'.$langs->trans("Ref").'</td>'; print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="left">'.$langs->trans("Montant").'</td>'; print '<td align="left">'.$langs->trans("Montant").'</td>';
print '<td colspan="2" align="left">'.$langs->trans("Compte").'</td>'; print '<td colspan="2" align="left">'.$langs->trans("Compte").'</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="'.$_GET["search_facture"].'"></td>'; print '<tr class="liste_titre"><td><input name="search_facture" size="8" value="'.$_GET["search_facture"].'"></td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print '<td align="right">&nbsp;</td>'; print '<td align="right">&nbsp;</td>';
print '<td align="center">&nbsp;</td>'; print '<td align="center">&nbsp;</td>';
print '<td align="right">'; print '<td align="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">'; print '<input type="image" class="liste_titre" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">';
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $facture_static=new Facture($db);
while ($i < min($num_lignes, $limit)) $product_static=new Product($db);
{
$objp = $db->fetch_object($result);
$var=!$var;
$codeCompta = $objp->numero.' '.stripslashes($objp->intitule);
print "<tr $bc[$var]>"; $var=True;
while ($i < min($num_lignes, $limit))
{
$objp = $db->fetch_object($result);
$var=!$var;
$codeCompta = $objp->numero.' '.$objp->intitule;
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a></td>'; print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->product_id.'">'.stripslashes($objp->product_ref).'</td>';
print '<td>'.stripslashes($objp->product_label).'</td>';
print '<td>'.stripslashes(nl2br($objp->description)).'</td>';
print '<td align="left">'.price($objp->price).'</td>';
print '<td align="left">'.$codeCompta.'</td>';
print "</tr>"; // Ref facture
$i++; $facture_static->ref=$objp->facnumber;
} $facture_static->id=$objp->facid;
print '<td>'.$facture_static->getNomUrl(1).'</td>';
// Ref produit
$product_static->ref=$objp->product_ref;
$product_static->id=$objp->product_id;
$product_static->type=$objp->type;
print '<td>';
if ($product_static->id) print $product_static->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print '<td>'.dolibarr_trunc($objp->product_label,24).'</td>';
print '<td>'.nl2br(dolibarr_trunc($objp->description,32)).'</td>';
print '<td align="left">'.price($objp->price).'</td>';
print '<td align="left">'.$codeCompta.'</td>';
print "</tr>";
$i++;
}
} }
else else
{ {
print $db->error(); print $db->error();
} }
print "</table></form>"; print "</table></form>";

View File

@ -30,10 +30,14 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/facture.class.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
$langs->load("compta");
$langs->load("bills");
$user->getrights('facture'); $user->getrights('facture');
$user->getrights('banque'); $user->getrights('banque');
$langs->load("bills");
if (!$user->rights->facture->lire) accessforbidden(); if (!$user->rights->facture->lire) accessforbidden();
if (!$user->rights->compta->ventilation->creer) accessforbidden(); if (!$user->rights->compta->ventilation->creer) accessforbidden();
@ -45,67 +49,82 @@ if ($user->societe_id > 0) accessforbidden();
llxHeader('','Ventilation'); llxHeader('','Ventilation');
/* /*
* Lignes de factures * Lignes de factures
* *
*/ */
$page = $_GET["page"]; $page = $_GET["page"];
if ($page < 0) $page = 0; if ($page < 0) $page = 0;
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.rowid, l.fk_code_ventilation"; $sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.rowid, l.fk_code_ventilation,";
$sql .= ",p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type";
$sql .= " FROM (".MAIN_DB_PREFIX."facturedet as l"; $sql.= " FROM (".MAIN_DB_PREFIX."facturedet as l";
$sql .= " , ".MAIN_DB_PREFIX."facture as f)"; $sql.= " , ".MAIN_DB_PREFIX."facture as f)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = l.fk_product)";
$sql .= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND fk_code_ventilation = 0"; $sql.= " WHERE f.rowid = l.fk_facture AND f.fk_statut = 1 AND fk_code_ventilation = 0";
$sql .= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); $sql.= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
$num_lignes = $db->num_rows($result); $num_lignes = $db->num_rows($result);
$i = 0; $i = 0;
print_barre_liste("Lignes de facture à ventiler",$page,"liste.php","",$sortfield,$sortorder,'',$num_lignes); print_barre_liste("Lignes de facture à ventiler",$page,"liste.php","",$sortfield,$sortorder,'',$num_lignes);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Invoice").'</td>'; print '<tr class="liste_titre"><td>'.$langs->trans("Invoice").'</td>';
print '<td>'.$langs->trans("Ref").'</td>'; print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Label").'</td>'; print '<td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("Description").'</td>'; print '<td>'.$langs->trans("Description").'</td>';
print '<td align="right">'.$langs->trans("Montant").'</td>'; print '<td align="right">'.$langs->trans("Montant").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
print "</tr>\n"; print "</tr>\n";
$var=True; $facture_static=new Facture($db);
while ($i < min($num_lignes, $limit)) $product_static=new Product($db);
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a></td>'; $var=True;
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->product_id.'">'.stripslashes($objp->product_ref).'</td>'; while ($i < min($num_lignes, $limit))
print '<td>'.stripslashes($objp->product_label).'</td>'; {
print '<td>'.stripslashes(nl2br($objp->description)).'</td>'; $objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print '<td align="right">'; // Ref facture
print price($objp->price); $facture_static->ref=$objp->facnumber;
print '</td>'; $facture_static->id=$objp->facid;
print '<td>'.$facture_static->getNomUrl(1).'</td>';
print '<td align="right"><a href="fiche.php?id='.$objp->rowid.'">'; // Ref produit
print img_edit(); $product_static->ref=$objp->product_ref;
print '</a></td>'; $product_static->id=$objp->product_id;
$product_static->type=$objp->type;
print '<td>';
if ($product_static->id) print $product_static->getNomUrl(1);
else print '&nbsp;';
print '</td>';
print "</tr>"; print '<td>'.dolibarr_trunc($objp->product_label,24).'</td>';
$i++; print '<td>'.nl2br(dolibarr_trunc($objp->description,32)).'</td>';
}
print "</table>"; print '<td align="right">';
print price($objp->price);
print '</td>';
print '<td align="right"><a href="fiche.php?id='.$objp->rowid.'">';
print img_edit();
print '</a></td>';
print "</tr>";
$i++;
}
print "</table>";
} }
else else
{ {
print $db->error(); print $db->error();
} }
$db->close(); $db->close();

View File

@ -29,8 +29,8 @@
*/ */
require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/export/modules_export.php");
require_once(PHP_WRITEEXCEL_PATH."class.writeexcel_workbookbig.inc.php"); require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbookbig.inc.php");
require_once(PHP_WRITEEXCEL_PATH."class.writeexcel_worksheet.inc.php"); require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
/** /**

View File

@ -53,3 +53,5 @@ AccountNumberShort=Account number
AccountNumber=Account number AccountNumber=Account number
NewAccount=New account NewAccount=New account
SalesTurnover=Sales turnover SalesTurnover=Sales turnover
AccountancyExport=Accountancy export
ErrorWrongAccountancyCodeForCompany=Bad customer accountancy code for %s

View File

@ -53,3 +53,5 @@ AccountNumberShort=N
AccountNumber=Numéro du compte AccountNumber=Numéro du compte
NewAccount=Nouveau compte NewAccount=Nouveau compte
SalesTurnover=Chiffre d'affaire SalesTurnover=Chiffre d'affaire
AccountancyExport=Export comptable
ErrorWrongAccountancyCodeForCompany=Code compta client incorrect pour %s

View File

@ -1757,6 +1757,29 @@ function get_each_prod()
} }
} }
/**
* \brief Renvoie nom clicable (avec eventuellement le picto)
* \param withpicto Inclut le picto dans le lien
* \param option Sur quoi pointe le lien
* \return string Chaine avec URL
*/
function getNomUrl($withpicto=0,$option='')
{
global $langs;
$result='';
$lien = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$this->id.'">';
$lienfin='</a>';
if ($withpicto) {
if ($this->type == 0) $result.=($lien.img_object($langs->trans("ShowProduct"),'product').$lienfin.' ');
if ($this->type == 1) $result.=($lien.img_object($langs->trans("ShowService"),'service').$lienfin.' ');
}
$result.=$lien.$this->ref.$lienfin;
return $result;
}
/** /**
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée) * \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto

View File

@ -22,9 +22,9 @@
* Export simple des contacts * Export simple des contacts
*/ */
require_once("../htdocs/master.inc.php"); require_once("../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php"); require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php");
require_once(DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php"); require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php");
$error = 0; $error = 0;