print '<td align="center">' . dol_print_date($db->jdate($objp->dfv), 'day'); print '</td>'; } else { print '<td> </td>'; } print '<td align="right">' . price($objp->total_ht) . "</td>\n"; $userstatic->id = $objp->fk_user_author; $userstatic->login = $objp->login; print '<td align="center">'; if ($userstatic->id) { print $userstatic->getLoginUrl(1); } else { print ' '; } print "</td>\n"; print '<td align="right">' . $objectstatic->LibStatut($objp->fk_statut, 5) . "</td>\n"; print '<td> </td>'; print "</tr>\n"; $total += $objp->total_ht; $subtotal += $objp->total_ht; $i++; } if ($total > 0) { if ($num < $limit) { $var = !$var; print '<tr class="liste_total"><td align="left">' . $langs->trans("TotalHT") . '</td>'; print '<td colspan="6" align="right">' . price($total) . '</td><td colspan="3"></td>'; print '</tr>'; } else { $var = !$var; print '<tr class="liste_total"><td align="left">' . $langs->trans("TotalHTforthispage") . '</td>';
if ($db->jdate($obj->dp) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); print '</td>'; print '<td width="16" align="center" class="nobordernopadding">'; $filename=dol_sanitizeFileName($obj->ref); $filedir=$conf->propale->dir_output . '/' . dol_sanitizeFileName($obj->ref); $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid; $formfile->show_documents('propal',$filename,$filedir,$urlsource,'','','',1,'',1); print '</td></tr></table>'; print "</td>"; print '<td align="left"><a href="fiche.php?socid='.$obj->rowid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,44).'</a></td>'."\n"; print '<td align="right">'; print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n"; print '<td align="right">'.price($obj->total_ttc).'</td>'; print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n"; print '</tr>'."\n"; $i++; $total += $obj->total_ttc; } if ($total>0) { print '<tr class="liste_total"><td colspan="3">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td><td> </td></tr>"; } print "</table><br>"; } } else { dol_print_error($db); } }
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastPropals", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/comm/propal.php?socid=' . $objsoc->id . '">' . $langs->trans("AllPropals") . ' (' . $num . ')</a></td>'; print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/comm/propal/stats/index.php?socid=' . $objsoc->id . '">' . img_picto($langs->trans("Statistics"), 'stats') . '</a></td>'; print '</tr></table></td>'; print '</tr>'; } $i = 0; while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); print "<tr {$bc[$var]}>"; print "<td nowrap><a href=\"propal.php?id={$objp->propalid}\">" . img_object($langs->trans("ShowPropal"), "propal") . " " . $objp->ref . "</a>\n"; if ($db->jdate($objp->dp) < $now - $conf->propal->cloture->warning_delay && $objp->fk_statut == 1) { print " " . img_warning(); } print '</td><td align="right" width="80">' . dol_print_date($db->jdate($objp->dp), 'day') . "</td>\n"; print '<td align="right" width="120">' . price($objp->total_ht) . '</td>'; print '<td align="right" nowrap="nowrap">' . $propal_static->LibStatut($objp->fk_statut, 5) . '</td></tr>'; $var = !$var; $i++; } $db->free($resql); } else { dol_print_error($db); } print "</table>"; } /* * Last orders */ if ($conf->commande->enabled && $user->rights->commande->lire) { $commande_static = new Commande($db); print '<table class="noborder" width="100%">';
/** * 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 $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $propalstatic = new Propal($db); $societestatic = new Societe($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "Propals", $max)); if ($user->rights->propale->lire) { $sql = "SELECT s.nom as name, s.rowid as socid, s.code_client, s.logo,"; $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.tva as total_tva, p.total as total_ttc, p.tms"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.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; } if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) { $sql .= " ORDER BY p.datep DESC, p.ref DESC "; } else { $sql .= " ORDER BY p.tms DESC, p.ref DESC "; } $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $line = 0; while ($line < $num) { $objp = $db->fetch_object($result); $date = $db->jdate($objp->dp); $datec = $db->jdate($objp->datec); $datem = $db->jdate($objp->tms); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $propalstatic->id = $objp->rowid; $propalstatic->ref = $objp->ref; $propalstatic->total_ht = $objp->total_ht; $propalstatic->total_tva = $objp->total_tva; $propalstatic->total_ttc = $objp->total_ttc; $societestatic->id = $objp->socid; $societestatic->name = $objp->name; $societestatic->code_client = $objp->code_client; $societestatic->logo = $objp->logo; $late = ''; if ($objp->fk_statut == 1 && $dateterm < $now - $conf->propal->cloture->warning_delay) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $propalstatic->getNomUrl(1), 'text2' => $late, 'asis' => 1); $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $societestatic->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($date, 'day')); $this->info_box_contents[$line][] = array('td' => 'align="right" width="18"', 'text' => $propalstatic->LibStatut($objp->fk_statut, 3)); $line++; } if ($num == 0) { $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProposals")); } $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")); } }
// Date print "<td align=\"right\">"; $y = dol_print_date($db->jdate($objp->dp),"%Y"); $m = dol_print_date($db->jdate($objp->dp),"%m"); $mt = dol_print_date($db->jdate($objp->dp),"%b"); $d = dol_print_date($db->jdate($objp->dp),"%d"); print $d."\n"; print " <a href=\"propal.php?year=$y&month=$m\">"; print $mt."</a>\n"; print " <a href=\"propal.php?year=$y\">"; print $y."</a></td>\n"; // Prix print "<td align=\"right\">".price($objp->total_ht)."</td>\n"; print "<td align=\"right\">".$propalstatic->LibStatut($objp->fk_statut,5)."</td>\n"; print "<td> </td>"; print "</tr>\n"; $i++; } print "</table>"; $db->free($result); } else { dol_print_error($db); } } $db->close();
/** * 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") . " " . 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") . " " . $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) . " " . 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") . " " . $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) . " " . 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") . " " . $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) . " " . 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") . " " . $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, ',', ' ') . " " . 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' => ""); }
while ($i < $num) { $row = $db->fetch_row($resql); if ($row) { $vals[$row[1]] = $row[0]; $totalinprocess += $row[0]; $total += $row[0]; } $i++; } $db->free($resql); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("Statistics") . ' - ' . $langs->trans("Proposals") . '</td></tr>' . "\n"; $var = true; $listofstatus = array(0, 1, 2, 3, 4); foreach ($listofstatus as $status) { $dataseries[] = array('label' => $propalstatic->LibStatut($status, 1), 'values' => array(0 => isset($vals[$status]) ? $vals[$status] : 0)); if (!$conf->use_javascript_ajax) { $var = !$var; print "<tr " . $bc[$var] . ">"; print '<td>' . $propalstatic->LibStatut($status, 0) . '</td>'; print '<td align="right"><a href="liste.php?statut=' . $status . '">' . (isset($vals[$status]) ? $vals[$status] : 0) . '</a></td>'; print "</tr>\n"; } } if ($conf->use_javascript_ajax) { print '<tr><td align="center" colspan="2">'; $data = array('series' => $dataseries); dol_print_graph('stats', 300, 180, $data, 1, 'pie', 1); print '</td></tr>'; } //if ($totalinprocess != $total)
/** * 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&paye=1&year=" . $data[$j]->annee; $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $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') . ' ' . $facturestatic->LibStatut(1, $data[$j]->fk_statut, 0), 'text' => $data[$j]->nb, 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&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 . "&paye=0"; $this->info_box_contents[$line][0] = array('td' => 'align="left" width="16"', 'tooltip' => $langs->trans('Bills') . ' ' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&leftmenu=customers_bills", 'logo' => 'bill'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Bills") . " " . $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') . ' ' . $facturestatic->LibStatut(0, $data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/compta/facture/list.php?" . $billurl . "&mainmenu=accountancy&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&leftmenu=orders&viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Orders") . " " . $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") . " " . $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") . " " . $commandestatic->LibStatut($data[$j]->fk_statut, 0, 0), 'url' => DOL_URL_ROOT . "/commande/list.php?mainmenu=commercial&leftmenu=orders&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&leftmenu=propals&viewstatut=" . $data[$j]->fk_statut, 'tooltip' => $langs->trans("Proposals") . " " . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'logo' => 'object_propal'); $this->info_box_contents[$line][1] = array('td' => 'align="left"', 'text' => $langs->trans("Proposals") . " " . $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") . " " . $propalstatic->LibStatut($data[$j]->fk_statut, 0), 'url' => DOL_URL_ROOT . "/comm/propal/list.php?mainmenu=commercial&leftmenu=propals&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") . " " . $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' => ""); }
/** * 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") . " " . $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") . " " . $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") . " " . $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") . " " . $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") . " " . $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' => ""); }
$objp = $db->fetch_object($result); $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>'; $propalstatic->id = $objp->propalid; $propalstatic->ref = $objp->ref; $propalstatic->ref_client = $objp->ref_client; print $propalstatic->getNomUrl(1); print "</td>\n"; $societestatic->fetch($objp->socid); print '<td>' . $societestatic->getNomUrl(1) . '</td>'; print '<td align="center">'; print dol_print_date($db->jdate($objp->datep)) . "</td>"; print "<td align=\"center\">" . $objp->qty . "</td>\n"; print '<td align="right">' . price($objp->amount) . '</td>' . "\n"; print '<td align="right">' . $propalstatic->LibStatut($objp->statut, 5) . '</td>'; print "</tr>\n"; $i++; if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $total_ht += $objp->total_ht; $total_qty += $objp->qty; } } } print '<tr class="liste_total">'; print '<td>' . $langs->trans('Total') . '</td>'; print '<td colspan="2"></td>'; print '<td align="center">' . $total_qty . '</td>'; print '<td align="right">' . price($total_ht) . '</td>'; print '<td></td>'; print "</table>";
/** * 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 $user, $langs, $db, $conf; $this->max = $max; include_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php"; $propalstatic = new Propal($db); $this->info_box_head = array('text' => $langs->trans("BoxTitleLastPropals", $max)); if ($user->rights->propale->lire) { $sql = "SELECT s.nom, s.rowid as socid,"; $sql .= " p.rowid, p.ref, p.fk_statut, p.datep as dp, p.datec, p.fin_validite, p.date_cloture"; $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s"; $sql .= ", " . MAIN_DB_PREFIX . "propal as p"; if (!$user->rights->societe->client->voir && !$user->societe_id) { $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; } $sql .= " WHERE p.fk_soc = s.rowid"; $sql .= " AND p.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 p.datep DESC, p.ref DESC "; $sql .= $db->plimit($max, 0); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $now = dol_now(); $i = 0; while ($i < $num) { $objp = $db->fetch_object($result); $datec = $db->jdate($objp->datec); $dateterm = $db->jdate($objp->fin_validite); $dateclose = $db->jdate($objp->date_cloture); $late = ''; if ($objp->fk_statut == 1 && $dateterm < $now - $conf->propal->cloture->warning_delay) { $late = img_warning($langs->trans("Late")); } $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/comm/propal.php?id=" . $objp->rowid); $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, 'text2' => $late, 'url' => DOL_URL_ROOT . "/comm/propal.php?id=" . $objp->rowid); $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' => dol_trunc($objp->nom, 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' => $propalstatic->LibStatut($objp->fk_statut, 3)); $i++; } if ($num == 0) { $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedProposals")); } } else { dol_print_error($db); } } else { $this->info_box_contents[0][0] = array('td' => 'align="left"', 'text' => $langs->trans("ReadPermissionNotAllowed")); } }
$var = !$var; print "<tr " . $bc[$var] . ">"; print '<td class="nowrap">'; $propal_static->id = $objp->propalid; $propal_static->ref = $objp->ref; $propal_static->ref_client = $objp->ref_client; $propal_static->total_ht = $objp->total_ht; $propal_static->total_tva = $objp->total_tva; $propal_static->total_ttc = $objp->total_ttc; print $propal_static->getNomUrl(1); if ($db->jdate($objp->dp) < $now - $conf->propal->cloture->warning_delay && $objp->fk_statut == 1) { print " " . img_warning(); } print '</td><td align="right" width="80">' . dol_print_date($db->jdate($objp->dp), 'day') . "</td>\n"; print '<td align="right" style="min-width: 60px">' . price($objp->total_ht) . '</td>'; print '<td align="right" style="min-width: 60px" class="nowrap">' . $propal_static->LibStatut($objp->fk_statut, 5) . '</td></tr>'; $i++; } $db->free($resql); if ($num > 0) { print "</table>"; } } else { dol_print_error($db); } } /* * Last orders */ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) { $commande_static = new Commande($db);