Exemplo n.º 1
0
	/**
	 *      \brief      Charge les donnees en memoire pour affichage ulterieur
	 *      \param      $max        Nombre maximum d'enregistrements a charger
	 */
	function loadBox($max=5)
	{
		global $conf, $user, $langs, $db;

		$this->max=$max;

		include_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
		$facturestatic=new Facture($db);

		$text = $langs->trans("BoxTitleLastCustomerBills",$max);
		$this->info_box_head = array(
				'text' => $text,
				'limit'=> dol_strlen($text)
		);

		if ($user->rights->facture->lire)
		{
			$sql = "SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.datef as df";
			$sql.= ", f.paye, f.fk_statut, f.datec, f.tms";
			$sql.= ", s.nom, s.rowid as socid";
			$sql.= ", f.date_lim_reglement as datelimite";
			$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.= ")";
			$sql.= " WHERE f.fk_soc = s.rowid";
			$sql.= " AND s.entity = ".$conf->entity;
			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.tms DESC";
			$sql.= $db->plimit($max, 0);

			$result = $db->query($sql);
			if ($result)
			{
				$num = $db->num_rows($result);
				$now=gmmktime();

				$i = 0;
				$l_due_date = $langs->trans('Late').' ('.strtolower($langs->trans('DateEcheance')).': %s)';

				while ($i < $num)
				{
					$objp = $db->fetch_object($result);
					$datelimite=$db->jdate($objp->datelimite);
					$datec=$db->jdate($objp->datec);

					$picto='bill';
					if ($objp->type == 1) $picto.='r';
					if ($objp->type == 2) $picto.='a';
					$late = '';
					if ($objp->paye == 0 && ($objp->fk_statut != 2 && $objp->fk_statut != 3) && $datelimite < ($now - $conf->facture->client->warning_delay)) { $late = img_warning(sprintf($l_due_date,dol_print_date($datelimite,'day')));}

					$this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"',
                    'logo' => $picto,
                    'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);

					$this->info_box_contents[$i][1] = array('td' => 'align="left"',
                    'text' => $objp->facnumber,
                    'text2'=> $late,
                    'url' => DOL_URL_ROOT."/compta/facture.php?facid=".$objp->facid);

					$this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"',
                    'logo' => 'company',
                    'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);

					$this->info_box_contents[$i][3] = array('td' => 'align="left"',
                    'text' => $objp->nom,
                    'maxlength'=>40,
                    'url' => DOL_URL_ROOT."/comm/fiche.php?socid=".$objp->socid);

					$this->info_box_contents[$i][4] = array('td' => 'align="right"',
                    'text' => dol_print_date($datec,'day'),
					);

					$this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"',
                    'text' => $facturestatic->LibStatut($objp->paye,$objp->fk_statut,3));

					$i++;
				}

				if ($num==0) $this->info_box_contents[$i][0] = array('td' => 'align="center"','text'=>$langs->trans("NoRecordedInvoices"));
			}
			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"));
		}
	}
Exemplo n.º 2
0
     $urlsource = $_SERVER['PHP_SELF'] . '?facid=' . $obj->rowid;
     print $formfile->getDocumentsLink($facturestatic->element, $filename, $filedir);
     print '</td></tr></table>';
     print '</td>';
     print '<td align="left">';
     $societestatic->id = $obj->socid;
     $societestatic->nom = $obj->nom;
     $societestatic->client = 1;
     print $societestatic->getNomUrl(1, 'customer', 44);
     print '</a></td>';
     if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
         print '<td align="right">' . price($obj->total) . '</td>';
     }
     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>';
     $total_ttc += $obj->total_ttc;
     $total += $obj->total;
     $totalam += $obj->am;
     $var = !$var;
     $i++;
 }
 print '<tr class="liste_total"><td colspan="2">' . $langs->trans("Total") . ' &nbsp; <font style="font-weight: normal">(' . $langs->trans("RemainderToTake") . ': ' . price($total_ttc - $totalam) . ')</font> </td>';
 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
     print '<td align="right">' . price($total) . '</td>';
 }
 print '<td align="right">' . price($total_ttc) . '</td>';
 print '<td align="right">' . price($totalam) . '</td>';
 print '<td>&nbsp;</td>';
 print '</tr>';
