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->rights->commande->lire) {
49$hookmanager->initHooks(array(
'ordersindex'));
53$socid =
GETPOST(
'socid',
'int');
54if ($user->socid > 0) {
56 $socid = $user->socid;
59$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
62$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
63$maxLatestEditCount = 5;
64$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD;
72$companystatic =
new Societe($db);
75$help_url =
"EN:Module_Customers_Orders|FR:Module_Commandes_Clients|ES:Módulo_Pedidos_de_clientes";
77llxHeader(
"", $langs->trans(
"Orders"), $help_url);
83print
'<div class="fichecenter"><div class="fichethirdleft">';
95if (isModEnabled(
'commande')) {
96 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
98 $sql .=
", s.code_client";
100 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
101 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
102 if (empty($user->rights->societe->client->voir) && !$socid) {
103 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
105 $sql .=
" WHERE c.fk_soc = s.rowid";
106 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
107 $sql .=
" AND c.fk_statut = 0";
109 $sql .=
" AND c.fk_soc = ".((int) $socid);
111 if (empty($user->rights->societe->client->voir) && !$socid) {
112 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
115 $resql = $db->query($sql);
117 print
'<div class="div-table-responsive-no-min">';
118 print
'<table class="noborder centpercent">';
119 print
'<tr class="liste_titre">';
120 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
121 $langs->load(
"orders");
122 $num = $db->num_rows($resql);
126 $obj = $db->fetch_object($resql);
128 $commandestatic->id = $obj->rowid;
129 $commandestatic->ref = $obj->ref;
131 $companystatic->id = $obj->socid;
132 $companystatic->name = $obj->name;
133 $companystatic->client = $obj->client;
134 $companystatic->code_client = $obj->code_client;
135 $companystatic->canvas = $obj->canvas;
137 print
'<tr class="oddeven">';
138 print
'<td class="nowrap">';
139 print $commandestatic->getNomUrl(1);
141 print
'<td class="nowrap">';
142 print $companystatic->getNomUrl(1,
'company', 16);
147 print
'<tr class="oddeven"><td colspan="3">'.$langs->trans(
"NoOrder").
'</td></tr>';
149 print
"</table></div><br>";
154print
'</div><div class="fichetwothirdright">';
163$sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_cloture as datec, c.tms as datem,";
164$sql .=
" s.nom as name, s.rowid as socid";
166$sql .=
", s.code_client";
168$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c,";
169$sql .=
" ".MAIN_DB_PREFIX.
"societe as s";
170if (empty($user->rights->societe->client->voir) && !$socid) {
171 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
173$sql .=
" WHERE c.fk_soc = s.rowid";
174$sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
177 $sql .=
" AND c.fk_soc = ".((int) $socid);
179if (empty($user->rights->societe->client->voir) && !$socid) {
180 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
182$sql .=
" ORDER BY c.tms DESC";
183$sql .= $db->plimit($max, 0);
185$resql = $db->query($sql);
187 print
'<div class="div-table-responsive-no-min">';
188 print
'<table class="noborder centpercent">';
189 print
'<tr class="liste_titre">';
190 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
'</th></tr>';
192 $num = $db->num_rows($resql);
196 $obj = $db->fetch_object($resql);
198 print
'<tr class="oddeven">';
199 print
'<td width="20%" class="nowrap">';
201 $commandestatic->id = $obj->rowid;
202 $commandestatic->ref = $obj->ref;
204 $companystatic->id = $obj->socid;
205 $companystatic->name = $obj->name;
206 $companystatic->client = $obj->client;
207 $companystatic->code_client = $obj->code_client;
208 $companystatic->canvas = $obj->canvas;
210 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
211 print
'<td width="96" class="nobordernopadding nowrap">';
212 print $commandestatic->getNomUrl(1);
215 print
'<td width="16" class="nobordernopadding nowrap">';
219 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
222 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
223 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
224 print
'</td></tr></table>';
228 print
'<td class="nowrap">';
229 print $companystatic->getNomUrl(1,
'company', 16);
231 print
'<td>'.dol_print_date($db->jdate($obj->datem),
'day').
'</td>';
232 print
'<td class="right">'.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).
'</td>';
237 print
"</table></div><br>";
247if (isModEnabled(
'commande')) {
248 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
249 $sql .=
", s.client";
250 $sql .=
", s.code_client";
251 $sql .=
", s.canvas";
252 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
253 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
254 if (empty($user->rights->societe->client->voir) && !$socid) {
255 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
257 $sql .=
" WHERE c.fk_soc = s.rowid";
258 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
259 $sql .=
" AND c.fk_statut = ".Commande::STATUS_VALIDATED;
261 $sql .=
" AND c.fk_soc = ".((int) $socid);
263 if (empty($user->rights->societe->client->voir) && !$socid) {
264 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
266 $sql .=
" ORDER BY c.rowid DESC";
268 $resql = $db->query($sql);
270 $num = $db->num_rows($resql);
272 print
'<div class="div-table-responsive-no-min">';
273 print
'<table class="noborder centpercent">';
274 print
'<tr class="liste_titre">';
275 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>';
279 while ($i < $num && $i < $max) {
280 $obj = $db->fetch_object($resql);
281 print
'<tr class="oddeven">';
282 print
'<td class="nowrap" width="20%">';
284 $commandestatic->id = $obj->rowid;
285 $commandestatic->ref = $obj->ref;
287 $companystatic->id = $obj->socid;
288 $companystatic->name = $obj->name;
289 $companystatic->client = $obj->client;
290 $companystatic->code_client = $obj->code_client;
291 $companystatic->canvas = $obj->canvas;
293 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
294 print
'<td width="96" class="nobordernopadding nowrap">';
295 print $commandestatic->getNomUrl(1);
298 print
'<td width="16" class="nobordernopadding nowrap">';
302 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
305 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
306 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
307 print
'</td></tr></table>';
311 print
'<td class="nowrap">';
312 print $companystatic->getNomUrl(1,
'company', 24);
315 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
317 print
'<td class="right">'.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).
'</td>';
323 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
327 print
"</table></div><br>";
336if (isModEnabled(
'commande')) {
337 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut, c.facture, c.date_commande as date, s.nom as name, s.rowid as socid";
338 $sql .=
", s.client";
339 $sql .=
", s.code_client";
340 $sql .=
", s.canvas";
341 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande as c";
342 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
343 if (empty($user->rights->societe->client->voir) && !$socid) {
344 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
346 $sql .=
" WHERE c.fk_soc = s.rowid";
347 $sql .=
" AND c.entity IN (".getEntity(
'commande').
")";
348 $sql .=
" AND c.fk_statut = ".((int) Commande::STATUS_ACCEPTED);
350 $sql .=
" AND c.fk_soc = ".((int) $socid);
352 if (empty($user->rights->societe->client->voir) && !$socid) {
353 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
355 $sql .=
" ORDER BY c.rowid DESC";
357 $resql = $db->query($sql);
359 $num = $db->num_rows($resql);
361 print
'<div class="div-table-responsive-no-min">';
362 print
'<table class="noborder centpercent">';
363 print
'<tr class="liste_titre">';
364 print
'<th colspan="4">'.$langs->trans(
"OnProcessOrders").
' <a href="'.DOL_URL_ROOT.
'/commande/list.php?search_status='.Commande::STATUS_ACCEPTED.
'"><span class="badge">'.$num.
'</span></a></th></tr>';
368 while ($i < $num && $i < $max) {
369 $obj = $db->fetch_object($resql);
370 print
'<tr class="oddeven">';
371 print
'<td width="20%" class="nowrap">';
373 $commandestatic->id = $obj->rowid;
374 $commandestatic->ref = $obj->ref;
376 $companystatic->id = $obj->socid;
377 $companystatic->name = $obj->name;
378 $companystatic->client = $obj->client;
379 $companystatic->code_client = $obj->code_client;
380 $companystatic->canvas = $obj->canvas;
382 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
383 print
'<td width="96" class="nobordernopadding nowrap">';
384 print $commandestatic->getNomUrl(1);
387 print
'<td width="16" class="nobordernopadding nowrap">';
391 print
'<td width="16" class="nobordernopadding hideonsmartphone right">';
394 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
395 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
396 print
'</td></tr></table>';
401 print $companystatic->getNomUrl(1,
'company');
404 print
'<td class="right">'.dol_print_date($db->jdate($obj->date),
'day').
'</td>'.
"\n";
406 print
'<td class="right">'.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).
'</td>';
412 print
'<tr><td><span class="opacitymedium">'.$langs->trans(
"More").
'...</span></td><td></td><td></td><td></td></tr>';
415 print
"</table></div><br>";
424$parameters = array(
'user' => $user);
425$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()
Empty header.
Class to manage customers orders.
const STATUS_VALIDATED
Validated status.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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.