29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
32require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
43$langs->loadLangs(array(
'bills',
'companies'));
47if ($user->socid > 0) {
49 $socid = $user->socid;
53$hookmanager->initHooks(array(
'supplierbalencelist',
'globalcard'));
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
60if (empty($page) || $page == -1) {
63$offset = $limit * $page;
67 $sortfield =
"f.datef,f.rowid";
78$userstatic =
new User($db);
80llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-fourn page-recap-fourn');
84 $societe->fetch($socid);
91 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), 0,
'company');
92 dol_banner_tab($societe,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
95 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
"fournisseur",
"facture",
"lire") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
"supplier_invoice",
"lire"))) {
102 $param .=
'&socid=' . $socid;
105 print
'<table class="noborder tagtable liste centpercent">';
106 print
'<tr class="liste_titre">';
107 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
108 print
'<td>' . $langs->trans(
"Element") .
'</td>';
109 print
'<td>' . $langs->trans(
"Status") .
'</td>';
110 print
'<td class="right">' . $langs->trans(
"Debit") .
'</td>';
111 print
'<td class="right">' . $langs->trans(
"Credit") .
'</td>';
112 print
'<td class="right">' . $langs->trans(
"Balance") .
'</td>';
113 print
'<td class="right">' . $langs->trans(
"Author") .
'</td>';
119 $sql =
"SELECT s.nom, s.rowid as socid, f.ref_supplier, f.total_ttc, f.datef as df,";
120 $sql .=
" f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
121 $sql .=
" u.login, u.rowid as userid";
122 $sql .=
" FROM " . MAIN_DB_PREFIX .
"societe as s," . MAIN_DB_PREFIX .
"facture_fourn as f," . MAIN_DB_PREFIX .
"user as u";
123 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = " . ((int) $societe->id);
124 $sql .=
" AND f.entity IN (" .
getEntity(
"facture_fourn") .
")";
125 $sql .=
" AND f.fk_user_valid = u.rowid";
126 $sql .= $db->order($sortfield, $sortorder);
128 $resql = $db->query($sql);
130 $num = $db->num_rows($resql);
133 for ($i = 0; $i < $num; $i++) {
134 $objf = $db->fetch_object($resql);
137 $ret = $fac->fetch($objf->facid);
139 print $fac->error .
"<br>";
142 $totalpaid = $fac->getSommePaiement();
144 $userstatic->id = $objf->userid;
145 $userstatic->login = $objf->login;
148 'fk_facture' => $objf->facid,
149 'date' => $fac->date,
150 'datefieldforsort' => $fac->date .
'-' . $fac->ref,
151 'link' => $fac->getNomUrl(1),
152 'status' => $fac->getLibStatut(2, $totalpaid),
153 'amount' => $fac->total_ttc,
154 'author' => $userstatic->getLoginUrl(1)
160 $sql =
"SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
161 $sql .=
" p.fk_user_author, u.login, u.rowid as userid";
162 $sql .=
" FROM " . MAIN_DB_PREFIX .
"paiementfourn_facturefourn as pf,";
163 $sql .=
" " . MAIN_DB_PREFIX .
"paiementfourn as p";
164 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u ON p.fk_user_author = u.rowid";
165 $sql .=
" WHERE pf.fk_paiementfourn = p.rowid";
166 $sql .=
" AND pf.fk_facturefourn = " . ((int) $fac->id);
167 $sql .=
" ORDER BY p.datep ASC, p.rowid ASC";
169 $resqlp = $db->query($sql);
171 $nump = $db->num_rows($resqlp);
175 $objp = $db->fetch_object($resqlp);
178 $paymentstatic->id = $objp->rowid;
180 $userstatic->id = $objp->userid;
181 $userstatic->login = $objp->login;
184 'fk_paiement' => $objp->rowid,
185 'date' => $db->jdate($objp->dp),
186 'datefieldforsort' => $db->jdate($objp->dp) .
'-' . $fac->ref,
187 'link' => $langs->trans(
"Payment") .
' ' . $paymentstatic->getNomUrl(1),
189 'amount' => -$objp->amount,
190 'author' => $userstatic->getLoginUrl(1)
208 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">' . $langs->trans(
"NoInvoice") .
'</span></td></tr>';
215 foreach (array_keys($TData) as $key) {
216 $balance += $TData[$key][
'amount'];
217 if (!array_key_exists(
'balance', $TData[$key])) {
218 $TData[$key][
'balance'] = 0;
220 $TData[$key][
'balance'] += $balance;
230 foreach ($TData as $data) {
232 if (!empty($data[
'fk_facture'])) {
233 $html_class =
'facid-' . $data[
'fk_facture'];
234 } elseif (!empty($data[
'fk_paiement'])) {
235 $html_class =
'payid-' . $data[
'fk_paiement'];
238 print
'<tr class="oddeven ' . $html_class .
'">';
241 if (!empty($data[
'fk_facture'])) {
248 print
'<td>' . $data[
'link'] .
"</td>\n";
250 print
'<td class="left">' . $data[
'status'] .
'</td>';
252 print
'<td class="right">' . (($data[
'amount'] > 0) ?
price(abs($data[
'amount'])) :
'') .
"</td>\n";
254 $totalDebit += ($data[
'amount'] > 0) ? abs($data[
'amount']) : 0;
256 print
'<td class="right">' . (($data[
'amount'] > 0) ?
'' :
price(abs($data[
'amount']))) .
"</td>\n";
257 $totalCredit += ($data[
'amount'] > 0) ? 0 : abs($data[
'amount']);
260 print
'<td class="right"><span class="amount">' .
price($data[
'balance']) .
"</span></td>\n";
263 print
'<td class="nowrap right">';
264 print $data[
'author'];
270 print
'<tr class="liste_total">';
271 print
'<td colspan="3"> </td>';
272 print
'<td class="right">' .
price($totalDebit) .
'</td>';
273 print
'<td class="right">' .
price($totalCredit) .
'</td>';
274 print
'<td class="right">' .
price(
price2num($totalDebit - $totalCredit,
'MT')) .
'</td>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage suppliers invoices.
Class to manage payments for supplier invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...