27require
'../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
33$langs->load(
"companies");
34if (isModEnabled(
'facture')) {
35 $langs->load(
"bills");
52$hookmanager->initHooks(array(
'recapcomptacard',
'globalcard'));
55$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
56$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
57$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
58$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
59if (empty($page) || $page == -1) {
62$offset = $limit * $page;
66 $sortfield =
"f.datef,f.rowid";
74 'f.datef'=>array(
'label'=>
"Date",
'checked'=>1),
79$hookmanager->initHooks(array(
'supplierbalencelist',
'globalcard'));
84$parameters = array(
'socid' => $id);
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object);
98$userstatic =
new User($db);
100$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Summary");
101if (
getDolGlobalString(
'MAIN_HTML_TITLE') && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
102 $title = $object->name.
' - '.$langs->trans(
"Summary");
104$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
111 $param .=
'&socid='.$id;
116 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), 0,
'company');
117 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom',
'',
'', 0,
'',
'', 1);
120 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')) {
124 print
'<table class="noborder tagtable liste centpercent">';
125 print
'<tr class="liste_titre">';
126 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
127 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
129 print
'<td>'.$langs->trans(
"Element").
'</td>';
130 print
'<td>'.$langs->trans(
"Status").
'</td>';
131 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
132 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
133 print
'<td class="right">'.$langs->trans(
"Balance").
'</td>';
134 print
'<td class="right">'.$langs->trans(
"Author").
'</td>';
139 $sql =
"SELECT s.nom, s.rowid as socid, f.ref, f.total_ttc, f.datef as df,";
140 $sql .=
" f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
141 $sql .=
" u.login, u.rowid as userid";
142 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f,".MAIN_DB_PREFIX.
"user as u";
143 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
144 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
145 $sql .=
" AND f.fk_user_valid = u.rowid";
146 $sql .= $db->order($sortfield, $sortorder);
148 $resql = $db->query($sql);
150 $num = $db->num_rows($resql);
153 for ($i = 0; $i < $num; $i++) {
154 $objf = $db->fetch_object($resql);
157 $ret = $fac->fetch($objf->facid);
159 print $fac->error.
"<br>";
162 $alreadypaid = $fac->getSommePaiement();
163 $alreadypaid += $fac->getSumDepositsUsed();
164 $alreadypaid += $fac->getSumCreditNotesUsed();
166 $userstatic->id = $objf->userid;
167 $userstatic->login = $objf->login;
170 'fk_facture' => $objf->facid,
171 'date' => $fac->date,
172 'datefieldforsort' => $fac->date.
'-'.$fac->ref,
173 'link' => $fac->getNomUrl(1),
174 'status' => $fac->getLibStatut(2, $alreadypaid),
175 'amount' => $fac->total_ttc,
176 'author' => $userstatic->getLoginUrl(1)
179 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic);
180 $reshook = $hookmanager->executeHooks(
'facdao', $parameters, $object);
188 $sql =
"SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
189 $sql .=
" p.fk_user_creat, u.login, u.rowid as userid";
190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf,";
191 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
192 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON p.fk_user_creat = u.rowid";
193 $sql .=
" WHERE pf.fk_paiement = p.rowid";
194 $sql .=
" AND p.entity = ".$conf->entity;
195 $sql .=
" AND pf.fk_facture = ".((int) $fac->id);
196 $sql .=
" ORDER BY p.datep ASC, p.rowid ASC";
198 $resqlp = $db->query($sql);
200 $nump = $db->num_rows($resqlp);
204 $objp = $db->fetch_object($resqlp);
207 $paymentstatic->id = $objp->rowid;
209 $userstatic->id = $objp->userid;
210 $userstatic->login = $objp->login;
213 'fk_paiement' => $objp->rowid,
214 'date' => $db->jdate($objp->dp),
215 'datefieldforsort' => $db->jdate($objp->dp).
'-'.$fac->ref,
216 'link' => $langs->trans(
"Payment").
' '.$paymentstatic->getNomUrl(1),
218 'amount' => -$objp->amount,
219 'author' => $userstatic->getLoginUrl(1)
222 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic,
'paymentstatic' => $paymentstatic);
223 $reshook = $hookmanager->executeHooks(
'paydao', $parameters, $object);
243 print
'<tr class="oddeven"><td colspan="7">'.$langs->trans(
"NoInvoice").
'</td></tr>';
250 foreach ($TData as &$data1) {
251 $balance += $data1[
'amount'];
252 if (!isset($data1[
'balance'])) {
253 $data1[
'balance'] = 0;
255 $data1[
'balance'] += $balance;
265 foreach ($TData as $data) {
267 if (!empty($data[
'fk_facture'])) {
268 $html_class =
'facid-'.$data[
'fk_facture'];
269 } elseif (!empty($data[
'fk_paiement'])) {
270 $html_class =
'payid-'.$data[
'fk_paiement'];
273 print
'<tr class="oddeven '.$html_class.
'">';
276 if (!empty($data[
'fk_facture'])) {
279 print
'<td class="center" title="'.dol_escape_htmltag($datedetail).
'">';
283 print
'<td>'.$data[
'link'].
"</td>\n";
285 print
'<td class="left">'.$data[
'status'].
'</td>';
287 print
'<td class="right">'.(($data[
'amount'] > 0) ?
price(abs($data[
'amount'])) :
'').
"</td>\n";
289 $totalDebit += ($data[
'amount'] > 0) ? abs($data[
'amount']) : 0;
291 print
'<td class="right">'.(($data[
'amount'] > 0) ?
'' :
price(abs($data[
'amount']))).
"</td>\n";
292 $totalCredit += ($data[
'amount'] > 0) ? 0 : abs($data[
'amount']);
295 print
'<td class="right"><span class="amount">'.price($data[
'balance']).
"</span></td>\n";
298 print
'<td class="nowrap right">';
299 print $data[
'author'];
305 print
'<tr class="liste_total">';
306 print
'<td colspan="3"> </td>';
307 print
'<td class="right">'.price($totalDebit).
'</td>';
308 print
'<td class="right">'.price($totalCredit).
'</td>';
309 print
'<td class="right">'.price(
price2num($totalDebit - $totalCredit,
'MT')).
'</td>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
Class to manage payments of customer 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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.