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';
39$langs->loadLangs(array(
'orders',
'bills'));
42if (!$user->hasRight(
'commande',
'lire')) {
49$hookmanager->initHooks(array(
'ordersindex'));
54if ($user->socid > 0) {
56 $socid = $user->socid;
61$maxDraftCount = !
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
62$maxLatestEditCount = 5;
63$maxOpenCount = !
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
71$companystatic =
new Societe($db);
74$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
76llxHeader(
'', $langs->trans(
"Orders"), $help_url,
'', 0, 0,
'',
'',
'',
'mod-commande page-index');
82print
'<div class="fichecenter"><div class="fichethirdleft">';
94if (isModEnabled(
'order')) {
95 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
97 $sql .=
", s.code_client";
99 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
100 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
101 if (!$user->hasRight(
'societe',
'client',
'voir')) {
102 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
104 $sql .=
" WHERE c.fk_soc = s.rowid";
105 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
106 $sql .=
" AND c.fk_statut = 0";
108 $sql .=
" AND c.fk_soc = ".((int) $socid);
110 if (!$user->hasRight(
'societe',
'client',
'voir')) {
111 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
114 $resql = $db->query($sql);
116 print
'<div class="div-table-responsive-no-min">';
117 print
'<table class="noborder centpercent">';
118 print
'<tr class="liste_titre">';
119 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
120 $langs->load(
"orders");
121 $num = $db->num_rows($resql);
125 $obj = $db->fetch_object($resql);
127 $commandestatic->id = $obj->rowid;
128 $commandestatic->ref = $obj->ref;
130 $companystatic->id = $obj->socid;
131 $companystatic->name = $obj->name;
132 $companystatic->client = $obj->client;
133 $companystatic->code_client = $obj->code_client;
134 $companystatic->canvas = $obj->canvas;
136 print
'<tr class="oddeven">';
137 print
'<td class="nowrap">';
138 print $commandestatic->getNomUrl(1);
140 print
'<td class="nowrap">';
141 print $companystatic->getNomUrl(1,
'company', 16);
146 print
'<tr class="oddeven"><td colspan="3">'.$langs->trans(
"NoOrder").
'</td></tr>';
148 print
"</table></div><br>";
153print
'</div><div class="fichetwothirdright">';
160$sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut as status, c.facture, c.date_cloture as datec, c.tms as datem,";
161$sql .=
" s.nom as name, s.rowid as socid";
163$sql .=
", s.code_client";
165$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
166$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
167if (!$user->hasRight(
'societe',
'client',
'voir')) {
168 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
170$sql .=
" WHERE c.fk_soc = s.rowid";
171$sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
174 $sql .=
" AND c.fk_soc = ".((int) $socid);
176if (!$user->hasRight(
'societe',
'client',
'voir')) {
177 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
179$sql .=
" ORDER BY c.tms DESC";
180$sql .= $db->plimit($max, 0);
182$resql = $db->query($sql);
184 $num = $db->num_rows($resql);
186 startSimpleTable($langs->trans(
"LastModifiedOrders", $max),
"commande/list.php",
"sortfield=c.tms&sortorder=DESC", 2, -1,
'order');
191 $obj = $db->fetch_object($resql);
193 print
'<tr class="oddeven">';
194 print
'<td width="20%" class="nowrap">';
196 $commandestatic->id = $obj->rowid;
197 $commandestatic->ref = $obj->ref;
199 $companystatic->id = $obj->socid;
200 $companystatic->name = $obj->name;
201 $companystatic->client = $obj->client;
202 $companystatic->code_client = $obj->code_client;
203 $companystatic->canvas = $obj->canvas;
205 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
206 print
'<td width="96" class="nobordernopadding nowrap">';
207 print $commandestatic->getNomUrl(1);
210 print
'<td width="16" class="nobordernopadding nowrap">';
214 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
217 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
218 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
219 print
'</td></tr></table>';
223 print
'<td class="nowrap">';
224 print $companystatic->getNomUrl(1,
'company', 16);
227 $datem = $db->jdate($obj->datem);
228 print
'<td class="center" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
': '.
dol_print_date($datem,
'dayhour',
'tzuserrel')).
'">';
232 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
246if (isModEnabled(
'order')) {
247 $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";
248 $sql .=
", s.client";
249 $sql .=
", s.code_client";
250 $sql .=
", s.canvas";
251 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
252 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
253 if (!$user->hasRight(
'societe',
'client',
'voir')) {
254 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
256 $sql .=
" WHERE c.fk_soc = s.rowid";
257 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
258 $sql .=
" AND c.fk_statut = ".Commande::STATUS_VALIDATED;
260 $sql .=
" AND c.fk_soc = ".((int) $socid);
262 if (!$user->hasRight(
'societe',
'client',
'voir')) {
263 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
265 $sql .=
" ORDER BY c.rowid DESC";
267 $resql = $db->query($sql);
269 $num = $db->num_rows($resql);
271 print
'<div class="div-table-responsive-no-min">';
272 print
'<table class="noborder centpercent">';
273 print
'<tr class="liste_titre">';
274 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>';
278 while ($i < $num && $i < $max) {
279 $obj = $db->fetch_object($resql);
280 print
'<tr class="oddeven">';
281 print
'<td class="nowrap" width="20%">';
283 $commandestatic->id = $obj->rowid;
284 $commandestatic->ref = $obj->ref;
286 $companystatic->id = $obj->socid;
287 $companystatic->name = $obj->name;
288 $companystatic->client = $obj->client;
289 $companystatic->code_client = $obj->code_client;
290 $companystatic->canvas = $obj->canvas;
292 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
293 print
'<td width="96" class="nobordernopadding nowrap">';
294 print $commandestatic->getNomUrl(1);
297 print
'<td width="16" class="nobordernopadding nowrap">';
301 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
304 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
305 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
306 print
'</td></tr></table>';
310 print
'<td class="nowrap">';
311 print $companystatic->getNomUrl(1,
'company', 24);
314 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
316 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
322 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
326 print
"</table></div><br>";
335if (isModEnabled(
'order')) {
336 $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";
337 $sql .=
", s.client";
338 $sql .=
", s.code_client";
339 $sql .=
", s.canvas";
340 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
341 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
342 if (!$user->hasRight(
'societe',
'client',
'voir')) {
343 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
345 $sql .=
" WHERE c.fk_soc = s.rowid";
346 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
349 $sql .=
" AND c.fk_soc = ".((int) $socid);
351 if (!$user->hasRight(
'societe',
'client',
'voir')) {
352 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
354 $sql .=
" ORDER BY c.rowid DESC";
356 $resql = $db->query($sql);
358 $num = $db->num_rows($resql);
360 print
'<div class="div-table-responsive-no-min">';
361 print
'<table class="noborder centpercent">';
362 print
'<tr class="liste_titre">';
363 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>';
367 while ($i < $num && $i < $max) {
368 $obj = $db->fetch_object($resql);
369 print
'<tr class="oddeven">';
370 print
'<td width="20%" class="nowrap">';
372 $commandestatic->id = $obj->rowid;
373 $commandestatic->ref = $obj->ref;
375 $companystatic->id = $obj->socid;
376 $companystatic->name = $obj->name;
377 $companystatic->client = $obj->client;
378 $companystatic->code_client = $obj->code_client;
379 $companystatic->canvas = $obj->canvas;
381 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
382 print
'<td width="96" class="nobordernopadding nowrap">';
383 print $commandestatic->getNomUrl(1);
386 print
'<td width="16" class="nobordernopadding nowrap">';
390 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
393 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
394 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
395 print
'</td></tr></table>';
400 print $companystatic->getNomUrl(1,
'company');
403 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
405 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, $obj->facture, 3).
'</td>';
411 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
414 print
"</table></div><br>";
423$parameters = array(
'user' => $user);
424$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()"...
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.