30require
'../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
37$langs->loadLangs(array(
"suppliers",
"orders"));
43 $socid = $user->socid;
45$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
50$hookmanager->initHooks(array(
'orderssuppliersindex'));
58llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"));
61$userstatic =
new User($db);
64print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
66print
'<div class="fichecenter"><div class="fichethirdleft">';
72$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
73$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
74$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
75if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
76 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
78$sql .=
" WHERE cf.fk_soc = s.rowid";
79$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
81 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
83if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
84 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
86$sql .=
" GROUP BY cf.fk_statut";
88$resql = $db->query($sql);
90 $num = $db->num_rows($resql);
94 $dataseries = array();
100 $obj = $db->fetch_object($resql);
110 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
112 print
'<div class="div-table-responsive-no-min">';
113 print
'<table class="noborder nohover centpercent">';
114 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders").
'</th></tr>';
116 $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
117 foreach ($listofstatus as $status) {
118 $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
120 $colorseries[$status] =
'-'.$badgeStatus0;
123 $colorseries[$status] =
'-'.$badgeStatus1;
126 $colorseries[$status] = $badgeStatus1;
129 $colorseries[$status] = $badgeStatus9;
132 $colorseries[$status] = $badgeStatus4;
135 $colorseries[$status] =
'-'.$badgeStatus4;
138 $colorseries[$status] = $badgeStatus6;
141 $colorseries[$status] = $badgeStatus9;
144 if (!$conf->use_javascript_ajax) {
145 print
'<tr class="oddeven">';
146 print
'<td>'.$commandestatic->LibStatut($status, 0).
'</td>';
147 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
151 if ($conf->use_javascript_ajax) {
152 print
'<tr class="impair"><td class="center" colspan="2">';
154 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
156 $dolgraph->SetData($dataseries);
157 $dolgraph->SetDataColor(array_values($colorseries));
158 $dolgraph->setShowLegend(2);
159 $dolgraph->setShowPercent(1);
160 $dolgraph->SetType(array(
'pie'));
161 $dolgraph->setHeight(
'200');
162 $dolgraph->draw(
'idgraphstatus');
163 print $dolgraph->show($total ? 0 : 1);
169 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
171 print
"</table></div><br>";
180if (isModEnabled(
"supplier_order")) {
181 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
182 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
183 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
184 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
185 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
187 $sql .=
" WHERE c.fk_soc = s.rowid";
188 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
189 $sql .=
" AND c.fk_statut = 0";
190 if (!empty($socid)) {
191 $sql .=
" AND c.fk_soc = ".((int) $socid);
193 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
194 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
197 $resql = $db->query($sql);
199 print
'<div class="div-table-responsive-no-min">';
200 print
'<table class="noborder centpercent">';
201 print
'<tr class="liste_titre">';
202 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
203 $langs->load(
"orders");
204 $num = $db->num_rows($resql);
208 $obj = $db->fetch_object($resql);
210 print
'<tr class="oddeven">';
211 print
'<td class="nowrap">';
212 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".
img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
213 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>';
217 print
"</table></div><br>";
227if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
230$sql .=
" u.rowid, u.lastname, u.firstname, u.email, u.statut";
231$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
232if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
233 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
234 $sql .=
" WHERE ((ug.fk_user = u.rowid";
235 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
236 $sql .=
" OR u.entity = 0)";
238 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
240$sql .=
" AND u.fk_soc IS NULL";
242$resql = $db->query($sql);
244 $num = $db->num_rows($resql);
247 print
'<div class="div-table-responsive-no-min">';
248 print
'<table class="liste centpercent">';
249 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
253 $obj = $db->fetch_object($resql);
255 $userstatic =
new User($db);
256 $userstatic->id = $obj->rowid;
257 $userstatic->getrights(
'fournisseur');
259 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
260 print
'<tr class="oddeven">';
262 $userstatic->lastname = $obj->lastname;
263 $userstatic->firstname = $obj->firstname;
264 $userstatic->email = $obj->email;
265 $userstatic->statut = $obj->statut;
266 print $userstatic->getNomUrl(1);
273 print
"</table></div><br>";
280print
'</div><div class="fichetwothirdright">';
288$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
289$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
290$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
291if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
292 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
294$sql .=
" WHERE c.fk_soc = s.rowid";
295$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
298 $sql .=
" AND c.fk_soc = ".((int) $socid);
300if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
301 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
303$sql .=
" ORDER BY c.tms DESC";
304$sql .= $db->plimit($max, 0);
306$resql = $db->query($sql);
308 print
'<div class="div-table-responsive-no-min">';
309 print
'<table class="noborder centpercent">';
310 print
'<tr class="liste_titre">';
311 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
'</th></tr>';
313 $num = $db->num_rows($resql);
317 $obj = $db->fetch_object($resql);
319 print
'<tr class="oddeven">';
320 print
'<td width="20%" class="nowrap">';
322 $commandestatic->id = $obj->rowid;
323 $commandestatic->ref = $obj->ref;
325 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
326 print
'<td width="96" class="nobordernopadding nowrap">';
327 print $commandestatic->getNomUrl(1);
330 print
'<td width="16" class="nobordernopadding nowrap">';
334 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
337 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
338 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
339 print
'</td></tr></table>';
343 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
344 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
345 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
350 print
"</table></div><br>";
427$parameters = array(
'user' => $user);
428$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()
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($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...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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_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 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.