29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
43$langs->load(
"companies");
44if (isModEnabled(
'invoice')) {
45 $langs->load(
"bills");
51if ($user->socid > 0) {
56$hookmanager->initHooks(array(
'recapcomptacard',
'globalcard'));
68$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
69$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71if (empty($page) || $page == -1) {
74$offset = $limit * $page;
78 $sortfield =
"f.datef,f.rowid";
86 'f.datef' => array(
'label' =>
"Date",
'checked' => 1),
91$hookmanager->initHooks(array(
'supplierbalencelist',
'globalcard'));
98$parameters = array(
'socid' => $id);
99$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object);
111$form =
new Form($db);
112$userstatic =
new User($db);
114$title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Summary");
116 $title =
$object->name.
' - '.$langs->trans(
"Summary");
118$help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
125 $param .=
'&socid='.$id;
130 print
dol_get_fiche_head($head,
'customer', $langs->trans(
"ThirdParty"), 0,
'company');
131 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom',
'',
'', 0,
'',
'', 1);
134 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'lire')) {
138 print
'<table class="noborder tagtable liste centpercent">';
139 print
'<tr class="liste_titre">';
140 if (!empty($arrayfields[
'f.datef'][
'checked'])) {
141 print_liste_field_titre($arrayfields[
'f.datef'][
'label'], $_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
143 print
'<td>'.$langs->trans(
"Element").
'</td>';
144 print
'<td>'.$langs->trans(
"Status").
'</td>';
145 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
146 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
147 print
'<td class="right">'.$langs->trans(
"Balance").
'</td>';
148 print
'<td class="right">'.$langs->trans(
"Author").
'</td>';
153 $sql =
"SELECT s.nom, s.rowid as socid, f.ref, f.total_ttc, f.datef as df,";
154 $sql .=
" f.paye as paye, f.fk_statut as statut, f.rowid as facid,";
155 $sql .=
" u.login, u.rowid as userid";
156 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s,".MAIN_DB_PREFIX.
"facture as f,".MAIN_DB_PREFIX.
"user as u";
157 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".((int)
$object->id);
158 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
159 $sql .=
" AND f.fk_user_valid = u.rowid";
160 $sql .= $db->order($sortfield, $sortorder);
162 $resql = $db->query($sql);
164 $num = $db->num_rows($resql);
167 for ($i = 0; $i < $num; $i++) {
168 $objf = $db->fetch_object($resql);
171 $ret = $fac->fetch($objf->facid);
173 print $fac->error.
"<br>";
177 $alreadypaid = $fac->getSommePaiement();
178 $alreadypaid += $fac->getSumDepositsUsed();
179 $alreadypaid += $fac->getSumCreditNotesUsed();
181 $userstatic->id = $objf->userid;
182 $userstatic->login = $objf->login;
185 'fk_facture' => $objf->facid,
186 'date' => $fac->date,
187 'datefieldforsort' => $fac->date.
'-'.$fac->ref,
188 'link' => $fac->getNomUrl(1),
189 'status' => $fac->getLibStatut(2, $alreadypaid),
190 'amount' => $fac->total_ttc,
191 'author' => $userstatic->getLoginUrl(1)
194 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic);
195 $reshook = $hookmanager->executeHooks(
'facdao', $parameters, $object);
203 $sql =
"SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
204 $sql .=
" p.fk_user_creat, u.login, u.rowid as userid";
205 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf,";
206 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
207 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON p.fk_user_creat = u.rowid";
208 $sql .=
" WHERE pf.fk_paiement = p.rowid";
209 $sql .=
" AND p.entity = ".$conf->entity;
210 $sql .=
" AND pf.fk_facture = ".((int) $fac->id);
211 $sql .=
" ORDER BY p.datep ASC, p.rowid ASC";
213 $resqlp = $db->query($sql);
215 $nump = $db->num_rows($resqlp);
219 $objp = $db->fetch_object($resqlp);
222 $paymentstatic->id = $objp->rowid;
224 $userstatic->id = $objp->userid;
225 $userstatic->login = $objp->login;
228 'fk_paiement' => $objp->rowid,
229 'date' => $db->jdate($objp->dp),
230 'datefieldforsort' => $db->jdate($objp->dp).
'-'.$fac->ref,
231 'link' => $langs->trans(
"Payment").
' '.$paymentstatic->getNomUrl(1),
233 'amount' => -$objp->amount,
234 'author' => $userstatic->getLoginUrl(1)
237 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic,
'paymentstatic' => $paymentstatic);
238 $reshook = $hookmanager->executeHooks(
'paydao', $parameters, $object);
258 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</span></td></tr>';
265 foreach (array_keys($TData) as $key) {
266 $balance += $TData[$key][
'amount'];
267 if (!array_key_exists(
'balance', $TData[$key])) {
268 $TData[$key][
'balance'] = 0;
270 $TData[$key][
'balance'] += $balance;
280 foreach ($TData as $data) {
282 if (!empty($data[
'fk_facture'])) {
283 $html_class =
'facid-'.$data[
'fk_facture'];
284 } elseif (!empty($data[
'fk_paiement'])) {
285 $html_class =
'payid-'.$data[
'fk_paiement'];
288 print
'<tr class="oddeven '.$html_class.
'">';
291 if (!empty($data[
'fk_facture'])) {
294 print
'<td class="center" title="'.dol_escape_htmltag($datedetail).
'">';
298 print
'<td>'.$data[
'link'].
"</td>\n";
300 print
'<td class="left">'.$data[
'status'].
'</td>';
302 print
'<td class="right">'.(($data[
'amount'] > 0) ?
price(abs($data[
'amount'])) :
'').
"</td>\n";
304 $totalDebit += ($data[
'amount'] > 0) ? abs($data[
'amount']) : 0;
306 print
'<td class="right">'.(($data[
'amount'] > 0) ?
'' :
price(abs($data[
'amount']))).
"</td>\n";
307 $totalCredit += ($data[
'amount'] > 0) ? 0 : abs($data[
'amount']);
310 print
'<td class="right"><span class="amount">'.price($data[
'balance']).
"</span></td>\n";
313 print
'<td class="nowrap right">';
314 print $data[
'author'];
320 print
'<tr class="liste_total">';
321 print
'<td colspan="3"> </td>';
322 print
'<td class="right">'.price($totalDebit).
'</td>';
323 print
'<td class="right">'.price($totalCredit).
'</td>';
324 print
'<td class="right">'.price(
price2num($totalDebit - $totalCredit,
'MT')).
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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)
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_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $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 the value of a given key, which produces ascending (default) or descending out...
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.