mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Enhancement in ecm module
This commit is contained in:
parent
f67962a049
commit
32801a3655
|
|
@ -236,7 +236,7 @@ print '<table class="nobordernopadding" width="100%"><tr><td valign="top">';
|
|||
|
||||
if (eregi('search',$action))
|
||||
{
|
||||
//print_fiche_titre($langs->trans("ECMManualOrg"));
|
||||
//print_fiche_titre($langs->trans("ECMSectionsManual"));
|
||||
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
|
|
@ -249,7 +249,7 @@ if (eregi('search',$action))
|
|||
print "</table></form>";
|
||||
//print $langs->trans("ECMManualOrgDesc");
|
||||
|
||||
//print_fiche_titre($langs->trans("ECMAutoOrg"));
|
||||
//print_fiche_titre($langs->trans("ECMSectionAuto"));
|
||||
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/ecm/search.php">';
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
|
@ -279,7 +279,7 @@ if (eregi('search',$action))
|
|||
|
||||
print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
|
||||
print "</table></form>";
|
||||
//print $langs->trans("ECMAutoOrgDesc");
|
||||
//print $langs->trans("ECMSectionAutoDesc");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -300,7 +300,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" align="left">'.$langs->trans("ECMSections").'</td>';
|
||||
print '<td class="liste_titre" colspan="4" align="right">';
|
||||
print '<td class="liste_titre" colspan="5" align="right">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?action=refreshmanual'.($section?'&section='.$section:'').'">'.$langs->trans("Refresh").' '.img_picto($langs->trans("Refresh"),'refresh').'</a>';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
|
@ -313,13 +313,14 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
|
||||
print '<td align="left" width="24px">';
|
||||
print img_picto_common('','treemenu/base.gif');
|
||||
print '</td><td align="left">'.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionAuto").')';
|
||||
print '</td><td align="left">'.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsAuto").')';
|
||||
print '</td>';
|
||||
print '</tr></table>';
|
||||
print '</td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="center">';
|
||||
$htmltooltip=$langs->trans("ECMAreaDesc2");
|
||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||
|
|
@ -343,15 +344,28 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print '<td align="left">';
|
||||
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
|
||||
tree_showpad($sectionauto,$key);
|
||||
print '</td><td valign="top">';
|
||||
print img_picto('','object_dir');
|
||||
print '</td><td valign="middle"> ';
|
||||
print '</td>';
|
||||
|
||||
print '<td valign="top">';
|
||||
$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 '</td>';
|
||||
|
||||
print '<td valign="middle">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/ecm/docother.php">';
|
||||
print $val['label'];
|
||||
print '</a></td></tr></table>';
|
||||
print "</td>\n";
|
||||
|
||||
// Nb of doc
|
||||
// Nb of doc in dir
|
||||
print '<td align="right"> </td>';
|
||||
|
||||
// Nb of doc in subdir
|
||||
print '<td align="right"> </td>';
|
||||
|
||||
// Edit link
|
||||
|
|
@ -363,7 +377,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
// Info
|
||||
print '<td align="center">';
|
||||
$htmltooltip='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMAutoOrg").'<br>';
|
||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionAuto").'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$langs->trans("ECMTypeAuto").'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['desc'];
|
||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||
|
|
@ -382,7 +396,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print '<table class="nobordernopadding"><tr class="nobordernopadding">';
|
||||
print '<td align="left" width="24px">';
|
||||
print img_picto_common('','treemenu/base.gif');
|
||||
print '</td><td align="left">'.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionManual").')';
|
||||
print '</td><td align="left">'.$langs->trans("ECMRoot").' ('.$langs->trans("ECMSectionsManual").')';
|
||||
print '</td>';
|
||||
print '</tr></table></td>';
|
||||
print '<td align="right">';
|
||||
|
|
@ -390,6 +404,7 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print '<td align="right"> </td>';
|
||||
//print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docdir.php?action=create">'.img_edit_add().'</a></td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="right"> </td>';
|
||||
print '<td align="center">';
|
||||
$htmltooltip=$langs->trans("ECMAreaDesc2");
|
||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||
|
|
@ -488,8 +503,11 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print '<table class="nobordernopadding"><tr class="nobordernopadding"><td>';
|
||||
$resarray=tree_showpad($fulltree,$key);
|
||||
$a=$resarray[0];
|
||||
$b=$resarray[1];
|
||||
$nbofsubdir=$resarray[1];
|
||||
$c=$resarray[2];
|
||||
$nboffilesinsubdir=$resarray[3];
|
||||
print '</td>';
|
||||
|
||||
// Show picto
|
||||
print '<td valign="top">';
|
||||
//print $val['fullpath']."(".$showline.")";
|
||||
|
|
@ -515,8 +533,13 @@ if (empty($action) || $action == 'file_manager' || eregi('refresh',$action) || $
|
|||
print "</td>\n";
|
||||
|
||||
// Nb of docs
|
||||
print '<td align="right">'.$val['cachenbofdoc'].'</td>';
|
||||
|
||||
print '<td align="right">';
|
||||
print $val['cachenbofdoc'];
|
||||
print '</td>';
|
||||
print '<td align="left">';
|
||||
if ($nbofsubdir && $nboffilesinsubdir) print '<font color="#AAAAAA">+'.$nboffilesinsubdir.'</font> ';
|
||||
print '</td>';
|
||||
|
||||
// Edit link
|
||||
print '<td align="right"><a href="'.DOL_URL_ROOT.'/ecm/docmine.php?section='.$val['id'].'">'.img_edit().'</a></td>';
|
||||
|
||||
|
|
@ -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='<b>'.$langs->trans("ECMSection").'</b>: '.$val['label'].'<br>';
|
||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMManualOrg").'<br>';
|
||||
$htmltooltip='<b>'.$langs->trans("Type").'</b>: '.$langs->trans("ECMSectionManual").'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationUser").'</b>: '.$userstatic->getNomUrl(1).'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("ECMCreationDate").'</b>: '.dolibarr_print_date($val['date_c'],"dayhour").'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'];
|
||||
$htmltooltip.='<b>'.$langs->trans("Description").'</b>: '.$val['description'].'<br>';
|
||||
$htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInDir").'</b>: '.$val['cachenbofdoc'].'<br>';
|
||||
if ($nbofsubdir) $htmltooltip.='<b>'.$langs->trans("ECMNbOfFilesInSubDir").'</b>: '.$nboffilesinsubdir;
|
||||
else $htmltooltip.='<b>'.$langs->trans("ECMNbOfSubDir").'</b>: '.$nbofsubdir.'<br>';
|
||||
print $form->textwithhelp('',$htmltooltip,1,0);
|
||||
print "</td>";
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
See http://dolibarr.com/wikidev/index.php/Documentation_traducteur
|
||||
See http://dolibarr.com/wikidev/index.php/Documentation_traducteur
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
google.lang
|
||||
google.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...).<br>* Les rubriques manuelles peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
|
||||
ECMSectionWasRemoved=La rubrique <b>%s</b> 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...).<br>* Les répertoires manuels peuvent etre utilisées pour stocker des documents divers, non liés à un objet particulier.
|
||||
ECMSectionWasRemoved=Le répertoire <b>%s</b> 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 <b>%s</b> ?
|
||||
ECMNoDirecotyYet=Aucun répertoire créée
|
||||
ShowECMSection=Afficher répertoire
|
||||
DeleteSection=Suppression répertoire
|
||||
ConfirmDeleteSection=Confirmez-vous la suppression du répertoire <b>%s</b> ?
|
||||
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...
|
||||
ECMSelectASection=Selectionner un répertoire sur l'arbre de gauche...
|
||||
|
|
@ -23,4 +23,4 @@ Enfin, la loi pour la confiance dans l'
|
|||
|
||||
<P class="bodytext">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é. </P>
|
||||
<P class="bodytext">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 <a href="http://www.cnil.fr/index.php?id=301" target="cnil">loi Informatique et Libertés du 6 janvier 1978</a>.
|
||||
</P>
|
||||
</P>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
htmlMimeMail
|
||||
htmlMimeMail
|
||||
|
|
|
|||
|
|
@ -1,69 +1,69 @@
|
|||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n";
|
||||
$var = True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td>';
|
||||
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* 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 '<table class="noborder" width="100%">';
|
||||
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n";
|
||||
$var = True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
$var = !$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td><a href="fiche.php?socid='.$obj->socid.'">'.$obj->nom.'</a></td>';
|
||||
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">'.img_delete().'</a></td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \mainpage Dolibarr project
|
||||
*
|
||||
* This is source documentation for Dolibarr.<br>
|
||||
* This documentation can be built or updated running the script <b>dolibarr-doxygen-build.pl</b><br>
|
||||
* <br>
|
||||
* Dolibarr official web site: <a href="http://dolibarr.org">dolibarr.org</a><br>
|
||||
<?php
|
||||
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \mainpage Dolibarr project
|
||||
*
|
||||
* This is source documentation for Dolibarr.<br>
|
||||
* This documentation can be built or updated running the script <b>dolibarr-doxygen-build.pl</b><br>
|
||||
* <br>
|
||||
* Dolibarr official web site: <a href="http://dolibarr.org">dolibarr.org</a><br>
|
||||
*/
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
//
|
||||
// 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;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,415 +1,415 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
\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;
|
||||
}
|
||||
|
||||
<?php
|
||||
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
\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;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user