Exemplo n.º 3
0
     print '</tr></table>';
     print "</td>\n";
     print '<td nowrap align="center">' . dol_print_date($db->jdate($objp->df), 'day') . '</td>' . "\n";
     print '<td nowrap align="center">' . dol_print_date($db->jdate($objp->datelimite), 'day') . '</td>' . "\n";
     print '<td><a href="' . DOL_URL_ROOT . '/comm/fiche.php?socid=' . $objp->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . dol_trunc($objp->nom, 28) . '</a></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>';
     if ($objp->am == 0) {
         print '<td align="right"></td>';
     } else {
         print '<td align="right">' . price($objp->total_ttc - $objp->am) . '</td>';
     }
     // Affiche statut de la facture
     print '<td align="right" nowrap="nowrap">';
     print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $objp->am);
     print '</td>';
     // Checkbox
     print '<td align="center">';
     if ($foundpdf) {
         print '<input id="cb' . $objp->facid . '" class="flat checkformerge" type="checkbox" name="toGenerate[]" value="' . $objp->facnumber . '">';
     } else {
         print '&nbsp;';
     }
     print '</td>';
     print "</tr>\n";
     $total_ht += $objp->total_ht;
     $total_ttc += $objp->total_ttc;
     $total_paid += $objp->am;
     $i++;
 }
Exemplo n.º 4
0
             $objp = $db->fetch_object($resql);
             $var = !$var;
             print "<tr {$bc[$var]}>";
             print '<td>';
             $facturestatic->id = $objp->facid;
             $facturestatic->ref = $objp->facnumber;
             $facturestatic->type = $objp->type;
             print $facturestatic->getNomUrl(1);
             print '</td>';
             if ($objp->df > 0) {
                 print "<td align=\"right\">" . dol_print_date($db->jdate($objp->df), 'day') . "</td>\n";
             } else {
                 print "<td align=\"right\"><b>!!!</b></td>\n";
             }
             print "<td align=\"right\">" . price($objp->total_ttc) . "</td>\n";
             print '<td align="right" nowrap="nowrap">' . $facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am) . "</td>\n";
             print "</tr>\n";
             $i++;
         }
         $db->free($resql);
     } else {
         dol_print_error($db);
     }
     print "</table>";
 }
 /*
  * Last linked chronodocs
  */
 // TODO add function to add an external module
 if (!empty($conf->global->MAIN_MODULE_CHRONODOCS) && $user->rights->chronodocs->entries->read) {
     print '<table class="noborder" width=100%>';
     print '</td>';
     print '<td align="left">';
     if (!$user->rights->societe->client->voir) {
         print $objp->nom;
     } else {
         $thirdparty = new Societe($db);
         $thirdparty->id = $objp->socid;
         $thirdparty->nom = $objp->nom;
         print $thirdparty->getNomUrl(1, 'customer');
     }
     print '</td>';
     $objttc = $objp->total_ttc;
     print '<td align="right">' . price($objttc) . '</td>';
     // Affiche statut de la ticket
     print '<td align="right" nowrap="nowrap">';
     print $ticketstatic->LibStatut($objp->paye, $objp->fk_statut, 2);
     print "</td>";
     print "<td>&nbsp;</td>";
     print "</tr>\n";
     $total_ttc += $objttc;
     $totaltickets++;
     $i++;
 }
 // Print total
 print '<tr class="liste_total">';
 print '<td class="liste_total" align="left">' . $langs->trans('Total') . '</td>';
 print '<td class="liste_total" align="left">' . $langs->trans('Tickets') . ': ' . $totaltickets . '</td>';
 print "<td>&nbsp;</td>";
 print "<td>&nbsp;</td>";
 print "<td>&nbsp;</td>";
 print '<td class="liste_total" align="right">' . price($total_ttc) . '</td>';
