38 global $db, $langs,
$conf, $user;
41 $langs->load(
"sendings");
43 $langs->load(
"orders");
48 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'lire')) {
49 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/commande/card.php', [
'id' =>
$object->id]);
50 $head[$h][1] = $langs->trans(
"CustomerOrder");
51 $head[$h][2] =
'order';
56 $nbContact = count(
$object->liste_contact(-1,
'internal')) + count(
$object->liste_contact(-1,
'external'));
57 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/commande/contact.php', [
'id' =>
$object->id]);
58 $head[$h][1] = $langs->trans(
'ContactsAddresses');
60 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbContact.
'</span>';
62 $head[$h][2] =
'contact';
66 if ((
getDolGlobalInt(
'MAIN_SUBMODULE_EXPEDITION') && $user->hasRight(
'expedition',
'lire'))
67 || (
getDolGlobalInt(
'MAIN_SUBMODULE_DELIVERY') && $user->hasRight(
'expedition',
'delivery',
'lire'))) {
68 $nbShipments =
$object->getNbOfShipments();
70 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/expedition/shipment.php', [
'id' =>
$object->id]);
73 $text .= $langs->trans(
"Shipments");
79 $text .= $langs->trans(
"Receivings");
81 if ($nbShipments > 0 || $nbReceiption > 0) {
82 $text .=
'<span class="badge marginleftonlyshort">'.($nbShipments ? $nbShipments : 0);
88 $text .= ($nbReceiption ? $nbReceiption : 0);
90 if ($nbShipments > 0 || $nbReceiption > 0) {
94 $head[$h][2] =
'shipping';
106 if (!empty(
$object->note_private)) {
109 if (!empty(
$object->note_public)) {
112 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/commande/note.php', [
'id' =>
$object->id]);
113 $head[$h][1] = $langs->trans(
'Notes');
115 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbNote.
'</span>';
117 $head[$h][2] =
'note';
121 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
122 require_once DOL_DOCUMENT_ROOT.
'/core/class/link.class.php';
124 $nbFiles = count(
dol_dir_list($upload_dir,
'files', 0,
'',
'(\.meta|_preview.*\.png)$'));
126 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/commande/document.php', [
'id' =>
$object->id]);
127 $head[$h][1] = $langs->trans(
'Documents');
128 if (($nbFiles + $nbLinks) > 0) {
129 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).
'</span>';
131 $head[$h][2] =
'documents';
135 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/commande/agenda.php', [
'id' =>
$object->id]);
136 $head[$h][1] = $langs->trans(
"Events");
137 if (
isModEnabled(
'agenda') && ($user->hasRight(
'agenda',
'myactions',
'read') || $user->hasRight(
'agenda',
'allactions',
'read'))) {
140 require_once DOL_DOCUMENT_ROOT.
'/core/lib/memory.lib.php';
141 $cachekey =
'count_events_propal_'.$object->id;
143 if (!is_null($dataretrieved)) {
144 $nbEvent = $dataretrieved;
146 $sql =
"SELECT COUNT(id) as nb";
147 $sql .=
" FROM ".MAIN_DB_PREFIX.
"actioncomm";
148 $sql .=
" WHERE fk_element = ".((int)
$object->id);
149 $sql .=
" AND elementtype = 'order'";
150 $resql = $db->query($sql);
152 $obj = $db->fetch_object($resql);
155 dol_syslog(
'Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
161 $head[$h][1] .= $langs->trans(
"Agenda");
163 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbEvent.
'</span>';
166 $head[$h][2] =
'agenda';
183 global $langs,
$conf, $extrafields;
185 $extrafields->fetch_name_optionals_label(
'commande');
186 $extrafields->fetch_name_optionals_label(
'commandedet');
191 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT .
'/admin/order.php');
192 $head[$h][1] = $langs->trans(
"Miscellaneous");
193 $head[$h][2] =
'general';
198 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/extrafields.php', array(
'elementtype' =>
'commande'));
199 $head[$h][1] = $langs->trans(
"ExtraFields");
200 $nbExtrafields = $extrafields->attributes[
'commande'][
'count'];
201 if ($nbExtrafields > 0) {
202 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
204 $head[$h][2] =
'attributes';
207 $head[$h][0] =
dolBuildUrl(DOL_URL_ROOT.
'/admin/extrafields.php', array(
'elementtype' =>
'commandedet'));
208 $head[$h][1] = $langs->trans(
"ExtraFieldsLines");
209 $nbExtrafields = $extrafields->attributes[
'commandedet'][
'count'];
210 if ($nbExtrafields > 0) {
211 $head[$h][1] .=
'<span class="badge marginleftonlyshort">'.$nbExtrafields.
'</span>';
213 $head[$h][2] =
'attributeslines';
231 global
$conf, $db, $langs, $user, $hookmanager;
235 if (!
isModEnabled(
'order') || !$user->hasRight(
'commande',
'lire')) {
239 $commandestatic =
new Commande($db);
244 if ($user->socid > 0) $socid = $user->socid;
245 $sql =
"SELECT count(c.rowid) as nb, c.fk_statut as status";
246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
247 $sql .=
", ".MAIN_DB_PREFIX.
"commande as c";
248 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
249 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
251 $sql .=
" WHERE c.fk_soc = s.rowid";
252 $sql .=
" AND c.entity IN (".getEntity($commandestatic->element).
")";
254 $sql .=
' AND c.fk_soc = '.((int) $user->socid);
256 if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
257 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
260 $parameters = array(
'socid' => $user->socid);
261 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $commandestatic);
262 $sql .= $hookmanager->resPrint;
263 $sql .=
" GROUP BY c.fk_statut";
265 $resql = $db->query($sql);
268 while ($row = $db->fetch_row($resql)) {
269 if (!isset($vals[$row[1]])) {
272 $vals[$row[1]] += $row[0];
276 require_once DOL_DOCUMENT_ROOT.
'/core/lib/dashboard.lib.php';
278 $colorofstatus = array(
287 foreach (array(0, 1, 2, 3, -1) as $status) {
289 'label' => $commandestatic->LibStatut($status, 0, 1, 1),
290 'labelnojs' => $commandestatic->LibStatut($status, 0, 0, 1),
291 'nb' => (isset($vals[$status]) ? (
int) $vals[$status] : 0),
292 'color' => $colorofstatus[$status],
293 'url' => DOL_URL_ROOT.
'/commande/list.php?search_status='.$status,
297 $result =
getStatusPieChart($langs->trans(
"Statistics").
' - '.$langs->trans(
"CustomersOrders"), $series, array(
'height' => 150,
'width' => 300));
299 dol_print_error($db);
if(! $sortfield) if(! $sortorder) $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.
getThemeBadgeStatusColors()
Return the colors of status badges defined by the current theme (theme_vars.inc.php)
getStatusPieChart($title, $series, $options=array())
Return the HTML table with a pie chart of values by status, as shown on the home page of a module.
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.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.