2005-09-04 21:10:18 +02:00
< ? php
/* Copyright ( C ) 2001 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2013-12-01 18:53:16 +01:00
* Copyright ( C ) 2004 - 2013 Laurent Destailleur < eldy @ users . sourceforge . net >
2015-10-02 11:21:23 +02:00
* Copyright ( C ) 2005 - 2015 Regis Houssin < regis . houssin @ capnetworks . com >
2016-06-03 23:58:54 +02:00
* Copyright ( C ) 2015 - 2016 Juanjo Menent < jmenent @ 2 byte . es >
2015-04-18 23:11:17 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2015-09-03 10:49:41 +02:00
* Copyright ( C ) 2015 Raphaël Doursenaud < rdoursenaud @ gpcsolutions . fr >
2016-04-09 22:34:55 +02:00
* Copyright ( C ) 2016 Marcos García < marcosgdf @ gmail . com >
2005-09-04 21:10:18 +02:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2005-09-04 21:10:18 +02:00
* ( 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
2011-08-03 02:45:22 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2005-09-04 21:10:18 +02:00
*/
2006-07-01 15:03:46 +02:00
/**
2009-03-09 20:48:29 +01:00
* \file htdocs / compta / index . php
* \ingroup compta
* \brief Main page of accountancy area
2009-02-20 23:53:15 +01:00
*/
2005-09-04 21:10:18 +02:00
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php' ;
2012-10-13 10:39:16 +02:00
if ( ! empty ( $conf -> commande -> enabled ))
require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php' ;
if ( ! empty ( $conf -> commande -> enabled ))
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php' ;
if ( ! empty ( $conf -> tax -> enabled ))
require_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php' ;
2005-09-04 21:10:18 +02:00
2009-11-06 17:03:54 +01:00
// L'espace compta/treso doit toujours etre actif car c'est un espace partage
2010-03-23 09:26:27 +01:00
// par de nombreux modules (banque, facture, commande a facturer, etc...) independamment
2006-05-20 12:10:41 +02:00
// de l'utilisation de la compta ou non. C'est au sein de cet espace que chaque sous fonction
2010-03-23 09:26:27 +01:00
// est protegee par le droit qui va bien du module concerne.
2006-05-20 12:10:41 +02:00
//if (!$user->rights->compta->general->lire)
// accessforbidden();
2005-09-06 16:12:53 +02:00
2018-05-26 16:35:29 +02:00
// Load translation files required by the page
2018-05-26 15:41:32 +02:00
$langs -> loadLangs ( array ( 'compta' , 'bills' ));
2012-10-13 10:39:16 +02:00
if ( ! empty ( $conf -> commande -> enabled ))
$langs -> load ( " orders " );
$action = GETPOST ( 'action' , 'alpha' );
$bid = GETPOST ( 'bid' , 'int' );
2005-09-04 21:10:18 +02:00
2008-11-08 23:09:00 +01:00
// Security check
2006-09-13 20:56:30 +02:00
$socid = '' ;
2005-09-04 21:10:18 +02:00
if ( $user -> societe_id > 0 )
{
2009-02-20 23:53:15 +01:00
$action = '' ;
$socid = $user -> societe_id ;
2005-09-04 21:10:18 +02:00
}
2017-02-21 14:17:44 +01:00
$max = 3 ;
2018-01-15 14:24:19 +01:00
$hookmanager -> initHooks ( array ( 'invoiceindex' ));
2005-09-04 21:10:18 +02:00
/*
* Actions
*/
2006-02-24 20:44:20 +01:00
2005-09-04 21:10:18 +02:00
/*
2009-05-10 06:20:37 +02:00
* View
2005-09-04 21:10:18 +02:00
*/
2006-02-24 20:44:20 +01:00
2010-11-20 14:20:22 +01:00
$now = dol_now ();
2009-01-07 16:21:16 +01:00
2006-10-14 19:05:06 +02:00
$facturestatic = new Facture ( $db );
2007-07-07 15:20:36 +02:00
$facturesupplierstatic = new FactureFournisseur ( $db );
2006-10-14 19:05:06 +02:00
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2008-01-20 14:53:02 +01:00
$formfile = new FormFile ( $db );
2010-11-20 14:20:22 +01:00
$thirdpartystatic = new Societe ( $db );
2007-07-13 18:32:34 +02:00
2006-02-24 20:44:20 +01:00
llxHeader ( " " , $langs -> trans ( " AccountancyTreasuryArea " ));
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $langs -> trans ( " AccountancyTreasuryArea " ), '' , 'title_accountancy.png' );
2005-09-04 21:10:18 +02:00
2013-04-12 16:16:39 +02:00
2013-03-30 14:27:13 +01:00
print '<div class="fichecenter"><div class="fichethirdleft">' ;
2005-09-04 21:10:18 +02:00
2013-04-12 16:16:39 +02:00
2017-02-21 14:17:44 +01:00
if ( ! empty ( $conf -> global -> MAIN_SEARCH_FORM_ON_HOME_AREAS )) // This is useless due to the global search combo
2005-09-06 16:12:53 +02:00
{
2017-02-21 14:17:44 +01:00
// Search customer invoices
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
{
$listofsearchfields [ 'search_invoice' ] = array ( 'text' => 'CustomerInvoice' );
}
// Search supplier invoices
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> lire )
{
$listofsearchfields [ 'search_supplier_invoice' ] = array ( 'text' => 'SupplierInvoice' );
}
if ( ! empty ( $conf -> don -> enabled ) && $user -> rights -> don -> lire )
{
$langs -> load ( " donations " );
$listofsearchfields [ 'search_donation' ] = array ( 'text' => 'Donation' );
}
2017-11-12 12:39:23 +01:00
2017-02-21 14:17:44 +01:00
if ( count ( $listofsearchfields ))
{
print '<form method="post" action="' . DOL_URL_ROOT . '/core/search.php">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<table class="noborder nohover centpercent">' ;
$i = 0 ;
foreach ( $listofsearchfields as $key => $value )
{
if ( $i == 0 ) print '<tr class="liste_titre"><td colspan="3">' . $langs -> trans ( " Search " ) . '</td></tr>' ;
print '<tr ' . $bc [ false ] . '>' ;
print '<td class="nowrap"><label for="' . $key . '">' . $langs -> trans ( $value [ " text " ]) . '</label></td><td><input type="text" class="flat inputsearch" name="' . $key . '" id="' . $key . '"></td>' ;
if ( $i == 0 ) print '<td rowspan="' . count ( $listofsearchfields ) . '"><input type="submit" value="' . $langs -> trans ( " Search " ) . '" class="button"></td>' ;
print '</tr>' ;
$i ++ ;
}
2017-11-12 12:39:23 +01:00
print '</table>' ;
2017-02-21 14:17:44 +01:00
print '</form>' ;
print '<br>' ;
}
2015-10-16 22:21:26 +02:00
}
2005-09-04 21:10:18 +02:00
/**
2009-03-09 20:48:29 +01:00
* Draft customers invoices
2005-09-04 21:10:18 +02:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2006-07-01 15:03:46 +02:00
{
2015-01-25 01:20:58 +01:00
$sql = " SELECT f.facnumber " ;
2017-10-24 11:17:02 +02:00
$sql .= " , f.rowid, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client " ;
2015-01-25 01:20:58 +01:00
$sql .= " , f.type " ;
$sql .= " , s.nom as name " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.rowid as socid, s.email " ;
$sql .= " , s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur " ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , sc.fk_soc, sc.fk_user " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " facture as f, " . MAIN_DB_PREFIX . " societe as s " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0 " ;
2009-05-02 16:45:23 +02:00
$sql .= " AND f.entity = " . $conf -> entity ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2006-07-01 15:03:46 +02:00
2007-07-07 15:20:36 +02:00
if ( $socid )
{
$sql .= " AND f.fk_soc = $socid " ;
}
2018-01-15 14:24:19 +01:00
// Add where from hooks
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereCustomerDraft' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2006-07-01 15:03:46 +02:00
2007-07-07 15:20:36 +02:00
$resql = $db -> query ( $sql );
2006-07-01 15:03:46 +02:00
2007-07-07 15:20:36 +02:00
if ( $resql )
{
$var = false ;
$num = $db -> num_rows ( $resql );
2007-03-16 20:14:06 +01:00
print '<table class="noborder" width="100%">' ;
2007-07-07 15:20:36 +02:00
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " CustomersDraftInvoices " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2007-07-07 15:20:36 +02:00
if ( $num )
{
$companystatic = new Societe ( $db );
2006-07-01 15:03:46 +02:00
2007-07-07 15:20:36 +02:00
$i = 0 ;
$tot_ttc = 0 ;
2013-12-01 18:53:16 +01:00
while ( $i < $num )
2007-07-07 15:20:36 +02:00
{
$obj = $db -> fetch_object ( $resql );
2018-02-05 00:36:54 +01:00
2007-07-07 15:20:36 +02:00
$facturestatic -> ref = $obj -> facnumber ;
$facturestatic -> id = $obj -> rowid ;
2018-02-05 00:36:54 +01:00
$facturestatic -> total_ht = $obj -> total_ht ;
$facturestatic -> total_tva = $obj -> total_tva ;
$facturestatic -> total_ttc = $obj -> total_ttc ;
$facturestatic -> ref_client = $obj -> ref_client ;
2007-07-07 15:20:36 +02:00
$facturestatic -> type = $obj -> type ;
2018-02-05 00:36:54 +01:00
$companystatic -> id = $obj -> socid ;
$companystatic -> name = $obj -> name ;
$companystatic -> email = $obj -> email ;
$companystatic -> client = 1 ;
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
print '<tr class="oddeven"><td class="nowrap">' ;
2007-07-07 15:20:36 +02:00
print $facturestatic -> getNomUrl ( 1 , '' );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2018-03-09 22:36:00 +01:00
print $companystatic -> getNomUrl ( 1 , 'customer' , 16 );
2007-07-07 15:20:36 +02:00
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td align="right" class="nowrap">' . price ( $obj -> total_ttc ) . '</td>' ;
2007-07-07 15:20:36 +02:00
print '</tr>' ;
$tot_ttc += $obj -> total_ttc ;
$i ++ ;
2017-11-12 12:39:23 +01:00
2007-07-07 15:20:36 +02:00
}
2006-07-01 15:03:46 +02:00
2007-07-07 15:20:36 +02:00
print '<tr class="liste_total"><td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
print '<td colspan="2" align="right">' . price ( $tot_ttc ) . '</td>' ;
print '</tr>' ;
}
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2007-07-07 15:20:36 +02:00
}
print " </table><br> " ;
$db -> free ( $resql );
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2007-07-07 15:20:36 +02:00
}
}
/**
2009-03-09 20:48:29 +01:00
* Draft suppliers invoices
2007-07-07 15:20:36 +02:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> facture -> lire )
2007-07-07 15:20:36 +02:00
{
2017-10-24 11:17:02 +02:00
$sql = " SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier " ;
2015-01-25 01:20:58 +01:00
$sql .= " , s.nom as name " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.rowid as socid, s.email " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur " ;
2018-07-13 09:08:42 +02:00
$sql .= " , cc.rowid as country_id, cc.code as country_code " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " facture_fourn as f, " . MAIN_DB_PREFIX . " societe as s LEFT JOIN " . MAIN_DB_PREFIX . " c_country as cc ON cc.rowid = s.fk_pays " ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE s.rowid = f.fk_soc AND f.fk_statut = 0 " ;
2009-05-02 16:45:23 +02:00
$sql .= " AND f.entity = " . $conf -> entity ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-05-02 16:45:23 +02:00
if ( $socid ) $sql .= " AND f.fk_soc = " . $socid ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereSupplierDraft' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2007-07-07 15:20:36 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th colspan="3">' . $langs -> trans ( " SuppliersDraftInvoices " ) . ( $num ? ' <span class="badge">' . $num . '</span>' : '' ) . '</th></tr>' ;
2007-07-07 15:20:36 +02:00
if ( $num )
{
$companystatic = new Societe ( $db );
$i = 0 ;
$tot_ttc = 0 ;
2013-12-01 18:53:16 +01:00
while ( $i < $num )
2007-07-07 15:20:36 +02:00
{
$obj = $db -> fetch_object ( $resql );
2018-02-05 00:36:54 +01:00
2013-04-01 16:04:15 +02:00
$facturesupplierstatic -> ref = $obj -> ref ;
2007-07-07 15:20:36 +02:00
$facturesupplierstatic -> id = $obj -> rowid ;
2018-02-05 00:36:54 +01:00
$facturesupplierstatic -> total_ht = $obj -> total_ht ;
$facturesupplierstatic -> total_tva = $obj -> total_tva ;
$facturesupplierstatic -> total_ttc = $obj -> total_ttc ;
$facturesupplierstatic -> ref_supplier = $obj -> ref_supplier ;
2007-07-07 15:20:36 +02:00
$facturesupplierstatic -> type = $obj -> type ;
2018-02-05 00:36:54 +01:00
2007-10-10 02:26:53 +02:00
$companystatic -> id = $obj -> socid ;
2014-10-04 17:20:17 +02:00
$companystatic -> name = $obj -> name ;
2018-02-05 00:36:54 +01:00
$companystatic -> email = $obj -> email ;
2018-07-13 09:08:42 +02:00
$companystatic -> country_id = $obj -> country_id ;
$companystatic -> country_code = $obj -> country_code ;
2015-01-25 01:20:58 +01:00
$companystatic -> fournisseur = 1 ;
2018-02-05 00:36:54 +01:00
$companystatic -> code_client = $obj -> code_client ;
$companystatic -> code_fournisseur = $obj -> code_fournisseur ;
$companystatic -> code_compta = $obj -> code_compta ;
$companystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
print '<tr class="oddeven"><td class="nowrap">' ;
print $facturesupplierstatic -> getNomUrl ( 1 , '' , 16 );
print '</td>' ;
print '<td>' ;
2015-01-25 01:20:58 +01:00
print $companystatic -> getNomUrl ( 1 , 'supplier' , 16 );
2007-07-07 15:20:36 +02:00
print '</td>' ;
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
print '</tr>' ;
$tot_ttc += $obj -> total_ttc ;
$i ++ ;
}
print '<tr class="liste_total"><td align="left">' . $langs -> trans ( " Total " ) . '</td>' ;
print '<td colspan="2" align="right">' . price ( $tot_ttc ) . '</td>' ;
print '</tr>' ;
}
else
{
2017-04-07 11:01:12 +02:00
print '<tr class="oddeven"><td colspan="3" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2007-07-07 15:20:36 +02:00
}
print " </table><br> " ;
$db -> free ( $resql );
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2007-07-07 15:20:36 +02:00
}
2005-09-04 21:10:18 +02:00
}
2013-03-16 14:53:15 +01:00
2013-03-30 14:27:13 +01:00
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">' ;
2013-03-16 14:53:15 +01:00
2005-09-04 21:10:18 +02:00
2018-06-17 01:50:10 +02:00
// Latest modified customer invoices
2012-09-15 09:02:20 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2009-05-10 06:20:37 +02:00
{
$langs -> load ( " boxes " );
$facstatic = new Facture ( $db );
2015-01-25 01:20:58 +01:00
$sql = " SELECT f.rowid, f.facnumber, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms " ;
$sql .= " , f.date_lim_reglement as datelimite " ;
$sql .= " , s.nom as name " ;
$sql .= " , s.rowid as socid " ;
2018-06-17 01:50:10 +02:00
$sql .= " , s.code_client, s.code_compta, s.email " ;
2018-07-13 09:08:42 +02:00
$sql .= " , cc.rowid as country_id, cc.code as country_code " ;
$sql .= " , sum(pf.amount) as am " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s LEFT JOIN " . MAIN_DB_PREFIX . " c_country as cc ON cc.rowid = s.fk_pays, " . MAIN_DB_PREFIX . " facture as f " ;
2009-05-10 06:20:37 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " paiement_facture as pf on f.rowid=pf.fk_facture " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE s.rowid = f.fk_soc " ;
$sql .= " AND f.entity = " . $conf -> entity ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND f.fk_soc = " . $socid ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereCustomerLastModified' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2018-02-05 00:36:54 +01:00
$sql .= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, " ;
2018-07-13 09:08:42 +02:00
$sql .= " s.nom, s.rowid, s.code_client, s.code_compta, s.email, " ;
$sql .= " cc.rowid, cc.code " ;
2009-05-10 06:20:37 +02:00
$sql .= " ORDER BY f.tms DESC " ;
$sql .= $db -> plimit ( $max , 0 );
$resql = $db -> query ( $sql );
if ( $resql )
{
$var = false ;
$num = $db -> num_rows ( $resql );
$i = 0 ;
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " BoxTitleLastCustomerBills " , $max ) . '</th>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<th align="right">' . $langs -> trans ( " AmountHT " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " DateModificationShort " ) . '</th>' ;
print '<th width="16"> </th>' ;
2009-05-10 06:20:37 +02:00
print '</tr>' ;
if ( $num )
{
$total_ttc = $totalam = $total = 0 ;
while ( $i < $num && $i < $conf -> liste_limit )
{
$obj = $db -> fetch_object ( $resql );
$facturestatic -> ref = $obj -> facnumber ;
$facturestatic -> id = $obj -> rowid ;
2018-02-05 00:36:54 +01:00
$facturestatic -> total_ht = $obj -> total_ht ;
$facturestatic -> total_tva = $obj -> total_tva ;
$facturestatic -> total_ttc = $obj -> total_ttc ;
2015-09-05 10:56:13 +02:00
$facturestatic -> statut = $obj -> fk_statut ;
$facturestatic -> date_lim_reglement = $db -> jdate ( $obj -> datelimite );
2009-05-10 06:20:37 +02:00
$facturestatic -> type = $obj -> type ;
2018-02-05 00:36:54 +01:00
$thirdpartystatic -> id = $obj -> socid ;
$thirdpartystatic -> name = $obj -> name ;
2018-06-17 01:50:10 +02:00
$thirdpartystatic -> email = $obj -> email ;
2018-07-13 09:08:42 +02:00
$thirdpartystatic -> country_id = $obj -> country_id ;
$thirdpartystatic -> country_code = $obj -> country_code ;
$thirdpartystatic -> email = $obj -> email ;
2018-02-05 00:36:54 +01:00
$thirdpartystatic -> client = 1 ;
$thirdpartystatic -> code_client = $obj -> code_client ;
//$thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
$thirdpartystatic -> code_compta = $obj -> code_compta ;
//$thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
print '<td width="110" class="nobordernopadding nowrap">' ;
2009-05-10 06:20:37 +02:00
print $facturestatic -> getNomUrl ( 1 , '' );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="20" class="nobordernopadding nowrap">' ;
2015-09-05 10:56:13 +02:00
if ( $facturestatic -> hasDelay ()) {
print img_warning ( $langs -> trans ( " Late " ));
}
2009-05-10 06:20:37 +02:00
print '</td>' ;
2013-04-25 20:27:45 +02:00
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">' ;
2009-05-10 06:20:37 +02:00
$filename = dol_sanitizeFileName ( $obj -> facnumber );
$filedir = $conf -> facture -> dir_output . '/' . dol_sanitizeFileName ( $obj -> facnumber );
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?facid=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $facturestatic -> element , $filename , $filedir );
2009-05-10 06:20:37 +02:00
print '</td></tr></table>' ;
print '</td>' ;
2010-11-20 14:20:22 +01:00
print '<td align="left">' ;
2018-02-05 00:36:54 +01:00
print $thirdpartystatic -> getNomUrl ( 1 , 'customer' , 44 );
2010-11-20 14:20:22 +01:00
print '</td>' ;
2015-01-25 01:20:58 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
2009-05-10 06:20:37 +02:00
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
print '<td align="right">' . dol_print_date ( $db -> jdate ( $obj -> tms ), 'day' ) . '</td>' ;
print '<td>' . $facstatic -> LibStatut ( $obj -> paye , $obj -> fk_statut , 3 , $obj -> am ) . '</td>' ;
print '</tr>' ;
$total_ttc += $obj -> total_ttc ;
2017-07-18 14:33:32 +02:00
$total += $obj -> total_ht ;
2009-05-10 06:20:37 +02:00
$totalam += $obj -> am ;
2017-11-12 12:39:23 +01:00
2009-05-10 06:20:37 +02:00
$i ++ ;
}
}
else
{
$colspan = 5 ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) $colspan ++ ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2009-05-10 06:20:37 +02:00
}
print '</table><br>' ;
$db -> free ( $resql );
}
else
{
dol_print_error ( $db );
}
}
// Last modified supplier invoices
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> facture -> lire )
2009-05-10 06:20:37 +02:00
{
$langs -> load ( " boxes " );
$facstatic = new FactureFournisseur ( $db );
2015-01-25 01:20:58 +01:00
$sql = " SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye " ;
$sql .= " , s.nom as name " ;
$sql .= " , s.rowid as socid " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur " ;
2009-12-22 16:13:49 +01:00
$sql .= " , SUM(pf.amount) as am " ;
2009-05-10 06:20:37 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture_fourn as ff " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn " ;
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
$sql .= " WHERE s.rowid = ff.fk_soc " ;
2012-02-01 11:32:55 +01:00
$sql .= " AND ff.entity = " . $conf -> entity ;
2009-05-10 06:20:37 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND ff.fk_soc = " . $socid ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereSupplierLastModified' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2018-02-05 00:36:54 +01:00
$sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, " ;
$sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur " ;
2009-05-10 06:20:37 +02:00
$sql .= " ORDER BY ff.tms DESC " ;
$sql .= $db -> plimit ( $max , 0 );
$resql = $db -> query ( $sql );
if ( $resql )
{
$var = false ;
$num = $db -> num_rows ( $resql );
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " BoxTitleLastSupplierBills " , $max ) . '</th>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<th align="right">' . $langs -> trans ( " AmountHT " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " DateModificationShort " ) . '</th>' ;
print '<th width="16"> </th>' ;
2009-05-10 06:20:37 +02:00
print " </tr> \n " ;
if ( $num )
{
$i = 0 ;
$total = $total_ttc = $totalam = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2018-02-05 00:36:54 +01:00
2013-04-01 16:04:15 +02:00
$facstatic -> ref = $obj -> ref ;
2018-02-05 00:36:54 +01:00
$facstatic -> id = $obj -> rowid ;
$facstatic -> total_ht = $obj -> total_ht ;
$facstatic -> total_tva = $obj -> total_tva ;
$facstatic -> total_ttc = $obj -> total_ttc ;
2010-11-20 14:20:22 +01:00
$thirdpartystatic -> id = $obj -> socid ;
2014-10-04 17:20:17 +02:00
$thirdpartystatic -> name = $obj -> name ;
2010-11-20 14:20:22 +01:00
$thirdpartystatic -> fournisseur = 1 ;
2018-02-05 00:36:54 +01:00
//$thirdpartystatic->code_client = $obj->code_client;
$thirdpartystatic -> code_fournisseur = $obj -> code_fournisseur ;
//$thirdpartystatic->code_compta = $obj->code_compta;
$thirdpartystatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
print '<tr class="oddeven"><td>' ;
print $facstatic -> getNomUrl ( 1 , '' );
print '</td>' ;
print '<td>' ;
2010-11-20 14:20:22 +01:00
print $thirdpartystatic -> getNomUrl ( 1 , 'supplier' , 44 );
print '</td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
2009-05-10 06:20:37 +02:00
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
print '<td align="right">' . dol_print_date ( $db -> jdate ( $obj -> tms ), 'day' ) . '</td>' ;
print '<td>' . $facstatic -> LibStatut ( $obj -> paye , $obj -> fk_statut , 3 ) . '</td>' ;
print '</tr>' ;
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
$totalam += $obj -> am ;
$i ++ ;
$var = ! $var ;
}
}
else
{
$colspan = 5 ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) $colspan ++ ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2009-05-10 06:20:37 +02:00
}
print '</table><br>' ;
}
else
{
dol_print_error ( $db );
}
}
2005-09-04 21:10:18 +02:00
2011-06-29 19:55:32 +02:00
// Last donations
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> don -> enabled ) && $user -> rights -> societe -> lire )
2007-03-16 20:14:06 +01:00
{
2015-03-25 22:37:14 +01:00
include_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php' ;
2010-04-27 10:25:13 +02:00
2007-03-16 20:14:06 +01:00
$langs -> load ( " boxes " );
2011-06-29 19:55:32 +02:00
$donationstatic = new Don ( $db );
2007-03-16 20:14:06 +01:00
2013-02-23 15:46:12 +01:00
$sql = " SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut " ;
2012-02-01 11:32:55 +01:00
$sql .= " FROM " . MAIN_DB_PREFIX . " don as d " ;
2017-11-12 12:39:23 +01:00
$sql .= " WHERE d.entity IN ( " . getEntity ( 'donation' ) . " ) " ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereLastDonations' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2012-02-01 11:32:55 +01:00
$sql .= $db -> order ( " d.tms " , " DESC " );
2009-05-02 16:45:23 +02:00
$sql .= $db -> plimit ( $max , 0 );
2007-03-16 20:14:06 +01:00
$result = $db -> query ( $sql );
if ( $result )
{
2007-07-07 15:20:36 +02:00
$var = false ;
2007-03-16 20:14:06 +01:00
$num = $db -> num_rows ( $result );
$i = 0 ;
2007-07-07 15:20:36 +02:00
print '<table class="noborder" width="100%">' ;
2017-02-17 01:41:33 +01:00
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th>' . $langs -> trans ( " BoxTitleLastModifiedDonations " , $max ) . '</th>' ;
2017-11-12 12:39:23 +01:00
print '<th></th>' ;
2017-03-07 22:45:22 +01:00
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
2017-11-12 12:39:23 +01:00
print '<th align="right">' . $langs -> trans ( " DateModificationShort " ) . '</th>' ;
2017-03-07 22:45:22 +01:00
print '<th width="16"> </th>' ;
2007-07-07 15:20:36 +02:00
print '</tr>' ;
2007-03-16 20:14:06 +01:00
if ( $num )
{
$total_ttc = $totalam = $total = 0 ;
while ( $i < $num && $i < $max )
{
$objp = $db -> fetch_object ( $result );
2017-11-12 12:39:23 +01:00
2011-06-29 19:55:32 +02:00
$donationstatic -> id = $objp -> rowid ;
2017-11-12 12:39:23 +01:00
$donationstatic -> ref = $objp -> rowid ;
2013-02-23 15:46:12 +01:00
$donationstatic -> lastname = $objp -> lastname ;
$donationstatic -> firstname = $objp -> firstname ;
2017-11-12 12:39:23 +01:00
2011-06-29 19:55:32 +02:00
$label = $donationstatic -> getFullName ( $langs );
if ( $objp -> societe ) $label .= ( $label ? ' - ' : '' ) . $objp -> societe ;
2017-11-12 12:39:23 +01:00
print '<tr class="oddeven">' ;
2011-06-29 19:55:32 +02:00
print '<td>' . $donationstatic -> getNomUrl ( 1 ) . '</td>' ;
2017-11-12 12:39:23 +01:00
print '<td>' . $label . '</td>' ;
print '<td align="right">' . price ( $objp -> amount ) . '</td>' ;
2010-07-29 17:15:03 +02:00
print '<td align="right">' . dol_print_date ( $db -> jdate ( $objp -> dm ), 'day' ) . '</td>' ;
2011-06-29 19:55:32 +02:00
print '<td>' . $donationstatic -> LibStatut ( $objp -> fk_statut , 3 ) . '</td>' ;
2007-03-16 20:14:06 +01:00
print '</tr>' ;
$i ++ ;
}
2009-02-20 23:53:15 +01:00
2007-03-16 20:14:06 +01:00
}
2007-07-07 15:20:36 +02:00
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="4" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2007-07-07 15:20:36 +02:00
}
print '</table><br>' ;
2007-03-16 20:14:06 +01:00
}
2011-06-29 19:55:32 +02:00
else dol_print_error ( $db );
2007-03-16 20:14:06 +01:00
}
2009-03-09 20:48:29 +01:00
/**
* Social contributions to pay
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> tax -> enabled ) && $user -> rights -> tax -> charges -> lire )
2009-03-09 20:48:29 +01:00
{
2009-05-02 16:45:23 +02:00
if ( ! $socid )
2009-03-09 20:48:29 +01:00
{
$chargestatic = new ChargeSociales ( $db );
$sql = " SELECT c.rowid, c.amount, c.date_ech, c.paye, " ;
$sql .= " cc.libelle, " ;
2010-03-24 14:26:27 +01:00
$sql .= " SUM(pc.amount) as sumpaid " ;
2010-03-26 22:41:14 +01:00
$sql .= " FROM ( " . MAIN_DB_PREFIX . " c_chargesociales as cc, " . MAIN_DB_PREFIX . " chargesociales as c) " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " paiementcharge as pc ON pc.fk_charge = c.rowid " ;
2009-05-02 16:45:23 +02:00
$sql .= " WHERE c.fk_type = cc.id " ;
$sql .= " AND c.entity = " . $conf -> entity ;
$sql .= " AND c.paye = 0 " ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereSocialContributions' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2009-03-09 20:48:29 +01:00
$sql .= " GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
print '<table class="noborder" width="100%">' ;
print '<tr class="liste_titre">' ;
2017-03-07 22:45:22 +01:00
print '<th>' . $langs -> trans ( " ContributionsToPay " ) . ( $num ? ' <a href="' . DOL_URL_ROOT . '/compta/sociales/index.php?status=0"><span class="badge">' . $num . '</span></a>' : '' ) . '</th>' ;
print '<th align="center">' . $langs -> trans ( " DateDue " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " Paid " ) . '</th>' ;
print '<th align="center" width="16"> </th>' ;
2009-03-09 20:48:29 +01:00
print '</tr>' ;
if ( $num )
{
$i = 0 ;
$tot_ttc = 0 ;
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2017-11-12 12:39:23 +01:00
2009-03-09 20:48:29 +01:00
$chargestatic -> id = $obj -> rowid ;
2010-07-29 15:40:32 +02:00
$chargestatic -> ref = $obj -> libelle ;
2009-03-09 20:48:29 +01:00
$chargestatic -> lib = $obj -> libelle ;
$chargestatic -> paye = $obj -> paye ;
2017-11-12 12:39:23 +01:00
print '<tr class="oddeven">' ;
2009-03-09 20:48:29 +01:00
print '<td>' . $chargestatic -> getNomUrl ( 1 ) . '</td>' ;
2015-09-01 10:52:57 +02:00
print '<td align="center">' . dol_print_date ( $db -> jdate ( $obj -> date_ech ), 'day' ) . '</td>' ;
2009-03-09 20:48:29 +01:00
print '<td align="right">' . price ( $obj -> amount ) . '</td>' ;
2009-08-19 19:16:47 +02:00
print '<td align="right">' . price ( $obj -> sumpaid ) . '</td>' ;
2009-03-09 20:48:29 +01:00
print '<td align="center">' . $chargestatic -> getLibStatut ( 3 ) . '</td>' ;
print '</tr>' ;
$tot_ttc += $obj -> amount ;
$i ++ ;
}
print '<tr class="liste_total"><td align="left" colspan="2">' . $langs -> trans ( " Total " ) . '</td>' ;
print '<td align="right">' . price ( $tot_ttc ) . '</td>' ;
print '<td align="right"></td>' ;
2014-12-27 11:28:10 +01:00
print '<td align="right"> </td>' ;
2009-03-09 20:48:29 +01:00
print '</tr>' ;
}
else
{
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="5" class="opacitymedium">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2009-03-09 20:48:29 +01:00
}
print " </table><br> " ;
$db -> free ( $resql );
}
else
{
dol_print_error ( $db );
}
}
}
2005-09-04 21:10:18 +02:00
/*
2009-10-29 18:30:29 +01:00
* Customers orders to be billed
2005-09-04 21:10:18 +02:00
*/
2016-02-26 19:13:25 +01:00
if ( ! empty ( $conf -> facture -> enabled ) && ! empty ( $conf -> commande -> enabled ) && $user -> rights -> commande -> lire && empty ( $conf -> global -> WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER ))
2005-09-04 21:10:18 +02:00
{
2006-07-01 15:03:46 +02:00
$commandestatic = new Commande ( $db );
$langs -> load ( " orders " );
2015-01-25 01:20:58 +01:00
$sql = " SELECT sum(f.total) as tot_fht, sum(f.total_ttc) as tot_fttc " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.nom as name, s.email " ;
2015-01-25 01:20:58 +01:00
$sql .= " , s.rowid as socid " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.code_client, s.code_compta " ;
2018-07-13 09:08:42 +02:00
$sql .= " , c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc, " ;
$sql .= " cc.rowid as country_id, cc.code as country_code " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s LEFT JOIN " . MAIN_DB_PREFIX . " c_country as cc ON cc.rowid = s.fk_pays " ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2009-12-12 21:41:27 +01:00
$sql .= " , " . MAIN_DB_PREFIX . " commande as c " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande' " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture' " ;
2009-12-14 19:59:42 +01:00
$sql .= " WHERE c.fk_soc = s.rowid " ;
$sql .= " AND c.entity = " . $conf -> entity ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-12-14 19:59:42 +01:00
if ( $socid ) $sql .= " AND c.fk_soc = " . $socid ;
$sql .= " AND c.fk_statut = 3 " ;
$sql .= " AND c.facture = 0 " ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereCustomerOrderToBill' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2018-08-16 01:06:44 +02:00
$sql .= " GROUP BY s.nom, s.email, s.rowid, s.code_client, s.code_compta, c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva, c.total_ttc, cc.rowid, cc.code " ;
2005-09-04 21:10:18 +02:00
2006-07-01 15:03:46 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2005-09-04 21:10:18 +02:00
{
2006-07-01 15:03:46 +02:00
$num = $db -> num_rows ( $resql );
2009-02-20 23:53:15 +01:00
2006-07-01 15:03:46 +02:00
if ( $num )
{
$i = 0 ;
print '<table class="noborder" width="100%">' ;
print " <tr class= \" liste_titre \" > " ;
2017-03-07 22:45:22 +01:00
print '<th colspan="2">' . $langs -> trans ( " OrdersDeliveredToBill " ) . ' <a href="' . DOL_URL_ROOT . '/commande/list.php?viewstatut=3&billed=0"><span class="badge">' . $num . '</span></a></th>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<th align="right">' . $langs -> trans ( " AmountHT " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " ToBill " ) . '</th>' ;
print '<th align="center" width="16"> </th>' ;
2006-07-01 15:03:46 +02:00
print '</tr>' ;
2018-02-05 00:36:54 +01:00
2006-07-01 15:03:46 +02:00
$tot_ht = $tot_ttc = $tot_tobill = 0 ;
2011-09-20 15:32:16 +02:00
$societestatic = new Societe ( $db );
2006-07-01 15:03:46 +02:00
while ( $i < $num )
{
$obj = $db -> fetch_object ( $resql );
2010-11-22 20:32:54 +01:00
2018-02-05 00:36:54 +01:00
$societestatic -> id = $obj -> socid ;
$societestatic -> name = $obj -> name ;
$societestatic -> email = $obj -> email ;
2018-07-13 09:08:42 +02:00
$societestatic -> country_id = $obj -> country_id ;
$societestatic -> country_code = $obj -> country_code ;
2018-02-05 00:36:54 +01:00
$societestatic -> client = 1 ;
$societestatic -> code_client = $obj -> code_client ;
//$societestatic->code_fournisseur = $obj->code_fournisseur;
$societestatic -> code_compta = $obj -> code_compta ;
//$societestatic->code_fournisseur = $obj->code_fournisseur;
2009-02-20 23:53:15 +01:00
2007-07-13 18:32:34 +02:00
$commandestatic -> id = $obj -> rowid ;
$commandestatic -> ref = $obj -> ref ;
2009-02-20 23:53:15 +01:00
2018-02-05 00:36:54 +01:00
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
2007-07-13 18:32:34 +02:00
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
2013-04-25 01:13:13 +02:00
print '<td width="110" class="nobordernopadding nowrap">' ;
2007-07-13 18:32:34 +02:00
print $commandestatic -> getNomUrl ( 1 );
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="20" class="nobordernopadding nowrap">' ;
2007-07-14 16:14:22 +02:00
print ' ' ;
print '</td>' ;
2013-04-25 20:27:45 +02:00
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">' ;
2009-04-29 20:02:50 +02:00
$filename = dol_sanitizeFileName ( $obj -> ref );
$filedir = $conf -> commande -> dir_output . '/' . dol_sanitizeFileName ( $obj -> ref );
2007-07-13 18:32:34 +02:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?id=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $commandestatic -> element , $filename , $filedir );
2007-07-13 18:32:34 +02:00
print '</td></tr></table>' ;
2009-02-20 23:53:15 +01:00
2007-07-13 18:32:34 +02:00
print '</td>' ;
2006-07-01 15:03:46 +02:00
2010-11-22 20:32:54 +01:00
print '<td align="left">' ;
print $societestatic -> getNomUrl ( 1 , 'customer' , 44 );
2014-11-25 18:54:56 +01:00
print '</td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
2005-09-04 21:10:18 +02:00
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
2006-07-01 15:03:46 +02:00
print '<td align="right">' . price ( $obj -> total_ttc - $obj -> tot_fttc ) . '</td>' ;
print '<td>' . $commandestatic -> LibStatut ( $obj -> fk_statut , $obj -> facture , 3 ) . '</td>' ;
print '</tr>' ;
2005-09-04 21:10:18 +02:00
$tot_ht += $obj -> total_ht ;
$tot_ttc += $obj -> total_ttc ;
2006-08-26 14:45:38 +02:00
//print "x".$tot_ttc."z".$obj->tot_fttc;
2005-09-04 21:10:18 +02:00
$tot_tobill += ( $obj -> total_ttc - $obj -> tot_fttc );
2006-07-01 15:03:46 +02:00
$i ++ ;
2017-11-12 12:39:23 +01:00
2006-07-01 15:03:46 +02:00
}
2009-10-29 18:30:29 +01:00
print '<tr class="liste_total"><td colspan="2">' . $langs -> trans ( " Total " ) . ' <font style="font-weight: normal">(' . $langs -> trans ( " RemainderToBill " ) . ': ' . price ( $tot_tobill ) . ')</font> </td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $tot_ht ) . '</td>' ;
2006-07-01 15:03:46 +02:00
print '<td align="right">' . price ( $tot_ttc ) . '</td>' ;
print '<td align="right">' . price ( $tot_tobill ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
print '</table><br>' ;
}
$db -> free ( $resql );
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2005-09-04 21:10:18 +02:00
}
}
2006-07-01 15:03:46 +02:00
/*
2010-03-26 22:41:14 +01:00
* Unpaid customers invoices
2006-07-01 15:03:46 +02:00
*/
2012-09-15 09:02:20 +02:00
if ( ! empty ( $conf -> facture -> enabled ) && $user -> rights -> facture -> lire )
2005-09-04 21:10:18 +02:00
{
2006-07-01 15:03:46 +02:00
$facstatic = new Facture ( $db );
2015-01-25 01:20:58 +01:00
$sql = " SELECT f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms " ;
$sql .= " , f.date_lim_reglement as datelimite " ;
$sql .= " , s.nom as name " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.rowid as socid, s.email " ;
$sql .= " , s.code_client, s.code_compta " ;
2018-07-13 09:08:42 +02:00
$sql .= " , cc.rowid as country_id, cc.code as country_code " ;
$sql .= " , sum(pf.amount) as am " ;
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s LEFT JOIN " . MAIN_DB_PREFIX . " c_country as cc ON cc.rowid = s.fk_pays, " . MAIN_DB_PREFIX . " facture as f " ;
2006-07-01 15:03:46 +02:00
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " paiement_facture as pf on f.rowid=pf.fk_facture " ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-06-12 00:51:47 +02:00
$sql .= " WHERE s.rowid = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1 " ;
2009-05-02 16:45:23 +02:00
$sql .= " AND f.entity = " . $conf -> entity ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
2009-05-02 16:45:23 +02:00
if ( $socid ) $sql .= " AND f.fk_soc = " . $socid ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereCustomerUnpaid' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2018-07-17 23:50:06 +02:00
$sql .= " GROUP BY f.rowid, f.facnumber, f.fk_statut, f.datef, f.type, f.total, f.tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement, " ;
2018-07-13 09:08:42 +02:00
$sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, cc.rowid, cc.code " ;
2006-07-01 15:03:46 +02:00
$sql .= " ORDER BY f.datef ASC, f.facnumber ASC " ;
$resql = $db -> query ( $sql );
if ( $resql )
{
$num = $db -> num_rows ( $resql );
$i = 0 ;
2005-09-04 21:10:18 +02:00
2017-04-07 11:01:12 +02:00
print '<div class="div-table-responsive-no-min">' ;
2007-07-07 15:20:36 +02:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " BillsCustomersUnpaid " , $num ) . ' <a href="' . DOL_URL_ROOT . '/compta/facture/list.php?search_status=1"><span class="badge">' . $num . '</span></a></th>' ;
print '<th align="right">' . $langs -> trans ( " DateDue " ) . '</th>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<th align="right">' . $langs -> trans ( " AmountHT " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " Received " ) . '</th>' ;
print '<th width="16"> </th>' ;
2007-07-07 15:20:36 +02:00
print '</tr>' ;
2006-07-01 15:03:46 +02:00
if ( $num )
{
2011-09-20 15:32:16 +02:00
$societestatic = new Societe ( $db );
2006-07-01 15:03:46 +02:00
$total_ttc = $totalam = $total = 0 ;
2007-03-16 20:14:06 +01:00
while ( $i < $num && $i < $conf -> liste_limit )
2006-07-01 15:03:46 +02:00
{
$obj = $db -> fetch_object ( $resql );
2010-11-22 20:32:54 +01:00
2007-03-16 20:14:06 +01:00
$facturestatic -> ref = $obj -> facnumber ;
$facturestatic -> id = $obj -> rowid ;
2018-02-05 00:36:54 +01:00
$facturestatic -> total_ht = $obj -> total_ht ;
$facturestatic -> total_tva = $obj -> total_tva ;
$facturestatic -> total_ttc = $obj -> total_ttc ;
2007-03-16 20:14:06 +01:00
$facturestatic -> type = $obj -> type ;
2015-09-05 10:56:13 +02:00
$facturestatic -> statut = $obj -> fk_statut ;
$facturestatic -> date_lim_reglement = $db -> jdate ( $obj -> datelimite );
2018-02-05 00:36:54 +01:00
$societestatic -> id = $obj -> socid ;
$societestatic -> name = $obj -> name ;
$societestatic -> email = $obj -> email ;
2018-07-13 09:08:42 +02:00
$societestatic -> country_id = $obj -> country_id ;
$societestatic -> country_code = $obj -> country_code ;
2018-02-05 00:36:54 +01:00
$societestatic -> client = 1 ;
$societestatic -> code_client = $obj -> code_client ;
$societestatic -> code_fournisseur = $obj -> code_fournisseur ;
$societestatic -> code_compta = $obj -> code_compta ;
$societestatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
print '<tr class="oddeven">' ;
print '<td class="nowrap">' ;
print '<table class="nobordernopadding"><tr class="nocellnopadd">' ;
print '<td width="110" class="nobordernopadding nowrap">' ;
2007-03-16 20:14:06 +01:00
print $facturestatic -> getNomUrl ( 1 , '' );
2007-07-13 18:11:35 +02:00
print '</td>' ;
2013-04-25 01:13:13 +02:00
print '<td width="20" class="nobordernopadding nowrap">' ;
2015-09-05 10:56:13 +02:00
if ( $facturestatic -> hasDelay ()) {
print img_warning ( $langs -> trans ( " Late " ));
}
2007-07-13 18:11:35 +02:00
print '</td>' ;
2013-04-25 20:27:45 +02:00
print '<td width="16" align="right" class="nobordernopadding hideonsmartphone">' ;
2009-04-29 20:02:50 +02:00
$filename = dol_sanitizeFileName ( $obj -> facnumber );
$filedir = $conf -> facture -> dir_output . '/' . dol_sanitizeFileName ( $obj -> facnumber );
2007-07-13 18:11:35 +02:00
$urlsource = $_SERVER [ 'PHP_SELF' ] . '?facid=' . $obj -> rowid ;
2012-09-15 09:02:20 +02:00
print $formfile -> getDocumentsLink ( $facturestatic -> element , $filename , $filedir );
2007-07-13 18:11:35 +02:00
print '</td></tr></table>' ;
2009-02-20 23:53:15 +01:00
2007-03-16 20:14:06 +01:00
print '</td>' ;
2010-11-22 17:38:39 +01:00
print '<td align="left">' ;
2011-09-20 15:32:16 +02:00
print $societestatic -> getNomUrl ( 1 , 'customer' , 44 );
2014-11-25 18:54:56 +01:00
print '</td>' ;
2015-10-02 11:21:23 +02:00
print '<td align="right">' . dol_print_date ( $db -> jdate ( $obj -> datelimite ), 'day' ) . '</td>' ;
2015-01-25 01:20:58 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
2007-03-16 20:14:06 +01:00
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
print '<td align="right">' . price ( $obj -> am ) . '</td>' ;
print '<td>' . $facstatic -> LibStatut ( $obj -> paye , $obj -> fk_statut , 3 , $obj -> am ) . '</td>' ;
print '</tr>' ;
2006-07-01 15:03:46 +02:00
$total_ttc += $obj -> total_ttc ;
2016-06-22 18:59:51 +02:00
$total += $obj -> total_ht ;
2006-07-01 15:03:46 +02:00
$totalam += $obj -> am ;
2017-11-12 12:39:23 +01:00
2006-07-01 15:03:46 +02:00
$i ++ ;
}
2009-10-29 18:30:29 +01:00
print '<tr class="liste_total"><td colspan="2">' . $langs -> trans ( " Total " ) . ' <font style="font-weight: normal">(' . $langs -> trans ( " RemainderToTake " ) . ': ' . price ( $total_ttc - $totalam ) . ')</font> </td>' ;
2015-10-02 08:58:09 +02:00
print '<td> </td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $total ) . '</td>' ;
2006-07-01 15:03:46 +02:00
print '<td align="right">' . price ( $total_ttc ) . '</td>' ;
print '<td align="right">' . price ( $totalam ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
}
2007-07-07 15:20:36 +02:00
else
{
2015-10-02 08:58:09 +02:00
$colspan = 6 ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) $colspan ++ ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2007-07-07 15:20:36 +02:00
}
2017-04-07 11:01:12 +02:00
print '</table></div><br>' ;
2006-07-01 15:03:46 +02:00
$db -> free ( $resql );
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2006-07-01 15:03:46 +02:00
}
}
2005-09-04 21:10:18 +02:00
2006-07-01 15:03:46 +02:00
/*
2010-03-26 22:41:14 +01:00
* Unpayed supplier invoices
2006-07-01 15:03:46 +02:00
*/
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && $user -> rights -> fournisseur -> facture -> lire )
2006-07-01 15:03:46 +02:00
{
$facstatic = new FactureFournisseur ( $db );
2005-09-04 21:10:18 +02:00
2015-01-25 01:20:58 +01:00
$sql = " SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye " ;
2015-10-02 08:58:09 +02:00
$sql .= " , ff.date_lim_reglement " ;
2015-01-25 01:20:58 +01:00
$sql .= " , s.nom as name " ;
2018-02-05 00:36:54 +01:00
$sql .= " , s.rowid as socid, s.email " ;
$sql .= " , s.code_client, s.code_compta " ;
$sql .= " , s.code_fournisseur, s.code_compta_fournisseur " ;
2015-01-25 01:20:58 +01:00
$sql .= " , sum(pf.amount) as am " ;
2007-07-07 15:20:36 +02:00
$sql .= " FROM " . MAIN_DB_PREFIX . " societe as s, " . MAIN_DB_PREFIX . " facture_fourn as ff " ;
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . " paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn " ;
2009-04-27 22:37:50 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " , " . MAIN_DB_PREFIX . " societe_commerciaux as sc " ;
2007-07-07 15:20:36 +02:00
$sql .= " WHERE s.rowid = ff.fk_soc " ;
2012-02-01 11:32:55 +01:00
$sql .= " AND ff.entity = " . $conf -> entity ;
2009-12-22 16:13:49 +01:00
$sql .= " AND ff.paye = 0 " ;
$sql .= " AND ff.fk_statut = 1 " ;
2009-05-02 16:45:23 +02:00
if ( ! $user -> rights -> societe -> client -> voir && ! $socid ) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user -> id ;
if ( $socid ) $sql .= " AND ff.fk_soc = " . $socid ;
2018-01-16 20:23:32 +01:00
// Add where from hooks
2018-01-15 14:24:19 +01:00
$parameters = array ();
2018-01-16 20:23:32 +01:00
$reshook = $hookmanager -> executeHooks ( 'printFieldListWhereSupplierUnpaid' , $parameters );
2018-01-15 14:24:19 +01:00
$sql .= $hookmanager -> resPrint ;
2018-01-16 20:23:32 +01:00
2018-02-05 00:36:54 +01:00
$sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.paye, ff.date_lim_reglement, " ;
$sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur " ;
2015-10-02 08:58:09 +02:00
$sql .= " ORDER BY ff.date_lim_reglement ASC " ;
2007-07-07 15:20:36 +02:00
$resql = $db -> query ( $sql );
if ( $resql )
2005-09-04 21:10:18 +02:00
{
2007-07-07 15:20:36 +02:00
$num = $db -> num_rows ( $resql );
2017-04-07 11:01:12 +02:00
print '<div class="div-table-responsive-no-min">' ;
2007-07-07 15:20:36 +02:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><th colspan="2">' . $langs -> trans ( " BillsSuppliersUnpaid " , $num ) . ' <a href="' . DOL_URL_ROOT . '/fourn/facture/impayees.php"><span class="badge">' . $num . '</span></a></th>' ;
print '<th align="right">' . $langs -> trans ( " DateDue " ) . '</th>' ;
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<th align="right">' . $langs -> trans ( " AmountHT " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " AmountTTC " ) . '</th>' ;
print '<th align="right">' . $langs -> trans ( " Paid " ) . '</th>' ;
print '<th width="16"> </th>' ;
2007-07-07 15:20:36 +02:00
print " </tr> \n " ;
2011-09-20 15:32:16 +02:00
$societestatic = new Societe ( $db );
2007-07-07 15:20:36 +02:00
if ( $num )
2005-09-04 21:10:18 +02:00
{
2007-07-07 15:20:36 +02:00
$i = 0 ;
$total = $total_ttc = $totalam = 0 ;
while ( $i < $num )
2006-07-01 15:03:46 +02:00
{
2007-07-07 15:20:36 +02:00
$obj = $db -> fetch_object ( $resql );
2010-11-22 20:32:54 +01:00
2013-04-01 16:04:15 +02:00
$facstatic -> ref = $obj -> ref ;
2015-01-25 01:20:58 +01:00
$facstatic -> id = $obj -> rowid ;
2018-02-05 00:36:54 +01:00
$facstatic -> total_ht = $obj -> total_ht ;
$facstatic -> total_tva = $obj -> total_tva ;
$facstatic -> total_ttc = $obj -> total_ttc ;
$societestatic -> id = $obj -> socid ;
$societestatic -> name = $obj -> name ;
$societestatic -> email = $obj -> email ;
$societestatic -> client = 0 ;
$societestatic -> fournisseur = 1 ;
$societestatic -> code_client = $obj -> code_client ;
$societestatic -> code_fournisseur = $obj -> code_fournisseur ;
$societestatic -> code_compta = $obj -> code_compta ;
$societestatic -> code_compta_fournisseur = $obj -> code_compta_fournisseur ;
print '<tr class="oddeven"><td>' ;
2007-07-07 15:20:36 +02:00
print $facstatic -> getNomUrl ( 1 , '' );
print '</td>' ;
2010-11-23 09:28:59 +01:00
print '<td>' . $societestatic -> getNomUrl ( 1 , 'supplier' , 44 ) . '</td>' ;
2015-10-02 11:21:23 +02:00
print '<td align="right">' . dol_print_date ( $db -> jdate ( $obj -> date_lim_reglement ), 'day' ) . '</td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $obj -> total_ht ) . '</td>' ;
2007-07-07 15:20:36 +02:00
print '<td align="right">' . price ( $obj -> total_ttc ) . '</td>' ;
print '<td align="right">' . price ( $obj -> am ) . '</td>' ;
print '<td>' . $facstatic -> LibStatut ( $obj -> paye , $obj -> fk_statut , 3 ) . '</td>' ;
2006-07-01 15:03:46 +02:00
print '</tr>' ;
2007-07-07 15:20:36 +02:00
$total += $obj -> total_ht ;
$total_ttc += $obj -> total_ttc ;
$totalam += $obj -> am ;
$i ++ ;
2006-07-01 15:03:46 +02:00
}
2007-07-07 15:20:36 +02:00
2009-10-29 18:30:29 +01:00
print '<tr class="liste_total"><td colspan="2">' . $langs -> trans ( " Total " ) . ' <font style="font-weight: normal">(' . $langs -> trans ( " RemainderToPay " ) . ': ' . price ( $total_ttc - $totalam ) . ')</font> </td>' ;
2015-10-02 08:58:09 +02:00
print '<td> </td>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) print '<td align="right">' . price ( $total ) . '</td>' ;
2007-07-07 15:20:36 +02:00
print '<td align="right">' . price ( $total_ttc ) . '</td>' ;
print '<td align="right">' . price ( $totalam ) . '</td>' ;
print '<td> </td>' ;
print '</tr>' ;
2006-07-01 15:03:46 +02:00
}
else
{
2015-10-02 08:58:09 +02:00
$colspan = 6 ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_HT_ON_SUMMARY )) $colspan ++ ;
2017-04-14 13:02:29 +02:00
print '<tr class="oddeven"><td colspan="' . $colspan . '" class="opacitymedium">' . $langs -> trans ( " NoInvoice " ) . '</td></tr>' ;
2005-09-04 21:10:18 +02:00
}
2017-04-07 11:01:12 +02:00
print '</table></div><br>' ;
2007-07-07 15:20:36 +02:00
}
else
{
2009-02-20 23:53:15 +01:00
dol_print_error ( $db );
2005-09-04 21:10:18 +02:00
}
}
2006-07-01 15:03:46 +02:00
2009-12-22 16:13:49 +01:00
// TODO Mettre ici recup des actions en rapport avec la compta
2005-09-04 21:10:18 +02:00
$resql = 0 ;
if ( $resql )
{
2009-02-20 23:53:15 +01:00
print '<table class="noborder" width="100%">' ;
2017-03-07 22:45:22 +01:00
print '<tr class="liste_titre"><thcolspan="2">' . $langs -> trans ( " TasksToDo " ) . '</th>' ;
2009-02-20 23:53:15 +01:00
print " </tr> \n " ;
$i = 0 ;
while ( $i < $db -> num_rows ( $resql ))
{
$obj = $db -> fetch_object ( $resql );
2017-11-12 12:39:23 +01:00
2009-02-20 23:53:15 +01:00
2015-09-01 10:52:57 +02:00
print " <tr " . $bc [ $var ] . " ><td> " . dol_print_date ( $db -> jdate ( $obj -> da ), " day " ) . " </td> " ;
2014-12-23 20:11:13 +01:00
print '<td><a href="action/card.php">' . $obj -> libelle . ' ' . $obj -> label . '</a></td></tr>' ;
2009-02-20 23:53:15 +01:00
$i ++ ;
}
$db -> free ( $resql );
print " </table><br> " ;
2005-09-04 21:10:18 +02:00
}
2013-04-12 16:16:39 +02:00
2013-04-01 20:59:51 +02:00
print '</div></div></div>' ;
2005-09-04 21:10:18 +02:00
2013-04-12 16:16:39 +02:00
2012-02-01 11:32:55 +01:00
llxFooter ();
2005-09-04 21:10:18 +02:00
2012-02-01 11:32:55 +01:00
$db -> close ();