Exemplo n.º 6
0
					print "<tr $bc[$var]>";
					print '<td>';
					$invoicestatic->id=$objp->facid;
					$invoicestatic->ref=$objp->facnumber;
					print $invoicestatic->getNomUrl(1);
					print "</td>\n";
					print "<td align=\"center\">";
					print dol_print_date($db->jdate($objp->datef),'day')."</td>";
					print "<td align=\"right\">".price($objp->selling_price)."</td>\n";
					print "<td align=\"right\">".price($objp->buying_price)."</td>\n";
					print "<td align=\"right\">".price($objp->marge)."</td>\n";
					if (! empty($conf->global->DISPLAY_MARGIN_RATES))
						print "<td align=\"right\">".(($marginRate === '')?'n/a':price($marginRate)."%")."</td>\n";
					if (! empty($conf->global->DISPLAY_MARK_RATES))
						print "<td align=\"right\">".(($markRate === '')?'n/a':price($markRate)."%")."</td>\n";
					print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
					print "</tr>\n";
					$i++;
					$cumul_achat += $objp->buying_price;
					$cumul_vente += $objp->selling_price;
				}
			}

			// affichage totaux marges
			$var=!$var;
			$totalMargin = $cumul_vente - $cumul_achat;
			$marginRate = ($cumul_achat != 0)?(100 * round($totalMargin / $cumul_achat, 5)):'' ;
			$markRate = ($cumul_vente != 0)?(100 * round($totalMargin / $cumul_vente, 5)):'' ;
			print '<tr '.$bc[$var].' style="border-top: 1px solid #ccc; font-weight: bold">';
			print '<td colspan=2>'.$langs->trans('TotalMargin')."</td>";
			print "<td align=\"right\">".price($cumul_vente)."</td>\n";
