29require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT .
'/core/lib/company.lib.php';
38require_once DOL_DOCUMENT_ROOT .
'/fourn/class/fournisseur.facture.class.php';
39require_once DOL_DOCUMENT_ROOT .
'/fourn/class/paiementfourn.class.php';
43$langs->loadLangs(array(
'bills',
'companies'));
47if ($user->isExternalUser()) {
49 $socid = $user->isExternalUser();
54$hookmanager->initHooks(array(
'supplierbalencelist',
'globalcard'));
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page == -1) {
64$offset = $limit * $page;
68 $sortfield =
"f.datef,f.rowid";
79$userstatic =
new User($db);
81llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-fourn page-recap-fourn');
85 $societe->fetch($socid);
92 print
dol_get_fiche_head($head,
'supplier', $langs->trans(
"ThirdParty"), 0,
'company');
93 dol_banner_tab($societe,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom');
96 if ((
isModEnabled(
"fournisseur") && $user->hasRight(
"fournisseur",
"facture",
"lire") && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (
isModEnabled(
"supplier_invoice") && $user->hasRight(
"supplier_invoice",
"lire"))) {
103 $param .=
'&socid=' . $socid;
106 print
'<table class="noborder tagtable liste centpercent">';
107 print
'<tr class="liste_titre">';
108 print_liste_field_titre(
"Date", $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
109 print
'<td>' . $langs->trans(
"Element") .
'</td>';
110 print
'<td>' . $langs->trans(
"Status") .
'</td>';
111 print
'<td class="right">' . $langs->trans(
"Debit") .
'</td>';
112 print
'<td class="right">' . $langs->trans(
"Credit") .
'</td>';
113 print
'<td class="right">' . $langs->trans(
"Balance") .
'</td>';
114 print
'<td class="right">' . $langs->trans(
"Author") .
'</td>';
120 $sql =
"SELECT s.nom, s.rowid as socid, f.ref_supplier, f.total_ttc, f.datef as df,";
121 $sql .=
" f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
122 $sql .=
" u.login, u.rowid as userid";
123 $sql .=
" FROM " . MAIN_DB_PREFIX .
"societe as s," . MAIN_DB_PREFIX .
"facture_fourn as f," . MAIN_DB_PREFIX .
"user as u";
124 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = " . ((int) $societe->id);
125 $sql .=
" AND f.entity IN (" .
getEntity(
"facture_fourn") .
")";
126 $sql .=
" AND f.fk_user_valid = u.rowid";
127 $sql .= $db->order($sortfield, $sortorder);
129 $resql = $db->query($sql);
131 $num = $db->num_rows($resql);
134 for ($i = 0; $i < $num; $i++) {
135 $objf = $db->fetch_object($resql);
138 $ret = $fac->fetch($objf->facid);
140 print $fac->error .
"<br>";
143 $totalpaid = $fac->getSommePaiement();
145 $userstatic->id = $objf->userid;
146 $userstatic->login = $objf->login;
149 'fk_facture' => $objf->facid,
150 'date' => $fac->date,
151 'datefieldforsort' => $fac->date .
'-' . $fac->ref,
152 'link' => $fac->getNomUrl(1),
153 'status' => $fac->getLibStatut(2, $totalpaid),
154 'amount' => $fac->total_ttc,
155 'author' => $userstatic->getLoginUrl(1)
161 $sql =
"SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
162 $sql .=
" p.fk_user_author, u.login, u.rowid as userid";
163 $sql .=
" FROM " . MAIN_DB_PREFIX .
"paiementfourn_facturefourn as pf,";
164 $sql .=
" " . MAIN_DB_PREFIX .
"paiementfourn as p";
165 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"user as u ON p.fk_user_author = u.rowid";
166 $sql .=
" WHERE pf.fk_paiementfourn = p.rowid";
167 $sql .=
" AND pf.fk_facturefourn = " . ((int) $fac->id);
168 $sql .=
" ORDER BY p.datep ASC, p.rowid ASC";
170 $resqlp = $db->query($sql);
172 $nump = $db->num_rows($resqlp);
176 $objp = $db->fetch_object($resqlp);
179 $paymentstatic->id = $objp->rowid;
181 $userstatic->id = $objp->userid;
182 $userstatic->login = $objp->login;
185 'fk_paiement' => $objp->rowid,
186 'date' => $db->jdate($objp->dp),
187 'datefieldforsort' => $db->jdate($objp->dp) .
'-' . $fac->ref,
188 'link' => $langs->trans(
"Payment") .
' ' . $paymentstatic->getNomUrl(1),
190 'amount' => -$objp->amount,
191 'author' => $userstatic->getLoginUrl(1)
201 dol_print_error($db);
205 dol_print_error($db);
209 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">' . $langs->trans(
"NoInvoice") .
'</span></td></tr>';
216 foreach (array_keys($TData) as $key) {
217 $balance += $TData[$key][
'amount'];
218 if (!array_key_exists(
'balance', $TData[$key])) {
219 $TData[$key][
'balance'] = 0;
221 $TData[$key][
'balance'] += $balance;
231 foreach ($TData as $data) {
233 if (!empty($data[
'fk_facture'])) {
234 $html_class =
'facid-' . $data[
'fk_facture'];
235 } elseif (!empty($data[
'fk_paiement'])) {
236 $html_class =
'payid-' . $data[
'fk_paiement'];
239 print
'<tr class="oddeven ' . $html_class .
'">';
242 if (!empty($data[
'fk_facture'])) {
249 print
'<td>' . $data[
'link'] .
"</td>\n";
251 print
'<td class="left">' . $data[
'status'] .
'</td>';
253 print
'<td class="right">' . (($data[
'amount'] > 0) ?
price(abs($data[
'amount'])) :
'') .
"</td>\n";
255 $totalDebit += ($data[
'amount'] > 0) ? abs($data[
'amount']) : 0;
257 print
'<td class="right">' . (($data[
'amount'] > 0) ?
'' :
price(abs($data[
'amount']))) .
"</td>\n";
258 $totalCredit += ($data[
'amount'] > 0) ? 0 : abs($data[
'amount']);
261 print
'<td class="right"><span class="amount">' .
price($data[
'balance']) .
"</span></td>\n";
264 print
'<td class="nowrap right">';
265 print $data[
'author'];
271 print
'<tr class="liste_total">';
272 print
'<td colspan="3"> </td>';
273 print
'<td class="right">' .
price($totalDebit) .
'</td>';
274 print
'<td class="right">' .
price($totalCredit) .
'</td>';
275 print
'<td class="right">' .
price(
price2num($totalDebit - $totalCredit,
'MT')) .
'</td>';
283 dol_print_error($db);
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, $subtabs='')
Return array of tabs to used on pages for third parties cards.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.