37 global $db, $langs,
$conf, $user;
38 if (isModEnabled(
"shipping")) {
39 $langs->load(
"sendings");
41 $langs->load(
"orders");
46 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
47 $head[$h][0] = DOL_URL_ROOT.
'/commande/card.php?id='.
$object->id;
48 $head[$h][1] = $langs->trans(
"CustomerOrder");
49 $head[$h][2] =
'order';
54 $nbContact = count(
$object->liste_contact(-1,
'internal')) + count(
$object->liste_contact(-1,
'external'));
55 $head[$h][0] = DOL_URL_ROOT.
'/commande/contact.php?id='.
$object->id;
56 $head[$h][1] = $langs->trans(
'ContactsAddresses');
58 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
60 $head[$h][2] =
'contact';
64 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'lire'))
65 || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'lire'))) {
66 $nbShipments =
$object->getNbOfShipments();
68 $head[$h][0] = DOL_URL_ROOT.
'/expedition/shipment.php?id='.
$object->id;
71 $text .= $langs->trans(
"Shipments");
77 $text .= $langs->trans(
"Receivings");
79 if ($nbShipments > 0 || $nbReceiption > 0) {
80 $text .=
'<span class="badge marginleftonlyshort">'.($nbShipments ? $nbShipments : 0);
86 $text .= ($nbReceiption ? $nbReceiption : 0);
88 if ($nbShipments > 0 || $nbReceiption > 0) {
92 $head[$h][2] =
'shipping';
104 if (!empty(
$object->note_private)) {
107 if (!empty(
$object->note_public)) {
110 $head[$h][0] = DOL_URL_ROOT.
'/commande/note.php?id='.
$object->id;
111 $head[$h][1] = $langs->trans(
'Notes');
113 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
115 $head[$h][2] =
'note';
119 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
120 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
122 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
124 $head[$h][0] = DOL_URL_ROOT.
'/commande/document.php?id='.
$object->id;
125 $head[$h][1] = $langs->trans(
'Documents');
126 if (($nbFiles + $nbLinks) > 0) {
127 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
129 $head[$h][2] =
'documents';
133 $head[$h][0] = DOL_URL_ROOT.
'/commande/agenda.php?id='.
$object->id;
134 $head[$h][1] = $langs->trans(
"Events");
135 if (isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
138 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
139 $cachekey =
'count_events_propal_'.$object->id;
141 if (!is_null($dataretrieved)) {
142 $nbEvent = $dataretrieved;
144 $sql =
"SELECT COUNT(id) as nb";
145 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
146 $sql .=
" WHERE fk_element = ".((int)
$object->id);
147 $sql .=
" AND elementtype = 'order'";
148 $resql = $db->query($sql);
150 $obj = $db->fetch_object($resql);
153 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
159 $head[$h][1] .= $langs->trans(
"Agenda");
161 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
164 $head[$h][2] =
'agenda';
181 global $langs,
$conf, $user, $db;
184 $extrafields->fetch_name_optionals_label(
'commande');
185 $extrafields->fetch_name_optionals_label(
'commandedet');
190 $head[$h][0] = DOL_URL_ROOT.
'/admin/order.php';
191 $head[$h][1] = $langs->trans(
"Miscellaneous");
192 $head[$h][2] =
'general';
195 $head[$h][0] = DOL_URL_ROOT.
'/admin/order_pdf.php';
196 $head[$h][1] = $langs->trans(
"PDF");
197 $head[$h][2] =
'pdf';
202 $head[$h][0] = DOL_URL_ROOT.
'/admin/order_extrafields.php';
203 $head[$h][1] = $langs->trans(
"ExtraFields");
204 $nbExtrafields = $extrafields->attributes[
'commande'][
'count'];
205 if ($nbExtrafields > 0) {
206 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
208 $head[$h][2] =
'attributes';
211 $head[$h][0] = DOL_URL_ROOT.
'/admin/orderdet_extrafields.php';
212 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
213 $nbExtrafields = $extrafields->attributes[
'commandedet'][
'count'];
214 if ($nbExtrafields > 0) {
215 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
217 $head[$h][2] =
'attributeslines';
235 global
$conf, $db, $langs, $user;
239 if (!isModEnabled(
'order') || !$user->hasRight(
'commande',
'lire')) {
243 $commandestatic =
new Commande($db);
248 if ($user->socid > 0) $socid = $user->socid;
249 $sql =
"SELECT count(c.rowid) as nb, c.fk_statut as status";
250 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
251 $sql .=
", ".MAIN_DB_PREFIX.
"commande as c";
252 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
253 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
255 $sql .=
" WHERE c.fk_soc = s.rowid";
256 $sql .=
" AND c.entity IN (".getEntity($commandestatic->element).
")";
258 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
260 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
261 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
263 $sql .=
" GROUP BY c.fk_statut";
265 $resql = $db->query($sql);
267 $num = $db->num_rows($resql);
272 $dataseries = array();
273 $colorseries = array();
277 $row = $db->fetch_row($resql);
279 if (!isset($vals[$row[1]])) {
282 $vals[$row[1]] += $row[0];
283 $totalinprocess += $row[0];
290 global $badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus6, $badgeStatus9;
291 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
293 $result =
'<div class="div-table-responsive-no-min">';
294 $result .=
'<table class="noborder nohover centpercent">';
295 $result .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CustomersOrders").
'</th></tr>'.
"\n";
296 $listofstatus = array(0, 1, 2, 3, -1);
297 foreach ($listofstatus as $status) {
298 $dataseries[] = array($commandestatic->LibStatut($status, 0, 1, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
300 $colorseries[$status] =
'-'.$badgeStatus0;
303 $colorseries[$status] = $badgeStatus1;
306 $colorseries[$status] = $badgeStatus4;
309 $colorseries[$status] = $badgeStatus6;
312 $colorseries[$status] = $badgeStatus9;
315 if (empty(
$conf->use_javascript_ajax)) {
316 $result .=
'<tr class="oddeven">';
317 $result .=
'<td>'.$commandestatic->LibStatut($status, 0, 0, 1).
'</td>';
318 $result .=
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
' ';
319 $result .= $commandestatic->LibStatut($status, 0, 3, 1);
320 $result .=
'</a></td>';
321 $result .=
"</tr>\n";
324 if (!empty(
$conf->use_javascript_ajax)) {
325 $result .=
'<tr class="oddeven"><td align="center" colspan="2">';
327 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
329 $dolgraph->SetData($dataseries);
330 $dolgraph->SetDataColor(array_values($colorseries));
331 $dolgraph->setShowLegend(2);
332 $dolgraph->setShowPercent(1);
333 $dolgraph->SetType(array(
'pie'));
334 $dolgraph->setHeight(
'150');
335 $dolgraph->setWidth(
'300');
336 $dolgraph->draw(
'idgraphstatus');
337 $result .= $dolgraph->show($total ? 0 : 1);
339 $result .=
'</td></tr>';
343 $result .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
344 $result .=
"</table></div><br>";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_CLOSED
Closed (Sent, billed or not)
const STATUS_CANCELED
Canceled status.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
static count($dbs, $objecttype, $objectid)
Return nb of links.
dol_dir_list($utf8_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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
dol_setcache($memoryid, $data, $expire=0, $filecache=0, $replace=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid, $filecache=0)
Read a memory area shared by all users, all sessions on server.
order_admin_prepare_head()
Return array head with list of tabs to view object information.
getCustomerOrderPieChart($socid=0)
Return a HTML table that contains a pie chart of sales orders.
commande_prepare_head(Commande $object)
Prepare array with list of tabs.