Exemplo n.º 7
0
 /**
  *  Charge les donnees en memoire pour affichage ulterieur
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     $totalMnt = 0;
     $totalnb = 0;
     include_once DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php";
     include_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php";
     include_once DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php";
     $facturestatic = new Facture($db);
     $propalstatic = new Propal($db);
     $commandestatic = new Commande($db);
     $textHead = $langs->trans("Activity") . "&nbsp;" . date("Y");
     $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead));
     // list the summary of the bills
     if ($conf->facture->enabled && $user->rights->facture->lire) {
         $sql = "SELECT f.paye, f.fk_statut, sum(f.total_ttc) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f";
         $sql .= " WHERE f.entity = " . $conf->entity;
         $sql .= " AND f.fk_soc = s.rowid";
         $sql .= " AND (DATE_FORMAT(f.datef,'%Y') = " . date("Y") . " or paye=0)";
         $sql .= " GROUP BY f.paye, f.fk_statut ";
         $sql .= " ORDER BY f.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $now = dol_now();
             $i = 0;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 0));
                 if ($objp->fk_statut == 0) {
                     // draft
                     $billurl = "viewstatut=0&paye=0";
                 } elseif ($objp->fk_statut == 1) {
                     // unpaid
                     $billurl = "viewstatut=1&paye=0";
                 } else {
                     // paid for current year
                     $billurl = "viewstatut=2&paye=1";
                 }
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills");
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     }
     // list the summary of the orders
     if ($conf->commande->enabled && $user->rights->commande->lire) {
         $sql = "SELECT c.fk_statut,c.facture, sum(c.total_ttc) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c";
         $sql .= " WHERE c.entity = " . $conf->entity;
         $sql .= " AND c.fk_soc = s.rowid";
         $sql .= " AND c.facture=0";
         $sql .= " GROUP BY c.fk_statut";
         $sql .= " ORDER BY c.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_order');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/commande/liste.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
         }
     }
     // list the summary of the propals
     if ($conf->propal->enabled && $user->rights->propal->lire) {
         $sql = "SELECT p.fk_statut, sum(p.total) as Mnttot, count(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p";
         $sql .= " WHERE p.entity = " . $conf->entity;
         $sql .= " AND p.fk_soc = s.rowid";
         $sql .= " AND DATE_FORMAT(p.datep,'%Y') = " . date("Y");
         $sql .= " AND p.date_cloture IS NULL ";
         // just unclosed
         $sql .= " GROUP BY p.fk_statut";
         $sql .= " ORDER BY p.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_propal');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($objp->fk_statut, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => dol_trunc(number_format($objp->Mnttot, 0, ',', ' '), 40) . "&nbsp;" . getCurrencySymbol($conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3));
                 $i++;
             }
         }
     }
     // Add the sum in the bottom of the boxes
     $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total") . "&nbsp;" . $textHead);
     $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => number_format($totalnb, 0, ',', ' '));
     $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => number_format($totalMnt, 0, ',', ' ') . "&nbsp;" . getCurrencySymbol($conf->currency));
     $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => "");
     $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => "");
 }
Exemplo n.º 8
0
     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>';
     print '<td align="right">' . price($objp->total_ht, 0, $langs) . '</td>';
     print '<td align="right">' . price($objp->total_tva, 0, $langs) . '</td>';
     print '<td align="right">' . price($objp->total_ttc, 0, $langs) . '</td>';
     print '<td align="right">' . (!empty($paiement) ? price($paiement, 0, $langs) : '&nbsp;') . '</td>';
     // Affiche statut de la facture
     print '<td align="right" class="nowrap">';
     print $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 5, $paiement, $objp->type);
     print "</td>";
     //print "<td>&nbsp;</td>";
     print "</tr>\n";
     $total_ht += $objp->total_ht;
     $total_tva += $objp->total_tva;
     $total_ttc += $objp->total_ttc;
     $totalrecu += $paiement;
     $i++;
 }
 if ($offset + $num <= $limit) {
     // Print total
     print '<tr class="liste_total">';
     print '<td class="liste_total" colspan="5" align="left">' . $langs->trans('Total') . '</td>';
     print '<td class="liste_total" align="right">' . price($total_ht, 0, $langs) . '</td>';
     print '<td class="liste_total" align="right">' . price($total_tva, 0, $langs) . '</td>';
Exemplo n.º 9
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;
                 $societestatic->id = $objp->socid;
                 $societestatic->name = $objp->name;
                 $societestatic->client = 1;
                 $societestatic->code_client = $objp->code_client;
                 $societestatic->logo = $objp->logo;
                 $late = '';
                 if ($datelimite < $now - $conf->facture->client->warning_delay) {
                     $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"));
     }
 }
Exemplo n.º 10
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';
     $facturestatic = new Facture($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 .= " f.facnumber, f.date_lim_reglement as datelimite,";
         $sql .= " f.amount, f.datef as df,";
         $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();
             $i = 0;
             $l_due_date = $langs->trans('Late') . ' (' . strtolower($langs->trans('DateEcheance')) . ': %s)';
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $datelimite = $db->jdate($objp->datelimite);
                 $late = '';
                 if ($datelimite < $now - $conf->facture->client->warning_delay) {
                     $late = img_warning(sprintf($l_due_date, dol_print_date($datelimite, 'day')));
                 }
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/compta/facture.php?facid=" . $objp->facid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->facnumber, 'text2' => $late, 'url' => DOL_URL_ROOT . "/compta/facture.php?facid=" . $objp->facid);
                 $this->info_box_contents[$i][2] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][3] = array('td' => 'align="left"', 'text' => $objp->name, 'maxlength' => 44, 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datelimite, 'day'));
                 $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut($objp->paye, $objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][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"));
     }
 }
Exemplo n.º 11
0
 /**
  *  Charge les donnees en memoire pour affichage ulterieur
  *
  *  @param  int     $max        Maximum number of records to load
  *  @return void
  */
 function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
     include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
     $totalMnt = 0;
     $totalnb = 0;
     $line = 0;
     $cachetime = 3600;
     $fileid = '-e' . $conf->entity . '-u' . $user->id . '-s' . $user->societe_id . '-r' . ($user->rights->societe->client->voir ? '1' : '0') . '.cache';
     $now = dol_now();
     $nbofyears = 2;
     if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
         $nbofyears = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
     }
     $textHead = $langs->trans("Activity") . ' - ' . $langs->trans("LastXMonthRolling", $nbofyears * 12);
     $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead));
     // compute the year limit to show
     $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofyears, "y");
     $cumuldata = array();
     // list the summary of the bills
     if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
         include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
         $facturestatic = new Facture($db);
         $cachedir = DOL_DATA_ROOT . '/facture/temp';
         $filename = '/boxactivity-invoice' . $fileid;
         $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
         $data = array();
         if ($refresh) {
             $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
             $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 .= ")";
             $sql .= " WHERE f.entity = " . $conf->entity;
             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 .= " AND f.fk_soc = s.rowid";
             $sql .= " AND f.datef >= '" . $db->idate($tmpdate) . "' AND paye=1";
             $sql .= " GROUP BY f.fk_statut";
             $sql .= " ORDER BY f.fk_statut DESC";
             $result = $db->query($sql);
             if ($result) {
                 $num = $db->num_rows($result);
                 $j = 0;
                 while ($j < $num) {
                     $data[$j] = $db->fetch_object($result);
                     $j++;
                 }
                 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
                     dol_filecache($cachedir, $filename, $data);
                 }
                 $db->free($result);
             } else {
                 dol_print_error($db);
             }
         } else {
             $data = dol_readcachefile($cachedir, $filename);
         }
         $cumuldata = array_merge($cumuldata, $data);
         if (!empty($data)) {
             $j = 0;
             while ($line < count($cumuldata)) {
                 $billurl = "viewstatut=2&amp;paye=1&amp;year=" . $data[$j]->annee;
                 $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . '&nbsp;' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'logo' => 'bill');
                 $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0) . " " . $data[$j]->annee);
                 $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'tooltip' => $langs->trans('Bills') . '&nbsp;' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&amp;mainmenu=accountancy&amp;leftmenu=customers_bills");
                 $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 // We add only for the current year
                 if ($data[$j]->annee == date("Y")) {
                     $totalnb += $data[$j]->nb;
                     $totalMnt += $data[$j]->Mnttot;
                 }
                 $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1, $data[$j]->fk_statut, 3));
                 $line++;
                 $j++;
             }
             if (count($data) == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
         }
         $cachedir = DOL_DATA_ROOT . '/facture/temp';
         $filename = '/boxactivity-invoice2' . $fileid;
         $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
         if ($refresh) {
             $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
             $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f";
             $sql .= " WHERE f.entity = " . $conf->entity;
             $sql .= " AND f.fk_soc = s.rowid";
             $sql .= " AND paye=0";
             $sql .= " GROUP BY f.fk_statut";
             $sql .= " ORDER BY f.fk_statut DESC";
             $result = $db->query($sql);
             if ($result) {
                 $num = $db->num_rows($result);
                 $j = 0;
                 while ($j < $num) {
                     $data[$j] = $db->fetch_object($result);
                     $j++;
                 }
                 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
                     dol_filecache($cachedir, $filename, $data);
                 }
                 $db->free($result);
             } else {
                 dol_print_error($db);
             }
         } else {
             $data = dol_readcachefile($cachedir, $filename);
         }
         $cumuldata = array_merge($cumuldata, $data);
         if (!empty($data)) {
             $j = 0;
             while ($line < count($cumuldata)) {
                 $billurl = "viewstatut=" . $data[$j]->fk_statut . "&amp;paye=0";
                 $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . '&nbsp;' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&amp;mainmenu=accountancy&amp;leftmenu=customers_bills", 'logo' => 'bill');
                 $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0));
                 $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans('Bills') . '&nbsp;' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&amp;mainmenu=accountancy&amp;leftmenu=customers_bills");
                 $totalnb += $data[$j]->nb;
                 $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0, $data[$j]->fk_statut, 3));
                 $line++;
                 $j++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     }
     // list the summary of the orders
     if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
         include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
         $commandestatic = new Commande($db);
         $cachedir = DOL_DATA_ROOT . '/commande/temp';
         $filename = '/boxactivity-order' . $fileid;
         $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
         $data = array();
         if ($refresh) {
             $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
             $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c";
             if (!$user->rights->societe->client->voir && !$user->societe_id) {
                 $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
             }
             $sql .= ")";
             $sql .= " WHERE c.entity = " . $conf->entity;
             $sql .= " AND c.fk_soc = s.rowid";
             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 .= " AND c.date_commande >= '" . $db->idate($tmpdate) . "'";
             $sql .= " AND c.facture=0";
             $sql .= " GROUP BY c.fk_statut";
             $sql .= " ORDER BY c.fk_statut DESC";
             $result = $db->query($sql);
             if ($result) {
                 $num = $db->num_rows($result);
                 $j = 0;
                 while ($j < $num) {
                     $data[$j] = $db->fetch_object($result);
                     $j++;
                 }
                 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
                     dol_filecache($cachedir, $filename, $data);
                 }
                 $db->free($result);
             } else {
                 dol_print_error($db);
             }
         } else {
             $data = dol_readcachefile($cachedir, $filename);
         }
         $cumuldata = array_merge($cumuldata, $data);
         if (!empty($data)) {
             $j = 0;
             while ($line < count($cumuldata)) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT . "/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'logo' => 'object_order');
                 $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0));
                 $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'url' => DOL_URL_ROOT . "/commande/list.php?mainmenu=commercial&amp;leftmenu=orders&amp;viewstatut=" . $data[$j]->fk_statut);
                 $totalnb += $data[$j]->nb;
                 $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $data[$j]->Mnttot;
                 $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($data[$j]->fk_statut, 0, 3));
                 $line++;
                 $j++;
             }
         }
     }
     // list the summary of the propals
     if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
         include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
         $propalstatic = new Propal($db);
         $cachedir = DOL_DATA_ROOT . '/propale/temp';
         $filename = '/boxactivity-propal' . $fileid;
         $refresh = dol_cache_refresh($cachedir, $filename, $cachetime);
         $data = array();
         if ($refresh) {
             $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
             $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p";
             if (!$user->rights->societe->client->voir && !$user->societe_id) {
                 $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
             }
             $sql .= ")";
             $sql .= " WHERE p.entity = " . $conf->entity;
             $sql .= " AND p.fk_soc = s.rowid";
             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 .= " AND p.datep >= '" . $db->idate($tmpdate) . "'";
             $sql .= " AND p.date_cloture IS NULL";
             // just unclosed
             $sql .= " GROUP BY p.fk_statut";
             $sql .= " ORDER BY p.fk_statut DESC";
             $result = $db->query($sql);
             if ($result) {
                 $num = $db->num_rows($result);
                 $j = 0;
                 while ($j < $num) {
                     $data[$j] = $db->fetch_object($result);
                     $j++;
                 }
                 if (!empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
                     dol_filecache($cachedir, $filename, $data);
                 }
                 $db->free($result);
             } else {
                 dol_print_error($db);
             }
         } else {
             $data = dol_readcachefile($cachedir, $filename);
         }
         $cumuldata = array_merge($cumuldata, $data);
         if (!empty($data)) {
             $j = 0;
             while ($line < count($cumuldata)) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal');
                 $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($data[$j]->fk_statut, 0));
                 $this->info_box_contents[$line][2] = array('td' => 'align="right"', 'text' => $data[$j]->nb, 'tooltip' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&amp;leftmenu=propals&amp;viewstatut=" . $data[$j]->fk_statut);
                 $totalnb += $data[$j]->nb;
                 $this->info_box_contents[$line][3] = array('td' => 'align="right"', 'text' => price($data[$j]->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $data[$j]->Mnttot;
                 $this->info_box_contents[$line][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($data[$j]->fk_statut, 3));
                 $line++;
                 $j++;
             }
         }
     }
     // Add the sum in the bottom of the boxes
     $this->info_box_contents[$line][0] = array('tr' => 'class="liste_total"');
     $this->info_box_contents[$line][1] = array('td' => 'align="left" class="liste_total" ', 'text' => $langs->trans("Total") . "&nbsp;" . $textHead);
     $this->info_box_contents[$line][2] = array('td' => 'align="right" class="liste_total" ', 'text' => $totalnb);
     $this->info_box_contents[$line][3] = array('td' => 'align="right" class="liste_total" ', 'text' => '');
     $this->info_box_contents[$line][4] = array('td' => 'align="right" class="liste_total" ', 'text' => "");
 }
