/** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ function load_board($user) { global $conf, $langs; $sql = 'SELECT ff.rowid, ff.date_lim_reglement as datefin, ff.fk_statut'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture_fourn as ff'; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= ' WHERE ff.paye=0'; $sql .= ' AND ff.fk_statut > 0'; $sql .= " AND ff.entity = " . $conf->entity; if ($user->societe_id) { $sql .= ' AND ff.fk_soc = ' . $user->societe_id; } if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND ff.fk_soc = sc.fk_soc AND sc.fk_user = "******"bills"); $now = dol_now(); $response = new WorkboardResponse(); $response->warning_delay = $conf->facture->fournisseur->warning_delay / 60 / 60 / 24; $response->label = $langs->trans("SupplierBillsToPay"); $response->url = DOL_URL_ROOT . '/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0'; $response->img = img_object($langs->trans("Bills"), "bill"); $facturestatic = new FactureFournisseur($this->db); while ($obj = $this->db->fetch_object($resql)) { $response->nbtodo++; $facturestatic->date_echeance = $this->db->jdate($obj->datefin); $facturestatic->statut = $obj->fk_statut; if ($facturestatic->hasDelay()) { $response->nbtodolate++; } } $this->db->free($resql); return $response; } else { dol_print_error($this->db); $this->error = $this->db->error(); return -1; } }
while ($i < $num) { $objp = $db->fetch_object($resql); $facturestatic->statut = $objp->fk_statut; $facturestatic->date_echeance = $db->jdate($objp->datelimite); $var = !$var; print "<tr " . $bc[$var] . ">"; $classname = "impayee"; print '<td class="nowrap">'; $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; print $facturestatic->getNomUrl(1); print "</td>\n"; print '<td class="nowrap">' . dol_trunc($objp->ref_supplier, 12) . '</td>'; print '<td class="nowrap" align="center">' . dol_print_date($db->jdate($objp->df), 'day') . "</td>\n"; print '<td class="nowrap" align="center">' . dol_print_date($db->jdate($objp->datelimite), 'day'); if ($facturestatic->hasDelay()) { print img_warning($langs->trans("Late")); } print "</td>\n"; print '<td>'; $companystatic->id = $objp->socid; $companystatic->name = $objp->name; print $companystatic->getNomUrl(1, 'supplier', 32); print '</td>'; print "<td align=\"right\">" . price($objp->total_ht) . "</td>"; print "<td align=\"right\">" . price($objp->total_ttc) . "</td>"; print "<td align=\"right\">" . price($objp->am) . "</td>"; // Show invoice status print '<td align="right" class="nowrap">'; print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $objp->am); print '</td>';
/** * Load data into info_box_contents array to show array later. * * @param int $max Maximum number of records to load * @return void */ function loadBox($max = 5) { global $conf, $user, $langs, $db; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $facturestatic = new FactureFournisseur($db); include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.class.php'; $thirdpartytmp = new Fournisseur($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidSupplierBills", $max)); if ($user->rights->fournisseur->facture->lire) { $sql = "SELECT s.nom as name, s.rowid as socid,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.date_lim_reglement as datelimite,"; $sql .= " f.amount, f.datef as df,"; $sql .= " f.total_ht as total_ht,"; $sql .= " f.tva as total_tva,"; $sql .= " f.total_ttc,"; $sql .= " f.paye, f.fk_statut, f.type"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= "," . MAIN_DB_PREFIX . "facture_fourn as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = " . $conf->entity; $sql .= " AND f.paye=0"; $sql .= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = "******" AND s.rowid = " . $user->societe_id; } $sql .= " ORDER BY datelimite DESC, f.ref_supplier DESC "; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $line = 0; $l_due_date = $langs->trans('Late') . ' (' . $langs->trans('DateEcheance') . ': %s)'; $facturestatic = new FactureFournisseur($db); while ($line < $num) { $objp = $db->fetch_object($result); $datelimite = $db->jdate($objp->datelimite); $date = $db->jdate($objp->df); $datem = $db->jdate($objp->tms); $facturestatic->id = $objp->facid; $facturestatic->ref = $objp->ref; $facturestatic->total_ht = $objp->total_ht; $facturestatic->total_tva = $objp->total_tva; $facturestatic->total_ttc = $objp->total_ttc; $facturestatic->date_echeance = $datelimite; $facturestatic->statut = $objp->fk_statut; $thirdpartytmp->id = $objp->socid; $thirdpartytmp->name = $objp->name; $thirdpartytmp->fournisseur = 1; $thirdpartytmp->code_fournisseur = $objp->code_fournisseur; $thirdpartytmp->logo = $objp->logo; $late = ''; if ($facturestatic->hasDelay()) { $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day'))); } $tooltip = $langs->trans('SupplierInvoice') . ': ' . ($objp->ref ? $objp->ref : $objp->facid) . '<br>' . $langs->trans('RefSupplier') . ': ' . $objp->ref_supplier; $this->info_box_contents[$line][] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'tooltip' => $tooltip, 'url' => DOL_URL_ROOT . "/fourn/facture/card.php?facid=" . $objp->facid); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2' => $late, 'asisi' => 1); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $thirdpartytmp->getNomUrl(1, '', 40), 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency)); $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => dol_print_date($datelimite, 'day')); $fac = new FactureFournisseur($db); $fac->fetch($objp->facid); $alreadypaid = $fac->getSommePaiement(); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3, $alreadypaid, $objp->type)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoUnpaidSupplierBills")); } $db->free($result); } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }