26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
28 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
32 $langs->load(
"companies");
33 if (!empty($conf->facture->enabled)) $langs->load(
"bills");
38 if ($user->socid) $id = $user->socid;
42 if ($id > 0) $object->fetch($id);
45 $hookmanager->initHooks(array(
'recapcomptacard',
'globalcard'));
48 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
49 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52 if (empty($page) || $page == -1) { $page = 0; }
53 $offset = $limit * $page;
54 $pageprev = $page - 1;
55 $pagenext = $page + 1;
56 if (!$sortfield) $sortfield =
"f.datef,f.rowid";
57 if (!$sortorder) $sortorder =
"DESC";
61 'f.datef'=>array(
'label'=>
"Date",
'checked'=>1),
66 $hookmanager->initHooks(array(
'supplierbalencelist',
'globalcard'));
71 $parameters = array(
'socid' => $id);
72 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object);
73 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
82 $form =
new Form($db);
83 $userstatic =
new User($db);
85 $title = $langs->trans(
"ThirdParty").
' - '.$langs->trans(
"Summary");
86 if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match(
'/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->name.
' - '.$langs->trans(
"Summary");
87 $help_url =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
94 if ($id > 0) $param .=
'&socid='.$id;
99 dol_banner_tab($object,
'socid',
'', ($user->socid ? 0 : 1),
'rowid',
'nom',
'',
'', 0,
'',
'', 1);
102 if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
107 print '<table class="noborder tagtable liste centpercent">';
108 print
'<tr class="liste_titre">';
109 if (!empty($arrayfields[
'f.datef'][
'checked']))
print_liste_field_titre($arrayfields[
'f.datef'][
'label'],
$_SERVER[
"PHP_SELF"],
"f.datef",
"", $param,
'align="center" class="nowrap"', $sortfield, $sortorder);
110 print
'<td>'.$langs->trans(
"Element").
'</td>';
111 print
'<td>'.$langs->trans(
"Status").
'</td>';
112 print
'<td class="right">'.$langs->trans(
"Debit").
'</td>';
113 print
'<td class="right">'.$langs->trans(
"Credit").
'</td>';
114 print
'<td class="right">'.$langs->trans(
"Balance").
'</td>';
115 print
'<td class="right">'.$langs->trans(
"Author").
'</td>';
120 $sql =
"SELECT s.nom, s.rowid as socid, f.ref, 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 as f,".MAIN_DB_PREFIX.
"user as u";
124 $sql .=
" WHERE f.fk_soc = s.rowid AND s.rowid = ".$object->id;
125 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
126 $sql .=
" AND f.fk_user_valid = u.rowid";
127 $sql .= $db->order($sortfield, $sortorder);
129 $resql = $db->query($sql);
132 $num = $db->num_rows(
$resql);
135 for ($i = 0; $i < $num; $i++)
137 $objf = $db->fetch_object(
$resql);
140 $ret = $fac->fetch($objf->facid);
143 print $fac->error.
"<br>";
146 $totalpaye = $fac->getSommePaiement();
148 $userstatic->id = $objf->userid;
149 $userstatic->login = $objf->login;
152 'fk_facture' => $objf->facid,
153 'date' => $fac->date,
154 'datefieldforsort' => $fac->date.
'-'.$fac->ref,
155 'link' => $fac->getNomUrl(1),
156 'status' => $fac->getLibStatut(2, $totalpaye),
157 'amount' => $fac->total_ttc,
158 'author' => $userstatic->getLoginUrl(1)
161 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic);
162 $reshook = $hookmanager->executeHooks(
'facdao', $parameters, $object);
163 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
168 $sql =
"SELECT p.rowid, p.datep as dp, pf.amount, p.statut,";
169 $sql .=
" p.fk_user_creat, u.login, u.rowid as userid";
170 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf,";
171 $sql .=
" ".MAIN_DB_PREFIX.
"paiement as p";
172 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON p.fk_user_creat = u.rowid";
173 $sql .=
" WHERE pf.fk_paiement = p.rowid";
174 $sql .=
" AND p.entity = ".$conf->entity;
175 $sql .=
" AND pf.fk_facture = ".$fac->id;
176 $sql .=
" ORDER BY p.datep ASC, p.rowid ASC";
178 $resqlp = $db->query($sql);
181 $nump = $db->num_rows($resqlp);
186 $objp = $db->fetch_object($resqlp);
189 $paymentstatic->id = $objp->rowid;
191 $userstatic->id = $objp->userid;
192 $userstatic->login = $objp->login;
195 'fk_paiement' => $objp->rowid,
196 'date' => $db->jdate($objp->dp),
197 'datefieldforsort' => $db->jdate($objp->dp).
'-'.$fac->ref,
198 'link' => $langs->trans(
"Payment").
' '.$paymentstatic->getNomUrl(1),
200 'amount' => -$objp->amount,
201 'author' => $userstatic->getLoginUrl(1)
204 $parameters = array(
'socid' => $id,
'values' => &$values,
'fac' => $fac,
'userstatic' => $userstatic,
'paymentstatic' => $paymentstatic);
205 $reshook = $hookmanager->executeHooks(
'paydao', $parameters, $object);
206 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
223 print
'<tr class="oddeven"><td colspan="7">'.$langs->trans(
"NoInvoice").
'</td></tr>';
230 foreach ($TData as &$data1) {
231 $balance += $data1[
'amount'];
232 $data1[
'balance'] += $balance;
242 foreach ($TData as $data) {
244 if (!empty($data[
'fk_facture'])) $html_class =
'facid-'.$data[
'fk_facture'];
245 elseif (!empty($data[
'fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement'];
247 print '<tr class="oddeven '.$html_class.'">';
249 print "<td class=\"center\">";
250 if (!empty($data['fk_facture'])) print
dol_print_date($data['date'], 'day');
251 elseif (!empty($data['fk_paiement'])) print
dol_print_date($data['date'], 'dayhour');
254 print '<td>'.$data['link']."</td>\n";
256 print '<td class="left">'.$data['status'].'</td>';
258 print '<td class="right">'.(($data['amount'] > 0) ?
price(abs($data['amount'])) : '')."</td>\n";
260 $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0;
262 print '<td class="right">'.(($data['amount'] > 0) ? '' :
price(abs($data['amount'])))."</td>\n";
263 $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']);
266 print '<td class="right">'.
price($data['balance'])."</td>\n";
269 print '<td class="nowrap right">';
270 print $data['author'];
276 print '<tr class="liste_total">';
277 print '<td colspan="3"> </td>';
278 print '<td class="right">'.
price($totalDebit).'</td>';
279 print '<td class="right">'.
price($totalCredit).'</td>';
280 print '<td class="right">'.
price(
price2num($totalDebit - $totalCredit, 'MT')).'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
Class to manage payments of customer invoices.
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
societe_prepare_head(Societe $object)
Return array of tabs to used on pages for third parties cards.
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.
print $_SERVER["PHP_SELF"] n
Edit parameters.
Class to manage invoices.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.