diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 629a5152324..88f68bdf6d4 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -236,7 +236,7 @@ print ''; print ''; - print ''; print ''; @@ -313,13 +313,14 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print '
'; if (eregi('search',$action)) { - //print_fiche_titre($langs->trans("ECMManualOrg")); + //print_fiche_titre($langs->trans("ECMSectionsManual")); print '
'; print ''; @@ -249,7 +249,7 @@ if (eregi('search',$action)) print "
"; //print $langs->trans("ECMManualOrgDesc"); - //print_fiche_titre($langs->trans("ECMAutoOrg")); + //print_fiche_titre($langs->trans("ECMSectionAuto")); print '
'; print ''; @@ -279,7 +279,7 @@ if (eregi('search',$action)) print ''; print "
"; - //print $langs->trans("ECMAutoOrgDesc"); + //print $langs->trans("ECMSectionAutoDesc"); } @@ -300,7 +300,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print '
'.$langs->trans("ECMSections").''; + print ''; print ''.$langs->trans("Refresh").' '.img_picto($langs->trans("Refresh"),'refresh').''; print '
'; print ''; print '
'; print img_picto_common('','treemenu/base.gif'); - print ''.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionAuto").')'; + print ''.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsAuto").')'; print '
'; print ''; print ' '; print ' '; print ' '; + print ' '; print ''; $htmltooltip=$langs->trans("ECMAreaDesc2"); print $form->textwithhelp('',$htmltooltip,1,0); @@ -343,15 +344,28 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print ''; print ''; + + print ''; + + print '
'; tree_showpad($sectionauto,$key); - print ''; - print img_picto('','object_dir'); - print ' '; + print ''; + $n=3; + $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1); + $oldref=$ecmdirstatic->ref; + $ecmdirstatic->ref=$ref; + print $ecmdirstatic->getNomUrl(0,$option); + $ecmdirstatic->ref=$oldref; + print img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/folder.gif','',1); + print ''; print ''; print $val['label']; print '
'; print "\n"; - // Nb of doc + // Nb of doc in dir + print ' '; + + // Nb of doc in subdir print ' '; // Edit link @@ -363,7 +377,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ // Info print ''; $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
'; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMAutoOrg").'
'; + $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionAuto").'
'; $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$langs->trans("ECMTypeAuto").'
'; $htmltooltip.=''.$langs->trans("Description").': '.$val['desc']; print $form->textwithhelp('',$htmltooltip,1,0); @@ -382,7 +396,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print ''; print ''; print '
'; print img_picto_common('','treemenu/base.gif'); - print ''.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionManual").')'; + print ''.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsManual").')'; print '
'; print ''; @@ -390,6 +404,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print ' '; //print ''.img_edit_add().''; print ' '; + print ' '; print ''; $htmltooltip=$langs->trans("ECMAreaDesc2"); print $form->textwithhelp('',$htmltooltip,1,0); @@ -488,8 +503,11 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print ''; + // Show picto print '\n"; // Nb of docs - print ''; - + print ''; + print ''; + // Edit link print ''; @@ -529,10 +552,13 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ $userstatic->id=$val['fk_user_c']; $userstatic->nom=$val['login_c']; $htmltooltip=''.$langs->trans("ECMSection").': '.$val['label'].'
'; - $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMManualOrg").'
'; + $htmltooltip=''.$langs->trans("Type").': '.$langs->trans("ECMSectionManual").'
'; $htmltooltip.=''.$langs->trans("ECMCreationUser").': '.$userstatic->getNomUrl(1).'
'; $htmltooltip.=''.$langs->trans("ECMCreationDate").': '.dolibarr_print_date($val['date_c'],"dayhour").'
'; - $htmltooltip.=''.$langs->trans("Description").': '.$val['description']; + $htmltooltip.=''.$langs->trans("Description").': '.$val['description'].'
'; + $htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").': '.$val['cachenbofdoc'].'
'; + if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").': '.$nboffilesinsubdir; + else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").': '.$nbofsubdir.'
'; print $form->textwithhelp('',$htmltooltip,1,0); print ""; diff --git a/htdocs/langs/HOWTO-Translation.txt b/htdocs/langs/HOWTO-Translation.txt index 16f9f5fd1d9..95fcab85925 100644 --- a/htdocs/langs/HOWTO-Translation.txt +++ b/htdocs/langs/HOWTO-Translation.txt @@ -1 +1 @@ -See http://dolibarr.com/wikidev/index.php/Documentation_traducteur +See http://dolibarr.com/wikidev/index.php/Documentation_traducteur diff --git a/htdocs/langs/en_US/ecm.lang b/htdocs/langs/en_US/ecm.lang index bbf243d7674..3560e6c42a0 100644 --- a/htdocs/langs/en_US/ecm.lang +++ b/htdocs/langs/en_US/ecm.lang @@ -13,6 +13,8 @@ ECMNbOfDocsSmall=Nb of doc. ECMSection=Directory ECMSectionManual=Manual directory ECMSectionAuto=Automatic directory +ECMSectionsManual=Manual directories +ECMSectionsAuto=Automatic directories ECMSections=Directories ECMRoot=Root ECMNewSection=New directory @@ -20,6 +22,9 @@ ECMAddSection=Add a manual directory ECMNewSection=New manual directory ECMNewDocument=New document ECMCreationDate=Creation date +ECMNbOfFilesInDir=Number of files in directory +ECMNbOfSubDir=Number of sub-directories +ECMNbOfFilesInSubDir=Nunber of iles in sub-directories ECMCreationUser=Creator ECMArea=ECM area ECMAreaDesc=The ECM (Electronic Content Management) area allows you to save, share and search quickly all kind of documents in Dolibarr. @@ -37,8 +42,6 @@ ECMDocsByOrders=Documents linked to customers orders ECMDocsByContracts=Documents linked to contracts ECMDocsByInvoices=Documents linked to customers invoices ECMDocsByProducts=Documents linked to products -ECMManualOrg=Manual directory -ECMAutoOrg=Automatic directory ECMNoDirecotyYet=No directory created ShowECMSection=Show directory DeleteSection=Remove directory diff --git a/htdocs/langs/fr_FR/.cvsignore b/htdocs/langs/fr_FR/.cvsignore index 63f874305ec..1fd02e68d65 100644 --- a/htdocs/langs/fr_FR/.cvsignore +++ b/htdocs/langs/fr_FR/.cvsignore @@ -1 +1 @@ -google.lang +google.lang diff --git a/htdocs/langs/fr_FR/ecm.lang b/htdocs/langs/fr_FR/ecm.lang index b2a7fe4e574..560a70b39c1 100644 --- a/htdocs/langs/fr_FR/ecm.lang +++ b/htdocs/langs/fr_FR/ecm.lang @@ -8,28 +8,33 @@ DocsContracts=Documents contrats DocsProposals=Documents propositions DocsOrders=Documents commandes DocsInvoices=Documents factures -ECMNbOfDocs=Nb de documents de la rubrique +ECMNbOfDocs=Nb de documents du répertoire ECMNbOfDocsSmall=Nb de doc. -ECMSection=Rubrique -ECMSectionManual=Rubriques manuelles -ECMSectionAuto=Rubriques automatiques -ECMSections=Rubriques +ECMSection=Répertoire +ECMSectionManual=Répertoire manuel +ECMSectionAuto=Répertoire automatique +ECMSectionsManual=Répertoires manuels +ECMSectionsAuto=Répertoires automatiques +ECMSections=Répertoires ECMRoot=Racine -ECMNewSection=Nouvelle rubrique -ECMAddSection=Ajouter rubrique manuelle -ECMNewSection=Nouvelle rubrique manuelle +ECMNewSection=Nouveau répertoire +ECMAddSection=Ajouter répertoire manuel +ECMNewSection=Nouveau répertoire manuel ECMNewDocument=Nouveau document ECMCreationDate=Date création +ECMNbOfFilesInDir=Nombre de fichiers dans le répertoire +ECMNbOfSubDir=Nombre de sous-répertoires +ECMNbOfFilesInSubDir=Nombre de fichiers dans les sous-répertoires ECMCreationUser=Créateur ECMArea=Espace GED ECMAreaDesc=L'espace GED (Gestion Electronique de Documents) vous permet de stocker dans Dolibarr et retrouver rapidement tout type de documents. -ECMAreaDesc2=* Les rubriques automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture...).
* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier. -ECMSectionWasRemoved=La rubrique %s a été effacée. +ECMAreaDesc2=* Les répertoires automatiques sont alimentées automatiquement lors de l'ajout d'un document depuis une fiche objet (propal, facture...).
* Les répertoires manuels peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier. +ECMSectionWasRemoved=Le répertoire %s a été effacée. ECMDocumentsSection=Document de la section ECMSearchByKeywords=Recherche par mots clés ECMSearchByEntity=Recherche par objet -ECMSectionOfDocuments=Rubriques des documents -ECMTypeManual=Manuelle +ECMSectionOfDocuments=Répertoires des documents +ECMTypeManual=Manuel ECMTypeAuto=Automatique ECMDocsByThirdParties=Documents associés aux tiers ECMDocsByProposals=Documents associés aux propositions @@ -37,13 +42,11 @@ ECMDocsByOrders=Documents associ ECMDocsByContracts=Documents associés aux contrats ECMDocsByInvoices=Documents associés aux factures ECMDocsByProducts=Documents associés aux produits -ECMManualOrg=Rubrique manuelle -ECMAutoOrg=Rubrique automatique -ECMNoDirecotyYet=Aucune rubrique créée -ShowECMSection=Afficher rubrique -DeleteSection=Suppression rubrique -ConfirmDeleteSection=Confirmez-vous la suppression de la rubrique %s ? +ECMNoDirecotyYet=Aucun répertoire créée +ShowECMSection=Afficher répertoire +DeleteSection=Suppression répertoire +ConfirmDeleteSection=Confirmez-vous la suppression du répertoire %s ? ECMDirectoryForFiles=Répertoire relatif pour les fichiers CannotRemoveDirectoryContainsFiles=Suppression impossible car des fichiers sont présents ECMFileManager=Gestionnaire fichier -ECMSelectASection=Selectionner une rubrique sur l'arbre de gauche... \ No newline at end of file +ECMSelectASection=Selectionner un répertoire sur l'arbre de gauche... \ No newline at end of file diff --git a/htdocs/langs/fr_FR/html/spam.html b/htdocs/langs/fr_FR/html/spam.html index 9d6dcccdc56..643e69a3fc0 100644 --- a/htdocs/langs/fr_FR/html/spam.html +++ b/htdocs/langs/fr_FR/html/spam.html @@ -23,4 +23,4 @@ Enfin, la loi pour la confiance dans l'