Exemplo n.º 12
0
 $num = $db->num_rows($resql);
 if ($socid) {
     $soc = new Societe($db);
     $soc->fetch($socid);
 }
 $param = '&amp;socid=' . $socid;
 if ($month) {
     $param .= '&amp;month=' . $month;
 }
 if ($year) {
     $param .= '&amp;year=' . $year;
 }
 $txtListe = $langs->trans('BillsCustomers');
 if ($viewstatut != '') {
     if ($viewstatut != 2) {
         $txtListe = $txtListe . " - " . $facturestatic->LibStatut(0, $viewstatut);
     } else {
         $txtListe = $txtListe . " - " . $facturestatic->LibStatut(1, $viewstatut);
     }
 }
 if ($viewtype != '') {
     $txtListe = $txtListe . " - " . $facturestatic->LibStatut(1, $viewstatut, '', '', 2);
 }
 print_barre_liste($txtListe . ' ' . ($socid ? ' ' . $soc->nom : ''), $page, 'listefac.php', $param, $sortfield, $sortorder, '', $num);
 $i = 0;
 print '<form method="get" action="' . $_SERVER["PHP_SELF"] . '">' . "\n";
 print '<table class="liste" width="100%">';
 print '<tr class="liste_titre">';
 print_liste_field_titre($langs->trans('Ref'), $_SERVER['PHP_SELF'], 'f.facnumber', '', $param, '', $sortfield, $sortorder);
 print_liste_field_titre($langs->trans('Date'), $_SERVER['PHP_SELF'], 'f.datef', '', $param, 'align="center"', $sortfield, $sortorder);
 print_liste_field_titre($langs->trans('Cash'), $_SERVER['PHP_SELF'], 'ca.name', '', $param, 'align="center"', $sortfield, $sortorder);
 /**
  *  Charge les donnees en memoire pour affichage ulterieur
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 5)
 {
     global $conf, $user, $langs, $db;
     $totalMnt = 0;
     $totalnb = 0;
     $i = 0;
     include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
     $nbofyears = 2;
     if (!empty($conf->global->MAIN_BOX_ACTIVITY_DURATION)) {
         $nbofyears = $conf->global->MAIN_BOX_ACTIVITY_DURATION;
     }
     $textHead = $langs->trans("Activity") . ' (' . $nbofyears . ' ' . $langs->trans("DurationYears") . ')';
     $this->info_box_head = array('text' => $textHead, 'limit' => dol_strlen($textHead));
     // compute the year limit to show
     $tmpdate = dol_time_plus_duree(dol_now(), -1 * $nbofyears, "y");
     // list the summary of the bills
     if (!empty($conf->facture->enabled) && $user->rights->facture->lire) {
         include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
         $facturestatic = new Facture($db);
         $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
         $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 .= ")";
         $sql .= " WHERE f.entity = " . $conf->entity;
         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 .= " AND f.fk_soc = s.rowid";
         $sql .= " AND f.datef >= '" . $db->idate($tmpdate) . "' AND paye=1";
         $sql .= " GROUP BY f.fk_statut";
         $sql .= " ORDER BY f.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut(1, $objp->fk_statut, 0) . " " . $objp->annee);
                 $billurl = "viewstatut=2&paye=1&year=" . $objp->annee;
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills");
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 // We add only for the current year
                 if ($objp->annee == date("Y")) {
                     $totalnb += $objp->nb;
                     $totalMnt += $objp->Mnttot;
                 }
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(1, $objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
             $db->free($result);
         } else {
             dol_print_error($db);
         }
         $sql = "SELECT f.fk_statut, SUM(f.total_ttc) as Mnttot, COUNT(*) as nb";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s," . MAIN_DB_PREFIX . "facture as f";
         $sql .= " WHERE f.entity = " . $conf->entity;
         $sql .= " AND f.fk_soc = s.rowid";
         $sql .= " AND paye=0";
         $sql .= " GROUP BY f.fk_statut";
         $sql .= " ORDER BY f.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             $now = dol_now();
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'bill');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . "&nbsp;" . $facturestatic->LibStatut(0, $objp->fk_statut, 0));
                 $billurl = "viewstatut=" . $objp->fk_statut . "&paye=0";
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills");
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $facturestatic->LibStatut(0, $objp->fk_statut, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedInvoices"));
             }
         } else {
             $this->info_box_contents[0][0] = array('td' => 'align="left"', 'maxlength' => 500, 'text' => $db->error() . ' sql=' . $sql);
         }
     }
     // list the summary of the orders
     if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
         include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
         $commandestatic = new Commande($db);
         $sql = "SELECT c.fk_statut, sum(c.total_ttc) as Mnttot, count(*) as nb";
         $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "commande as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= ")";
         $sql .= " WHERE c.entity = " . $conf->entity;
         $sql .= " AND c.fk_soc = s.rowid";
         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 .= " AND c.date_commande >= '" . $db->idate($tmpdate) . "'";
         $sql .= " AND c.facture=0";
         $sql .= " GROUP BY c.fk_statut";
         $sql .= " ORDER BY c.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_order');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Orders") . "&nbsp;" . $commandestatic->LibStatut($objp->fk_statut, 0, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/commande/liste.php?mainmenu=commercial&leftmenu=orders&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, 0, 3));
                 $i++;
             }
         } else {
             dol_print_error($db);
         }
     }
     // list the summary of the propals
     if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
         include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php';
         $propalstatic = new Propal($db);
         $sql = "SELECT p.fk_statut, SUM(p.total) as Mnttot, COUNT(*) as nb";
         $sql .= " FROM (" . MAIN_DB_PREFIX . "societe as s, " . MAIN_DB_PREFIX . "propal as p";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= ")";
         $sql .= " WHERE p.entity = " . $conf->entity;
         $sql .= " AND p.fk_soc = s.rowid";
         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 .= " AND p.datep >= '" . $db->idate($tmpdate) . "'";
         $sql .= " AND p.date_cloture IS NULL";
         // just unclosed
         $sql .= " GROUP BY p.fk_statut";
         $sql .= " ORDER BY p.fk_statut DESC";
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result) + $i;
             while ($i < $num) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => 'object_propal');
                 $objp = $db->fetch_object($result);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . "&nbsp;" . $propalstatic->LibStatut($objp->fk_statut, 0));
                 $this->info_box_contents[$i][2] = array('td' => 'align="right"', 'text' => $objp->nb, 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&viewstatut=" . $objp->fk_statut);
                 $totalnb += $objp->nb;
                 $this->info_box_contents[$i][3] = array('td' => 'align="right"', 'text' => price($objp->Mnttot, 1, $langs, 0, 0, -1, $conf->currency));
                 $totalMnt += $objp->Mnttot;
                 $this->info_box_contents[$i][4] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3));
                 $i++;
             }
         } else {
             dol_print_error($db);
         }
     }
     // Add the sum in the bottom of the boxes
     $this->info_box_contents[$i][1] = array('td' => 'align="left" ', 'text' => $langs->trans("Total") . "&nbsp;" . $textHead);
     $this->info_box_contents[$i][2] = array('td' => 'align="right" ', 'text' => price($totalnb, 1, $langs, 0, 0, -1, $conf->currency));
     $this->info_box_contents[$i][3] = array('td' => 'align="right" ', 'text' => price($totalMnt, 1, $langs, 0, 0, -1, $conf->currency));
     $this->info_box_contents[$i][4] = array('td' => 'align="right" ', 'text' => "");
     $this->info_box_contents[$i][5] = array('td' => 'align="right"', 'text' => "");
 }
Exemplo n.º 14
0
             $objp = $db->fetch_object($resql);
             $var = !$var;
             print "<tr {$bc[$var]}>";
             print '<td>';
             $facturestatic->id = $objp->facid;
             $facturestatic->ref = $objp->facnumber;
             $facturestatic->type = $objp->type;
             print $facturestatic->getNomUrl(1);
             print '</td>';
             if ($objp->df > 0) {
                 print '<td align="right" width="80">' . dol_print_date($db->jdate($objp->df), 'day') . '</td>';
             } else {
                 print '<td align="right"><b>!!!</b></td>';
             }
             print '<td align="right" width="120">' . price($objp->total_ttc) . '</td>';
             print '<td align="right" nowrap="nowrap" width="100" >' . $facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am) . '</td>';
             print "</tr>\n";
             $i++;
         }
         $db->free($resql);
         if ($num > 0) {
             print "</table>";
         }
     } else {
         dol_print_error($db);
     }
 }
 print "</td></tr>";
 print "</table>";
 print "\n</div>\n";
 /*
Exemplo n.º 15
0
             print $facturestatic->getNomUrl(1);
             print '</td>';
             if ($objp->df > 0) {
                 print '<td align="right" width="80px">' . dol_print_date($db->jdate($objp->df), 'day') . '</td>';
             } else {
                 print '<td align="right"><b>!!!</b></td>';
             }
             print '<td align="right" style="min-width: 60px">';
             print price($objp->total_ht);
             print '</td>';
             if (!empty($conf->global->MAIN_SHOW_PRICE_WITH_TAX_IN_SUMMARIES)) {
                 print '<td align="right" style="min-width: 60px">';
                 print price($objp->total_ttc);
                 print '</td>';
             }
             print '<td align="right" class="nowrap" style="min-width: 60px">' . $facturestatic->LibStatut($objp->paye, $objp->statut, 5, $objp->am) . '</td>';
             print "</tr>\n";
             $i++;
         }
         $db->free($resql);
         if ($num > 0) {
             print "</table>";
         }
     } else {
         dol_print_error($db);
     }
 }
 print '</div></div></div>';
 print '<div style="clear:both"></div>';
 dol_fiche_end();
 /*