30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/notify.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/order.lib.php';
46$langs->loadLangs(array(
'orders',
'bills'));
49if (!$user->hasRight(
'commande',
'lire')) {
56$hookmanager->initHooks(array(
'ordersindex'));
61if ($user->socid > 0) {
63 $socid = $user->socid;
69$maxLatestEditCount = 5;
78$companystatic =
new Societe($db);
81$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
83llxHeader(
'', $langs->trans(
"Orders"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-commande page-index');
89print
'<div class="fichecenter"><div class="fichethirdleft">';
101if (isModEnabled(
'order')) {
102 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
103 $sql .=
", s.client";
104 $sql .=
", s.code_client";
105 $sql .=
", s.canvas";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
107 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
108 if (!$user->hasRight(
'societe',
'client',
'voir')) {
109 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
111 $sql .=
" WHERE c.fk_soc = s.rowid";
112 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
113 $sql .=
" AND c.fk_statut = 0";
115 $sql .=
" AND c.fk_soc = ".((int) $socid);
117 if (!$user->hasRight(
'societe',
'client',
'voir')) {
118 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
121 $resql = $db->query($sql);
123 print
'<div class="div-table-responsive-no-min">';
124 print
'<table class="noborder centpercent">';
125 print
'<tr class="liste_titre">';
126 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
127 $langs->load(
"orders");
128 $num = $db->num_rows($resql);
132 $obj = $db->fetch_object($resql);
134 $commandestatic->id = $obj->rowid;
135 $commandestatic->ref = $obj->ref;
137 $companystatic->id = $obj->socid;
138 $companystatic->name = $obj->name;
139 $companystatic->client = $obj->client;
140 $companystatic->code_client = $obj->code_client;
141 $companystatic->canvas = $obj->canvas;
143 print
'<tr class="oddeven">';
144 print
'<td class="nowrap">';
145 print $commandestatic->getNomUrl(1);
147 print
'<td class="nowrap">';
148 print $companystatic->getNomUrl(1,
'company', 16);
153 print
'<tr class="oddeven"><td colspan="3">'.$langs->trans(
"NoOrder").
'</td></tr>';
155 print
"</table></div><br>";
160print
'</div><div class="fichetwothirdright">';
167$sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_cloture as datec, c.tms as datem,";
168$sql .=
" s.nom as name, s.rowid as socid";
170$sql .=
", s.code_client";
172$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
173$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
174if (!$user->hasRight(
'societe',
'client',
'voir')) {
175 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
177$sql .=
" WHERE c.fk_soc = s.rowid";
178$sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
181 $sql .=
" AND c.fk_soc = ".((int) $socid);
183if (!$user->hasRight(
'societe',
'client',
'voir')) {
184 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
186$sql .=
" ORDER BY c.tms DESC";
187$sql .= $db->plimit($max, 0);
189$resql = $db->query($sql);
191 $num = $db->num_rows($resql);
193 startSimpleTable($langs->trans(
"LastModifiedOrders", $max),
"commande/list.php",
"sortfield=c.tms&sortorder=DESC", 2, -1,
'order');
198 $obj = $db->fetch_object($resql);
200 print
'<tr class="oddeven">';
201 print
'<td width="20%" class="nowrap">';
203 $commandestatic->id = $obj->rowid;
204 $commandestatic->ref = $obj->ref;
206 $companystatic->id = $obj->socid;
207 $companystatic->name = $obj->name;
208 $companystatic->client = $obj->client;
209 $companystatic->code_client = $obj->code_client;
210 $companystatic->canvas = $obj->canvas;
212 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
213 print
'<td width="96" class="nobordernopadding nowrap">';
214 print $commandestatic->getNomUrl(1);
217 print
'<td width="16" class="nobordernopadding nowrap">';
221 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
224 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
225 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
226 print
'</td></tr></table>';
230 print
'<td class="nowrap">';
231 print $companystatic->getNomUrl(1,
'company', 16);
234 $datem = $db->jdate($obj->datem);
235 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
239 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
253if (isModEnabled(
'order')) {
254 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
255 $sql .=
", s.client";
256 $sql .=
", s.code_client";
257 $sql .=
", s.canvas";
258 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
259 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
260 if (!$user->hasRight(
'societe',
'client',
'voir')) {
261 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
263 $sql .=
" WHERE c.fk_soc = s.rowid";
264 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
265 $sql .=
" AND c.fk_statut = ".Commande::STATUS_VALIDATED;
267 $sql .=
" AND c.fk_soc = ".((int) $socid);
269 if (!$user->hasRight(
'societe',
'client',
'voir')) {
270 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
272 $sql .=
" ORDER BY c.rowid DESC";
274 $resql = $db->query($sql);
276 $num = $db->num_rows($resql);
278 print
'<div class="div-table-responsive-no-min">';
279 print
'<table class="noborder centpercent">';
280 print
'<tr class="liste_titre">';
281 print
'<th colspan="4">'.$langs->trans(
"OrdersToProcess").
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?search_status='.
Commande::STATUS_VALIDATED.
'"><span class="badge">'.$num.
'</span></a></th></tr>';
285 while ($i < $num && $i < $max) {
286 $obj = $db->fetch_object($resql);
287 print
'<tr class="oddeven">';
288 print
'<td class="nowrap" width="20%">';
290 $commandestatic->id = $obj->rowid;
291 $commandestatic->ref = $obj->ref;
293 $companystatic->id = $obj->socid;
294 $companystatic->name = $obj->name;
295 $companystatic->client = $obj->client;
296 $companystatic->code_client = $obj->code_client;
297 $companystatic->canvas = $obj->canvas;
299 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
300 print
'<td width="96" class="nobordernopadding nowrap">';
301 print $commandestatic->getNomUrl(1);
304 print
'<td width="16" class="nobordernopadding nowrap">';
308 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
311 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
312 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
313 print
'</td></tr></table>';
317 print
'<td class="nowrap">';
318 print $companystatic->getNomUrl(1,
'company', 24);
321 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
323 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
329 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
333 print
"</table></div><br>";
342if (isModEnabled(
'order')) {
343 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
344 $sql .=
", s.client";
345 $sql .=
", s.code_client";
346 $sql .=
", s.canvas";
347 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
348 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
349 if (!$user->hasRight(
'societe',
'client',
'voir')) {
350 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
352 $sql .=
" WHERE c.fk_soc = s.rowid";
353 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
356 $sql .=
" AND c.fk_soc = ".((int) $socid);
358 if (!$user->hasRight(
'societe',
'client',
'voir')) {
359 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
361 $sql .=
" ORDER BY c.rowid DESC";
363 $resql = $db->query($sql);
365 $num = $db->num_rows($resql);
367 print
'<div class="div-table-responsive-no-min">';
368 print
'<table class="noborder centpercent">';
369 print
'<tr class="liste_titre">';
370 print
'<th colspan="4">'.$langs->trans(
"OnProcessOrders").
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?search_status='.
Commande::STATUS_SHIPMENTONPROCESS.
'"><span class="badge">'.$num.
'</span></a></th></tr>';
374 while ($i < $num && $i < $max) {
375 $obj = $db->fetch_object($resql);
376 print
'<tr class="oddeven">';
377 print
'<td width="20%" class="nowrap">';
379 $commandestatic->id = $obj->rowid;
380 $commandestatic->ref = $obj->ref;
382 $companystatic->id = $obj->socid;
383 $companystatic->name = $obj->name;
384 $companystatic->client = $obj->client;
385 $companystatic->code_client = $obj->code_client;
386 $companystatic->canvas = $obj->canvas;
388 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
389 print
'<td width="96" class="nobordernopadding nowrap">';
390 print $commandestatic->getNomUrl(1);
393 print
'<td width="16" class="nobordernopadding nowrap">';
397 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
400 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
401 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
402 print
'</td></tr></table>';
407 print $companystatic->getNomUrl(1,
'company');
410 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
412 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
418 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
421 print
"</table></div><br>";
430$parameters = array(
'user' => $user);
431$reshook = $hookmanager->executeHooks(
'dashboardOrders', $parameters, $object);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage customers orders.
const STATUS_SHIPMENTONPROCESS
Shipment on process.
const STATUS_VALIDATED
Validated status.
Class to manage third parties objects (customers, suppliers, prospects...)
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line)
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
startSimpleTable($header, $link="", $arguments="", $emptyColumns=0, $number=-1, $pictofulllist='')
Start a table with headers and a optional clickable number (don't forget to use "finishSimpleTable()"...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
getCustomerOrderPieChart($socid=0)
Return a HTML table that contains a pie chart of sales orders.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.