Ainsi, les entreprises peuvent jusqu'au 22 décembre 2004 adresser, à partir de fichiers constitués dans le respect des dispositions de la loi Informatique et libertés du 6 janvier 1978, un courrier électronique afin de recueillir le consentement des personnes. L'absence de réponse de celles-ci dans la période des 6 mois équivaudra à un refus d'être démarché. 

Indépendamment des règles spécifiques prévues dans le code des postes et des télécommunications et dans celui de la consommation, les opérations de prospection par courrier électronique, quelque soit leur nature (commerciale, caritative, politique, religieuse ou associative par exemple), sont soumises au respect de la législation relative à la protection des données personnelles, à savoir la loi Informatique et Libertés du 6 janvier 1978. -

+

diff --git a/htdocs/lib/.cvsignore b/htdocs/lib/.cvsignore index 6c8214fdbe2..60dbf5fcb1a 100644 --- a/htdocs/lib/.cvsignore +++ b/htdocs/lib/.cvsignore @@ -1 +1 @@ -htmlMimeMail +htmlMimeMail diff --git a/htdocs/lib/bookmark.lib.php b/htdocs/lib/bookmark.lib.php index 689bfcf611d..8e0c8b6331d 100644 --- a/htdocs/lib/bookmark.lib.php +++ b/htdocs/lib/bookmark.lib.php @@ -1,69 +1,69 @@ - - * - * 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. - * or see http://www.gnu.org/ - * - * $Id$ - * $Source$ - */ - -/** - \file htdocs/lib/invoice.lib.php - \brief Ensemble de fonctions de base pour le module factures - \version $Revision$ - - Ensemble de fonctions de base de dolibarr sous forme d'include -*/ - -function showArrayOfBookmark($fac) -{ - $sql = "SELECT s.rowid as socid, s.nom, b.rowid as bid"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; - $sql .= " WHERE b.fk_soc = s.rowid AND b.fk_user = ".$user->id; - $sql .= " ORDER BY lower(s.nom) ASC"; - - $resql = $db->query($sql); - - if ( $resql ) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - print '
'; $resarray=tree_showpad($fulltree,$key); $a=$resarray[0]; - $b=$resarray[1]; + $nbofsubdir=$resarray[1]; + $c=$resarray[2]; + $nboffilesinsubdir=$resarray[3]; print ''; //print $val['fullpath']."(".$showline.")"; @@ -515,8 +533,13 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $ print "'.$val['cachenbofdoc'].''; + print $val['cachenbofdoc']; + print ''; + if ($nbofsubdir && $nboffilesinsubdir) print '+'.$nboffilesinsubdir.' '; + print ''.img_edit().'
'; - print "\n"; - $var = True; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $var = !$var; - print ""; - print ''; - print ''; - print ''; - $i++; - } - print '
".$langs->trans("Bookmarks")."
'.$obj->nom.''.img_delete().'
'; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } -} - + + * + * 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. + * or see http://www.gnu.org/ + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/lib/invoice.lib.php + \brief Ensemble de fonctions de base pour le module factures + \version $Revision$ + + Ensemble de fonctions de base de dolibarr sous forme d'include +*/ + +function showArrayOfBookmark($fac) +{ + $sql = "SELECT s.rowid as socid, s.nom, b.rowid as bid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; + $sql .= " WHERE b.fk_soc = s.rowid AND b.fk_user = ".$user->id; + $sql .= " ORDER BY lower(s.nom) ASC"; + + $resql = $db->query($sql); + + if ( $resql ) + { + $num = $db->num_rows($resql); + $i = 0; + if ($num) + { + print ''; + print "\n"; + $var = True; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $var = !$var; + print ""; + print ''; + print ''; + print ''; + $i++; + } + print '
".$langs->trans("Bookmarks")."
'.$obj->nom.''.img_delete().'
'; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } +} + ?> \ No newline at end of file diff --git a/htdocs/lib/contract.lib.php b/htdocs/lib/contract.lib.php index 974e488e313..f908c8782ee 100644 --- a/htdocs/lib/contract.lib.php +++ b/htdocs/lib/contract.lib.php @@ -1,4 +1,4 @@ - * * This program is free software; you can redistribute it and/or modify @@ -21,41 +21,41 @@ \file htdocs/lib/contract.lib.php \brief Ensemble de fonctions de base pour le module contrat \version $Id$ -*/ - -function contract_prepare_head($contrat) -{ - global $langs, $conf; - $h = 0; - $head = array(); - +*/ + +function contract_prepare_head($contrat) +{ + global $langs, $conf; + $h = 0; + $head = array(); + $head[$h][0] = DOL_URL_ROOT.'/contrat/fiche.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("ContractCard"); - $head[$h][2] = 'card'; + $head[$h][1] = $langs->trans("ContractCard"); + $head[$h][2] = 'card'; $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/contact.php?id='.$contrat->id; $head[$h][1] = $langs->trans("ContractContacts"); - $head[$h][2] = 'contact'; + $head[$h][2] = 'contact'; $h++; $head[$h][0] = DOL_URL_ROOT.'/contrat/note.php?id='.$contrat->id; $head[$h][1] = $langs->trans("Note"); - $head[$h][2] = 'note'; + $head[$h][2] = 'note'; $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("Documents"); - $head[$h][2] = 'documents'; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; - $h++; - - - return $head; -} - + + $head[$h][0] = DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/contrat/info.php?id='.$contrat->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + + return $head; +} + ?> \ No newline at end of file diff --git a/htdocs/lib/doxygen.php b/htdocs/lib/doxygen.php index 04e71cd5cd7..860ea218870 100644 --- a/htdocs/lib/doxygen.php +++ b/htdocs/lib/doxygen.php @@ -1,27 +1,27 @@ - - * - * 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. - * or see http://www.gnu.org/ - */ - -/** -* \mainpage Dolibarr project -* -* This is source documentation for Dolibarr.
-* This documentation can be built or updated running the script dolibarr-doxygen-build.pl
-*
-* Dolibarr official web site: dolibarr.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. + * or see http://www.gnu.org/ + */ + +/** +* \mainpage Dolibarr project +* +* This is source documentation for Dolibarr.
+* This documentation can be built or updated running the script dolibarr-doxygen-build.pl
+*
+* Dolibarr official web site: dolibarr.org
*/ \ No newline at end of file diff --git a/htdocs/lib/lib_foot.js b/htdocs/lib/lib_foot.js index 39fedd0fe61..5ce21a2c051 100644 --- a/htdocs/lib/lib_foot.js +++ b/htdocs/lib/lib_foot.js @@ -1,11 +1,11 @@ // Copyright (C) 2005-2008 Laurent Destailleur -// -// Script javascript mis en bas de page (avant fin de body) -// +// +// Script javascript mis en bas de page (avant fin de body) +// // \file htdocs/lib/lib_foot.js // \brief File that include javascript functions (included if option use_javascript activated) // \version $Revision$ - + /*********************************************** * Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com) @@ -81,4 +81,4 @@ function hidetip() document.onmousemove=positiontip; - + diff --git a/htdocs/lib/tax.lib.php b/htdocs/lib/tax.lib.php index bcaef4a0d40..b2ec8c54040 100644 --- a/htdocs/lib/tax.lib.php +++ b/htdocs/lib/tax.lib.php @@ -1,415 +1,415 @@ - - * Copyright (C) 2006-2007 Yannick Warnier - * - * 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. - */ - -/** - \file htdocs/lib/tax.lib.php - \ingroup tax - \brief Library for tax module - \version $Id$ -*/ - - -/** - * \brief Look for collectable VAT clients in the chosen year - * \param db Database handle - * \param y Year - * \param modetax 0 or 1 (option vat on debit) - * \param direction 'sell' or 'buy' - * \return array List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error - */ -function vat_by_thirdparty($db, $y, $modetax, $direction) -{ - global $conf; - - $list=array(); - //print "xx".$conf->global->MAIN_MODULE_COMPTABILITEEXPERT; - //print "xx".$conf->global->MAIN_MODULE_COMPTABILITE; - - if ($direction == 'sell') - { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $total_tva='total_tva'; - } - if ($direction == 'buy') - { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $total_tva='tva'; - } - - // Define sql request - $sql=''; - if ($modetax == 1) - { - // If vat payed on due invoices (non draft) - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql = 'TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,"; - $sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva,"; - $sql.= " s.tva_assuj as assuj, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) - $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; - $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; - $sql.= " GROUP BY s.rowid"; - } - } - else - { - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // If vat payed on payments - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql = 'TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - // Tva sur factures payés (should be on payment) -/* $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,"; - $sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva,"; - $sql.= " s.tva_assuj as assuj, s.rowid as socid"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (2)"; // Payed (partially or completely) - $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; - $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; - $sql.= " GROUP BY s.rowid"; -*/ - $sql = 'TODO'; - } - } - - if (! $sql) return -1; - if ($sql && $sql=='TODO') return -2; - if ($sql && $sql!='TODO') - { - dolibarr_syslog("Client::vat_by_customer sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - while($assoc = $db->fetch_array($resql)) - { - $list[] = $assoc; - } - $db->free($resql); - return $list; - } - else - { - dolibarr_print_error($db); - return -3; - } - } -} - - -/** - * \brief Gets VAT to collect for the given month of the given year - * The function gets the VAT in split results, as the VAT declaration asks - * to report the amounts for different VAT rates as different lines. - * This function also accounts recurrent invoices - * \param db Database handler object - * \param y Year - * \param q Year quarter (1-4) - * \param modetax 0 or 1 (option vat on debit) - * \param direction 'sell' or 'buy' - * \return array List of quarters with vat - */ -function vat_by_quarter($db, $y, $q, $modetax, $direction) -{ - global $conf; - - $list=array(); - - if ($direction == 'sell') - { - $invoicetable='facture'; - $invoicedettable='facturedet'; - $fk_facture='fk_facture'; - $fk_facture2='fk_facture'; - $fk_payment='fk_paiement'; - $total_tva='total_tva'; - $paymenttable='paiement'; - $paymentfacturetable='paiement_facture'; - } - if ($direction == 'buy') - { - $invoicetable='facture_fourn'; - $invoicedettable='facture_fourn_det'; - $fk_facture='fk_facture_fourn'; - $fk_facture2='fk_facturefourn'; - $fk_payment='fk_paiementfourn'; - $total_tva='tva'; - $paymenttable='paiementfourn'; - $paymentfacturetable='paiementfourn_facturefourn'; - } - - // CAS DES BIENS - - // Define sql request - $sql=''; - if ($modetax == 1) - { - // If vat payed on due invoices (non draft) - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql='TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - $sql.= " AND d.product_type = 0"; // Limit to products - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - else - { - // If vat payed on payments - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql='TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - // Tva sur factures payés (should be on payment) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - $sql.= " AND d.product_type = 0"; // Limit to products - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - - if (! $sql) return -1; - if ($sql && $sql=='TODO') return -2; - if ($sql && $sql!='TODO') - { - dolibarr_syslog("Client::vat_by_quarter sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0; - - if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { - $oldrowid=$assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - } - $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; - - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['rate']]['descr'][] = $assoc['descr']; - - $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; - - $list[$assoc['rate']]['pid'][] = $assoc['pid']; - $list[$assoc['rate']]['pref'][] = $assoc['pref']; - $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; - - $rate = $assoc['rate']; - } - } - else - { - dolibarr_print_error($db); - return -3; - } - } - - - // CAS DES SERVICES - - // Define sql request - $sql=''; - if ($modetax == 1) // Option vat on debit - { - // If vat payed on due invoices (non draft) - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql='TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) - $sql.= " AND f.rowid = d.".$fk_facture; - $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; - $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; - $sql.= " AND d.product_type = 1"; // Limit to services - $sql.= " ORDER BY d.rowid, d.".$fk_facture; - } - } - else - { - // If vat payed on payments - if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) - { - // \todo a ce jour on se sait pas la compter car le montant tva d'un payment - // n'est pas stocké dans la table des payments. - // Seul le module compta expert peut résoudre ce problème. - // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le - // detail part tva et part ht). - $sql='TODO'; - } - if ($conf->global->MAIN_MODULE_COMPTABILITE) - { - // Tva sur factures payés (should be on payment) - $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; - $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; - $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; - $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; - $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; - $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; - $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; - $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; - $sql.= " WHERE "; - $sql.= " f.fk_statut in (1,2)"; // Payed (partially or completely) - $sql.= " AND f.rowid = d.".$fk_facture;; - $sql.= " AND pf.".$fk_facture2." = f.rowid"; - $sql.= " AND pa.rowid = pf.".$fk_payment; - $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; - $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; - $sql.= " AND d.product_type = 1"; // Limit to services - $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; - } - } - - if (! $sql) return -1; - if ($sql && $sql=='TODO') return -2; - if ($sql && $sql!='TODO') - { - dolibarr_syslog("Client::vat_by_quarter sql=".$sql); - $resql = $db->query($sql); - if ($resql) - { - $rate = -1; - $oldrowid=''; - while($assoc = $db->fetch_array($resql)) - { - if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0; - if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0; - - if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid - { - $oldrowid=$assoc['rowid']; - $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; - $list[$assoc['rate']]['vat'] += $assoc['total_vat']; - } - $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; - $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; - - $list[$assoc['rate']]['facid'][] = $assoc['facid']; - $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; - $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; - $list[$assoc['rate']]['descr'][] = $assoc['descr']; - - $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; - $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; - - $list[$assoc['rate']]['pid'][] = $assoc['pid']; - $list[$assoc['rate']]['pref'][] = $assoc['pref']; - $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; - - $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; - $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; - - $rate = $assoc['rate']; - } - } - else - { - dolibarr_print_error($db); - return -3; - } - } - - return $list; -} - + + * Copyright (C) 2006-2007 Yannick Warnier + * + * 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. + */ + +/** + \file htdocs/lib/tax.lib.php + \ingroup tax + \brief Library for tax module + \version $Id$ +*/ + + +/** + * \brief Look for collectable VAT clients in the chosen year + * \param db Database handle + * \param y Year + * \param modetax 0 or 1 (option vat on debit) + * \param direction 'sell' or 'buy' + * \return array List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error + */ +function vat_by_thirdparty($db, $y, $modetax, $direction) +{ + global $conf; + + $list=array(); + //print "xx".$conf->global->MAIN_MODULE_COMPTABILITEEXPERT; + //print "xx".$conf->global->MAIN_MODULE_COMPTABILITE; + + if ($direction == 'sell') + { + $invoicetable='facture'; + $invoicedettable='facturedet'; + $fk_facture='fk_facture'; + $total_tva='total_tva'; + } + if ($direction == 'buy') + { + $invoicetable='facture_fourn'; + $invoicedettable='facture_fourn_det'; + $fk_facture='fk_facture_fourn'; + $total_tva='tva'; + } + + // Define sql request + $sql=''; + if ($modetax == 1) + { + // If vat payed on due invoices (non draft) + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql = 'TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,"; + $sql.= " sum(fd.total_ht) as amount, sum(fd.".$total_tva.") as tva,"; + $sql.= " s.tva_assuj as assuj, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicedettable." as fd, ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) + $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; + $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; + $sql.= " GROUP BY s.rowid"; + } + } + else + { + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // If vat payed on payments + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql = 'TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + // Tva sur factures payés (should be on payment) +/* $sql = "SELECT s.nom as nom, s.tva_intra as tva_intra,"; + $sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva,"; + $sql.= " s.tva_assuj as assuj, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (2)"; // Payed (partially or completely) + $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; + $sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture; + $sql.= " GROUP BY s.rowid"; +*/ + $sql = 'TODO'; + } + } + + if (! $sql) return -1; + if ($sql && $sql=='TODO') return -2; + if ($sql && $sql!='TODO') + { + dolibarr_syslog("Client::vat_by_customer sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + while($assoc = $db->fetch_array($resql)) + { + $list[] = $assoc; + } + $db->free($resql); + return $list; + } + else + { + dolibarr_print_error($db); + return -3; + } + } +} + + +/** + * \brief Gets VAT to collect for the given month of the given year + * The function gets the VAT in split results, as the VAT declaration asks + * to report the amounts for different VAT rates as different lines. + * This function also accounts recurrent invoices + * \param db Database handler object + * \param y Year + * \param q Year quarter (1-4) + * \param modetax 0 or 1 (option vat on debit) + * \param direction 'sell' or 'buy' + * \return array List of quarters with vat + */ +function vat_by_quarter($db, $y, $q, $modetax, $direction) +{ + global $conf; + + $list=array(); + + if ($direction == 'sell') + { + $invoicetable='facture'; + $invoicedettable='facturedet'; + $fk_facture='fk_facture'; + $fk_facture2='fk_facture'; + $fk_payment='fk_paiement'; + $total_tva='total_tva'; + $paymenttable='paiement'; + $paymentfacturetable='paiement_facture'; + } + if ($direction == 'buy') + { + $invoicetable='facture_fourn'; + $invoicedettable='facture_fourn_det'; + $fk_facture='fk_facture_fourn'; + $fk_facture2='fk_facturefourn'; + $fk_payment='fk_paiementfourn'; + $total_tva='tva'; + $paymenttable='paiementfourn'; + $paymentfacturetable='paiementfourn_facturefourn'; + } + + // CAS DES BIENS + + // Define sql request + $sql=''; + if ($modetax == 1) + { + // If vat payed on due invoices (non draft) + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql='TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; + $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; + $sql.= " AND d.product_type = 0"; // Limit to products + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + else + { + // If vat payed on payments + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql='TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + // Tva sur factures payés (should be on payment) + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; + $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; + $sql.= " AND d.product_type = 0"; // Limit to products + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + + if (! $sql) return -1; + if ($sql && $sql=='TODO') return -2; + if ($sql && $sql!='TODO') + { + dolibarr_syslog("Client::vat_by_quarter sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + $rate = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0; + if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + } + $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; + + $list[$assoc['rate']]['facid'][] = $assoc['facid']; + $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; + $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['rate']]['descr'][] = $assoc['descr']; + + $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; + + $list[$assoc['rate']]['pid'][] = $assoc['pid']; + $list[$assoc['rate']]['pref'][] = $assoc['pref']; + $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; + + $rate = $assoc['rate']; + } + } + else + { + dolibarr_print_error($db); + return -3; + } + } + + + // CAS DES SERVICES + + // Define sql request + $sql=''; + if ($modetax == 1) // Option vat on debit + { + // If vat payed on due invoices (non draft) + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql='TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d" ; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; // Validated or payed (partially or completely) + $sql.= " AND f.rowid = d.".$fk_facture; + $sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'"; + $sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")"; + $sql.= " AND d.product_type = 1"; // Limit to services + $sql.= " ORDER BY d.rowid, d.".$fk_facture; + } + } + else + { + // If vat payed on payments + if ($conf->global->MAIN_MODULE_COMPTABILITEEXPERT) + { + // \todo a ce jour on se sait pas la compter car le montant tva d'un payment + // n'est pas stocké dans la table des payments. + // Seul le module compta expert peut résoudre ce problème. + // (Il faut quand un payment a lieu, stocker en plus du montant du paiement le + // detail part tva et part ht). + $sql='TODO'; + } + if ($conf->global->MAIN_MODULE_COMPTABILITE) + { + // Tva sur factures payés (should be on payment) + $sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,"; + $sql.= " f.facnumber as facnum, f.total_ttc as ftotal_ttc,"; + $sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,"; + $sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount"; + $sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f,"; + $sql.= " ".MAIN_DB_PREFIX.$paymentfacturetable." as pf,"; + $sql.= " ".MAIN_DB_PREFIX.$paymenttable." as pa,"; + $sql.= " ".MAIN_DB_PREFIX.$invoicedettable." as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p on d.fk_product = p.rowid"; + $sql.= " WHERE "; + $sql.= " f.fk_statut in (1,2)"; // Payed (partially or completely) + $sql.= " AND f.rowid = d.".$fk_facture;; + $sql.= " AND pf.".$fk_facture2." = f.rowid"; + $sql.= " AND pa.rowid = pf.".$fk_payment; + $sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'"; + $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")"; + $sql.= " AND d.product_type = 1"; // Limit to services + $sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid"; + } + } + + if (! $sql) return -1; + if ($sql && $sql=='TODO') return -2; + if ($sql && $sql!='TODO') + { + dolibarr_syslog("Client::vat_by_quarter sql=".$sql); + $resql = $db->query($sql); + if ($resql) + { + $rate = -1; + $oldrowid=''; + while($assoc = $db->fetch_array($resql)) + { + if (! isset($list[$assoc['rate']]['totalht'])) $list[$assoc['rate']]['total_ht']=0; + if (! isset($list[$assoc['rate']]['vat'])) $list[$assoc['rate']]['total_vat']=0; + + if ($assoc['rowid'] != $oldrowid) // Si rupture sur d.rowid + { + $oldrowid=$assoc['rowid']; + $list[$assoc['rate']]['totalht'] += $assoc['total_ht']; + $list[$assoc['rate']]['vat'] += $assoc['total_vat']; + } + $list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc']; + $list[$assoc['rate']]['dtype'][] = $assoc['dtype']; + + $list[$assoc['rate']]['facid'][] = $assoc['facid']; + $list[$assoc['rate']]['facnum'][] = $assoc['facnum']; + $list[$assoc['rate']]['ftotal_ttc'][] = $assoc['ftotal_ttc']; + $list[$assoc['rate']]['descr'][] = $assoc['descr']; + + $list[$assoc['rate']]['totalht_list'][] = $assoc['total_ht']; + $list[$assoc['rate']]['vat_list'][] = $assoc['total_vat']; + + $list[$assoc['rate']]['pid'][] = $assoc['pid']; + $list[$assoc['rate']]['pref'][] = $assoc['pref']; + $list[$assoc['rate']]['ptype'][] = $assoc['ptype']; + + $list[$assoc['rate']]['payment_id'][] = $assoc['payment_id']; + $list[$assoc['rate']]['payment_amount'][] = $assoc['payment_amount']; + + $rate = $assoc['rate']; + } + } + else + { + dolibarr_print_error($db); + return -3; + } + } + + return $list; +} + ?> \ No newline at end of file diff --git a/htdocs/lib/treeview.lib.php b/htdocs/lib/treeview.lib.php index 35c43b1fc03..04f682beda3 100644 --- a/htdocs/lib/treeview.lib.php +++ b/htdocs/lib/treeview.lib.php @@ -91,6 +91,8 @@ function tree_showpad(&$fulltree,$key,$selected=0) $atleastonofthislevelafter=0; $nbofhigherlevelafter=0; + $nbofdirinsub=0; + $nbofdocinsub=0; $found=0; //print 'x'.$key; foreach($fulltree as $key2 => $val2) @@ -99,6 +101,8 @@ function tree_showpad(&$fulltree,$key,$selected=0) { if ($fulltree[$key2]['level'] > $pos) { + $nbofdirinsub++; + $nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; $nbofhigherlevelafter++; } if ($fulltree[$key2]['level'] == $pos) @@ -110,7 +114,10 @@ function tree_showpad(&$fulltree,$key,$selected=0) break; } } - if ($key2 == $key) $found=1; + if ($key2 == $key) + { + $found=1; + } } //print $atleastonofthislevelafter; @@ -127,7 +134,7 @@ function tree_showpad(&$fulltree,$key,$selected=0) $pos++; } - return array($atleastonofthislevelafter,$nbofhigherlevelafter); + return array($atleastonofthislevelafter,$nbofhigherlevelafter,$nbofdirinsub,$nbofdocinsub); }