dolibarr  7.0.0-beta
order.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2006-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
4  * Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  * or see http://www.gnu.org/
20  */
21 
35 {
36  global $db, $langs, $conf, $user;
37  if (! empty($conf->expedition->enabled)) $langs->load("sendings");
38  $langs->load("orders");
39 
40  $h = 0;
41  $head = array();
42 
43  if (! empty($conf->commande->enabled) && $user->rights->commande->lire)
44  {
45  $head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
46  $head[$h][1] = $langs->trans("OrderCard");
47  $head[$h][2] = 'order';
48  $h++;
49  }
50 
51  if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
52  {
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');
56  if ($nbContact > 0) $head[$h][1].= ' <span class="badge">'.$nbContact.'</span>';
57  $head[$h][2] = 'contact';
58  $h++;
59  }
60 
61  if (($conf->expedition_bon->enabled && $user->rights->expedition->lire)
62  || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->lire))
63  {
64  $nbShipments=$object->getNbOfShipments(); $nbReceiption=0;
65  $head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
66  $text='';
67  if ($conf->expedition_bon->enabled) $text.=$langs->trans("Shipments");
68  if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
69  if ($conf->livraison_bon->enabled) $text.=$langs->trans("Receivings");
70  if ($nbShipments > 0 || $nbReceiption > 0) $text.= ' <span class="badge">'.($nbShipments?$nbShipments:0);
71  if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text.='/';
72  if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text.= ($nbReceiption?$nbReceiption:0);
73  if ($nbShipments > 0 || $nbReceiption > 0) $text.= '</span>';
74  $head[$h][1] = $text;
75  $head[$h][2] = 'shipping';
76  $h++;
77  }
78 
79  // Show more tabs from modules
80  // Entries must be declared in modules descriptor with line
81  // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
82  // $this->tabs = array('entity:-tabname); to remove a tab
83  complete_head_from_modules($conf,$langs,$object,$head,$h,'order');
84 
85  if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
86  {
87  $nbNote = 0;
88  if(!empty($object->note_private)) $nbNote++;
89  if(!empty($object->note_public)) $nbNote++;
90  $head[$h][0] = DOL_URL_ROOT.'/commande/note.php?id='.$object->id;
91  $head[$h][1] = $langs->trans('Notes');
92  if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
93  $head[$h][2] = 'note';
94  $h++;
95  }
96 
97  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
98  require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
99  $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref);
100  $nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview.*\.png)$'));
101  $nbLinks=Link::count($db, $object->element, $object->id);
102  $head[$h][0] = DOL_URL_ROOT.'/commande/document.php?id='.$object->id;
103  $head[$h][1] = $langs->trans('Documents');
104  if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' <span class="badge">'.($nbFiles+$nbLinks).'</span>';
105  $head[$h][2] = 'documents';
106  $h++;
107 
108  $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$object->id;
109  $head[$h][1] = $langs->trans("Info");
110  $head[$h][2] = 'info';
111  $h++;
112 
113  complete_head_from_modules($conf,$langs,$object,$head,$h,'order','remove');
114 
115  return $head;
116 }
117 
124 {
125  global $langs, $conf, $user;
126 
127  $h = 0;
128  $head = array();
129 
130  $head[$h][0] = DOL_URL_ROOT.'/admin/commande.php';
131  $head[$h][1] = $langs->trans("Miscellaneous");
132  $head[$h][2] = 'general';
133  $h++;
134 
135  complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin');
136 
137  $head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
138  $head[$h][1] = $langs->trans("ExtraFields");
139  $head[$h][2] = 'attributes';
140  $h++;
141 
142  $head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
143  $head[$h][1] = $langs->trans("ExtraFieldsLines");
144  $head[$h][2] = 'attributeslines';
145  $h++;
146 
147  complete_head_from_modules($conf,$langs,null,$head,$h,'order_admin','remove');
148 
149  return $head;
150 }
151 
152 
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
order_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: order.lib.php:123
Class to manage customers orders.
liste_contact($statut=-1, $source='external', $list=0, $code='')
Get array of all contacts for an object.
commande_prepare_head(Commande $object)
Prepare array with list of tabs.
Definition: order.lib.php:34
getNbOfShipments()
Count numbe rof shipments for this order.