/**
  *  Load data for box to show them 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 . '/commande/class/commande.class.php';
     $commandestatic = new Commande($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerOrders", $max));
     if ($user->rights->commande->lire) {
         $sql = "SELECT s.nom, s.rowid as socid,";
         $sql .= " c.ref, c.tms, c.rowid,";
         $sql .= " c.fk_statut, c.facture";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE c.fk_soc = s.rowid";
         $sql .= " AND c.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 c.date_commande DESC, c.ref DESC ";
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $datem = $db->jdate($objp->tms);
                 $this->info_box_contents[$i][0] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/commande/fiche.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][1] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => DOL_URL_ROOT . "/commande/fiche.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' => $objp->nom, 'url' => DOL_URL_ROOT . "/comm/fiche.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][4] = array('td' => 'align="right"', 'text' => dol_print_date($datem, 'day'));
                 $this->info_box_contents[$i][5] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders"));
             }
             $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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
     $urlsource = $_SERVER['PHP_SELF'] . '?id=' . $obj->rowid;
     print $formfile->getDocumentsLink($commandestatic->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_ht) . '</td>';
     }
     print '<td align="right">' . price($obj->total_ttc) . '</td>';
     print '<td align="right">' . price($obj->total_ttc - $obj->tot_fttc) . '</td>';
     print '<td>' . $commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3) . '</td>';
     print '</tr>';
     $tot_ht += $obj->total_ht;
     $tot_ttc += $obj->total_ttc;
     //print "x".$tot_ttc."z".$obj->tot_fttc;
     $tot_tobill += $obj->total_ttc - $obj->tot_fttc;
     $i++;
     $var = !$var;
 }
 print '<tr class="liste_total"><td colspan="2">' . $langs->trans("Total") . ' &nbsp; <font style="font-weight: normal">(' . $langs->trans("RemainderToBill") . ': ' . price($tot_tobill) . ')</font> </td>';
 if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) {
     print '<td align="right">' . price($tot_ht) . '</td>';
 }
 print '<td align="right">' . price($tot_ttc) . '</td>';
 print '<td align="right">' . price($tot_tobill) . '</td>';
 print '<td>&nbsp;</td>';
示例#3
0
文件: fiche.php 项目: netors/dolibarr
         if ($num > 0) {
             print '<tr class="liste_titre">';
             print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>' . $langs->trans("LastOrders", $num <= $MAXLIST ? "" : $MAXLIST) . '</td><td align="right"><a href="' . DOL_URL_ROOT . '/commande/liste.php?socid=' . $objsoc->id . '">' . $langs->trans("AllOrders") . ' (' . $num . ')</a></td>';
             print '<td width="20px" align="right"><a href="' . DOL_URL_ROOT . '/commande/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);
             $var = !$var;
             print "<tr {$bc[$var]}>";
             print '<td nowrap="nowrap"><a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=' . $objp->cid . '">' . img_object($langs->trans("ShowOrder"), "order") . ' ' . $objp->ref . "</a>\n";
             print '</td><td align="right" width="80">' . dol_print_date($db->jdate($objp->dc), 'day') . "</td>\n";
             print '<td align="right" width="120">' . price($objp->total_ht) . '</td>';
             print '<td align="right" width="100">' . $commande_static->LibStatut($objp->fk_statut, $objp->facture, 5) . '</td></tr>';
             $i++;
         }
         $db->free($resql);
     } else {
         dol_print_error($db);
     }
     print "</table>";
 }
 /*
  * Last linked contracts
  */
 if ($conf->contrat->enabled && $user->rights->contrat->lire) {
     $contratstatic = new Contrat($db);
     print '<table class="noborder" width="100%">';
     $sql = "SELECT s.nom, s.rowid, c.rowid as id, c.ref as ref, c.statut, c.datec as dc";
示例#4
0
             }
         }
     }
     print '</td>';
     // Order date
     print '<td align="center">';
     print dol_print_date($db->jdate($objp->date_commande), 'day');
     print '</td>';
     // Delivery date
     print '<td align="center">';
     print dol_print_date($db->jdate($objp->date_delivery), 'day');
     print '</td>';
     // Amount HT
     print '<td align="right" class="nowrap">' . price($objp->total_ht) . '</td>';
     // Statut
     print '<td align="right" class="nowrap">' . $generic_commande->LibStatut($objp->fk_statut, $objp->billed, 5, 1) . '</td>';
     // Billed
     print '<td align="center">' . yn($objp->billed) . '</td>';
     print '<td></td>';
     print '</tr>';
     $total += $objp->total_ht;
     $subtotal += $objp->total_ht;
     $i++;
 }
 if (!empty($conf->global->MAIN_SHOW_TOTAL_FOR_LIMITED_LIST)) {
     $var = !$var;
     print '<tr ' . $bc[$var] . '>';
     print '<td class="nowrap" colspan="5">' . $langs->trans('TotalHT') . '</td>';
     // Total HT
     print '<td align="right" class="nowrap">' . price($total) . '</td>';
     print '<td></td>';
示例#5
0
         if (!isset($vals[$row[1] . $bool])) {
             $vals[$row[1] . $bool] = 0;
         }
         $vals[$row[1] . $bool] += $row[0];
         $totalinprocess += $row[0];
         $total += $row[0];
     }
     $i++;
 }
 $db->free($resql);
 print '<table class="noborder nohover" width="100%">';
 print '<tr class="liste_titre"><td colspan="2">' . $langs->trans("Statistics") . ' - ' . $langs->trans("CustomersOrders") . '</td></tr>' . "\n";
 $listofstatus = array(0, 1, 2, 3, 3, -1);
 $bool = false;
 foreach ($listofstatus as $status) {
     $dataseries[] = array('label' => $commandestatic->LibStatut($status, $bool, 1), 'data' => isset($vals[$status . $bool]) ? (int) $vals[$status . $bool] : 0);
     if ($status == 3 && $bool == false) {
         $bool = true;
     } else {
         $bool = false;
     }
 }
 if ($conf->use_javascript_ajax) {
     print '<tr class="impair"><td align="center" colspan="2">';
     $data = array('series' => $dataseries);
     dol_print_graph('stats', 300, 180, $data, 1, 'pie', 1);
     print '</td></tr>';
 }
 $var = true;
 $bool = false;
 foreach ($listofstatus as $status) {
示例#6
0
            if ($num > 0) {
                $var = True;
                while ($i < $num && $i < $conf->liste_limit) {
                    $objp = $db->fetch_object($result);
                    $var = !$var;
                    print "<tr " . $bc[$var] . ">";
                    print '<td><a href="' . DOL_URL_ROOT . '/commande/card.php?id=' . $objp->commandeid . '">' . img_object($langs->trans("ShowOrder"), "order") . ' ';
                    print $objp->ref;
                    print "</a></td>\n";
                    print '<td><a href="' . DOL_URL_ROOT . '/comm/card.php?socid=' . $objp->socid . '">' . img_object($langs->trans("ShowCompany"), "company") . ' ' . dol_trunc($objp->name, 44) . '</a></td>';
                    print "<td>" . $objp->code_client . "</td>\n";
                    print "<td align=\"center\">";
                    print dol_print_date($db->jdate($objp->date_commande)) . "</td>";
                    print "<td align=\"center\">" . $objp->qty . "</td>\n";
                    print "<td align=\"right\">" . price($objp->total_ht) . "</td>\n";
                    print '<td align="right">' . $commandestatic->LibStatut($objp->statut, $objp->facture, 5) . '</td>';
                    print "</tr>\n";
                    $i++;
                }
            }
        } else {
            dol_print_error($db);
        }
        print "</table>";
        print '<br>';
        $db->free($result);
    }
} else {
    dol_print_error();
}
llxFooter();
示例#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' => "");
 }
             }
         }
     }
     print '</td>';
     // Order date
     print '<td align="center">';
     print dol_print_date($db->jdate($objp->date_commande), 'day');
     print '</td>';
     // Delivery date
     print '<td align="center">';
     print dol_print_date($db->jdate($objp->date_delivery), 'day');
     print '</td>';
     // Amount HT
     print '<td align="right" class="nowrap">' . price($objp->total_ht) . '</td>';
     // Statut
     print '<td align="right" class="nowrap">' . $generic_commande->LibStatut($objp->fk_statut, $objp->facturee, 5) . '</td>';
     print '</tr>';
     $total += $objp->total_ht;
     $subtotal += $objp->total_ht;
     $i++;
 }
 if (!empty($conf->global->MAIN_SHOW_TOTAL_FOR_LIMITED_LIST)) {
     $var = !$var;
     print '<tr ' . $bc[$var] . '>';
     print '<td class="nowrap" colspan="5">' . $langs->trans('TotalHT') . '</td>';
     // Total HT
     print '<td align="right" class="nowrap">' . price($total) . '</td>';
     print '<td class="nowrap">&nbsp;</td>';
     print '</tr>';
 }
 print '</table>';
 /**
  *  Load data for box to show them later
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 20)
 {
     global $user, $langs, $db, $conf;
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
     $commandestatic = new Commande($db);
     $userstatic = new User($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "CustomerOrders", $max));
     /* 
     Consulta de Pedidos de Cliente con Referencia del cliente, Fecha de entrega, Factura (SI/NO), validados.
     SELECT s.nom as name, s.rowid as socid, c.ref_client, c.tms, c.rowid, c.date_commande, c.date_livraison, c.fk_statut, c.fk_user_valid, c.facture, c.total_ht
     FROM llx_societe as s, llx_commande as c
     WHERE c.fk_soc = s.rowid
     AND c.fk_statut = 1
     ORDER BY c.tms DESC, c.date_livraison DESC
     */
     if ($user->rights->commande->lire) {
         $sql = "SELECT s.nom as name, s.rowid as socid,";
         $sql .= " c.ref, c.tms, c.rowid, c.date_commande,";
         $sql .= " c.fk_statut, c.fk_user_valid, c.facture, c.total_ht";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE c.fk_soc = s.rowid";
         $sql .= " AND c.entity = " . $conf->entity;
         if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) {
             $sql .= " AND c.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;
         }
         if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
             $sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
         } else {
             $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
         }
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $date = $db->jdate($objp->date_commande);
                 $datem = $db->jdate($objp->tms);
                 $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/commande/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => DOL_URL_ROOT . "/commande/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->name, 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => price($objp->total_ht));
                 if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) {
                     if ($objp->fk_user_valid > 0) {
                         $userstatic->fetch($objp->fk_user_valid);
                     }
                     $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => $objp->fk_user_valid > 0 ? $userstatic->getNomUrl(1) : '', 'url' => $objp->fk_user_valid > 0 ? DOL_URL_ROOT . '/user/card.php?id=' . $objp->fk_user_valid : '');
                 }
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day'));
                 $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders"));
             }
             $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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
