36 global $db, $langs, $conf, $user;
37 if (!empty($conf->expedition->enabled)) {
38 $langs->load(
"sendings");
40 $langs->load(
"orders");
45 if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
46 $head[$h][0] = DOL_URL_ROOT.
'/commande/card.php?id='.$object->id;
47 $head[$h][1] = $langs->trans(
"CustomerOrder");
48 $head[$h][2] =
'order';
52 if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
53 $nbContact = count($object->liste_contact(-1,
'internal')) + count($object->liste_contact(-1,
'external'));
54 $head[$h][0] = DOL_URL_ROOT.
'/commande/contact.php?id='.$object->id;
55 $head[$h][1] = $langs->trans(
'ContactsAddresses');
57 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
59 $head[$h][2] =
'contact';
63 if ((
isModEnabled(
'expedition_bon') && $user->rights->expedition->lire)
64 || ($conf->delivery_note->enabled && $user->rights->expedition->delivery->lire)) {
65 $nbShipments = $object->getNbOfShipments();
67 $head[$h][0] = DOL_URL_ROOT.
'/expedition/shipment.php?id='.$object->id;
69 if ($conf->expedition_bon->enabled) {
70 $text .= $langs->trans(
"Shipments");
72 if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) {
75 if ($conf->delivery_note->enabled) {
76 $text .= $langs->trans(
"Receivings");
78 if ($nbShipments > 0 || $nbReceiption > 0) {
79 $text .=
'<span class="badge marginleftonlyshort">'.($nbShipments ? $nbShipments : 0);
81 if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
84 if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
85 $text .= ($nbReceiption ? $nbReceiption : 0);
87 if ($nbShipments > 0 || $nbReceiption > 0) {
91 $head[$h][2] =
'shipping';
101 if (empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
103 if (!empty($object->note_private)) {
106 if (!empty($object->note_public)) {
109 $head[$h][0] = DOL_URL_ROOT.
'/commande/note.php?id='.$object->id;
110 $head[$h][1] = $langs->trans(
'Notes');
112 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
114 $head[$h][2] =
'note';
118 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
119 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
120 $upload_dir = $conf->commande->multidir_output[$object->entity].
"/".
dol_sanitizeFileName($object->ref);
121 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
122 $nbLinks =
Link::count($db, $object->element, $object->id);
123 $head[$h][0] = DOL_URL_ROOT.
'/commande/document.php?id='.$object->id;
124 $head[$h][1] = $langs->trans(
'Documents');
125 if (($nbFiles + $nbLinks) > 0) {
126 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
128 $head[$h][2] =
'documents';
131 $head[$h][0] = DOL_URL_ROOT.
'/commande/info.php?id='.$object->id;
132 $head[$h][1] = $langs->trans(
"Info");
133 $head[$h][2] =
'info';
148 global $langs, $conf, $user;
153 $head[$h][0] = DOL_URL_ROOT.
'/admin/commande.php';
154 $head[$h][1] = $langs->trans(
"Miscellaneous");
155 $head[$h][2] =
'general';
160 $head[$h][0] = DOL_URL_ROOT.
'/admin/order_extrafields.php';
161 $head[$h][1] = $langs->trans(
"ExtraFields");
162 $head[$h][2] =
'attributes';
165 $head[$h][0] = DOL_URL_ROOT.
'/admin/orderdet_extrafields.php';
166 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
167 $head[$h][2] =
'attributeslines';
185 global $conf, $db, $langs, $user;
189 if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
193 $commandestatic =
new Commande($db);
199 $sql =
"SELECT count(c.rowid) as nb, c.fk_statut as status";
200 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
201 $sql .=
", ".MAIN_DB_PREFIX.
"commande as c";
202 if (empty($user->rights->societe->client->voir) && !$socid) {
203 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
205 $sql .=
" WHERE c.fk_soc = s.rowid";
206 $sql .=
" AND c.entity IN (".getEntity(
'societe').
")";
208 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
210 if (empty($user->rights->societe->client->voir) && !$socid) {
211 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
213 $sql .=
" GROUP BY c.fk_statut";
215 $resql = $db->query($sql);
217 $num = $db->num_rows(
$resql);
222 $dataseries = array();
223 $colorseries = array();
227 $row = $db->fetch_row(
$resql);
231 if (!isset($vals[$row[1]])) {
234 $vals[$row[1]] += $row[0];
235 $totalinprocess += $row[0];
243 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
245 $result =
'<div class="div-table-responsive-no-min">';
246 $result .=
'<table class="noborder nohover centpercent">';
247 $result .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CustomersOrders").
'</th></tr>'.
"\n";
248 $listofstatus = array(0, 1, 2, 3, -1);
249 foreach ($listofstatus as $status) {
250 $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
252 $colorseries[$status] =
'-'.$badgeStatus0;
255 $colorseries[$status] = $badgeStatus1;
258 $colorseries[$status] = $badgeStatus4;
261 $colorseries[$status] = $badgeStatus6;
264 $colorseries[$status] = $badgeStatus6;
267 $colorseries[$status] = $badgeStatus9;
270 if (empty($conf->use_javascript_ajax)) {
271 $result .=
'<tr class="oddeven">';
272 $result .=
'<td>'.$commandestatic->LibStatut($status, 0, 0, 1).
'</td>';
273 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
' ';
274 $result .= $commandestatic->LibStatut($status, 0, 3, 1);
275 $result .=
'</a></td>';
276 $result .=
"</tr>\n";
279 if ($conf->use_javascript_ajax) {
280 $result .=
'<tr class="impair"><td align="center" colspan="2">';
282 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
284 $dolgraph->SetData($dataseries);
285 $dolgraph->SetDataColor(array_values($colorseries));
286 $dolgraph->setShowLegend(2);
287 $dolgraph->setShowPercent(1);
288 $dolgraph->SetType(array(
'pie'));
289 $dolgraph->setHeight(
'150');
290 $dolgraph->setWidth(
'300');
291 $dolgraph->draw(
'idgraphstatus');
292 $result .= $dolgraph->show($total ? 0 : 1);
294 $result .=
'</td></tr>';
298 $result .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
299 $result .=
"</table></div><br>";