18 |
* |
* |
19 |
* $Id$ |
* $Id$ |
20 |
* $Source$ |
* $Source$ |
|
* |
|
21 |
*/ |
*/ |
22 |
|
|
23 |
/** |
/** |
24 |
\file htdocs/compta/paiement/avalider.php |
\file htdocs/compta/paiement/avalider.php |
25 |
\ingroup compta |
\ingroup compta |
26 |
\brief Page liste des paiements a valider des factures clients |
\brief Page liste des paiements a valider des factures clients |
27 |
\version $Revision$ |
\version $Revision$ |
28 |
*/ |
*/ |
29 |
|
|
30 |
require("./pre.inc.php"); |
require("./pre.inc.php"); |
31 |
|
|
32 |
/* |
$user->getrights("facture"); |
33 |
* Sécurité accés client |
|
34 |
*/ |
|
35 |
|
// Sécurité accés client |
36 |
|
if (! $user->rights->facture->lire) |
37 |
|
accessforbidden(); |
38 |
|
|
39 |
|
$socidp=0; |
40 |
if ($user->societe_id > 0) |
if ($user->societe_id > 0) |
41 |
{ |
{ |
42 |
$action = ''; |
$action = ''; |
43 |
$socidp = $user->societe_id; |
$socidp = $user->societe_id; |
44 |
} |
} |
45 |
|
|
46 |
|
|
47 |
/* |
/* |
48 |
* Affichage |
* Affichage |
49 |
*/ |
*/ |
53 |
$page=$_GET["page"]; |
$page=$_GET["page"]; |
54 |
$sortorder=$_GET["sortorder"]; |
$sortorder=$_GET["sortorder"]; |
55 |
$sortfield=$_GET["sortfield"]; |
$sortfield=$_GET["sortfield"]; |
|
|
|
|
if ($page == -1) |
|
|
$page = 0 ; |
|
|
|
|
|
$limit = $conf->liste_limit; |
|
|
$offset = $limit * $page ; |
|
|
|
|
56 |
if (! $sortorder) $sortorder="DESC"; |
if (! $sortorder) $sortorder="DESC"; |
57 |
if (! $sortfield) $sortfield="p.rowid"; |
if (! $sortfield) $sortfield="p.rowid"; |
58 |
|
if ($page == -1) $page = 0 ; |
59 |
|
$limit = $conf->liste_limit; |
60 |
|
$offset = $limit * $page ; |
61 |
|
|
62 |
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount, p.statut"; |
$sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount, p.statut"; |
63 |
$sql .=", c.libelle as paiement_type, p.num_paiement"; |
$sql .=", c.libelle as paiement_type, p.num_paiement"; |
64 |
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c"; |
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c"; |
65 |
|
if ($socidp) |
66 |
|
{ |
67 |
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement"; |
68 |
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON pf.fk_facture = f.rowid"; |
69 |
|
} |
70 |
$sql .= " WHERE p.fk_paiement = c.id"; |
$sql .= " WHERE p.fk_paiement = c.id"; |
71 |
|
if ($socidp) |
72 |
|
{ |
73 |
|
$sql.= " AND f.fk_soc = ".$socidp; |
74 |
|
} |
75 |
$sql .= " AND p.statut = 0"; |
$sql .= " AND p.statut = 0"; |
76 |
$sql .= " ORDER BY $sortfield $sortorder"; |
$sql .= " ORDER BY $sortfield $sortorder"; |
77 |
$sql .= $db->plimit( $limit +1 ,$offset); |
$sql .= $db->plimit( $limit +1 ,$offset); |
78 |
$result = $db->query($sql); |
$resql = $db->query($sql); |
79 |
|
|
80 |
if ($result) |
if ($resql) |
81 |
{ |
{ |
82 |
$num = $db->num_rows(); |
$num = $db->num_rows($resql); |
83 |
$i = 0; |
$i = 0; |
84 |
$var=True; |
$var=True; |
85 |
|
|
86 |
print_barre_liste("Paiements clients a valider", $page, "avalider.php","",$sortfield,$sortorder,'',$num); |
print_barre_liste($langs->trans("ReceivedCustomersPaymentsToValid"), $page, "avalider.php","",$sortfield,$sortorder,'',$num); |
87 |
|
|
88 |
print '<table class="noborder" width="100%">'; |
print '<table class="noborder" width="100%">'; |
89 |
print '<tr class="liste_titre">'; |
print '<tr class="liste_titre">'; |
90 |
print_liste_field_titre($langs->trans("Ref"),"avalider.php","p.rowid","","","",$sortfield); |
print_liste_field_titre($langs->trans("Ref"),"avalider.php","p.rowid","","","",$sortfield); |
91 |
print_liste_field_titre($langs->trans("Date"),"avalider.php","dp","","","",$sortfield); |
print_liste_field_titre($langs->trans("Date"),"avalider.php","dp","","","",$sortfield); |
92 |
print_liste_field_titre($langs->trans("Type"),"avalider.php","c.libelle","","","",$sortfield); |
print_liste_field_titre($langs->trans("Type"),"avalider.php","c.libelle","","","",$sortfield); |
93 |
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; |
print '<td align="right">'.$langs->trans("AmountTTC").'</td>'; |
94 |
print "<td> </td>"; |
print "<td> </td>"; |
95 |
print "</tr>\n"; |
print "</tr>\n"; |
96 |
|
|
97 |
while ($i < min($num,$limit)) |
while ($i < min($num,$limit)) |
98 |
{ |
{ |
99 |
$objp = $db->fetch_object($result); |
$objp = $db->fetch_object($resql); |
100 |
$var=!$var; |
$var=!$var; |
101 |
print "<tr $bc[$var]>"; |
print "<tr $bc[$var]>"; |
102 |
print '<td>'.'<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.'</a></td>'; |
print '<td>'.'<a href="'.DOL_URL_ROOT.'/compta/paiement/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowPayment"),"payment").' '.$objp->rowid.'</a></td>'; |
103 |
print '<td>'.dolibarr_print_date($objp->dp)."</td>\n"; |
print '<td>'.dolibarr_print_date($objp->dp)."</td>\n"; |
104 |
print "<td>$objp->paiement_type $objp->num_paiement</td>\n"; |
print "<td>$objp->paiement_type $objp->num_paiement</td>\n"; |
105 |
print '<td align="right">'.price($objp->amount).'</td>'; |
print '<td align="right">'.price($objp->amount).'</td>'; |
106 |
print '<td align="center">'; |
print '<td align="center">'; |
107 |
|
|
108 |
if ($objp->statut == 0) |
if ($objp->statut == 0) |
109 |
{ |
{ |
110 |
print '<a href="fiche.php?id='.$objp->rowid.'&action=valide">A valider</a>'; |
print '<a href="fiche.php?id='.$objp->rowid.'&action=valide">'.$langs->trans("ToValid").'</a>'; |
111 |
} |
} |
112 |
else |
else |
113 |
{ |
{ |
114 |
print "-"; |
print "-"; |
115 |
} |
} |
116 |
|
|
117 |
print '</td>'; |
print '</td>'; |
118 |
print "</tr>"; |
print "</tr>"; |
119 |
$i++; |
$i++; |
120 |
} |
} |
121 |
print "</table>"; |
print "</table>"; |
122 |
} |
} |
123 |
|
|
124 |
$db->close(); |
$db->close(); |