示例#10
0
             print $formfile->getDocumentsLink($orderstatic->element, $filename, $filedir);
             print '</td></tr></table>';
             print "</td>";
             print '<td class="nowrap">';
             $companystatic->id = $obj->rowid;
             $companystatic->name = $obj->name;
             $companystatic->client = $obj->client;
             $companystatic->code_client = $obj->code_client;
             $companystatic->code_fournisseur = $obj->code_fournisseur;
             $companystatic->canvas = $obj->canvas;
             print $companystatic->getNomUrl(1, 'company', 44);
             print '</td>';
             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">' . $orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3) . '</td>' . "\n";
             print '</tr>' . "\n";
             $i++;
             $total += $obj->total_ttc;
         }
         if ($num > $nbofloop) {
             print '<tr class="liste_total"><td colspan="5">' . $langs->trans("XMoreLines", $num - $nbofloop) . "</td></tr>";
         } else {
             if ($total > 0) {
                 print '<tr class="liste_total"><td colspan="3">' . $langs->trans("Total") . "</td><td align=\"right\">" . price($total) . "</td><td>&nbsp;</td></tr>";
             }
         }
         print "</table><br>";
     }
 } else {
     dol_print_error($db);
示例#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' => "");
 }
 /**
  *  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' => "");
 }
示例#13
0
         $i = 0;
         while ($i < $num && $i < $MAXLIST) {
             $objp = $db->fetch_object($resql);
             $var = !$var;
             print "<tr " . $bc[$var] . ">";
             print '<td class="nowrap">';
             $commande_static->id = $objp->cid;
             $commande_static->ref = $objp->ref;
             $commande_static->ref_client = $objp->ref_client;
             $commande_static->total_ht = $objp->total_ht;
             $commande_static->total_tva = $objp->total_tva;
             $commande_static->total_ttc = $objp->total_ttc;
             print $commande_static->getNomUrl(1);
             print '</td><td align="right" width="80">' . dol_print_date($db->jdate($objp->dc), '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">' . $commande_static->LibStatut($objp->fk_statut, $objp->facture, 5) . '</td></tr>';
             $i++;
         }
         $db->free($resql);
         if ($num > 0) {
             print "</table>";
         }
     } else {
         dol_print_error($db);
     }
 }
 /*
  *   Last sendings
  */
 if (!empty($conf->expedition->enabled) && $user->rights->expedition->lire) {
     $sendingstatic = new Expedition($db);
示例#14
0
 /**
  *  Load data for box to show them 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 . '/commande/class/commande.class.php';
     include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
     $commandestatic = new Commande($db);
     $societestatic = new Societe($db);
     $userstatic = new User($db);
     $this->info_box_head = array('text' => $langs->trans("BoxTitleLast" . ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE ? "" : "Modified") . "CustomerOrders", $max));
     if ($user->rights->commande->lire) {
         $sql = "SELECT s.nom as name";
         $sql .= ", s.rowid as socid";
         $sql .= ", s.code_client";
         $sql .= ", s.logo";
         $sql .= ", c.ref, c.tms";
         $sql .= ", c.rowid";
         $sql .= ", c.date_commande";
         $sql .= ", c.ref_client";
         $sql .= ", c.fk_statut";
         $sql .= ", c.fk_user_valid";
         $sql .= ", c.facture";
         $sql .= ", c.total_ht";
         $sql .= ", c.tva as total_tva";
         $sql .= ", c.total_ttc";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE c.fk_soc = s.rowid";
         $sql .= " AND c.entity = " . $conf->entity;
         if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) {
             $sql .= " AND c.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;
         }
         if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
             $sql .= " ORDER BY c.date_commande DESC, c.ref DESC ";
         } else {
             $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
         }
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $line = 0;
             while ($line < $num) {
                 $objp = $db->fetch_object($result);
                 $date = $db->jdate($objp->date_commande);
                 $datem = $db->jdate($objp->tms);
                 $commandestatic->id = $objp->rowid;
                 $commandestatic->ref = $objp->ref;
                 $commandestatic->ref_client = $objp->ref_client;
                 $commandestatic->total_ht = $objp->total_ht;
                 $commandestatic->total_tva = $objp->total_tva;
                 $commandestatic->total_ttc = $objp->total_ttc;
                 $societestatic->id = $objp->socid;
                 $societestatic->name = $objp->name;
                 $societestatic->code_client = $objp->code_client;
                 $societestatic->logo = $objp->logo;
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $commandestatic->getNomUrl(1), 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="left"', 'text' => $societestatic->getNomUrl(1), 'asis' => 1);
                 $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency));
                 if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) {
                     if ($objp->fk_user_valid > 0) {
                         $userstatic->fetch($objp->fk_user_valid);
                     }
                     $this->info_box_contents[$line][] = array('td' => 'align="right"', 'text' => $objp->fk_user_valid > 0 ? $userstatic->getNomUrl(1) : '', 'asis' => 1);
                 }
                 $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' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $line++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$line][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders"));
             }
             $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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }
 /**
  *  Load data for box to show them later
  *
  *  @param	int		$max        Maximum number of records to load
  *  @return	void
  */
 function loadBox($max = 20)
 {
     global $user, $langs, $db, $conf;
     $this->max = $max;
     include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
     $commandestatic = new Commande($db);
     $userstatic = new User($db);
     $url2 = DOL_URL_ROOT . "/custom/berrypro/list_commande.php?";
     $this->info_box_head = array('text' => $langs->trans("LastModifiedCustomersOrders", $max) . ' - <a href="' . $url2 . '" class="bold"> Ver m&aacute;s...</a>');
     if ($user->rights->commande->lire) {
         $sql = "SELECT s.nom as name, s.rowid as socid,";
         $sql .= " c.ref, c.tms, c.rowid, c.ref_client, c.date_commande, c.date_livraison,";
         $sql .= " c.fk_statut, c.fk_user_valid, c.facture, c.total_ht";
         $sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
         $sql .= ", " . MAIN_DB_PREFIX . "commande as c";
         if (!$user->rights->societe->client->voir && !$user->societe_id) {
             $sql .= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc";
         }
         $sql .= " WHERE c.fk_soc = s.rowid";
         $sql .= " AND c.entity = " . $conf->entity;
         $sql .= ' AND c.fk_statut IN (1,2,3)';
         $sql .= ' AND c.facture = 0';
         // need to create invoice
         if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_VALIDATED_ONLY)) {
             $sql .= " AND c.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;
         }
         if ($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) {
             $sql .= " ORDER BY c.date_commande ASC, c.ref DESC ";
         } else {
             $sql .= " ORDER BY c.tms DESC, c.ref DESC ";
         }
         $sql .= $db->plimit($max, 0);
         $result = $db->query($sql);
         if ($result) {
             $num = $db->num_rows($result);
             $i = 0;
             while ($i < $num) {
                 $objp = $db->fetch_object($result);
                 $date = $db->jdate($objp->date_commande);
                 $datel = $db->jdate($objp->date_livraison);
                 $datem = $db->jdate($objp->tms);
                 $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => $this->boximg, 'url' => DOL_URL_ROOT . "/commande/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->ref, 'url' => DOL_URL_ROOT . "/commande/card.php?id=" . $objp->rowid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left" width="16"', 'logo' => 'company', 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->name, 'url' => DOL_URL_ROOT . "/comm/card.php?socid=" . $objp->socid);
                 /*$this->info_box_contents[$i][] = array('td' => 'align="right"',
                                  'text' => price($objp->total_ht),
                 		);*/
                 if (!empty($conf->global->ORDER_BOX_LAST_ORDERS_SHOW_VALIDATE_USER)) {
                     if ($objp->fk_user_valid > 0) {
                         $userstatic->fetch($objp->fk_user_valid);
                     }
                     $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => $objp->fk_user_valid > 0 ? $userstatic->getNomUrl(1) : '', 'url' => $objp->fk_user_valid > 0 ? DOL_URL_ROOT . '/user/card.php?id=' . $objp->fk_user_valid : '');
                 }
                 $this->info_box_contents[$i][] = array('td' => 'align="left"', 'text' => $objp->ref_client);
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => dol_print_date($date, 'day'));
                 $this->info_box_contents[$i][] = array('td' => 'align="right"', 'text' => dol_print_date($datel, 'day'));
                 $this->info_box_contents[$i][] = array('td' => 'align="right" width="18"', 'text' => $commandestatic->LibStatut($objp->fk_statut, $objp->facture, 3));
                 $i++;
             }
             if ($num == 0) {
                 $this->info_box_contents[$i][0] = array('td' => 'align="center"', 'text' => $langs->trans("NoRecordedOrders"));
             }
             $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('align' => 'left', 'text' => $langs->trans("ReadPermissionNotAllowed"));
     }
 }