Exemplo n.º 1
0
 print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
 print '</td>';
 print '</tr>';
 print '</table>';
 print "</td>\n";
 // Customer ref
 print '<td class="nowrap">';
 print $objp->ref_client;
 print '</td>';
 // Date
 print '<td align="center" class="nowrap">';
 print dol_print_date($db->jdate($objp->df), 'day');
 print '</td>';
 // Date limit
 print '<td align="center" class="nowrap">' . dol_print_date($datelimit, 'day');
 if ($facturestatic->hasDelay()) {
     print img_warning($langs->trans('Late'));
 }
 print '</td>';
 print '<td>';
 $thirdparty = new Societe($db);
 $thirdparty->id = $objp->socid;
 $thirdparty->name = $objp->name;
 $thirdparty->client = $objp->client;
 $thirdparty->code_client = $objp->code_client;
 print $thirdparty->getNomUrl(1, 'customer');
 print '</td>';
 // Payment mode
 print '<td>';
 $form->form_modes_reglement($_SERVER['PHP_SELF'], $objp->fk_mode_reglement, 'none', '', -1);
 print '</td>';
Exemplo n.º 2
0
 /**
  *	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, $user, $langs;
     $clause = " WHERE";
     $sql = "SELECT f.rowid, f.date_lim_reglement as datefin";
     $sql .= " FROM " . MAIN_DB_PREFIX . "facture as f";
     if (!$user->rights->societe->client->voir && !$user->societe_id) {
         $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as sc ON f.fk_soc = sc.fk_soc";
         $sql .= " WHERE sc.fk_user = "******" AND";
     }
     $sql .= $clause . " f.paye=0";
     $sql .= " AND f.entity = " . $conf->entity;
     $sql .= " AND f.fk_statut = " . self::STATUS_VALIDATED;
     if ($user->societe_id) {
         $sql .= " AND f.fk_soc = " . $user->societe_id;
     }
     $resql = $this->db->query($sql);
     if ($resql) {
         $langs->load("bills");
         $now = dol_now();
         $response = new WorkboardResponse();
         $response->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24;
         $response->label = $langs->trans("CustomerBillsUnpaid");
         $response->url = DOL_URL_ROOT . '/compta/facture/list.php?search_status=1';
         $response->img = img_object($langs->trans("Bills"), "bill");
         $generic_facture = new Facture($this->db);
         while ($obj = $this->db->fetch_object($resql)) {
             $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin);
             $response->nbtodo++;
             if ($generic_facture->hasDelay()) {
                 $response->nbtodolate++;
             }
         }
         return $response;
     } else {
         dol_print_error($this->db);
         $this->error = $this->db->error();
         return -1;
     }
 }
Exemplo n.º 3
0
 /**
  *  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 . '/compta/facture/class/facture.class.php';
     include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
     $facturestatic = new Facture($db);
     $societestatic = new Societe($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleOldestUnpaidCustomerBills", $max));
     if ($user->rights->facture->lire) {
         $sql = "SELECT s.nom as name, s.rowid as socid,";
         $sql .= " s.code_client,";
         $sql .= " s.logo,";
         $sql .= " f.facnumber, f.date_lim_reglement as datelimite,";
         $sql .= " f.type,";
         $sql .= " f.amount, f.datef as df,";
         $sql .= " f.total as total_ht,";
         $sql .= " f.tva as total_tva,";
         $sql .= " f.total_ttc,";
         $sql .= " f.paye, f.fk_statut, f.rowid as facid";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture 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 f.datef DESC, f.facnumber DESC ";
         $sql .= " ORDER BY datelimite ASC, f.facnumber ASC ";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $now = dol_now();
             $line = 0;
             $l_due_date = $langs->trans('Late') . ' (' . strtolower($langs->trans('DateEcheance')) . ': %s)';
             while ($line < $num) {
                 $objp = $db->fetch_object($result);
                 $datelimite = $db->jdate($objp->datelimite);
                 $facturestatic->id = $objp->facid;
                 $facturestatic->ref = $objp->facnumber;
                 $facturestatic->type = $objp->type;
                 $facturestatic->total_ht = $objp->total_ht;
                 $facturestatic->total_tva = $objp->total_tva;
                 $facturestatic->total_ttc = $objp->total_ttc;
                 $facturestatic->statut = $objp->fk_statut;
                 $facturestatic->date_lim_reglement = $db->jdate($objp->datelimite);
                 $societestatic->id = $objp->socid;
                 $societestatic->name = $objp->name;
                 $societestatic->client = 1;
                 $societestatic->code_client = $objp->code_client;
                 $societestatic->logo = $objp->logo;
                 $late = '';
                 if ($facturestatic->hasDelay()) {
                     $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
                 }
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $facturestatic->getNomUrl(1), 'text2' => $late, 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $societestatic->getNomUrl(1, '', 44), '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'));
                 $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3));
                 $line++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoUnpaidCustomerBills"));
             }
             $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"));
     }
 }