31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
38$langs->loadLangs(array(
"suppliers",
"orders"));
43$hookmanager->initHooks(array(
'orderssuppliersindex'));
50 $socid = $user->socid;
52$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
59llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-supplier-order page-stats');
62$userstatic =
new User($db);
65print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
67print
'<div class="fichecenter"><div class="fichethirdleft">';
73$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
74$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
75$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
76if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
77 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
79$sql .=
" WHERE cf.fk_soc = s.rowid";
80$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
82 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
84if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
85 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
87$sql .=
" GROUP BY cf.fk_statut";
89$resql = $db->query($sql);
91 $num = $db->num_rows($resql);
95 $dataseries = array();
96 $colorseries = array();
102 $obj = $db->fetch_object($resql);
112 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
114 print
'<div class="div-table-responsive-no-min">';
115 print
'<table class="noborder nohover centpercent">';
116 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders").
'</th></tr>';
118 $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
119 foreach ($listofstatus as $status) {
120 $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
122 $colorseries[$status] =
'-'.$badgeStatus0;
125 $colorseries[$status] =
'-'.$badgeStatus1;
128 $colorseries[$status] = $badgeStatus1;
131 $colorseries[$status] = $badgeStatus9;
134 $colorseries[$status] = $badgeStatus4;
137 $colorseries[$status] =
'-'.$badgeStatus4;
140 $colorseries[$status] = $badgeStatus6;
143 $colorseries[$status] = $badgeStatus9;
146 if (!$conf->use_javascript_ajax) {
147 print
'<tr class="oddeven">';
148 print
'<td>'.$commandestatic->LibStatut($status, 0).
'</td>';
149 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
153 if ($conf->use_javascript_ajax) {
154 print
'<tr class="impair"><td class="center" colspan="2">';
156 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
158 $dolgraph->SetData($dataseries);
159 $dolgraph->SetDataColor(array_values($colorseries));
160 $dolgraph->setShowLegend(2);
161 $dolgraph->setShowPercent(1);
162 $dolgraph->SetType(array(
'pie'));
163 $dolgraph->setHeight(
'200');
164 $dolgraph->draw(
'idgraphstatus');
165 print $dolgraph->show($total ? 0 : 1);
171 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
173 print
"</table></div><br>";
182if (isModEnabled(
"supplier_order")) {
183 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
184 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
185 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
186 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
187 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
189 $sql .=
" WHERE c.fk_soc = s.rowid";
190 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
191 $sql .=
" AND c.fk_statut = 0";
192 if (!empty($socid)) {
193 $sql .=
" AND c.fk_soc = ".((int) $socid);
195 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
196 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
199 $resql = $db->query($sql);
201 print
'<div class="div-table-responsive-no-min">';
202 print
'<table class="noborder centpercent">';
203 print
'<tr class="liste_titre">';
204 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
205 $langs->load(
"orders");
206 $num = $db->num_rows($resql);
210 $obj = $db->fetch_object($resql);
212 print
'<tr class="oddeven">';
213 print
'<td class="nowrap">';
214 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".
img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
215 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.
dol_trunc($obj->name, 24).
'</a></td></tr>';
219 print
"</table></div><br>";
229if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
232$sql .=
" u.rowid, u.lastname, u.firstname, u.email, u.statut";
233$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
234if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
235 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
236 $sql .=
" WHERE ((ug.fk_user = u.rowid";
237 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
238 $sql .=
" OR u.entity = 0)";
240 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
242$sql .=
" AND u.fk_soc IS NULL";
244$resql = $db->query($sql);
246 $num = $db->num_rows($resql);
249 print
'<div class="div-table-responsive-no-min">';
250 print
'<table class="liste centpercent">';
251 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
255 $obj = $db->fetch_object($resql);
257 $userstatic =
new User($db);
258 $userstatic->id = $obj->rowid;
259 $userstatic->loadRights(
'fournisseur');
261 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
262 print
'<tr class="oddeven">';
264 $userstatic->lastname = $obj->lastname;
265 $userstatic->firstname = $obj->firstname;
266 $userstatic->email = $obj->email;
267 $userstatic->status = $obj->statut;
268 print $userstatic->getNomUrl(1);
275 print
"</table></div><br>";
282print
'</div><div class="fichetwothirdright">';
289$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
290$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
291$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
292if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
293 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
295$sql .=
" WHERE c.fk_soc = s.rowid";
296$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
299 $sql .=
" AND c.fk_soc = ".((int) $socid);
301if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
302 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
304$sql .=
" ORDER BY c.tms DESC";
305$sql .= $db->plimit($max, 0);
307$resql = $db->query($sql);
309 print
'<div class="div-table-responsive-no-min">';
310 print
'<table class="noborder centpercent">';
311 print
'<tr class="liste_titre">';
312 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
' ';
313 print
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
314 print
'<span class="badge">...</span>';
318 $num = $db->num_rows($resql);
322 $obj = $db->fetch_object($resql);
324 print
'<tr class="oddeven">';
325 print
'<td width="20%" class="nowrap">';
327 $commandestatic->id = $obj->rowid;
328 $commandestatic->ref = $obj->ref;
330 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
331 print
'<td width="96" class="nobordernopadding nowrap">';
332 print $commandestatic->getNomUrl(1);
335 print
'<td width="16" class="nobordernopadding nowrap">';
339 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
342 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
343 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
344 print
'</td></tr></table>';
348 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
349 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
350 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
355 print
"</table></div><br>";
432$parameters = array(
'user' => $user);
433$reshook = $hookmanager->executeHooks(
'dashboardOrdersSuppliers', $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 predefined suppliers products.
const STATUS_CANCELED_AFTER_ORDER
Order canceled/never received.
const STATUS_RECEIVED_PARTIALLY
Received partially.
const STATUS_CANCELED
Order canceled.
const STATUS_VALIDATED
Validated status.
const STATUS_RECEIVED_COMPLETELY
Received completely.
const STATUS_DRAFT
Draft status.
const STATUS_ACCEPTED
Accepted.
const STATUS_ORDERSENT
Order sent, shipment on process.
const STATUS_REFUSED
Refused.
Class to manage Dolibarr users.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.