36require 
'../main.inc.php';
 
   37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
 
   38require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
 
   39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
 
   40require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
 
   41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
 
   42require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
 
   43require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
 
   44require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
 
   54$langs->loadLangs(array(
'compta', 
'bills'));
 
   55if (isModEnabled(
'commande')) {
 
   56  $langs->load(
"orders");
 
   60$action = 
GETPOST(
'action', 
'aZ09');
 
   65if ($user->socid > 0) {
 
   67  $socid = $user->socid;
 
   70$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
 
   73$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
 
   74$maxLatestEditCount = 5;
 
   75$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
 
   78$hookmanager->initHooks(array(
'invoiceindex'));
 
   81$maxofloop = (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD);
 
   99$thirdpartystatic = 
new Societe($db);
 
  101llxHeader(
"", $langs->trans(
"InvoicesArea"));
 
  106print 
'<div class="fichecenter"><div class="fichethirdleft">';
 
  108if (isModEnabled(
'facture')) {
 
  113if (isModEnabled(
'fournisseur') || isModEnabled(
'supplier_invoice')) {
 
  118if (isModEnabled(
'facture')) {
 
  123if (isModEnabled(
'fournisseur') || isModEnabled(
'supplier_invoice')) {
 
  128print 
'</div><div class="fichetwothirdright">';
 
  132if (isModEnabled(
'facture') && $user->hasRight(
'facture', 
'lire')) {
 
  133  $langs->load(
"boxes");
 
  134  $tmpinvoice = 
new Facture($db);
 
  136  $sql = 
"SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms";
 
  137  $sql .= 
", f.date_lim_reglement as datelimite";
 
  138  $sql .= 
", s.nom as name";
 
  139  $sql .= 
", s.rowid as socid";
 
  140  $sql .= 
", s.code_client, s.code_compta, s.email";
 
  141  $sql .= 
", cc.rowid as country_id, cc.code as country_code";
 
  142  $sql .= 
", sum(pf.amount) as am";
 
  143  $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";
 
  144  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiement_facture as pf on f.rowid=pf.fk_facture";
 
  145  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  146    $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  148  $sql .= 
" WHERE s.rowid = f.fk_soc";
 
  149  $sql .= 
" AND f.entity IN (".getEntity(
'invoice').
")";
 
  150  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  151    $sql .= 
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
  154    $sql .= 
" AND f.fk_soc = ".((int) $socid);
 
  157  $parameters = array();
 
  158  $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerLastModified', $parameters);
 
  159  $sql .= $hookmanager->resPrint;
 
  161  $sql .= 
" GROUP BY f.rowid, f.ref, f.fk_statut, f.type, f.total_ht, f.total_tva, f.total_ttc, f.paye, f.tms, f.date_lim_reglement,";
 
  162  $sql .= 
" s.nom, s.rowid, s.code_client, s.code_compta, s.email,";
 
  163  $sql .= 
" cc.rowid, cc.code";
 
  164  $sql .= 
" ORDER BY f.tms DESC";
 
  165  $sql .= $db->plimit($max, 0);
 
  167  $resql = $db->query($sql);
 
  169    $num = $db->num_rows($resql);
 
  173    print 
'<div class="div-table-responsive-no-min">';
 
  174    print 
'<table class="noborder centpercent">';
 
  175    print 
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"BoxTitleLastCustomerBills", $max).
'</th>';
 
  176    if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  177      print 
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
 
  179    print 
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
 
  180    print 
'<th class="right">'.$langs->trans(
"DateModificationShort").
'</th>';
 
  181    print 
'<th width="16"> </th>';
 
  184      $total_ttc = $totalam = $total_ht = 0;
 
  185      while ($i < $num && $i < $conf->liste_limit) {
 
  186        $obj = $db->fetch_object($resql);
 
  191          $total_ht += $obj->total_ht;
 
  192          $total_ttc += $obj->total_ttc;
 
  196        $tmpinvoice->ref = $obj->ref;
 
  197        $tmpinvoice->id = $obj->rowid;
 
  198        $tmpinvoice->total_ht = $obj->total_ht;
 
  199        $tmpinvoice->total_tva = $obj->total_tva;
 
  200        $tmpinvoice->total_ttc = $obj->total_ttc;
 
  201        $tmpinvoice->statut = $obj->status;
 
  202        $tmpinvoice->paye = $obj->paye;
 
  203        $tmpinvoice->date_lim_reglement = $db->jdate($obj->datelimite);
 
  204        $tmpinvoice->type = $obj->type;
 
  206        $thirdpartystatic->id = $obj->socid;
 
  207        $thirdpartystatic->name = $obj->name;
 
  208        $thirdpartystatic->email = $obj->email;
 
  209        $thirdpartystatic->country_id = $obj->country_id;
 
  210        $thirdpartystatic->country_code = $obj->country_code;
 
  211        $thirdpartystatic->email = $obj->email;
 
  212        $thirdpartystatic->client = 1;
 
  213        $thirdpartystatic->code_client = $obj->code_client;
 
  215        $thirdpartystatic->code_compta = $obj->code_compta;
 
  218        $totalallpayments = $tmpinvoice->getSommePaiement(0);
 
  219        $totalallpayments += $tmpinvoice->getSumCreditNotesUsed(0);
 
  220        $totalallpayments += $tmpinvoice->getSumDepositsUsed(0);
 
  221        print 
'<tr class="oddeven">';
 
  222        print 
'<td class="nowrap">';
 
  224        print 
'<table class="nobordernopadding"><tr class="nocellnopadd">';
 
  226        print 
'<td class="nobordernopadding nowraponall">';
 
  227        print $tmpinvoice->getNomUrl(1, 
'');
 
  229        if ($tmpinvoice->hasDelay()) {
 
  230          print 
'<td width="20" class="nobordernopadding nowrap">';
 
  234        print 
'<td width="16" class="nobordernopadding hideonsmartphone right">';
 
  237        $urlsource = $_SERVER[
'PHP_SELF'].
'?facid='.$obj->rowid;
 
  238        print $formfile->getDocumentsLink($tmpinvoice->element, $filename, $filedir);
 
  239        print 
'</td></tr></table>';
 
  243        print 
'<td class="tdoverflowmax150">';
 
  244        print $thirdpartystatic->getNomUrl(1, 
'customer', 44);
 
  246        if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  247          print 
'<td class="nowrap right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
 
  249        print 
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
 
  251        print 
'<td class="right" title="'.dol_escape_htmltag($langs->trans(
"DateModificationShort").
' : '.
dol_print_date($db->jdate($obj->tms), 
'dayhour', 
'tzuserrel')).
'">'.
dol_print_date($db->jdate($obj->tms), 
'day', 
'tzuserrel').
'</td>';
 
  253        print 
'<td>'.$tmpinvoice->getLibStatut(3, $totalallpayments).
'</td>';
 
  257        $total_ttc += $obj->total_ttc;
 
  258        $total_ht += $obj->total_ht;
 
  259        $totalam += $obj->am;
 
  265        print 
'<tr class="oddeven">';
 
  266        print 
'<td class="nowrap" colspan="5">';
 
  267        print 
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
 
  273      if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  276      print 
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</span></td></tr>';
 
  278    print 
'</table></div><br>';
 
  287if ((isModEnabled(
'fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight(
"fournisseur", 
"facture", 
"lire")) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
"supplier_invoice", 
"lire"))) {
 
  288  $langs->load(
"boxes");
 
  291  $sql = 
"SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, ff.ref_supplier";
 
  292  $sql .= 
", s.nom as name";
 
  293  $sql .= 
", s.rowid as socid";
 
  294  $sql .= 
", s.code_fournisseur, s.code_compta_fournisseur, s.email";
 
  295  $sql .= 
", SUM(pf.amount) as am";
 
  296  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s, ".MAIN_DB_PREFIX.
"facture_fourn as ff";
 
  297  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as pf on ff.rowid=pf.fk_facturefourn";
 
  298  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  299    $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  301  $sql .= 
" WHERE s.rowid = ff.fk_soc";
 
  302  $sql .= 
" AND ff.entity = ".$conf->entity;
 
  303  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  304    $sql .= 
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
  307    $sql .= 
" AND ff.fk_soc = ".((int) $socid);
 
  310  $parameters = array();
 
  311  $reshook = $hookmanager->executeHooks(
'printFieldListWhereSupplierLastModified', $parameters);
 
  312  $sql .= $hookmanager->resPrint;
 
  314  $sql .= 
" GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye, ff.ref_supplier,";
 
  315  $sql .= 
" s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur, s.email";
 
  316  $sql .= 
" ORDER BY ff.tms DESC ";
 
  317  $sql .= $db->plimit($max, 0);
 
  319  $resql = $db->query($sql);
 
  321    $num = $db->num_rows($resql);
 
  323    print 
'<div class="div-table-responsive-no-min">';
 
  324    print 
'<table class="noborder centpercent">';
 
  325    print 
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"BoxTitleLastSupplierBills", $max).
'</th>';
 
  326    if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  327      print 
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
 
  329    print 
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
 
  330    print 
'<th class="right">'.$langs->trans(
"DateModificationShort").
'</th>';
 
  331    print 
'<th width="16"> </th>';
 
  335      $total_ht = $total_ttc = $totalam = 0;
 
  339        $obj = $db->fetch_object($resql);
 
  344          $total_ht += $obj->total_ht;
 
  345          $total_ttc += $obj->total_ttc;
 
  349        $facstatic->ref = $obj->ref;
 
  350        $facstatic->id = $obj->rowid;
 
  351        $facstatic->total_ht = $obj->total_ht;
 
  352        $facstatic->total_tva = $obj->total_tva;
 
  353        $facstatic->total_ttc = $obj->total_ttc;
 
  354        $facstatic->statut = $obj->status;
 
  355        $facstatic->paye = $obj->paye;
 
  356        $facstatic->type = $obj->type;
 
  357        $facstatic->ref_supplier = $obj->ref_supplier;
 
  359        $thirdpartystatic->id = $obj->socid;
 
  360        $thirdpartystatic->name = $obj->name;
 
  361        $thirdpartystatic->email = $obj->email;
 
  362        $thirdpartystatic->country_id = 0;
 
  363        $thirdpartystatic->country_code = 
'';
 
  364        $thirdpartystatic->client = 0;
 
  365        $thirdpartystatic->fournisseur = 1;
 
  366        $thirdpartystatic->code_client = 
'';
 
  367        $thirdpartystatic->code_fournisseur = $obj->code_fournisseur;
 
  368        $thirdpartystatic->code_compta = 
'';
 
  369        $thirdpartystatic->code_compta_fournisseur = $obj->code_compta_fournisseur;
 
  371        print 
'<tr class="oddeven nowraponall tdoverflowmax100"><td>';
 
  372        print $facstatic->getNomUrl(1, 
'');
 
  374        print 
'<td class="nowrap tdoverflowmax100">';
 
  375        print $thirdpartystatic->getNomUrl(1, 
'supplier');
 
  377        if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  378          print 
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
 
  380        print 
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
 
  381        print 
'<td class="right" title="'.dol_escape_htmltag($langs->trans(
"DateModificationShort").
' : '.
dol_print_date($db->jdate($obj->tms), 
'dayhour', 
'tzuserrel')).
'">'.
dol_print_date($db->jdate($obj->tms), 
'day', 
'tzuserrel').
'</td>';
 
  382        $alreadypaid = $facstatic->getSommePaiement();
 
  383        $alreadypaid += $facstatic->getSumCreditNotesUsed();
 
  384        $alreadypaid += $facstatic->getSumDepositsUsed();
 
  385        print 
'<td>'.$facstatic->getLibStatut(3, $alreadypaid).
'</td>';
 
  387        $total_ht += $obj->total_ht;
 
  388        $total_ttc += $obj->total_ttc;
 
  389        $totalam += $obj->am;
 
  394        print 
'<tr class="oddeven">';
 
  395        print 
'<td class="nowrap" colspan="5">';
 
  396        print 
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
 
  402      if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  405      print 
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoInvoice").
'</span></td></tr>';
 
  407    print 
'</table></div><br>';
 
  416if (isModEnabled(
'don') && $user->hasRight(
'don', 
'lire')) {
 
  417  include_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
 
  419  $langs->load(
"boxes");
 
  420  $donationstatic = 
new Don($db);
 
  422  $sql = 
"SELECT d.rowid, d.lastname, d.firstname, d.societe, d.datedon as date, d.tms as dm, d.amount, d.fk_statut as status";
 
  423  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"don as d";
 
  424  $sql .= 
" WHERE d.entity IN (".getEntity(
'donation').
")";
 
  426  $parameters = array();
 
  427  $reshook = $hookmanager->executeHooks(
'printFieldListWhereLastDonations', $parameters);
 
  428  $sql .= $hookmanager->resPrint;
 
  430  $sql .= $db->order(
"d.tms", 
"DESC");
 
  431  $sql .= $db->plimit($max, 0);
 
  433  $result = $db->query($sql);
 
  435    $num = $db->num_rows($result);
 
  440    print 
'<div class="div-table-responsive-no-min">';
 
  441    print 
'<table class="noborder centpercent">';
 
  442    print 
'<tr class="liste_titre">';
 
  443    print 
'<th>'.$langs->trans(
"BoxTitleLastModifiedDonations", $max).
'</th>';
 
  445    print 
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
 
  446    print 
'<th class="right">'.$langs->trans(
"DateModificationShort").
'</th>';
 
  447    print 
'<th width="16"> </th>';
 
  451      $total_ttc = $totalam = $total_ht = 0;
 
  453      while ($i < $num && $i < $max) {
 
  454        $obj = $db->fetch_object($result);
 
  459          $total_ht += $obj->total_ht;
 
  460          $total_ttc += $obj->total_ttc;
 
  464        $donationstatic->id = $obj->rowid;
 
  465        $donationstatic->ref = $obj->rowid;
 
  466        $donationstatic->lastname = $obj->lastname;
 
  467        $donationstatic->firstname = $obj->firstname;
 
  468        $donationstatic->date = $db->jdate($obj->date);
 
  469        $donationstatic->statut = $obj->status;
 
  470        $donationstatic->status = $obj->status;
 
  472        $label = $donationstatic->getFullName($langs);
 
  474          $label .= ($label ? 
' - ' : 
'').$obj->societe;
 
  477        print 
'<tr class="oddeven tdoverflowmax100">';
 
  478        print 
'<td>'.$donationstatic->getNomUrl(1).
'</td>';
 
  479        print 
'<td>'.$label.
'</td>';
 
  480        print 
'<td class="nowrap right"><span class="amount">'.price($obj->amount).
'</span></td>';
 
  481        print 
'<td class="right" title="'.dol_escape_htmltag($langs->trans(
"DateModificationShort").
' : '.
dol_print_date($db->jdate($obj->dm), 
'dayhour', 
'tzuserrel')).
'">'.
dol_print_date($db->jdate($obj->dm), 
'day', 
'tzuserrel').
'</td>';
 
  482        print 
'<td>'.$donationstatic->getLibStatut(3).
'</td>';
 
  489        print 
'<tr class="oddeven">';
 
  490        print 
'<td class="nowrap" colspan="5">';
 
  491        print 
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
 
  496      print 
'<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
 
  498    print 
'</table></div><br>';
 
  507if (isModEnabled(
'tax') && !empty($user->rights->tax->charges->lire)) {
 
  511    $sql = 
"SELECT c.rowid, c.amount, c.date_ech, c.paye,";
 
  512    $sql .= 
" cc.libelle as label,";
 
  513    $sql .= 
" SUM(pc.amount) as sumpaid";
 
  514    $sql .= 
" FROM (".MAIN_DB_PREFIX.
"c_chargesociales as cc, ".MAIN_DB_PREFIX.
"chargesociales as c)";
 
  515    $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"paiementcharge as pc ON pc.fk_charge = c.rowid";
 
  516    $sql .= 
" WHERE c.fk_type = cc.id";
 
  517    $sql .= 
" AND c.entity IN (".getEntity(
'tax').
')';
 
  518    $sql .= 
" AND c.paye = 0";
 
  520    $parameters = array();
 
  521    $reshook = $hookmanager->executeHooks(
'printFieldListWhereSocialContributions', $parameters);
 
  522    $sql .= $hookmanager->resPrint;
 
  524    $sql .= 
" GROUP BY c.rowid, c.amount, c.date_ech, c.paye, cc.libelle";
 
  526    $resql = $db->query($sql);
 
  528      $num = $db->num_rows($resql);
 
  530      print 
'<div class="div-table-responsive-no-min">';
 
  531      print 
'<table class="noborder centpercent">';
 
  532      print 
'<tr class="liste_titre">';
 
  533      print 
'<th>'.$langs->trans(
"ContributionsToPay").($num ? 
' <a href="'.DOL_URL_ROOT.
'/compta/sociales/list.php?status=0"><span class="badge">'.$num.
'</span></a>' : 
'').
'</th>';
 
  534      print 
'<th align="center">'.$langs->trans(
"DateDue").
'</th>';
 
  535      print 
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
 
  536      print 
'<th class="right">'.$langs->trans(
"Paid").
'</th>';
 
  537      print 
'<th align="center" width="16"> </th>';
 
  545          $obj = $db->fetch_object($resql);
 
  549            $tot_ttc += $obj->amount;
 
  554          $chargestatic->id = $obj->rowid;
 
  555          $chargestatic->ref = $obj->rowid;
 
  556          $chargestatic->label = $obj->label;
 
  557          $chargestatic->paye = $obj->paye;
 
  558          $chargestatic->status = $obj->paye;
 
  560          print 
'<tr class="oddeven">';
 
  561          print 
'<td class="nowraponall">'.$chargestatic->getNomUrl(1).
'</td>';
 
  562          print 
'<td class="center">'.dol_print_date($db->jdate($obj->date_ech), 
'day').
'</td>';
 
  563          print 
'<td class="nowrap right"><span class="amount">'.price($obj->amount).
'</span></td>';
 
  564          print 
'<td class="nowrap right"><span class="amount">'.price($obj->sumpaid).
'</span></td>';
 
  565          print 
'<td class="center">'.$chargestatic->getLibStatut(3).
'</td>';
 
  568          $tot_ttc += $obj->amount;
 
  573          print 
'<tr class="oddeven">';
 
  574          print 
'<td class="nowrap" colspan="5">';
 
  575          print 
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
 
  580        print 
'<tr class="liste_total"><td class="left" colspan="2">'.$langs->trans(
"Total").
'</td>';
 
  581        print 
'<td class="nowrap right">'.price($tot_ttc).
'</td>';
 
  582        print 
'<td class="right"></td>';
 
  583        print 
'<td class="right"> </td>';
 
  586        print 
'<tr class="oddeven"><td colspan="5"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
 
  588      print 
"</table></div><br>";
 
  599if (isModEnabled(
'facture') && isModEnabled(
'commande') && $user->hasRight(
"commande", 
"lire") && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) {
 
  600  $commandestatic = 
new Commande($db);
 
  601  $langs->load(
"orders");
 
  603  $sql = 
"SELECT sum(f.total_ht) as tot_fht, sum(f.total_ttc) as tot_fttc";
 
  604  $sql .= 
", s.nom as name, s.email";
 
  605  $sql .= 
", s.rowid as socid";
 
  606  $sql .= 
", s.code_client, s.code_compta";
 
  607  $sql .= 
", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.total_tva, c.total_ttc,";
 
  608  $sql .= 
" cc.rowid as country_id, cc.code as country_code";
 
  609  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"societe as s LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as cc ON cc.rowid = s.fk_pays";
 
  610  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  611    $sql .= 
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
 
  613  $sql .= 
", ".MAIN_DB_PREFIX.
"commande as c";
 
  614  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"element_element as el ON el.fk_source = c.rowid AND el.sourcetype = 'commande'";
 
  615  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"facture AS f ON el.fk_target = f.rowid AND el.targettype = 'facture'";
 
  616  $sql .= 
" WHERE c.fk_soc = s.rowid";
 
  617  $sql .= 
" AND c.entity = ".$conf->entity;
 
  618  if (empty($user->rights->societe->client->voir) && !$socid) {
 
  619    $sql .= 
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
 
  622    $sql .= 
" AND c.fk_soc = ".((int) $socid);
 
  624  $sql .= 
" AND c.fk_statut = ".Commande::STATUS_CLOSED;
 
  625  $sql .= 
" AND c.facture = 0";
 
  627  $parameters = array();
 
  628  $reshook = $hookmanager->executeHooks(
'printFieldListWhereCustomerOrderToBill', $parameters);
 
  629  $sql .= $hookmanager->resPrint;
 
  631  $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.total_tva, c.total_ttc, cc.rowid, cc.code";
 
  633  $resql = $db->query($sql);
 
  635    $num = $db->num_rows($resql);
 
  641      print 
'<div class="div-table-responsive-no-min">';
 
  642      print 
'<table class="noborder centpercent">';
 
  644      print 
"<tr class=\"liste_titre\">";
 
  645      print 
'<th colspan="2">';
 
  646      print $langs->trans(
"OrdersDeliveredToBill").
' ';
 
  648      print 
'<span class="badge">'.$num.
'</span>';
 
  652      if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  653        print 
'<th class="right">'.$langs->trans(
"AmountHT").
'</th>';
 
  655      print 
'<th class="right">'.$langs->trans(
"AmountTTC").
'</th>';
 
  656      print 
'<th class="right">'.$langs->trans(
"ToBill").
'</th>';
 
  657      print 
'<th align="center" width="16"> </th>';
 
  660      $tot_ht = $tot_ttc = $tot_tobill = 0;
 
  661      $societestatic = 
new Societe($db);
 
  663        $obj = $db->fetch_object($resql);
 
  668          $total_ht += $obj->total_ht;
 
  669          $total_ttc += $obj->total_ttc;
 
  673        $societestatic->id = $obj->socid;
 
  674        $societestatic->name = $obj->name;
 
  675        $societestatic->email = $obj->email;
 
  676        $societestatic->country_id = $obj->country_id;
 
  677        $societestatic->country_code = $obj->country_code;
 
  678        $societestatic->client = 1;
 
  679        $societestatic->code_client = $obj->code_client;
 
  681        $societestatic->code_compta = $obj->code_compta;
 
  684        $commandestatic->id = $obj->rowid;
 
  685        $commandestatic->ref = $obj->ref;
 
  686        $commandestatic->statut = $obj->status;
 
  687        $commandestatic->billed = $obj->facture;
 
  689        print 
'<tr class="oddeven">';
 
  690        print 
'<td class="nowrap">';
 
  692        print 
'<table class="nobordernopadding"><tr class="nocellnopadd">';
 
  693        print 
'<td class="nobordernopadding nowrap">';
 
  694        print $commandestatic->getNomUrl(1);
 
  696        print 
'<td width="20" class="nobordernopadding nowrap">';
 
  699        print 
'<td width="16" class="nobordernopadding hideonsmartphone right">';
 
  702        $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
 
  703        print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
 
  704        print 
'</td></tr></table>';
 
  708        print 
'<td class="nowrap tdoverflowmax100">';
 
  709        print $societestatic->getNomUrl(1, 
'customer');
 
  711        if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  712          print 
'<td class="right"><span class="amount">'.price($obj->total_ht).
'</span></td>';
 
  714        print 
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
 
  715        print 
'<td class="nowrap right"><span class="amount">'.price($obj->total_ttc - $obj->tot_fttc).
'</span></td>';
 
  716        print 
'<td>'.$commandestatic->getLibStatut(3).
'</td>';
 
  718        $tot_ht += $obj->total_ht;
 
  719        $tot_ttc += $obj->total_ttc;
 
  721        $tot_tobill += ($obj->total_ttc - $obj->tot_fttc);
 
  726        print 
'<tr class="oddeven">';
 
  727        print 
'<td class="nowrap" colspan="5">';
 
  728        print 
'<span class="opacitymedium">'.$langs->trans(
"More").
'... ('.$othernb.
')</span>';
 
  733      print 
'<tr class="liste_total"><td colspan="2">'.$langs->trans(
"Total").
'   <span style="font-weight: normal">('.$langs->trans(
"RemainderToBill").
': '.
price($tot_tobill).
')</span> </td>';
 
  734      if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
 
  735        print 
'<td class="right">'.price($tot_ht).
'</td>';
 
  737      print 
'<td class="nowrap right">'.price($tot_ttc).
'</td>';
 
  738      print 
'<td class="nowrap right">'.price($tot_tobill).
'</td>';
 
  739      print 
'<td> </td>';
 
  741      print 
'</table></div><br>';
 
  753  print 
'<div class="div-table-responsive-no-min">';
 
  754  print 
'<table class="noborder centpercent">';
 
  755  print 
'<tr class="liste_titre"><thcolspan="2">'.$langs->trans(
"TasksToDo").
'</th>';
 
  758  $resql = $db->query($sql);
 
  760    $num_rows = $db->num_rows($resql);
 
  761    while ($i < $num_rows) {
 
  762      $obj = $db->fetch_object($resql);
 
  764      print 
'<tr class="oddeven"><td>'.dol_print_date($db->jdate($obj->da), 
"day").
'</td>';
 
  765      print 
'<td><a href="action/card.php">'.$obj->label.
'</a></td></tr>';
 
  770  print 
"</table></div><br>";
 
  776$parameters = array(
'user' => $user);
 
  777$reshook = $hookmanager->executeHooks(
'dashboardAccountancy', $parameters, $object); 
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Classe permettant la gestion des paiements des charges La tva collectee n'est calculee que sur les fa...
 
Class to manage customers orders.
 
const STATUS_CLOSED
Closed (Sent, billed or not)
 
Class to manage donations.
 
Class to manage suppliers invoices.
 
Class to manage invoices.
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
dol_now($mode='auto')
Return date for now.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
 
getNumberInvoicesPieChart($mode)
Return an HTML table that contains a pie chart of the number of customers or supplier invoices.
 
getCustomerInvoiceDraftTable($maxCount=500, $socid=0)
Return a HTML table that contains a list with customer invoice drafts.
 
getDraftSupplierTable($maxCount=500, $socid=0)
Return a HTML table that contains a list with customer invoice drafts.