diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php index 034aaead30d..d44b8d3553e 100644 --- a/htdocs/comm/prospect/recap-prospect.php +++ b/htdocs/comm/prospect/recap-prospect.php @@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); -// Sécurité accés client +// Security check $socid = $_GET["socid"]; if ($user->societe_id > 0) { @@ -42,9 +42,7 @@ if ($user->societe_id > 0) /* - * - * Mode fiche - * + * View */ llxHeader(); @@ -52,7 +50,7 @@ llxHeader(); if ($socid > 0) { $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe->fetch($socid); /* * Affichage onglets diff --git a/htdocs/comm/recap-client.php b/htdocs/comm/recap-client.php index c1941cb871c..ee16e420334 100644 --- a/htdocs/comm/recap-client.php +++ b/htdocs/comm/recap-client.php @@ -18,11 +18,11 @@ */ /** - \file htdocs/comm/recap-client.php - \ingroup societe - \brief Page de fiche recap client - \version $Id$ -*/ + * \file htdocs/comm/recap-client.php + * \ingroup societe + * \brief Page de fiche recap client + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); @@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); -// Sécurité accés client +// Security check $socid = $_GET["socid"]; if ($user->societe_id > 0) { @@ -42,9 +42,7 @@ if ($user->societe_id > 0) /* - * - * Mode fiche - * + * View */ llxHeader(); @@ -52,18 +50,18 @@ llxHeader(); if ($socid > 0) { $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe->fetch($socid); /* * Affichage onglets */ $head = societe_prepare_head($societe); - + dol_fiche_head($head, 'customer', $langs->trans("ThirdParty")); print "\n"; - print '
'; + print '
'; print ''; @@ -74,7 +72,7 @@ if ($socid > 0) print ''; - + print "
'.$langs->trans("Prefix").''; print ($societe->prefix_comm?$societe->prefix_comm:' '); print '
"; print "
\n"; diff --git a/htdocs/compta/export/modules/compta.export.class.php b/htdocs/compta/export/modules/compta.export.class.php index 092224d68b7..6a4aec89f57 100644 --- a/htdocs/compta/export/modules/compta.export.class.php +++ b/htdocs/compta/export/modules/compta.export.class.php @@ -1,7 +1,7 @@ * 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 * the Free Software Foundation; either version 2 of the License, or @@ -21,215 +21,215 @@ */ /** - \file htdocs/compta/export/modules/compta.export.class.php - \ingroup compta - \brief Fichier de la classe d'export compta - \version $Revision$ -*/ + \file htdocs/compta/export/modules/compta.export.class.php + \ingroup compta + \brief Fichier de la classe d'export compta + \version $Revision$ + */ /** - \class ComptaExport - \brief Classe permettant les exports comptables -*/ + \class ComptaExport + \brief Classe permettant les exports comptables + */ 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; - - dol_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.rowid as socid, 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.rowid = 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) + /** + \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; + + dol_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.rowid as socid, 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.rowid = 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->socid); + $this->error_message.= $langs->transnoentities("ErrorWrongAccountancyCodeForCompany",$societe->getNomUrl(1))."
"; + $error++; + } + + $i++; + } + $this->db->free($resql); + } + + return $error; + } + + /** + \brief Lecture des paiements dans la base + \param id Id ligne + */ + + function ReadLinesPayment($id=0) + { + dol_syslog("ComptaExport::ReadLinesPayment id=".$id); + $error = 0; + + $sql = "SELECT p.rowid as paymentid, f.facnumber"; + $sql .= " ,".$this->db->pdate("p.datep")." as datep"; + $sql .= " , pf.amount"; + $sql .= " , s.nom, s.code_compta"; + $sql .= " , cp.libelle, f.increment"; + + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= " , ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= " , ".MAIN_DB_PREFIX."c_paiement as cp"; + $sql .= " , ".MAIN_DB_PREFIX."facture as f"; + $sql .= " , ".MAIN_DB_PREFIX."societe as s"; + + $sql .= " WHERE p.fk_export_compta = ".$id; + $sql .= " AND p.rowid = pf.fk_paiement"; + $sql .= " AND cp.id = p.fk_paiement"; + $sql .= " AND f.rowid = pf.fk_facture"; + $sql .= " AND f.fk_soc = s.rowid"; + $sql .= " AND p.statut = 1 "; + + $sql .= " ORDER BY f.rowid ASC, p.rowid ASC"; + + $resql = $this->db->query($sql); + + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + $this->linep = 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->socid); - $this->error_message.= $langs->transnoentities("ErrorWrongAccountancyCodeForCompany",$societe->getNomUrl(1))."
"; - $error++; - } - - $i++; - } - $this->db->free($resql); - } - - return $error; - } - - /** - \brief Lecture des paiements dans la base - \param id Id ligne - */ - - function ReadLinesPayment($id=0) - { - dol_syslog("ComptaExport::ReadLinesPayment id=".$id); - $error = 0; - - $sql = "SELECT p.rowid as paymentid, f.facnumber"; - $sql .= " ,".$this->db->pdate("p.datep")." as datep"; - $sql .= " , pf.amount"; - $sql .= " , s.nom, s.code_compta"; - $sql .= " , cp.libelle, f.increment"; + $obj = $this->db->fetch_object($resql); - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; - $sql .= " , ".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql .= " , ".MAIN_DB_PREFIX."c_paiement as cp"; - $sql .= " , ".MAIN_DB_PREFIX."facture as f"; - $sql .= " , ".MAIN_DB_PREFIX."societe as s"; - - $sql .= " WHERE p.fk_export_compta = ".$id; - $sql .= " AND p.rowid = pf.fk_paiement"; - $sql .= " AND cp.id = p.fk_paiement"; - $sql .= " AND f.rowid = pf.fk_facture"; - $sql .= " AND f.fk_soc = s.rowid"; - $sql .= " AND p.statut = 1 "; + $this->linep[$i][0] = $obj->datep; + $this->linep[$i][1] = $obj->paymentid; + $this->linep[$i][2] = $obj->code_compta; + $this->linep[$i][3] = $obj->nom; + $this->linep[$i][4] = $obj->facnumber; + $this->linep[$i][5] = $obj->amount; + $this->linep[$i][6] = $obj->libelle; - $sql .= " ORDER BY f.rowid ASC, p.rowid ASC"; + if (strlen(trim( $obj->increment)) > 0) + { + $this->linep[$i][7] = $obj->increment; + } + else + { + $this->linep[$i][7] = $obj->facnumber; + } - $resql = $this->db->query($sql); - - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - $this->linep = array(); - - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - - $this->linep[$i][0] = $obj->datep; - $this->linep[$i][1] = $obj->paymentid; - $this->linep[$i][2] = $obj->code_compta; - $this->linep[$i][3] = $obj->nom; - $this->linep[$i][4] = $obj->facnumber; - $this->linep[$i][5] = $obj->amount; - $this->linep[$i][6] = $obj->libelle; - - if (strlen(trim( $obj->increment)) > 0) - { - $this->linep[$i][7] = $obj->increment; - } - else - { - $this->linep[$i][7] = $obj->facnumber; - } - - $i++; + $i++; } - $this->db->free($resql); + $this->db->free($resql); - } - else - { - $error++; - } - - return $error; - } + } + else + { + $error++; + } - /** - \brief Créé le fichier d'export - */ + return $error; + } - function Export($id=0, $dir) - { - $error = 0; + /** + \brief Cr�� le fichier d'export + */ - dol_syslog("ComptaExport::Export"); + function Export($id=0, $dir) + { + $error = 0; - $error += $this->ReadLines($id); - $error += $this->ReadLinesPayment($id); + dol_syslog("ComptaExport::Export"); - dol_syslog("ComptaExport::Export Lignes de factures : ".sizeof($this->linec)); - dol_syslog("ComptaExport::Export Lignes de paiements : ".sizeof($this->linep)); + $error += $this->ReadLines($id); + $error += $this->ReadLinesPayment($id); - if (!$error && (sizeof($this->linec) > 0 || sizeof($this->linep) > 0)) - { - include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.'.strtolower($this->classe_export).'.class.php'; + dol_syslog("ComptaExport::Export Lignes de factures : ".sizeof($this->linec)); + dol_syslog("ComptaExport::Export Lignes de paiements : ".sizeof($this->linep)); - $objexport_name = "ComptaExport".$this->classe_export; + if (!$error && (sizeof($this->linec) > 0 || sizeof($this->linep) > 0)) + { + include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.'.strtolower($this->classe_export).'.class.php'; - $objexport = new $objexport_name($this->db, $this->user); + $objexport_name = "ComptaExport".$this->classe_export; - $objexport->Export($dir, $this->linec, $this->linep, $id); + $objexport = new $objexport_name($this->db, $this->user); - $this->id = $objexport->id; - $this->ref = $objexport->ref; - } - } + $objexport->Export($dir, $this->linec, $this->linep, $id); + + $this->id = $objexport->id; + $this->ref = $objexport->ref; + } + } } diff --git a/htdocs/compta/fiche.php b/htdocs/compta/fiche.php index ad21f415cf9..71d38c504ad 100644 --- a/htdocs/compta/fiche.php +++ b/htdocs/compta/fiche.php @@ -83,7 +83,7 @@ $form = new Form($db); if ($socid > 0) { $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe->fetch($socid); if ($societe->id <= 0) { dol_print_error($db,$societe->error); diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 165fb25056b..afde5f2cba1 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); -// Sécurité accés client +// Security check $socid = $_GET["socid"]; if ($user->societe_id > 0) { @@ -39,10 +39,9 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } + /* - * - * Mode fiche - * + * View */ llxHeader(); @@ -50,7 +49,7 @@ llxHeader(); if ($socid > 0) { $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe->fetch($socid); /* * Affichage onglets @@ -171,7 +170,7 @@ if ($socid > 0) print ""; print ''.dol_print_date($objp->dp)."\n"; print ''; - print '      '; // Décalage + print '      '; // D�calage print ''.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.''; print " \n"; print " \n"; diff --git a/htdocs/fichinter/apercu.php b/htdocs/fichinter/apercu.php index 9c3c07f78c2..34d641323e5 100644 --- a/htdocs/fichinter/apercu.php +++ b/htdocs/fichinter/apercu.php @@ -86,15 +86,15 @@ if ($_GET["id"] > 0) { print ''; - // Ref - print '"; - print ''; + // Ref + print '"; + print ''; - $nbrow=4; + $nbrow=4; print '
'.$langs->trans("Ref")."'.$fichinter->ref.'
'.$langs->trans("Ref")."'.$fichinter->ref.''; /* - * Documents + * Documents */ $fichinterref = dol_sanitizeFileName($fichinter->ref); $dir_output = $conf->ficheinter->dir_output . "/"; @@ -104,7 +104,7 @@ if ($_GET["id"] > 0) { $relativepath = "${fichinterref}/${fichinterref}.pdf"; $relativepathdetail = "${fichinterref}/${fichinterref}-detail.pdf"; - // Chemin vers png aper�us + // Chemin vers png apercus $relativepathimage = "${fichinterref}/${fichinterref}.pdf.png"; $fileimage = $file.".png"; // Si PDF d'1 page $fileimagebis = $file.".png.0"; // Si PDF de plus d'1 page diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index 7421bc91e4c..d97ac1385a0 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -31,7 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); -// Sécurité accés client +// Security check $socid = $_GET["socid"]; if ($user->societe_id > 0) { @@ -42,9 +42,7 @@ if ($user->societe_id > 0) /* - * - * Mode fiche - * + * View */ llxHeader(); @@ -52,7 +50,7 @@ llxHeader(); if ($socid > 0) { $societe = new Societe($db); - $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + $societe->fetch($socid); /* * Affichage onglets diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 636487a44c4..3e172fcbe81 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -479,11 +479,11 @@ class Societe extends CommonObject /** * \brief Load a third party from database into memory - * \param socid Id third party to load - * \param user User object - * \return int >0 if OK, <0 if KO + * \param socid Id third party to load + * \param ref Name of third party (Warning, this can return several records) + * \return int >0 if OK, <0 if KO or if two records found for same ref. */ - function fetch($socid, $user=0) + function fetch($socid, $ref='') { global $langs; global $conf; @@ -534,13 +534,21 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_forme_juridique as fj ON s.fk_forme_juridique = fj.code'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; - $sql .= ' WHERE s.rowid = '.$socid; + if ($socid) $sql .= ' WHERE s.rowid = '.$socid; + if ($ref) $sql .= " WHERE s.nom = '".addslashes($ref)."' AND s.entity = ".$conf->entity; $resql=$this->db->query($sql); dol_syslog("Societe::fetch ".$sql); if ($resql) { - if ($this->db->num_rows($resql)) + $num=$this->db->num_rows($resql); + if ($num > 1) + { + $this->error='Societe::Fetch several records found for ref='.$ref; + dol_syslog($this->error, LOG_ERR); + $result = -1; + } + if ($num) { $obj = $this->db->fetch_object($resql); @@ -624,8 +632,8 @@ class Societe extends CommonObject } else { - dol_syslog('Erreur Societe::Fetch aucune societe avec id='.$this->id.' - '.$sql); - $this->error='Erreur Societe::Fetch aucune societe avec id='.$this->id.' - '.$sql; + $this->error='Societe::Fetch no third party found for id='.$this->id; + dol_syslog($this->error, LOG_ERR); $result = -2; } diff --git a/htdocs/societe.php b/htdocs/societe.php index 606ea93db98..d11d0fe824a 100644 --- a/htdocs/societe.php +++ b/htdocs/societe.php @@ -60,7 +60,6 @@ $pagenext = $page + 1; /* * Actions - * */ // Recherche