36 global $db, $langs, $conf, $user;
37 if (isModEnabled(
"expedition")) {
38 $langs->load(
"sendings");
40 $langs->load(
"orders");
45 if (isModEnabled(
'commande') && $user->hasRight(
'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 ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'lire'))
64 || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'lire'))) {
65 $nbShipments = $object->getNbOfShipments();
67 $head[$h][0] = DOL_URL_ROOT.
'/expedition/shipment.php?id='.$object->id;
70 $text .= $langs->trans(
"Shipments");
76 $text .= $langs->trans(
"Receivings");
78 if ($nbShipments > 0 || $nbReceiption > 0) {
79 $text .=
'<span class="badge marginleftonlyshort">'.($nbShipments ? $nbShipments : 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';
132 $head[$h][0] = DOL_URL_ROOT.
'/commande/agenda.php?id='.$object->id;
133 $head[$h][1] = $langs->trans(
"Events");
134 if (isModEnabled(
'agenda')&& ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
137 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
138 $cachekey =
'count_events_propal_'.$object->id;
140 if (!is_null($dataretrieved)) {
141 $nbEvent = $dataretrieved;
143 $sql =
"SELECT COUNT(id) as nb";
144 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
145 $sql .=
" WHERE fk_element = ".((int) $object->id);
146 $sql .=
" AND elementtype = 'order'";
147 $resql = $db->query($sql);
149 $obj = $db->fetch_object($resql);
152 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
158 $head[$h][1] .= $langs->trans(
"Agenda");
160 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
163 $head[$h][2] =
'agenda';
180 global $langs, $conf, $user, $db;
183 $extrafields->fetch_name_optionals_label(
'commande');
184 $extrafields->fetch_name_optionals_label(
'commandedet');
189 $head[$h][0] = DOL_URL_ROOT.
'/admin/commande.php';
190 $head[$h][1] = $langs->trans(
"Miscellaneous");
191 $head[$h][2] =
'general';
196 $head[$h][0] = DOL_URL_ROOT.
'/admin/order_extrafields.php';
197 $head[$h][1] = $langs->trans(
"ExtraFields");
198 $nbExtrafields = $extrafields->attributes[
'commande'][
'count'];
199 if ($nbExtrafields > 0) {
200 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
202 $head[$h][2] =
'attributes';
205 $head[$h][0] = DOL_URL_ROOT.
'/admin/orderdet_extrafields.php';
206 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
207 $nbExtrafields = $extrafields->attributes[
'commandedet'][
'count'];
208 if ($nbExtrafields > 0) {
209 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
211 $head[$h][2] =
'attributeslines';
229 global $conf, $db, $langs, $user;
233 if (!isModEnabled(
'commande') || !$user->hasRight(
'commande',
'lire')) {
237 $commandestatic =
new Commande($db);
243 $sql =
"SELECT count(c.rowid) as nb, c.fk_statut as status";
244 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
245 $sql .=
", ".MAIN_DB_PREFIX.
"commande as c";
246 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
247 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
249 $sql .=
" WHERE c.fk_soc = s.rowid";
250 $sql .=
" AND c.entity IN (".getEntity($commandestatic->element).
")";
252 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
254 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
255 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
257 $sql .=
" GROUP BY c.fk_statut";
259 $resql = $db->query($sql);
261 $num = $db->num_rows($resql);
266 $dataseries = array();
267 $colorseries = array();
271 $row = $db->fetch_row($resql);
273 if (!isset($vals[$row[1]])) {
276 $vals[$row[1]] += $row[0];
277 $totalinprocess += $row[0];
284 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
286 $result =
'<div class="div-table-responsive-no-min">';
287 $result .=
'<table class="noborder nohover centpercent">';
288 $result .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CustomersOrders").
'</th></tr>'.
"\n";
289 $listofstatus = array(0, 1, 2, 3, -1);
290 foreach ($listofstatus as $status) {
291 $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
293 $colorseries[$status] =
'-'.$badgeStatus0;
296 $colorseries[$status] = $badgeStatus1;
299 $colorseries[$status] = $badgeStatus4;
302 $colorseries[$status] = $badgeStatus6;
305 $colorseries[$status] = $badgeStatus6;
308 $colorseries[$status] = $badgeStatus9;
311 if (empty($conf->use_javascript_ajax)) {
312 $result .=
'<tr class="oddeven">';
313 $result .=
'<td>'.$commandestatic->LibStatut($status, 0, 0, 1).
'</td>';
314 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
' ';
315 $result .= $commandestatic->LibStatut($status, 0, 3, 1);
316 $result .=
'</a></td>';
317 $result .=
"</tr>\n";
320 if (!empty($conf->use_javascript_ajax)) {
321 $result .=
'<tr class="impair"><td align="center" colspan="2">';
323 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
325 $dolgraph->SetData($dataseries);
326 $dolgraph->SetDataColor(array_values($colorseries));
327 $dolgraph->setShowLegend(2);
328 $dolgraph->setShowPercent(1);
329 $dolgraph->SetType(array(
'pie'));
330 $dolgraph->setHeight(
'150');
331 $dolgraph->setWidth(
'300');
332 $dolgraph->draw(
'idgraphstatus');
333 $result .= $dolgraph->show($total ? 0 : 1);
335 $result .=
'</td></tr>';
339 $result .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
340 $result .=
"</table></div><br>";
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.