12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553 |
- <?php
- /* Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
- * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
- * Copyright (C) 2012-2014 Raphaël Dourseanud <rdoursenaud@gpcsolutions.fr>
- * Copyright (C) 2014-2106 Ferran Marcet <fmarcet@2byte.es>
- * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
- * Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
- * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
- * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
- * Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/compta/resultat/clientfourn.php
- * \ingroup compta, accountancy
- * \brief Page reporting
- */
- require '../../main.inc.php';
- require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
- require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
- require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
- require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
- // Load translation files required by the page
- $langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy', 'loan'));
- $date_startmonth = GETPOST('date_startmonth', 'int');
- $date_startday = GETPOST('date_startday', 'int');
- $date_startyear = GETPOST('date_startyear', 'int');
- $date_endmonth = GETPOST('date_endmonth', 'int');
- $date_endday = GETPOST('date_endday', 'int');
- $date_endyear = GETPOST('date_endyear', 'int');
- $showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ? GETPOST('showaccountdetail', 'aZ09') : 'yes';
- $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
- $sortfield = GETPOST('sortfield', 'aZ09comma');
- $sortorder = GETPOST('sortorder', 'aZ09comma');
- $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
- if (empty($page) || $page == -1) {
- $page = 0;
- } // If $page is not defined, or '' or -1
- $offset = $limit * $page;
- $pageprev = $page - 1;
- $pagenext = $page + 1;
- //if (! $sortfield) $sortfield='s.nom, s.rowid';
- if (!$sortorder) {
- $sortorder = 'ASC';
- }
- // Date range
- $year = GETPOST('year', 'int');
- if (empty($year)) {
- $year_current = strftime("%Y", dol_now());
- $month_current = strftime("%m", dol_now());
- $year_start = $year_current;
- } else {
- $year_current = $year;
- $month_current = strftime("%m", dol_now());
- $year_start = $year;
- }
- $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
- $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
- // We define date_start and date_end
- if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
- $q = GETPOST("q") ?GETPOST("q") : 0;
- if ($q == 0) {
- // We define date_start and date_end
- $year_end = $year_start;
- $month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
- if (!GETPOST('month')) {
- if (!GETPOST("year") && $month_start > $month_current) {
- $year_start--;
- $year_end--;
- }
- $month_end = $month_start - 1;
- if ($month_end < 1) {
- $month_end = 12;
- } else {
- $year_end++;
- }
- } else {
- $month_end = $month_start;
- }
- $date_start = dol_get_first_day($year_start, $month_start, false);
- $date_end = dol_get_last_day($year_end, $month_end, false);
- }
- if ($q == 1) {
- $date_start = dol_get_first_day($year_start, 1, false);
- $date_end = dol_get_last_day($year_start, 3, false);
- }
- if ($q == 2) {
- $date_start = dol_get_first_day($year_start, 4, false);
- $date_end = dol_get_last_day($year_start, 6, false);
- }
- if ($q == 3) {
- $date_start = dol_get_first_day($year_start, 7, false);
- $date_end = dol_get_last_day($year_start, 9, false);
- }
- if ($q == 4) {
- $date_start = dol_get_first_day($year_start, 10, false);
- $date_end = dol_get_last_day($year_start, 12, false);
- }
- }
- // $date_start and $date_end are defined. We force $year_start and $nbofyear
- $tmps = dol_getdate($date_start);
- $year_start = $tmps['year'];
- $tmpe = dol_getdate($date_end);
- $year_end = $tmpe['year'];
- $nbofyear = ($year_end - $year_start) + 1;
- //var_dump("year_start=".$year_start." year_end=".$year_end." nbofyear=".$nbofyear." date_start=".dol_print_date($date_start, 'dayhour')." date_end=".dol_print_date($date_end, 'dayhour'));
- // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
- $modecompta = $conf->global->ACCOUNTING_MODE;
- if (!empty($conf->accounting->enabled)) {
- $modecompta = 'BOOKKEEPING';
- }
- if (GETPOST("modecompta", 'alpha')) {
- $modecompta = GETPOST("modecompta", 'alpha');
- }
- $AccCat = new AccountancyCategory($db);
- // Security check
- $socid = GETPOST('socid', 'int');
- if ($user->socid > 0) {
- $socid = $user->socid;
- }
- if (!empty($conf->comptabilite->enabled)) {
- $result = restrictedArea($user, 'compta', '', '', 'resultat');
- }
- if (!empty($conf->accounting->enabled)) {
- $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
- }
- /*
- * View
- */
- llxHeader();
- $form = new Form($db);
- $periodlink = '';
- $exportlink = '';
- $total_ht = 0;
- $total_ttc = 0;
- // Affiche en-tete de rapport
- if ($modecompta == "CREANCES-DETTES") {
- $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
- $calcmode = $langs->trans("CalcModeDebt");
- $calcmode .= '<br>('.$langs->trans("SeeReportInInputOutputMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>'), $calcmode);
- if (!empty($conf->accounting->enabled)) {
- $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>'), $calcmode);
- }
- $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
- $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
- $description = $langs->trans("RulesResultDue");
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $description .= $langs->trans("DepositsAreNotIncluded");
- } else {
- $description .= $langs->trans("DepositsAreIncluded");
- }
- $builddate = dol_now();
- //$exportlink=$langs->trans("NotYetAvailable");
- } elseif ($modecompta == "RECETTES-DEPENSES") {
- $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
- $calcmode = $langs->trans("CalcModeEngagement");
- $calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>'), $calcmode);
- if (!empty($conf->accounting->enabled)) {
- $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=BOOKKEEPING">', '</a>'), $calcmode);
- }
- $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
- $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
- $description = $langs->trans("RulesResultInOut");
- $builddate = dol_now();
- //$exportlink=$langs->trans("NotYetAvailable");
- } elseif ($modecompta == "BOOKKEEPING") {
- $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPredefinedAccountGroups");
- $calcmode = $langs->trans("CalcModeBookkeeping");
- $calcmode .= '<br>('.$langs->trans("SeeReportInInputOutputMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=RECETTES-DEPENSES">', '</a>'), $calcmode);
- $calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '{s1}', '{s2}').')';
- $calcmode = str_replace(array('{s1}', '{s2}'), array('<a href="'.$_SERVER["PHP_SELF"].'?date_startyear='.$tmps['year'].'&date_startmonth='.$tmps['mon'].'&date_startday='.$tmps['mday'].'&date_endyear='.$tmpe['year'].'&date_endmonth='.$tmpe['mon'].'&date_endday='.$tmpe['mday'].'&modecompta=CREANCES-DETTES">', '</a>'), $calcmode);
- $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
- $arraylist = array('no'=>$langs->trans("CustomerCode"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
- $period .= ' '.$langs->trans("DetailByAccount").' '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
- $periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] - 1)."&modecompta=".$modecompta."&showaccountdetail=".$showaccountdetail."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($tmps['year'] + 1)."&modecompta=".$modecompta."&showaccountdetail=".$showaccountdetail."'>".img_next()."</a>" : "");
- $description = $langs->trans("RulesResultBookkeepingPredefined");
- $description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("Chartofaccounts")).')';
- $builddate = dol_now();
- //$exportlink=$langs->trans("NotYetAvailable");
- }
- $hselected = 'report';
- report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'showaccountdetail'=>$showaccountdetail), $calcmode);
- if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING') {
- print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
- }
- // Show report array
- $param = '&modecompta='.urlencode($modecompta).'&showaccountdetail='.urlencode($showaccountdetail);
- if ($date_startday) {
- $param .= '&date_startday='.$date_startday;
- }
- if ($date_startmonth) {
- $param .= '&date_startmonth='.$date_startmonth;
- }
- if ($date_startyear) {
- $param .= '&date_startyear='.$date_startyear;
- }
- if ($date_endday) {
- $param .= '&date_endday='.$date_endday;
- }
- if ($date_endmonth) {
- $param .= '&date_endmonth='.$date_endmonth;
- }
- if ($date_endyear) {
- $param .= '&date_endyear='.$date_endyear;
- }
- print '<table class="noborder centpercent">';
- print '<tr class="liste_titre">';
- if ($modecompta == 'BOOKKEEPING') {
- print_liste_field_titre("PredefinedGroups", $_SERVER["PHP_SELF"], 'f.thirdparty_code,f.rowid', '', $param, '', $sortfield, $sortorder, 'width200 ');
- } else {
- print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'width200 ');
- }
- print_liste_field_titre('');
- if ($modecompta == 'BOOKKEEPING') {
- print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], 'amount', '', $param, 'class="right"', $sortfield, $sortorder);
- } else {
- if ($modecompta == 'CREANCES-DETTES') {
- print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], 'amount_ht', '', $param, 'class="right"', $sortfield, $sortorder);
- }
- print_liste_field_titre("AmountTTC", $_SERVER["PHP_SELF"], 'amount_ttc', '', $param, 'class="right"', $sortfield, $sortorder);
- }
- print "</tr>\n";
- $total_ht_outcome = $total_ttc_outcome = $total_ht_income = $total_ttc_income = 0;
- if ($modecompta == 'BOOKKEEPING') {
- $predefinedgroupwhere = "(";
- $predefinedgroupwhere .= " (pcg_type = 'EXPENSE')";
- $predefinedgroupwhere .= " OR ";
- $predefinedgroupwhere .= " (pcg_type = 'INCOME')";
- $predefinedgroupwhere .= ")";
- $charofaccountstring = $conf->global->CHARTOFACCOUNTS;
- $charofaccountstring = dol_getIdFromCode($db, $conf->global->CHARTOFACCOUNTS, 'accounting_system', 'rowid', 'pcg_version');
- $sql = "SELECT -1 as socid, aa.pcg_type, SUM(f.credit - f.debit) as amount";
- if ($showaccountdetail == 'no') {
- $sql .= ", f.thirdparty_code as name";
- }
- $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as f";
- $sql .= ", ".MAIN_DB_PREFIX."accounting_account as aa";
- $sql .= " WHERE f.numero_compte = aa.account_number";
- $sql .= " AND ".$predefinedgroupwhere;
- $sql .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
- $sql .= " AND f.entity = ".$conf->entity;
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND f.doc_date >= '".$db->idate($date_start)."' AND f.doc_date <= '".$db->idate($date_end)."'";
- }
- $sql .= " GROUP BY pcg_type DESC";
- if ($showaccountdetail == 'no') {
- $sql .= ", name, socid"; // group by "accounting group" (INCOME/EXPENSE), then "customer".
- }
- $sql .= $db->order($sortfield, $sortorder);
- $oldpcgtype = '';
- dol_syslog("get bookkeeping entries", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num > 0) {
- while ($i < $num) {
- $objp = $db->fetch_object($result);
- if ($showaccountdetail == 'no') {
- if ($objp->pcg_type != $oldpcgtype) {
- print '<tr class="trforbreak"><td colspan="3" class="tdforbreak">'.$objp->pcg_type.'</td></tr>';
- $oldpcgtype = $objp->pcg_type;
- }
- }
- if ($showaccountdetail == 'no') {
- print '<tr class="oddeven">';
- print '<td></td>';
- print '<td>';
- print $objp->pcg_type;
- print ($objp->name ? ' ('.$objp->name.')' : ' ('.$langs->trans("Unknown").')');
- print "</td>\n";
- print '<td class="right"><span class="amount">'.price($objp->amount)."</span></td>\n";
- print "</tr>\n";
- } else {
- print '<tr class="oddeven trforbreak">';
- print '<td colspan="2" class="tdforbreak">';
- print $objp->pcg_type;
- print "</td>\n";
- print '<td class="right tdforbreak"><span class="amount">'.price($objp->amount)."</span></td>\n";
- print "</tr>\n";
- }
- $total_ht += (isset($objp->amount) ? $objp->amount : 0);
- $total_ttc += (isset($objp->amount) ? $objp->amount : 0);
- if ($objp->pcg_type == 'INCOME') {
- $total_ht_income += (isset($objp->amount) ? $objp->amount : 0);
- $total_ttc_income += (isset($objp->amount) ? $objp->amount : 0);
- }
- if ($objp->pcg_type == 'EXPENSE') {
- $total_ht_outcome -= (isset($objp->amount) ? $objp->amount : 0);
- $total_ttc_outcome -= (isset($objp->amount) ? $objp->amount : 0);
- }
- // Loop on detail of all accounts
- // This make 14 calls for each detail of account (NP, N and month m)
- if ($showaccountdetail != 'no') {
- $tmppredefinedgroupwhere = "pcg_type = '".$db->escape($objp->pcg_type)."'";
- $tmppredefinedgroupwhere .= " AND fk_pcg_version = '".$db->escape($charofaccountstring)."'";
- //$tmppredefinedgroupwhere .= " AND thirdparty_code = '".$db->escape($objp->name)."'";
- // Get cpts of category/group
- $cpts = $AccCat->getCptsCat(0, $tmppredefinedgroupwhere);
- foreach ($cpts as $j => $cpt) {
- $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cpt['dc']);
- if ($return < 0) {
- setEventMessages(null, $AccCat->errors, 'errors');
- $resultN = 0;
- } else {
- $resultN = $AccCat->sdc;
- }
- if ($showaccountdetail == 'all' || $resultN <> 0) {
- print '<tr>';
- print '<td></td>';
- print '<td class="tdoverflowmax200"> '.length_accountg($cpt['account_number']).' - '.$cpt['account_label'].'</td>';
- print '<td class="right"><span class="amount">'.price($resultN).'</span></td>';
- print "</tr>\n";
- }
- }
- }
- $i++;
- }
- } else {
- print '<tr><td colspan="3" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
- }
- } else {
- dol_print_error($db);
- }
- } else {
- /*
- * Customer invoices
- */
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("CustomersInvoices").'</td></tr>';
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."facture as f";
- $sql .= " WHERE f.fk_soc = s.rowid";
- $sql .= " AND f.fk_statut IN (1,2)";
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (0,1,2,5)";
- } else {
- $sql .= " AND f.type IN (0,1,2,3,5)";
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
- }
- } elseif ($modecompta == 'RECETTES-DEPENSES') {
- /*
- * List of payments (old payments are not seen by this query because, on older versions, they were not linked via payment_invoice.
- * old versions, they were not linked via payment_invoice. They are added later)
- */
- $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."facture as f";
- $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf";
- $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
- $sql .= " WHERE p.rowid = pf.fk_paiement";
- $sql .= " AND pf.fk_facture = f.rowid";
- $sql .= " AND f.fk_soc = s.rowid";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- }
- $sql .= " AND f.entity IN (".getEntity('invoice').")";
- if ($socid) {
- $sql .= " AND f.fk_soc = ".((int) $socid);
- }
- $sql .= " GROUP BY name, socid";
- $sql .= $db->order($sortfield, $sortorder);
- dol_syslog("get customer invoices", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- while ($i < $num) {
- $objp = $db->fetch_object($result);
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("Bills").' <a href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$objp->socid.'">'.$objp->name."</td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price($objp->amount_ht)."</span>";
- }
- print "</td>\n";
- print '<td class="right"><span class="amount">'.price($objp->amount_ttc)."</span></td>\n";
- $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
- $total_ttc += $objp->amount_ttc;
- print "</tr>\n";
- $i++;
- }
- $db->free($result);
- } else {
- dol_print_error($db);
- }
- // We add the old customer payments, not linked by payment_invoice
- if ($modecompta == 'RECETTES-DEPENSES') {
- $sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
- $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
- $sql .= ", ".MAIN_DB_PREFIX."paiement as p";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON p.rowid = pf.fk_paiement";
- $sql .= " WHERE pf.rowid IS NULL";
- $sql .= " AND p.fk_bank = b.rowid";
- $sql .= " AND b.fk_account = ba.rowid";
- $sql .= " AND ba.entity IN (".getEntity('bank_account').")";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- $sql .= " GROUP BY name, idp";
- $sql .= " ORDER BY name";
- dol_syslog("get old customer payments not linked to invoices", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $objp = $db->fetch_object($result);
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("Bills")." ".$langs->trans("Other")." (".$langs->trans("PaymentsNotLinkedToInvoice").")\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price($objp->amount_ht)."</span></td>\n";
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price($objp->amount_ttc)."</span></td>\n";
- $total_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
- $total_ttc += $objp->amount_ttc;
- print "</tr>\n";
- $i++;
- }
- }
- $db->free($result);
- } else {
- dol_print_error($db);
- }
- }
- if ($total_ttc == 0) {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- $total_ht_income += $total_ht;
- $total_ttc_income += $total_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price($total_ht);
- }
- print '</td>';
- print '<td class="right">'.price($total_ttc).'</td>';
- print '</tr>';
- /*
- * Donations
- */
- if (!empty($conf->don->enabled)) {
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Donations").'</td></tr>';
- if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT p.societe as name, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."don as p";
- $sql .= " WHERE p.entity IN (".getEntity('donation').")";
- $sql .= " AND fk_statut in (1,2)";
- } else {
- $sql = "SELECT p.societe as nom, p.firstname, p.lastname, date_format(p.datedon,'%Y-%m') as dm, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."don as p";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_donation as pe ON pe.fk_donation = p.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
- $sql .= " WHERE p.entity IN (".getEntity('donation').")";
- $sql .= " AND fk_statut >= 2";
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datedon >= '".$db->idate($date_start)."' AND p.datedon <= '".$db->idate($date_end)."'";
- }
- }
- $sql .= " GROUP BY p.societe, p.firstname, p.lastname, dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'p.societe, p.firstname, p.lastname, dm';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get dunning");
- $result = $db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $total_ht += $obj->amount;
- $total_ttc += $obj->amount;
- $subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name." ".$obj->firstname." ".$obj->lastname."</a></td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price($obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price($obj->amount).'</span></td>';
- print '</tr>';
- $i++;
- }
- } else {
- print '<tr class="oddeven"><td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_income += $subtotal_ht;
- $total_ttc_income += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price($subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price($subtotal_ttc).'</td>';
- print '</tr>';
- }
- /*
- * Suppliers invoices
- */
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT s.nom as name, s.rowid as socid, sum(f.total_ht) as amount_ht, sum(f.total_ttc) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
- $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
- $sql .= " WHERE f.fk_soc = s.rowid";
- $sql .= " AND f.fk_statut IN (1,2)";
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (0,1,2)";
- } else {
- $sql .= " AND f.type IN (0,1,2,3)";
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
- }
- } elseif ($modecompta == 'RECETTES-DEPENSES') {
- $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
- $sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f";
- $sql .= " ON pf.fk_facturefourn = f.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s";
- $sql .= " ON f.fk_soc = s.rowid";
- $sql .= " WHERE p.rowid = pf.fk_paiementfourn ";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- }
- $sql .= " AND f.entity = ".((int) $conf->entity);
- if ($socid) {
- $sql .= " AND f.fk_soc = ".((int) $socid);
- }
- $sql .= " GROUP BY name, socid";
- $sql .= $db->order($sortfield, $sortorder);
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SuppliersInvoices").'</td></tr>';
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- dol_syslog("get suppliers invoices", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num > 0) {
- while ($i < $num) {
- $objp = $db->fetch_object($result);
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("Bills").' <a href="'.DOL_URL_ROOT."/fourn/facture/list.php?socid=".$objp->socid.'">'.$objp->name.'</a></td>'."\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$objp->amount_ht)."</span>";
- }
- print "</td>\n";
- print '<td class="right"><span class="amount">'.price(-$objp->amount_ttc)."</span></td>\n";
- $total_ht -= (isset($objp->amount_ht) ? $objp->amount_ht : 0);
- $total_ttc -= $objp->amount_ttc;
- $subtotal_ht += (isset($objp->amount_ht) ? $objp->amount_ht : 0);
- $subtotal_ttc += $objp->amount_ttc;
- print "</tr>\n";
- $i++;
- }
- } else {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- $db->free($result);
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome += $subtotal_ht;
- $total_ttc_outcome += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price(-$subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price(-$subtotal_ttc).'</td>';
- print '</tr>';
- /*
- * Social / Fiscal contributions who are not deductible
- */
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsNondeductibles").'</td></tr>';
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(cs.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
- $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
- $sql .= " WHERE cs.fk_type = c.id";
- $sql .= " AND c.deductible = 0";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
- }
- } elseif ($modecompta == 'RECETTES-DEPENSES') {
- $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
- $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
- $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
- $sql .= " WHERE p.fk_charge = cs.rowid";
- $sql .= " AND cs.fk_type = c.id";
- $sql .= " AND c.deductible = 0";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- }
- $sql .= " AND cs.entity = ".$conf->entity;
- $sql .= " GROUP BY c.libelle, c.id, c.accountancy_code";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'c.libelle, c.id';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get social contributions deductible=0", LOG_DEBUG);
- $result = $db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $total_ht -= $obj->amount;
- $total_ttc -= $obj->amount;
- $subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- $titletoshow = '';
- if ($obj->accountancy_code) {
- $titletoshow = $langs->trans("AccountingCode").': '.$obj->accountancy_code;
- $tmpaccountingaccount = new AccountingAccount($db);
- $tmpaccountingaccount->fetch(0, $obj->accountancy_code, 1);
- $titletoshow .= ' - '.$langs->trans("AccountingCategory").': '.$tmpaccountingaccount->pcg_type;
- }
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td'.($obj->accountancy_code ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>'.dol_escape_htmltag($obj->label).'</td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
- print '</tr>';
- $i++;
- }
- } else {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome += $subtotal_ht;
- $total_ttc_outcome += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price(-$subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price(-$subtotal_ttc).'</td>';
- print '</tr>';
- /*
- * Social / Fiscal contributions who are deductible
- */
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("SocialContributionsDeductibles").'</td></tr>';
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(cs.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
- $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
- $sql .= " WHERE cs.fk_type = c.id";
- $sql .= " AND c.deductible = 1";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND cs.entity = ".$conf->entity;
- } elseif ($modecompta == 'RECETTES-DEPENSES') {
- $sql = "SELECT c.id, c.libelle as label, c.accountancy_code, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
- $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
- $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
- $sql .= " WHERE p.fk_charge = cs.rowid";
- $sql .= " AND cs.fk_type = c.id";
- $sql .= " AND c.deductible = 1";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND cs.entity = ".$conf->entity;
- }
- $sql .= " GROUP BY c.libelle, c.id, c.accountancy_code";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'c.libelle, c.id';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get social contributions deductible=1", LOG_DEBUG);
- $result = $db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $total_ht -= $obj->amount;
- $total_ttc -= $obj->amount;
- $subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- $titletoshow = '';
- if ($obj->accountancy_code) {
- $titletoshow = $langs->trans("AccountingCode").': '.$obj->accountancy_code;
- $tmpaccountingaccount = new AccountingAccount($db);
- $tmpaccountingaccount->fetch(0, $obj->accountancy_code, 1);
- $titletoshow .= ' - '.$langs->trans("AccountingCategory").': '.$tmpaccountingaccount->pcg_type;
- }
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td'.($obj->accountancy_code ? ' title="'.dol_escape_htmltag($titletoshow).'"' : '').'>'.dol_escape_htmltag($obj->label).'</td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
- print '</tr>';
- $i++;
- }
- } else {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome += $subtotal_ht;
- $total_ttc_outcome += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price(-$subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price(-$subtotal_ttc).'</td>';
- print '</tr>';
- /*
- * Salaries
- */
- if (!empty($conf->salaries->enabled)) {
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("Salaries").'</td></tr>';
- if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
- if ($modecompta == 'CREANCES-DETTES') {
- //$column = 's.dateep'; // We use the date of salary
- $column = 'p.datep';
- } else {
- $column = 'p.datep';
- }
- $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user";
- $sql .= " WHERE s.entity IN (".getEntity('salary').")";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
- }
- $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm";
- // For backward compatibility with old module salary
- $column = 'p.datep';
- $sql .= " UNION ";
- $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user";
- $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
- }
- $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'u.firstname, u.lastname';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- }
- dol_syslog("get payment salaries");
- $result = $db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $total_ht -= $obj->amount;
- $total_ttc -= $obj->amount;
- $subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- print '<tr class="oddeven"><td> </td>';
- $userstatic = new User($db);
- $userstatic->fetch($obj->fk_user);
- print "<td>".$langs->trans("Salary")." <a href=\"".DOL_URL_ROOT."/salaries/list.php?search_user=".urlencode($userstatic->getFullName($langs))."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
- print '</tr>';
- $i++;
- }
- } else {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome += $subtotal_ht;
- $total_ttc_outcome += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price(-$subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price(-$subtotal_ttc).'</td>';
- print '</tr>';
- }
- /*
- * Expense report
- */
- if (!empty($conf->expensereport->enabled)) {
- if ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES') {
- $langs->load('trips');
- if ($modecompta == 'CREANCES-DETTES') {
- $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(date_valid,'%Y-%m') as dm, sum(p.total_ht) as amount_ht,sum(p.total_ttc) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
- $sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
- $sql .= " AND p.fk_statut>=5";
- $column = 'p.date_valid';
- } else {
- $sql = "SELECT p.rowid, p.ref, u.rowid as userid, u.firstname, u.lastname, date_format(pe.datep,'%Y-%m') as dm, sum(p.total_ht) as amount_ht, sum(p.total_ttc) as amount_ttc";
- $sql .= " FROM ".MAIN_DB_PREFIX."expensereport as p";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user_author";
- $sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_expensereport as pe ON pe.fk_expensereport = p.rowid";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON pe.fk_typepayment = c.id";
- $sql .= " WHERE p.entity IN (".getEntity('expensereport').")";
- $sql .= " AND p.fk_statut>=5";
- $column = 'pe.datep';
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'";
- }
- $sql .= " GROUP BY u.rowid, p.rowid, p.ref, u.firstname, u.lastname, dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'p.ref';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- }
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("ExpenseReport").'</td></tr>';
- dol_syslog("get expense report outcome");
- $result = $db->query($sql);
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($result) {
- $num = $db->num_rows($result);
- if ($num) {
- while ($obj = $db->fetch_object($result)) {
- $total_ht -= $obj->amount_ht;
- $total_ttc -= $obj->amount_ttc;
- $subtotal_ht += $obj->amount_ht;
- $subtotal_ttc += $obj->amount_ttc;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("ExpenseReport")." <a href=\"".DOL_URL_ROOT."/expensereport/list.php?search_user=".$obj->userid."\">".$obj->firstname." ".$obj->lastname."</a></td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$obj->amount_ht).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price(-$obj->amount_ttc).'</span></td>';
- print '</tr>';
- }
- } else {
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
- print '</tr>';
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome += $subtotal_ht;
- $total_ttc_outcome += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price(-$subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price(-$subtotal_ttc).'</td>';
- print '</tr>';
- }
- /*
- * Various Payments
- */
- //$conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY = 1;
- if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_VARPAY) && !empty($conf->banque->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VariousPayment").'</td></tr>';
- // Debit
- $sql = "SELECT SUM(p.amount) AS amount FROM ".MAIN_DB_PREFIX."payment_various as p";
- $sql .= ' WHERE 1 = 1';
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- $sql .= ' GROUP BY p.sens';
- $sql .= ' ORDER BY p.sens';
- dol_syslog('get various payments', LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- // Debit (payment of suppliers for example)
- $obj = $db->fetch_object($result);
- if (isset($obj->amount)) {
- $subtotal_ht += -$obj->amount;
- $subtotal_ttc += -$obj->amount;
- $total_ht_outcome += $obj->amount;
- $total_ttc_outcome += $obj->amount;
- }
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("Debit")."</td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price(-$obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
- print "</tr>\n";
- // Credit (payment received from customer for example)
- $obj = $db->fetch_object($result);
- if (isset($obj->amount)) {
- $subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- $total_ht_income += $obj->amount;
- $total_ttc_income += $obj->amount;
- }
- print '<tr class="oddeven"><td> </td>';
- print "<td>".$langs->trans("Credit")."</td>\n";
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<span class="amount">'.price($obj->amount).'</span>';
- }
- print '</td>';
- print '<td class="right"><span class="amount">'.price($obj->amount)."</span></td>\n";
- print "</tr>\n";
- // Total
- $total_ht += $subtotal_ht;
- $total_ttc += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price($subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price($subtotal_ttc).'</td>';
- print '</tr>';
- } else {
- dol_print_error($db);
- }
- }
- /*
- * Payment Loan
- */
- if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) {
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("PaymentLoan").'</td></tr>';
- $sql = 'SELECT l.rowid as id, l.label AS label, SUM(p.amount_capital + p.amount_insurance + p.amount_interest) as amount FROM '.MAIN_DB_PREFIX.'payment_loan as p';
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'loan AS l ON l.rowid = p.fk_loan';
- $sql .= ' WHERE 1 = 1';
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
- }
- $sql .= ' GROUP BY p.fk_loan';
- $sql .= ' ORDER BY p.fk_loan';
- dol_syslog('get loan payments', LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
- $loan_static = new Loan($db);
- while ($obj = $db->fetch_object($result)) {
- $loan_static->id = $obj->id;
- $loan_static->ref = $obj->id;
- $loan_static->label = $obj->label;
- print '<tr class="oddeven"><td> </td>';
- print "<td>".$loan_static->getNomUrl(1).' - '.$obj->label."</td>\n";
- if ($modecompta == 'CREANCES-DETTES') {
- print '<td class="right"><span class="amount">'.price(-$obj->amount).'</span></td>';
- }
- print '<td class="right"><span class="amount">'.price(-$obj->amount)."</span></td>\n";
- print "</tr>\n";
- $subtotal_ht -= $obj->amount;
- $subtotal_ttc -= $obj->amount;
- }
- $total_ht += $subtotal_ht;
- $total_ttc += $subtotal_ttc;
- $total_ht_income += $subtotal_ht;
- $total_ttc_income += $subtotal_ttc;
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right">';
- if ($modecompta == 'CREANCES-DETTES') {
- print price($subtotal_ht);
- }
- print '</td>';
- print '<td class="right">'.price($subtotal_ttc).'</td>';
- print '</tr>';
- } else {
- dol_print_error($db);
- }
- }
- /*
- * VAT
- */
- print '<tr class="trforbreak"><td colspan="4">'.$langs->trans("VAT").'</td></tr>';
- $subtotal_ht = 0;
- $subtotal_ttc = 0;
- if ($conf->tax->enabled && ($modecompta == 'CREANCES-DETTES' || $modecompta == 'RECETTES-DEPENSES')) {
- if ($modecompta == 'CREANCES-DETTES') {
- // VAT to pay
- $amount = 0;
- $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture as f";
- $sql .= " WHERE f.fk_statut IN (1,2)";
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (0,1,2,5)";
- } else {
- $sql .= " AND f.type IN (0,1,2,3,5)";
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND f.entity IN (".getEntity('invoice').")";
- $sql .= " GROUP BY dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'dm';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get vat to pay", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $amount -= $obj->amount;
- //$total_ht -= $obj->amount;
- $total_ttc -= $obj->amount;
- //$subtotal_ht -= $obj->amount;
- $subtotal_ttc -= $obj->amount;
- $i++;
- }
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome -= 0;
- $total_ttc_outcome -= $amount;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("VATToPay")."</td>\n";
- print '<td class="right"> </td>'."\n";
- print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
- print "</tr>\n";
- // VAT to retrieve
- $amount = 0;
- $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
- $sql .= " WHERE f.fk_statut IN (1,2)";
- if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
- $sql .= " AND f.type IN (0,1,2)";
- } else {
- $sql .= " AND f.type IN (0,1,2,3)";
- }
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND f.entity = ".$conf->entity;
- $sql .= " GROUP BY dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'dm';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get vat received back", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $amount += $obj->amount;
- //$total_ht += $obj->amount;
- $total_ttc += $obj->amount;
- //$subtotal_ht += $obj->amount;
- $subtotal_ttc += $obj->amount;
- $i++;
- }
- }
- } else {
- dol_print_error($db);
- }
- $total_ht_income += 0;
- $total_ttc_income += $amount;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print '<td>'.$langs->trans("VATToCollect")."</td>\n";
- print '<td class="right"> </td>'."\n";
- print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
- print "</tr>\n";
- } else {
- // VAT really already paid
- $amount = 0;
- $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
- $sql .= " WHERE amount > 0";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND t.entity = ".$conf->entity;
- $sql .= " GROUP BY dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'dm';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get vat really paid", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $amount -= $obj->amount;
- $total_ht -= $obj->amount;
- $total_ttc -= $obj->amount;
- $subtotal_ht -= $obj->amount;
- $subtotal_ttc -= $obj->amount;
- $i++;
- }
- }
- $db->free($result);
- } else {
- dol_print_error($db);
- }
- $total_ht_outcome -= 0;
- $total_ttc_outcome -= $amount;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("VATPaid")."</td>\n";
- print '<td <class="right"></td>'."\n";
- print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
- print "</tr>\n";
- // VAT really received
- $amount = 0;
- $sql = "SELECT date_format(t.datev,'%Y-%m') as dm, sum(t.amount) as amount";
- $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
- $sql .= " WHERE amount < 0";
- if (!empty($date_start) && !empty($date_end)) {
- $sql .= " AND t.datev >= '".$db->idate($date_start)."' AND t.datev <= '".$db->idate($date_end)."'";
- }
- $sql .= " AND t.entity = ".$conf->entity;
- $sql .= " GROUP BY dm";
- $newsortfield = $sortfield;
- if ($newsortfield == 's.nom, s.rowid') {
- $newsortfield = 'dm';
- }
- if ($newsortfield == 'amount_ht') {
- $newsortfield = 'amount';
- }
- if ($newsortfield == 'amount_ttc') {
- $newsortfield = 'amount';
- }
- $sql .= $db->order($newsortfield, $sortorder);
- dol_syslog("get vat really received back", LOG_DEBUG);
- $result = $db->query($sql);
- if ($result) {
- $num = $db->num_rows($result);
- $i = 0;
- if ($num) {
- while ($i < $num) {
- $obj = $db->fetch_object($result);
- $amount += -$obj->amount;
- $total_ht += -$obj->amount;
- $total_ttc += -$obj->amount;
- $subtotal_ht += -$obj->amount;
- $subtotal_ttc += -$obj->amount;
- $i++;
- }
- }
- $db->free($result);
- } else {
- dol_print_error($db);
- }
- $total_ht_income += 0;
- $total_ttc_income += $amount;
- print '<tr class="oddeven">';
- print '<td> </td>';
- print "<td>".$langs->trans("VATCollected")."</td>\n";
- print '<td class="right"></td>'."\n";
- print '<td class="right"><span class="amount">'.price($amount)."</span></td>\n";
- print "</tr>\n";
- }
- }
- if ($mysoc->tva_assuj != '0') { // Assujetti
- print '<tr class="liste_total">';
- print '<td></td>';
- print '<td></td>';
- print '<td class="right"> </td>';
- print '<td class="right">'.price(price2num($subtotal_ttc, 'MT')).'</td>';
- print '</tr>';
- }
- }
- $action = "balanceclient";
- $object = array(&$total_ht, &$total_ttc);
- $parameters["mode"] = $modecompta;
- $parameters["date_start"] = $date_start;
- $parameters["date_end"] = $date_end;
- // Initialize technical object to manage hooks of expenses. Note that conf->hooks_modules contains array array
- $hookmanager->initHooks(array('externalbalance'));
- $reshook = $hookmanager->executeHooks('addBalanceLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
- print $hookmanager->resPrint;
- // Total
- print '<tr>';
- print '<td colspan="4"> </td>';
- print '</tr>';
- print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Income").'</td>';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<td class="liste_total right">'.price(price2num($total_ht_income, 'MT')).'</td>';
- }
- print '<td class="liste_total right">'.price(price2num($total_ttc_income, 'MT')).'</td>';
- print '</tr>';
- print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Outcome").'</td>';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<td class="liste_total right">'.price(price2num(-$total_ht_outcome, 'MT')).'</td>';
- }
- print '<td class="liste_total right">'.price(price2num(-$total_ttc_outcome, 'MT')).'</td>';
- print '</tr>';
- print '<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans("Profit").'</td>';
- if ($modecompta == 'CREANCES-DETTES') {
- print '<td class="liste_total right">'.price(price2num($total_ht, 'MT')).'</td>';
- }
- print '<td class="liste_total right">'.price(price2num($total_ttc, 'MT')).'</td>';
- print '</tr>';
- print "</table>";
- print '<br>';
- // End of page
- llxFooter();
- $db->close();
|