From 5e822a1d715f6a865f7cf057eafe99443ed7b6d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 16 Sep 2006 12:14:36 +0000 Subject: [PATCH] Qual: Debuggage module compta simple --- htdocs/compta/export/index.php | 21 ++- htdocs/compta/export/liste.php | 18 +- .../export/modules/compta.export.class.php | 178 +++++++++--------- .../modules/compta.export.poivre.class.php | 46 ++--- .../modules/compta.export.safran.class.php | 4 +- htdocs/compta/index.php | 20 +- htdocs/compta/ventilation/fiche.php | 25 ++- htdocs/compta/ventilation/index.php | 12 +- htdocs/compta/ventilation/lignes.php | 145 +++++++------- htdocs/compta/ventilation/liste.php | 111 ++++++----- .../modules/export/export_excel.modules.php | 4 +- htdocs/langs/en_US/compta.lang | 4 +- htdocs/langs/fr_FR/compta.lang | 4 +- htdocs/product.class.php | 23 +++ scripts/company/export-mailing.php | 6 +- 15 files changed, 354 insertions(+), 267 deletions(-) diff --git a/htdocs/compta/export/index.php b/htdocs/compta/export/index.php index 9c00f28f817..1dbbc49069c 100644 --- a/htdocs/compta/export/index.php +++ b/htdocs/compta/export/index.php @@ -31,6 +31,9 @@ require("./pre.inc.php"); require_once("./ComptaJournalPaiement.class.php"); require_once("./ComptaJournalVente.class.php"); +$langs->load("compta"); + + /* * Actions */ @@ -70,11 +73,11 @@ if ($_GET["action"] == '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 '
'.$exc->error_message.'
'; } @@ -105,9 +108,11 @@ if ($resql) } print ''; -print ''; -print ''; -print ''; +print ''; +$var=false; +print ''; +$var=!$var; +print ''; print "
TypeNb
Factures à exporter'.$nbfac.'
Paiements à exporter'.$nbp.'
'.$langs->trans("Nb").''.$langs->trans("Nb").'
'.$langs->trans("Invoices").''.$nbfac.'
'.$langs->trans("Payments").''.$nbp.'
\n"; print ''; @@ -116,7 +121,7 @@ $dir = DOL_DATA_ROOT."/compta/export/"; print ''; print ''; -print ''; +print ''; print ''; print "\n"; @@ -137,5 +142,5 @@ print "
'.$langs->trans("Name").''.$langs->trans("File").' 
"; print ''; -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/export/liste.php b/htdocs/compta/export/liste.php index 7791c02b7fc..2a7bd0d33b5 100644 --- a/htdocs/compta/export/liste.php +++ b/htdocs/compta/export/liste.php @@ -17,14 +17,14 @@ * * $Id$ * $Source$ - * */ + require("./pre.inc.php"); -llxHeader('','Compta - Export'); -/* - * Sécurité accés client - */ +$langs->load("compta"); + + +// Sécurité accés client if ($user->societe_id > 0) { $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 * - * - * */ $sql = "SELECT ec.rowid,".$db->pdate("ec.date_export")." as date_export, ec.ref"; @@ -85,7 +85,7 @@ if ($result) print ""; - print ''.stripslashes($obj->ref).''; + print ''.$obj->ref.''; print ''.strftime("%a %e %b %Y %H:%M:%S",$obj->date_export).''; print 'Regénérer'; print "\n"; @@ -101,5 +101,5 @@ else $db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +llxFooter('$Date$ - $Revision$'); ?> diff --git a/htdocs/compta/export/modules/compta.export.class.php b/htdocs/compta/export/modules/compta.export.class.php index 33dcf936346..d8edafbd77b 100644 --- a/htdocs/compta/export/modules/compta.export.class.php +++ b/htdocs/compta/export/modules/compta.export.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2006 Laurent Destailleur * * 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 @@ -34,94 +35,97 @@ class ComptaExport { + /** + \brief Constructeur de la class + \param DB Object de base de données + \param USER Object utilisateur + \param classe Nom de la classe utilisée pour formater les rapports + */ + function ComptaExport ($DB, $USER, $classe) + { + $this->db = $DB; + $this->user = $USER; + $this->classe_export = $classe; + $this->error_message = ''; + } + + + /** + \brief Lecture des factures dans la base + \param id Id ligne + */ + function ReadLines($id=0) + { + global $langs; - /** - \brief Constructeur de la class - \param DB Object de base de données - \param USER Object utilisateur - \param classe Nom de la classe utilisée pour formater les rapports - */ - function ComptaExport ($DB, $USER, $classe) - { - $this->db = $DB; - $this->user = $USER; - $this->classe_export = $classe; - $this->error_message = ''; - } - - - /** - \brief Lecture des factures dans la base - \param id Id ligne - */ - function ReadLines($id=0) - { - dolibarr_syslog("ComptaExport::ReadLines id=".$id); - - $error = 0; - - $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_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 .= " , ".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 l.fk_export_compta = ".$id; - - $sql .= " AND c.rowid = l.fk_code_ventilation"; - - $sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC"; - - - $resql = $this->db->query($sql); - - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - $this->linec = array(); - - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - - $this->linec[$i][0] = $obj->datef; - $this->linec[$i][1] = $obj->facid; - $this->linec[$i][2] = $obj->code_compta; - $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; - $this->linec[$i][9] = $obj->increment; - $this->linec[$i][10] = $obj->lrowid; - - if ($obj->code_compta == '') - { - $this->error_message .= "Code compta non valide pour $obj->nom
"; - $error++; - } - - $i++; - } - $this->db->free($resql); - } - - return $error; - } + dolibarr_syslog("ComptaExport::ReadLines id=".$id); + + $error = 0; + + $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.idp, 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 .= " , ".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 l.fk_export_compta = ".$id; + + $sql .= " AND c.rowid = l.fk_code_ventilation"; + + $sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC"; + + + $resql = $this->db->query($sql); + + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + $this->linec = array(); + + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + + $this->linec[$i][0] = $obj->datef; + $this->linec[$i][1] = $obj->facid; + $this->linec[$i][2] = $obj->code_compta; + $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; + $this->linec[$i][9] = $obj->increment; + $this->linec[$i][10] = $obj->lrowid; + + if ($obj->code_compta == '') + { + $societe=new Societe($this->db); + $societe->fetch($obj->idp); + $this->error_message.= $langs->transnoentities("ErrorWrongAccountancyCodeForCompany",$societe->getNomUrl(1)); + $error++; + } + + $i++; + } + $this->db->free($resql); + } + + return $error; + } /** \brief Lecture des paiements dans la base diff --git a/htdocs/compta/export/modules/compta.export.poivre.class.php b/htdocs/compta/export/modules/compta.export.poivre.class.php index 3d135b3d255..64d58c2b4cd 100644 --- a/htdocs/compta/export/modules/compta.export.poivre.class.php +++ b/htdocs/compta/export/modules/compta.export.poivre.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2006 Laurent Destailleur * * 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 @@ -19,9 +20,8 @@ * $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"; - +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"); +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); class ComptaExportPoivre extends ComptaExport @@ -170,16 +170,16 @@ class ComptaExportPoivre extends ComptaExport // Pour les factures - //A 0 Date Opération 040604 pour 4 juin 2004 - //B 1 VE -> ventilation - //C 2 code Compte général - //D 3 code client - //E 4 Intitul - //F 5 Numéro de pièce - //G 6 Date d'échéance, = à la date d'opération si pas d'échéance - //H 7 Montant - //I 8 Type opération D pour Débit ou C pour Crédit - //J 9 EUR pour Monnaie en Euros + // A 0 Date Opération 040604 pour 4 juin 2004 + // B 1 VE -> ventilation + // C 2 code Compte général + // D 3 code client + // E 4 Intitul + // F 5 Numéro de pièce + // G 7 Montant + // H 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 EUR pour Monnaie en Euros // Pour les paiements @@ -250,16 +250,16 @@ class ComptaExportPoivre extends ComptaExport // Pour les paiements - // Date Opération 040604 pour 4 juin 2004 - // CE -> caisse d'epargne - // 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 + // A Date Opération 040604 pour 4 juin 2004 + // B CE -> caisse d'epargne + // C code Compte général + // D code client + // E Intitul + // F Numéro de pièce + // G Montant + // H 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 EUR pour Monnaie en Euros $i = 0; //$j = 0; diff --git a/htdocs/compta/export/modules/compta.export.safran.class.php b/htdocs/compta/export/modules/compta.export.safran.class.php index 2e985a4cfbf..6ad9f2cdc1c 100644 --- a/htdocs/compta/export/modules/compta.export.safran.class.php +++ b/htdocs/compta/export/modules/compta.export.safran.class.php @@ -19,8 +19,8 @@ * $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"; +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbook.inc.php"); +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); class ComptaExportTableur extends ComptaExport diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index c11843cd976..cc73168308f 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -100,16 +100,16 @@ print ''; */ if ($conf->facture->enabled) { - print '
'; - - print ''; - print ""; - print ''; - print "'; - print ''; - print "'; - print ''; - print "
'.$langs->trans("SearchABill").'
".$langs->trans("Ref").':
".$langs->trans("Other").':

"; + print '
'; + + print ''; + print ""; + print ''; + print "'; + print ''; + print "'; + print ''; + print "
'.$langs->trans("SearchABill").'
".$langs->trans("Ref").':
".$langs->trans("Other").':

"; } diff --git a/htdocs/compta/ventilation/fiche.php b/htdocs/compta/ventilation/fiche.php index 1e5b4bb9bef..b855b7e83f6 100644 --- a/htdocs/compta/ventilation/fiche.php +++ b/htdocs/compta/ventilation/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005 Laurent Destailleur +/* Copyright (C) 2004 Rodolphe Quiedeville + * Copyright (C) 2005-2006 Laurent Destailleur * * 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 @@ -28,14 +28,19 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("bills"); - $mesg = ''; if (!$user->rights->compta->ventilation->creer) accessforbidden(); + +/* + * Actions + */ + if ($_POST["action"] == 'ventil' && $user->rights->compta->ventilation->creer) { $sql = " UPDATE ".MAIN_DB_PREFIX."facturedet"; @@ -79,6 +84,7 @@ if ($result) * */ $form = new Form($db); +$facture_static=new Facture($db); if($_GET["id"]) { @@ -110,14 +116,19 @@ if($_GET["id"]) } - print_titre("Ventilation"); + print_fiche_titre("Ventilation"); print ''; - print ''; - print ''; + + // Ref facture + print ''; + $facture_static->ref=$objp->facnumber; + $facture_static->id=$objp->facid; + print ''; + print ''; print ''; - print ''; + print ''; print ''; + + // Ref produit + $product_static->ref=$objp->product_ref; + $product_static->id=$objp->product_id; + $product_static->type=$objp->type; + print ''; + + print ''; + print ''; + + print ''; + + print ''; + + print ""; + $i++; + } + print "
'.$langs->trans("Bill").''.$objp->facnumber.'
'.$langs->trans("Invoice").''.$facture_static->getNomUrl(1).'
Ligne'.stripslashes(nl2br($objp->description)).'
'.nl2br($objp->description).'
Ventiler dans le compte :'; if($objp->fk_code_ventilation == 0) diff --git a/htdocs/compta/ventilation/index.php b/htdocs/compta/ventilation/index.php index ddf829c0086..ac77370249f 100644 --- a/htdocs/compta/ventilation/index.php +++ b/htdocs/compta/ventilation/index.php @@ -29,6 +29,8 @@ require("./pre.inc.php"); +$langs->load("compta"); + llxHeader('','Compta - Ventilation'); @@ -66,18 +68,18 @@ if ($result) $var=true; print ''; -print ''; -print ''; +print ''; +print ''; $var=!$var; -print "".''; +print "".''; $var=!$var; -print "".''; +print "".''; print "
Lignes a ventiler
TypeNb
'.$langs->trans("Lines").'
'.$langs->trans("Type").''.$langs->trans("Nb").'
Factures'.$nbfac.'
'.$langs->trans("Invoices").''.$nbfac.'
Paiements'.$nbp.'
'.$langs->trans("Payments").''.$nbp.'
\n"; print '
'; print ''; -print ''; +print ''; $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"; diff --git a/htdocs/compta/ventilation/lignes.php b/htdocs/compta/ventilation/lignes.php index ff78392a98d..ff4e962f97c 100644 --- a/htdocs/compta/ventilation/lignes.php +++ b/htdocs/compta/ventilation/lignes.php @@ -1,5 +1,6 @@ + * Copyright (C) 2006 Laurent Destailleur * * 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 @@ -20,48 +21,51 @@ */ /** - \file htdocs/compta/ventilation/lignes.php - \ingroup facture - \brief Page de detail des lignes de ventilation d'une facture - \version $Revision$ + \file htdocs/compta/ventilation/lignes.php + \ingroup facture + \brief Page de detail des lignes de ventilation d'une facture + \version $Revision$ */ 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('banque'); -$langs->load("bills"); if (!$user->rights->facture->lire) accessforbidden(); if (!$user->rights->compta->ventilation->creer) accessforbidden(); -/* - * Sécurité accés client - */ + +// Sécurité accés client if ($user->societe_id > 0) accessforbidden(); + llxHeader(''); /* - * Lignes de factures - * - */ +* Lignes de factures +* +*/ $page = $_GET["page"]; if ($page < 0) $page = 0; $limit = $conf->liste_limit; $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 .= ",p.rowid as product_id, p.ref as product_ref, p.label as product_label"; -$sql .= " FROM (".MAIN_DB_PREFIX."facturedet as l"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f"; -$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 .= " 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 = "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, p.fk_product_type as type"; +$sql.= " FROM (".MAIN_DB_PREFIX."facturedet as l"; +$sql.= " , ".MAIN_DB_PREFIX."facture as f"; +$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.= " 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"; 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"; @@ -71,54 +75,69 @@ $result = $db->query($sql); if ($result) { - $num_lignes = $db->num_rows($result); - $i = 0; - - print_barre_liste("Lignes de facture ventilées",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); + $num_lignes = $db->num_rows($result); + $i = 0; - print '
'; - print '
TypeNb de lignesNumeroID
Type'.$langs->trans("NbOfLines").''.$langs->trans("AccountNumber").''.$langs->trans("TransID").'
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print_barre_liste("Lignes de facture ventilées",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); - $var=True; - while ($i < min($num_lignes, $limit)) - { - $objp = $db->fetch_object($result); - $var=!$var; - $codeCompta = $objp->numero.' '.stripslashes($objp->intitule); - - print ""; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''; + print '
'.$langs->trans("Invoice").''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Description").''.$langs->trans("Montant").''.$langs->trans("Compte").'
    '; - print ''; - print '
'.$objp->facnumber.''.stripslashes($objp->product_ref).''.stripslashes($objp->product_label).''.stripslashes(nl2br($objp->description)).''.price($objp->price).''.$codeCompta.'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - print ""; - $i++; - } + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $facture_static=new Facture($db); + $product_static=new Product($db); + + $var=True; + while ($i < min($num_lignes, $limit)) + { + $objp = $db->fetch_object($result); + $var=!$var; + $codeCompta = $objp->numero.' '.$objp->intitule; + + print ""; + + // Ref facture + $facture_static->ref=$objp->facnumber; + $facture_static->id=$objp->facid; + print ''; + + // Ref produit + $product_static->ref=$objp->product_ref; + $product_static->id=$objp->product_id; + $product_static->type=$objp->type; + print ''; + + print ''; + print ''; + print ''; + print ''; + + print ""; + $i++; + } } else { - print $db->error(); + print $db->error(); } print "
'.$langs->trans("Invoice").''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Description").''.$langs->trans("Montant").''.$langs->trans("Compte").'
    '; + print ''; + print '
'.$facture_static->getNomUrl(1).''; + if ($product_static->id) print $product_static->getNomUrl(1); + else print ' '; + print ''.dolibarr_trunc($objp->product_label,24).''.nl2br(dolibarr_trunc($objp->description,32)).''.price($objp->price).''.$codeCompta.'
"; diff --git a/htdocs/compta/ventilation/liste.php b/htdocs/compta/ventilation/liste.php index 2d4e2d9189d..caded546e21 100644 --- a/htdocs/compta/ventilation/liste.php +++ b/htdocs/compta/ventilation/liste.php @@ -22,7 +22,7 @@ */ -/** +/** \file htdocs/compta/ventilation/liste.php \ingroup compta \brief Page de ventilation des lignes de facture @@ -30,10 +30,14 @@ */ 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('banque'); -$langs->load("bills"); if (!$user->rights->facture->lire) accessforbidden(); if (!$user->rights->compta->ventilation->creer) accessforbidden(); @@ -45,67 +49,82 @@ if ($user->societe_id > 0) accessforbidden(); llxHeader('','Ventilation'); /* - * Lignes de factures - * - */ +* Lignes de factures +* +*/ $page = $_GET["page"]; if ($page < 0) $page = 0; $limit = $conf->liste_limit; $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 .= ",p.rowid as product_id, p.ref as product_ref, p.label as product_label"; -$sql .= " FROM (".MAIN_DB_PREFIX."facturedet as l"; -$sql .= " , ".MAIN_DB_PREFIX."facture as f)"; -$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 .= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); +$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, p.fk_product_type as type"; +$sql.= " FROM (".MAIN_DB_PREFIX."facturedet as l"; +$sql.= " , ".MAIN_DB_PREFIX."facture as f)"; +$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.= " ORDER BY l.rowid DESC ".$db->plimit($limit+1,$offset); $result = $db->query($sql); if ($result) { - $num_lignes = $db->num_rows($result); - $i = 0; - - print_barre_liste("Lignes de facture à ventiler",$page,"liste.php","",$sortfield,$sortorder,'',$num_lignes); + $num_lignes = $db->num_rows($result); + $i = 0; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; + print_barre_liste("Lignes de facture à ventiler",$page,"liste.php","",$sortfield,$sortorder,'',$num_lignes); - $var=True; - while ($i < min($num_lignes, $limit)) - { - $objp = $db->fetch_object($result); - $var=!$var; - print ""; - - print ''; - print ''; - print ''; - print ''; + print '
'.$langs->trans("Invoice").''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Description").''.$langs->trans("Montant").' 
'.$objp->facnumber.''.stripslashes($objp->product_ref).''.stripslashes($objp->product_label).''.stripslashes(nl2br($objp->description)).'
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; - print ''; + $facture_static=new Facture($db); + $product_static=new Product($db); - print ''; + $var=True; + while ($i < min($num_lignes, $limit)) + { + $objp = $db->fetch_object($result); + $var=!$var; + print ""; - print ""; - $i++; - } - print "
'.$langs->trans("Invoice").''.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Description").''.$langs->trans("Montant").' 
'; - print price($objp->price); - print ''; - print img_edit(); - print '
"; + // Ref facture + $facture_static->ref=$objp->facnumber; + $facture_static->id=$objp->facid; + print '
'.$facture_static->getNomUrl(1).''; + if ($product_static->id) print $product_static->getNomUrl(1); + else print ' '; + print ''.dolibarr_trunc($objp->product_label,24).''.nl2br(dolibarr_trunc($objp->description,32)).''; + print price($objp->price); + print ''; + print img_edit(); + print '
"; } else { - print $db->error(); + print $db->error(); } $db->close(); diff --git a/htdocs/includes/modules/export/export_excel.modules.php b/htdocs/includes/modules/export/export_excel.modules.php index f5222f77ff4..569c698a270 100644 --- a/htdocs/includes/modules/export/export_excel.modules.php +++ b/htdocs/includes/modules/export/export_excel.modules.php @@ -29,8 +29,8 @@ */ 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_worksheet.inc.php"); +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_workbookbig.inc.php"); +require_once(PHP_WRITEEXCEL_PATH."/class.writeexcel_worksheet.inc.php"); /** diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 92fd2fef929..0ada3d471f2 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -52,4 +52,6 @@ AlreadyPayed=Already payed AccountNumberShort=Account number AccountNumber=Account number NewAccount=New account -SalesTurnover=Sales turnover \ No newline at end of file +SalesTurnover=Sales turnover +AccountancyExport=Accountancy export +ErrorWrongAccountancyCodeForCompany=Bad customer accountancy code for %s \ No newline at end of file diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 175e925b643..60ce5cd6fff 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -52,4 +52,6 @@ AlreadyPayed=D AccountNumberShort=N° du compte AccountNumber=Numéro du compte NewAccount=Nouveau compte -SalesTurnover=Chiffre d'affaire \ No newline at end of file +SalesTurnover=Chiffre d'affaire +AccountancyExport=Export comptable +ErrorWrongAccountancyCodeForCompany=Code compta client incorrect pour %s \ No newline at end of file diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 45ae2c1ccd0..eb8a6ee7209 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -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 = ''; + $lienfin=''; + + 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) * \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto diff --git a/scripts/company/export-mailing.php b/scripts/company/export-mailing.php index 9e8c2187cc4..93d274d69ed 100644 --- a/scripts/company/export-mailing.php +++ b/scripts/company/export-mailing.php @@ -22,9 +22,9 @@ * Export simple des contacts */ -require_once("../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"); +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"); $error = 0;