1 |
<?php |
<?php |
2 |
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> |
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> |
3 |
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> |
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> |
4 |
* |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
6 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
7 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
8 |
* (at your option) any later version. |
* (at your option) any later version. |
9 |
* |
* |
10 |
* This program is distributed in the hope that it will be useful, |
* This program is distributed in the hope that it will be useful, |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
14 |
* |
* |
15 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
16 |
* along with this program; if not, write to the Free Software |
* along with this program; if not, write to the Free Software |
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 |
* |
* |
19 |
* $Id$ |
* $Id$ |
20 |
* $Source$ |
* $Source$ |
21 |
*/ |
*/ |
22 |
|
|
23 |
/** |
/** |
24 |
\file htdocs/compta/index.php |
\file htdocs/compta/index.php |
25 |
\ingroup compta |
\ingroup compta |
26 |
\brief Page accueil zone comptabilité |
\brief Page accueil zone comptabilité |
27 |
\version $Revision$ |
\version $Revision$ |
28 |
*/ |
*/ |
29 |
|
|
30 |
require("./pre.inc.php"); |
require("./pre.inc.php"); |
31 |
|
|
32 |
$user->getrights(); // On a besoin des permissions sur plusieurs modules |
$user->getrights(); // On a besoin des permissions sur plusieurs modules |
33 |
|
|
34 |
$langs->load("compta"); |
$langs->load("compta"); |
35 |
$langs->load("bills"); |
$langs->load("bills"); |
36 |
|
|
37 |
// Sécurité accés client |
// Sécurité accés client |
38 |
$socidp=''; |
$socidp=''; |
39 |
if ($user->societe_id > 0) |
if ($user->societe_id > 0) |
40 |
{ |
{ |
41 |
$action = ''; |
$action = ''; |
42 |
$socidp = $user->societe_id; |
$socidp = $user->societe_id; |
43 |
} |
} |
44 |
|
|
45 |
|
|
46 |
llxHeader("",$langs->trans("AccountancyTreasuryArea")); |
llxHeader("",$langs->trans("AccountancyTreasuryArea")); |
47 |
|
|
48 |
|
|
49 |
/* |
/* |
50 |
* Actions |
* Actions |
51 |
*/ |
*/ |
52 |
|
|
53 |
if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') |
if (isset($_GET["action"]) && $_GET["action"] == 'add_bookmark') |
54 |
{ |
{ |
55 |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id; |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id; |
56 |
if (! $db->query($sql) ) |
if (! $db->query($sql) ) |
57 |
{ |
{ |
58 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
59 |
} |
} |
60 |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");"; |
$sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");"; |
61 |
if (! $db->query($sql) ) |
if (! $db->query($sql) ) |
62 |
{ |
{ |
63 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
64 |
} |
} |
65 |
} |
} |
66 |
|
|
67 |
if (isset($_GET["action"]) && $_GET["action"] == 'del_bookmark') |
if (isset($_GET["action"]) && $_GET["action"] == 'del_bookmark') |
68 |
{ |
{ |
69 |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; |
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=".$_GET["bid"]; |
70 |
$result = $db->query($sql); |
$result = $db->query($sql); |
71 |
} |
} |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
/* |
/* |
76 |
* Affichage page |
* Affichage page |
77 |
* |
* |
78 |
*/ |
*/ |
79 |
print_fiche_titre($langs->trans("AccountancyTreasuryArea")); |
print_fiche_titre($langs->trans("AccountancyTreasuryArea")); |
80 |
|
|
81 |
print '<table border="0" width="100%" class="notopnoleftnoright">'; |
print '<table border="0" width="100%" class="notopnoleftnoright">'; |
82 |
|
|
83 |
print '<tr><td valign="top" width="30%" class="notopnoleft">'; |
print '<tr><td valign="top" width="30%" class="notopnoleft">'; |
84 |
|
|
85 |
/* |
/* |
86 |
* Zone recherche facture |
* Zone recherche facture |
87 |
*/ |
*/ |
88 |
if ($conf->facture->enabled) { |
if ($conf->facture->enabled) { |
89 |
print '<form method="post" action="facture.php">'; |
print '<form method="post" action="facture.php">'; |
90 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
91 |
print "<tr class=\"liste_titre\">"; |
print "<tr class=\"liste_titre\">"; |
92 |
print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>'; |
print '<td colspan="3">'.$langs->trans("SearchABill").'</td></tr>'; |
93 |
print "<tr $bc[0]><td>".$langs->trans("Ref").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'; |
print "<tr $bc[0]><td>".$langs->trans("Ref").':</td><td><input type="text" name="sf_ref" class="flat" size="18"></td>'; |
94 |
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; |
print '<td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>'; |
95 |
print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>'; |
print "<tr $bc[0]><td>".$langs->trans("Other").':</td><td><input type="text" name="sall" class="flat" size="18"></td>'; |
96 |
print '</tr>'; |
print '</tr>'; |
97 |
print "</table></form><br>"; |
print "</table></form><br>"; |
98 |
} |
} |
99 |
|
|
100 |
|
|
101 |
/** |
/** |
102 |
* Factures brouillons |
* Factures brouillons |
103 |
*/ |
*/ |
104 |
if ($conf->facture->enabled && $user->rights->facture->lire) |
if ($conf->facture->enabled && $user->rights->facture->lire) |
105 |
{ |
{ |
106 |
|
|
107 |
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom, s.idp"; |
$sql = "SELECT f.facnumber, f.rowid, f.total_ttc, s.nom, s.idp"; |
108 |
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; |
$sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; |
109 |
$sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; |
$sql .= " WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; |
110 |
|
|
111 |
if ($socidp) |
if ($socidp) |
112 |
{ |
{ |
113 |
$sql .= " AND f.fk_soc = $socidp"; |
$sql .= " AND f.fk_soc = $socidp"; |
114 |
} |
} |
115 |
|
|
116 |
$resql = $db->query($sql); |
$resql = $db->query($sql); |
117 |
|
|
118 |
if ( $resql ) |
if ( $resql ) |
119 |
{ |
{ |
120 |
$num = $db->num_rows($resql); |
$num = $db->num_rows($resql); |
121 |
if ($num) |
if ($num) |
122 |
{ |
{ |
123 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
124 |
print '<tr class="liste_titre">'; |
print '<tr class="liste_titre">'; |
125 |
print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>'; |
print '<td colspan="3">'.$langs->trans("DraftBills").' ('.$num.')</td></tr>'; |
126 |
$i = 0; |
$i = 0; |
127 |
$tot_ttc = 0; |
$tot_ttc = 0; |
128 |
$var = True; |
$var = True; |
129 |
while ($i < $num && $i < 20) |
while ($i < $num && $i < 20) |
130 |
{ |
{ |
131 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
132 |
$var=!$var; |
$var=!$var; |
133 |
print '<tr '.$bc[$var].'><td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; |
print '<tr '.$bc[$var].'><td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; |
134 |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,20).'</a></td>'; |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dolibarr_trunc($obj->nom,20).'</a></td>'; |
135 |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
136 |
print '</tr>'; |
print '</tr>'; |
137 |
$tot_ttc+=$obj->total_ttc; |
$tot_ttc+=$obj->total_ttc; |
138 |
$i++; |
$i++; |
139 |
} |
} |
140 |
|
|
141 |
print '<tr class="liste_total"><td colspan="2" align="left">'.$langs->trans("Total").'</td>'; |
print '<tr class="liste_total"><td colspan="2" align="left">'.$langs->trans("Total").'</td>'; |
142 |
print '<td align="right">'.price($tot_ttc).'</td>'; |
print '<td align="right">'.price($tot_ttc).'</td>'; |
143 |
print '</tr>'; |
print '</tr>'; |
144 |
|
|
145 |
print "</table><br>"; |
print "</table><br>"; |
146 |
} |
} |
147 |
$db->free($resql); |
$db->free($resql); |
148 |
} |
} |
149 |
else |
else |
150 |
{ |
{ |
151 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
152 |
} |
} |
153 |
} |
} |
154 |
|
|
155 |
/** |
/** |
156 |
* Charges a payer |
* Charges a payer |
157 |
*/ |
*/ |
158 |
if ($conf->compta->enabled) |
if ($conf->compta->enabled) |
159 |
{ |
{ |
160 |
if ($user->societe_id == 0) |
if ($user->societe_id == 0) |
161 |
{ |
{ |
162 |
|
|
163 |
$sql = "SELECT c.rowid, c.amount, cc.libelle"; |
$sql = "SELECT c.rowid, c.amount, cc.libelle"; |
164 |
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc"; |
$sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc"; |
165 |
$sql .= " WHERE c.fk_type = cc.id AND c.paye=0"; |
$sql .= " WHERE c.fk_type = cc.id AND c.paye=0"; |
166 |
|
|
167 |
$resql = $db->query($sql); |
$resql = $db->query($sql); |
168 |
|
|
169 |
if ( $resql ) |
if ( $resql ) |
170 |
{ |
{ |
171 |
$num = $db->num_rows($resql); |
$num = $db->num_rows($resql); |
172 |
if ($num) |
if ($num) |
173 |
{ |
{ |
174 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
175 |
print '<tr class="liste_titre">'; |
print '<tr class="liste_titre">'; |
176 |
print '<td colspan="2">'.$langs->trans("ContributionsToPay").' ('.$num.')</td></tr>'; |
print '<td colspan="2">'.$langs->trans("ContributionsToPay").' ('.$num.')</td></tr>'; |
177 |
$i = 0; |
$i = 0; |
178 |
$tot_ttc=0; |
$tot_ttc=0; |
179 |
$var = True; |
$var = True; |
180 |
while ($i < $num) |
while ($i < $num) |
181 |
{ |
{ |
182 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
183 |
$var = !$var; |
$var = !$var; |
184 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
185 |
print '<td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->libelle.'</td>'; |
print '<td><a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->libelle.'</td>'; |
186 |
print '<td align="right">'.price($obj->amount).'</td>'; |
print '<td align="right">'.price($obj->amount).'</td>'; |
187 |
print '</tr>'; |
print '</tr>'; |
188 |
$tot_ttc+=$obj->amount; |
$tot_ttc+=$obj->amount; |
189 |
$i++; |
$i++; |
190 |
} |
} |
191 |
|
|
192 |
print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>'; |
print '<tr class="liste_total"><td align="left">'.$langs->trans("Total").'</td>'; |
193 |
print '<td align="right">'.price($tot_ttc).'</td>'; |
print '<td align="right">'.price($tot_ttc).'</td>'; |
194 |
print '</tr>'; |
print '</tr>'; |
195 |
|
|
196 |
print '</table><br>'; |
print '</table><br>'; |
197 |
} |
} |
198 |
$db->free($resql); |
$db->free($resql); |
199 |
} |
} |
200 |
else |
else |
201 |
{ |
{ |
202 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
203 |
} |
} |
204 |
} |
} |
205 |
} |
} |
206 |
|
|
207 |
|
|
208 |
/** |
/** |
209 |
* Bookmark |
* Bookmark |
210 |
*/ |
*/ |
211 |
$sql = "SELECT s.idp, s.nom,b.rowid as bid"; |
$sql = "SELECT s.idp, s.nom,b.rowid as bid"; |
212 |
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; |
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; |
213 |
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; |
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; |
214 |
$sql .= " ORDER BY lower(s.nom) ASC"; |
$sql .= " ORDER BY lower(s.nom) ASC"; |
215 |
|
|
216 |
$resql = $db->query($sql); |
$resql = $db->query($sql); |
217 |
|
|
218 |
if ( $resql ) |
if ( $resql ) |
219 |
{ |
{ |
220 |
$num = $db->num_rows($resql); |
$num = $db->num_rows($resql); |
221 |
$i = 0; |
$i = 0; |
222 |
if ($num) |
if ($num) |
223 |
{ |
{ |
224 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
225 |
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n"; |
print "<tr class=\"liste_titre\"><td colspan=\"2\">".$langs->trans("Bookmarks")."</td></tr>\n"; |
226 |
$var = True; |
$var = True; |
227 |
while ($i < $num) |
while ($i < $num) |
228 |
{ |
{ |
229 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
230 |
$var = !$var; |
$var = !$var; |
231 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
232 |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>'; |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>'; |
233 |
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">'.img_delete().'</a></td>'; |
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">'.img_delete().'</a></td>'; |
234 |
print '</tr>'; |
print '</tr>'; |
235 |
$i++; |
$i++; |
236 |
} |
} |
237 |
print '</table>'; |
print '</table>'; |
238 |
} |
} |
239 |
$db->free($resql); |
$db->free($resql); |
240 |
} |
} |
241 |
else |
else |
242 |
{ |
{ |
243 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
244 |
} |
} |
245 |
|
|
246 |
|
|
247 |
print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; |
print '</td><td valign="top" width="70%" class="notopnoleftnoright">'; |
248 |
|
|
249 |
|
|
250 |
/* |
/* |
251 |
* Commandes à facturer |
* Commandes à facturer |
252 |
*/ |
*/ |
253 |
if ($conf->commande->enabled && $user->rights->commande->lire) |
if ($conf->commande->enabled && $user->rights->commande->lire) |
254 |
{ |
{ |
255 |
$langs->load("orders"); |
$langs->load("orders"); |
256 |
|
|
257 |
$sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; |
$sql = "SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc"; |
258 |
$sql .= " ,s.nom, s.idp, p.rowid, p.ref, p.total_ht, p.total_ttc"; |
$sql .= " ,s.nom, s.idp, p.rowid, p.ref, p.total_ht, p.total_ttc"; |
259 |
$sql .= " FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s"; |
$sql .= " FROM ".MAIN_DB_PREFIX."commande AS p, llx_societe AS s"; |
260 |
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid"; |
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."co_fa AS co_fa ON co_fa.fk_commande = p.rowid"; |
261 |
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid"; |
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture AS f ON co_fa.fk_facture = f.rowid"; |
262 |
$sql .= " WHERE p.fk_soc = s.idp"; |
$sql .= " WHERE p.fk_soc = s.idp"; |
263 |
if ($socidp) |
if ($socidp) |
264 |
{ |
{ |
265 |
$sql .= " AND p.fk_soc = $socidp"; |
$sql .= " AND p.fk_soc = $socidp"; |
266 |
} |
} |
267 |
$sql .= " AND p.fk_statut >=1 AND p.facture=0"; |
$sql .= " AND p.fk_statut >=1 AND p.facture=0"; |
268 |
$sql .= " GROUP BY p.rowid"; |
$sql .= " GROUP BY p.rowid"; |
269 |
|
|
270 |
$resql = $db->query($sql); |
$resql = $db->query($sql); |
271 |
|
|
272 |
if ( $resql ) |
if ( $resql ) |
273 |
{ |
{ |
274 |
$num = $db->num_rows($resql); |
$num = $db->num_rows($resql); |
275 |
if ($num) |
if ($num) |
276 |
{ |
{ |
277 |
$i = 0; |
$i = 0; |
278 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
279 |
print "<tr class=\"liste_titre\">"; |
print "<tr class=\"liste_titre\">"; |
280 |
print '<td colspan="2">'.$langs->trans("OrdersToBill").' ('.$num.')</td>'; |
print '<td colspan="2">'.$langs->trans("OrdersToBill").' ('.$num.')</td>'; |
281 |
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; |
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; |
282 |
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; |
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; |
283 |
print '<td align="right">'.$langs->trans("ToBill").'</td>'; |
print '<td align="right">'.$langs->trans("ToBill").'</td>'; |
284 |
print '</tr>'; |
print '</tr>'; |
285 |
$var = True; |
$var = True; |
286 |
$tot_ht=$tot_ttc=$tot_tobill=0; |
$tot_ht=$tot_ttc=$tot_tobill=0; |
287 |
while ($i < $num) |
while ($i < $num) |
288 |
{ |
{ |
289 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
290 |
// if ($obj->total_ttc-$obj->tot_fttc >0) |
// if ($obj->total_ttc-$obj->tot_fttc >0) |
291 |
// { |
// { |
292 |
$var=!$var; |
$var=!$var; |
293 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
294 |
print "<td width=\"20%\"><a href=\"commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a> '; |
print "<td width=\"20%\"><a href=\"commande/fiche.php?id=$obj->rowid\">".img_object($langs->trans("ShowOrder"),"order").'</a> '; |
295 |
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>'; |
print "<a href=\"commande/fiche.php?id=$obj->rowid\">".$obj->ref.'</a></td>'; |
296 |
|
|
297 |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> '; |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").'</a> '; |
298 |
print '<a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,50).'</a></td>'; |
print '<a href="fiche.php?socid='.$obj->idp.'">'.dolibarr_trunc($obj->nom,50).'</a></td>'; |
299 |
print '<td align="right">'.price($obj->total_ht).'</td>'; |
print '<td align="right">'.price($obj->total_ht).'</td>'; |
300 |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
301 |
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>'; |
print '<td align="right">'.price($obj->total_ttc-$obj->tot_fttc).'</td></tr>'; |
302 |
$tot_ht += $obj->total_ht; |
$tot_ht += $obj->total_ht; |
303 |
$tot_ttc += $obj->total_ttc; |
$tot_ttc += $obj->total_ttc; |
304 |
$tot_tobill += ($obj->total_ttc-$obj->tot_fttc); |
$tot_tobill += ($obj->total_ttc-$obj->tot_fttc); |
305 |
// } |
// } |
306 |
$i++; |
$i++; |
307 |
} |
} |
308 |
$var=!$var; |
$var=!$var; |
309 |
|
|
310 |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>'; |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToBill").': '.price($tot_tobill).')</font> </td>'; |
311 |
print '<td align="right">'.price($tot_ht).'</td>'; |
print '<td align="right">'.price($tot_ht).'</td>'; |
312 |
print '<td align="right">'.price($tot_ttc).'</td>'; |
print '<td align="right">'.price($tot_ttc).'</td>'; |
313 |
print '<td align="right">'.price($tot_tobill).'</td>'; |
print '<td align="right">'.price($tot_tobill).'</td>'; |
314 |
print '</tr>'; |
print '</tr>'; |
315 |
print '</table><br>'; |
print '</table><br>'; |
316 |
} |
} |
317 |
$db->free($resql); |
$db->free($resql); |
318 |
} |
} |
319 |
else |
else |
320 |
{ |
{ |
321 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
322 |
} |
} |
323 |
} |
} |
324 |
|
|
325 |
|
|
326 |
if ($conf->facture->enabled && $user->rights->facture->lire) |
if ($conf->facture->enabled && $user->rights->facture->lire) |
327 |
{ |
{ |
328 |
|
|
329 |
/* |
/* |
330 |
* Factures impayées |
* Factures impayées |
331 |
* |
* |
332 |
*/ |
*/ |
333 |
|
|
334 |
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc, ".$db->pdate("f.date_lim_reglement")." as datelimite, sum(pf.amount) as am"; |
$sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc, ".$db->pdate("f.date_lim_reglement")." as datelimite, sum(pf.amount) as am"; |
335 |
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; |
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; |
336 |
$sql.= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; |
$sql.= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; |
337 |
if ($socidp) $sql .= " AND f.fk_soc = $socidp"; |
if ($socidp) $sql .= " AND f.fk_soc = $socidp"; |
338 |
$sql.= " GROUP BY f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc"; |
$sql.= " GROUP BY f.facnumber, f.rowid, s.nom, s.idp, f.total, f.total_ttc"; |
339 |
$sql.= " ORDER BY f.datef ASC "; |
$sql.= " ORDER BY f.datef ASC "; |
340 |
|
|
341 |
$resql = $db->query($sql); |
$resql = $db->query($sql); |
342 |
if ($resql) |
if ($resql) |
343 |
{ |
{ |
344 |
$num = $db->num_rows($resql); |
$num = $db->num_rows($resql); |
345 |
$i = 0; |
$i = 0; |
346 |
|
|
347 |
if ($num) |
if ($num) |
348 |
{ |
{ |
349 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
350 |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpayed").' ('.$num.')</td>'; |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsCustomersUnpayed").' ('.$num.')</td>'; |
351 |
print '<td align="right">'.$langs->trans("AmountHT").'</td><td align="right">'.$langs->trans("AmountTTC").'</td><td align="right">'.$langs->trans("Received").'</td></tr>'; |
print '<td align="right">'.$langs->trans("AmountHT").'</td><td align="right">'.$langs->trans("AmountTTC").'</td><td align="right">'.$langs->trans("Received").'</td></tr>'; |
352 |
$var = True; |
$var = True; |
353 |
$total_ttc = $totalam = $total = 0; |
$total_ttc = $totalam = $total = 0; |
354 |
while ($i < $num) |
while ($i < $num) |
355 |
{ |
{ |
356 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
357 |
|
|
358 |
if ($i < $conf->liste_limit) |
if ($i < $conf->liste_limit) |
359 |
{ |
{ |
360 |
$var=!$var; |
$var=!$var; |
361 |
print '<tr '.$bc[$var].'>'; |
print '<tr '.$bc[$var].'>'; |
362 |
print '<td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a>'; |
print '<td nowrap><a href="facture.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a>'; |
363 |
if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); |
if ($obj->datelimite < (time() - $conf->facture->client->warning_delay)) print img_warning($langs->trans("Late")); |
364 |
print '</td>'; |
print '</td>'; |
365 |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>'; |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowCustomer"),"company").' '.dolibarr_trunc($obj->nom,44).'</a></td>'; |
366 |
print '<td align="right">'.price($obj->total).'</td>'; |
print '<td align="right">'.price($obj->total).'</td>'; |
367 |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
368 |
print '<td align="right">'.price($obj->am).'</td></tr>'; |
print '<td align="right">'.price($obj->am).'</td></tr>'; |
369 |
} |
} |
370 |
$total_ttc += $obj->total_ttc; |
$total_ttc += $obj->total_ttc; |
371 |
$total += $obj->total; |
$total += $obj->total; |
372 |
$totalam += $obj->am; |
$totalam += $obj->am; |
373 |
$i++; |
$i++; |
374 |
} |
} |
375 |
$var=!$var; |
$var=!$var; |
376 |
|
|
377 |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</font> </td>'; |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToTake").': '.price($total_ttc-$totalam).')</font> </td>'; |
378 |
print '<td align="right">'.price($total).'</td>'; |
print '<td align="right">'.price($total).'</td>'; |
379 |
print '<td align="right">'.price($total_ttc).'</td>'; |
print '<td align="right">'.price($total_ttc).'</td>'; |
380 |
print '<td align="right">'.price($totalam).'</td>'; |
print '<td align="right">'.price($totalam).'</td>'; |
381 |
print '</tr>'; |
print '</tr>'; |
382 |
print '</table><br>'; |
print '</table><br>'; |
383 |
} |
} |
384 |
$db->free($resql); |
$db->free($resql); |
385 |
} |
} |
386 |
else |
else |
387 |
{ |
{ |
388 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
389 |
} |
} |
390 |
} |
} |
391 |
|
|
392 |
|
|
393 |
// \todo Mettre ici recup des actions en rapport avec la compta |
// \todo Mettre ici recup des actions en rapport avec la compta |
394 |
$resql = 0; |
$resql = 0; |
395 |
if ($resql) |
if ($resql) |
396 |
{ |
{ |
397 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
398 |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TasksToDo").'</td>'; |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("TasksToDo").'</td>'; |
399 |
print "</tr>\n"; |
print "</tr>\n"; |
400 |
$var = True; |
$var = True; |
401 |
$i = 0; |
$i = 0; |
402 |
while ($i < $db->num_rows($resql) ) |
while ($i < $db->num_rows($resql) ) |
403 |
{ |
{ |
404 |
$obj = $db->fetch_object($resql); |
$obj = $db->fetch_object($resql); |
405 |
$var=!$var; |
$var=!$var; |
406 |
|
|
407 |
print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td><td><a href=\"action/fiche.php\">$obj->libelle $obj->label</a></td></tr>"; |
print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td><td><a href=\"action/fiche.php\">$obj->libelle $obj->label</a></td></tr>"; |
408 |
$i++; |
$i++; |
409 |
} |
} |
410 |
$db->free($resql); |
$db->free($resql); |
411 |
print "</table><br>"; |
print "</table><br>"; |
412 |
} |
} |
413 |
|
|
414 |
|
|
415 |
/* |
/* |
416 |
* Factures a payer |
* Factures a payer |
417 |
*/ |
*/ |
418 |
if ($conf->facture->enabled) { |
if ($conf->facture->enabled) { |
419 |
|
|
420 |
if ($user->societe_id == 0) |
if ($user->societe_id == 0) |
421 |
{ |
{ |
422 |
$sql = "SELECT ff.rowid, ff.facnumber, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.idp"; |
$sql = "SELECT ff.rowid, ff.facnumber, ff.libelle, ff.total_ht, ff.total_ttc, s.nom, s.idp"; |
423 |
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; |
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_fourn as ff"; |
424 |
$sql .= " WHERE s.idp = ff.fk_soc"; |
$sql .= " WHERE s.idp = ff.fk_soc"; |
425 |
$sql .= " AND ff.paye=0"; |
$sql .= " AND ff.paye=0"; |
426 |
|
|
427 |
$result=$db->query($sql); |
$result=$db->query($sql); |
428 |
if ($result) |
if ($result) |
429 |
{ |
{ |
430 |
$num = $db->num_rows(); |
$num = $db->num_rows(); |
431 |
if ($num) |
if ($num) |
432 |
{ |
{ |
433 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
434 |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsSuppliersUnpayed").' ('.$num.')</td>'; |
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("BillsSuppliersUnpayed").' ('.$num.')</td>'; |
435 |
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; |
print '<td align="right">'.$langs->trans("AmountHT").'</td>'; |
436 |
print '<td align="right">'.$langs->trans("AmountTTC").'</td></tr>'; |
print '<td align="right">'.$langs->trans("AmountTTC").'</td></tr>'; |
437 |
print "</tr>\n"; |
print "</tr>\n"; |
438 |
$i = 0; |
$i = 0; |
439 |
$var = True; |
$var = True; |
440 |
$total = $total_ttc = $totalam = 0; |
$total = $total_ttc = $totalam = 0; |
441 |
while ($i < $num) |
while ($i < $num) |
442 |
{ |
{ |
443 |
$obj = $db->fetch_object($result); |
$obj = $db->fetch_object($result); |
444 |
$var = !$var; |
$var = !$var; |
445 |
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; |
print '<tr '.$bc[$var].'><td><a href="'.DOL_URL_ROOT.'/fourn/facture/fiche.php?facid='.$obj->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$obj->facnumber.'</a></td>'; |
446 |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,50).'</a></td>'; |
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.img_object($langs->trans("ShowSupplier"),"company").' '.dolibarr_trunc($obj->nom,50).'</a></td>'; |
447 |
print '<td align="right">'.price($obj->total_ht).'</td>'; |
print '<td align="right">'.price($obj->total_ht).'</td>'; |
448 |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
print '<td align="right">'.price($obj->total_ttc).'</td>'; |
449 |
print '</tr>'; |
print '</tr>'; |
450 |
$total += $obj->total_ht; |
$total += $obj->total_ht; |
451 |
$total_ttc += $obj->total_ttc; |
$total_ttc += $obj->total_ttc; |
452 |
$totalam += $obj->am; |
$totalam += $obj->am; |
453 |
$i++; |
$i++; |
454 |
} |
} |
455 |
$var=!$var; |
$var=!$var; |
456 |
|
|
457 |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</font> </td>'; |
print '<tr class="liste_total"><td colspan="2" align="right">'.$langs->trans("Total").' <font style="font-weight: normal">('.$langs->trans("RemainderToPay").': '.price($total_ttc-$totalam).')</font> </td>'; |
458 |
print '<td align="right">'.price($total).'</td>'; |
print '<td align="right">'.price($total).'</td>'; |
459 |
print '<td align="right">'.price($total_ttc).'</td>'; |
print '<td align="right">'.price($total_ttc).'</td>'; |
460 |
print '</tr>'; |
print '</tr>'; |
461 |
print '</table><br>'; |
print '</table><br>'; |
462 |
} |
} |
463 |
} |
} |
464 |
else |
else |
465 |
{ |
{ |
466 |
dolibarr_print_error($db); |
dolibarr_print_error($db); |
467 |
} |
} |
468 |
} |
} |
469 |
|
|
470 |
} |
} |
471 |
|
|
472 |
|
|
473 |
print '</td></tr>'; |
print '</td></tr>'; |
474 |
|
|
475 |
print '</table>'; |
print '</table>'; |
476 |
|
|
477 |
$db->close(); |
$db->close(); |
478 |
|
|
479 |
|
|
480 |
llxFooter('$Date$ - $Revision$'); |
llxFooter('$Date$ - $Revision$'); |
481 |
?> |
?> |