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';
46$langs->loadLangs(array(
"suppliers",
"orders"));
49$hookmanager->initHooks(array(
'orderssuppliersindex'));
56 $socid = $user->socid;
58$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
65llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-supplier-order page-stats');
68$userstatic =
new User($db);
71print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
73print
'<div class="fichecenter"><div class="fichethirdleft">';
79$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
80$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
81$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
82if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
83 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
85$sql .=
" WHERE cf.fk_soc = s.rowid";
86$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
88 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
90if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
91 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
93$sql .=
" GROUP BY cf.fk_statut";
95$resql = $db->query($sql);
97 $num = $db->num_rows($resql);
101 $dataseries = array();
102 $colorseries = array();
108 $obj = $db->fetch_object($resql);
118 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
120 print
'<div class="div-table-responsive-no-min">';
121 print
'<table class="noborder nohover centpercent">';
122 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders").
'</th></tr>';
124 $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
125 foreach ($listofstatus as $status) {
126 $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
128 $colorseries[$status] =
'-'.$badgeStatus0;
131 $colorseries[$status] =
'-'.$badgeStatus1;
134 $colorseries[$status] = $badgeStatus1;
137 $colorseries[$status] = $badgeStatus9;
140 $colorseries[$status] = $badgeStatus4;
143 $colorseries[$status] =
'-'.$badgeStatus4;
146 $colorseries[$status] = $badgeStatus6;
149 $colorseries[$status] = $badgeStatus9;
152 if (!
$conf->use_javascript_ajax) {
153 print
'<tr class="oddeven">';
154 print
'<td>'.$commandestatic->LibStatut($status, 0).
'</td>';
155 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
159 if (
$conf->use_javascript_ajax) {
160 print
'<tr class="impair"><td class="center" colspan="2">';
162 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
164 $dolgraph->SetData($dataseries);
165 $dolgraph->SetDataColor(array_values($colorseries));
166 $dolgraph->setShowLegend(2);
167 $dolgraph->setShowPercent(1);
168 $dolgraph->SetType(array(
'pie'));
169 $dolgraph->setHeight(
'200');
170 $dolgraph->draw(
'idgraphstatus');
171 print $dolgraph->show($total ? 0 : 1);
177 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
179 print
"</table></div><br>";
188if (isModEnabled(
"supplier_order")) {
189 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
190 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
191 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
192 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
193 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
195 $sql .=
" WHERE c.fk_soc = s.rowid";
196 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
197 $sql .=
" AND c.fk_statut = 0";
198 if (!empty($socid)) {
199 $sql .=
" AND c.fk_soc = ".((int) $socid);
201 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
202 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
205 $resql = $db->query($sql);
207 print
'<div class="div-table-responsive-no-min">';
208 print
'<table class="noborder centpercent">';
209 print
'<tr class="liste_titre">';
210 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
211 $langs->load(
"orders");
212 $num = $db->num_rows($resql);
216 $obj = $db->fetch_object($resql);
218 print
'<tr class="oddeven">';
219 print
'<td class="nowrap">';
220 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".
img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
221 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>';
225 print
"</table></div><br>";
235if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
238$sql .=
" u.rowid, u.lastname, u.firstname, u.email, u.statut";
239$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
240if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
241 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
242 $sql .=
" WHERE ((ug.fk_user = u.rowid";
243 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
244 $sql .=
" OR u.entity = 0)";
246 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
248$sql .=
" AND u.fk_soc IS NULL";
250$resql = $db->query($sql);
252 $num = $db->num_rows($resql);
255 print
'<div class="div-table-responsive-no-min">';
256 print
'<table class="liste centpercent">';
257 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
261 $obj = $db->fetch_object($resql);
263 $userstatic =
new User($db);
264 $userstatic->id = $obj->rowid;
265 $userstatic->loadRights(
'fournisseur');
267 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
268 print
'<tr class="oddeven">';
270 $userstatic->lastname = $obj->lastname;
271 $userstatic->firstname = $obj->firstname;
272 $userstatic->email = $obj->email;
273 $userstatic->status = $obj->statut;
274 print $userstatic->getNomUrl(1);
281 print
"</table></div><br>";
288print
'</div><div class="fichetwothirdright">';
295$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
296$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
297$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
298if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
299 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
301$sql .=
" WHERE c.fk_soc = s.rowid";
302$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
305 $sql .=
" AND c.fk_soc = ".((int) $socid);
307if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
308 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
310$sql .=
" ORDER BY c.tms DESC";
311$sql .= $db->plimit($max, 0);
313$resql = $db->query($sql);
315 print
'<div class="div-table-responsive-no-min">';
316 print
'<table class="noborder centpercent">';
317 print
'<tr class="liste_titre">';
318 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
' ';
319 print
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
320 print
'<span class="badge">...</span>';
324 $num = $db->num_rows($resql);
328 $obj = $db->fetch_object($resql);
330 print
'<tr class="oddeven">';
331 print
'<td width="20%" class="nowrap">';
333 $commandestatic->id = $obj->rowid;
334 $commandestatic->ref = $obj->ref;
336 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
337 print
'<td width="96" class="nobordernopadding nowrap">';
338 print $commandestatic->getNomUrl(1);
341 print
'<td width="16" class="nobordernopadding nowrap">';
345 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
348 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
349 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
350 print
'</td></tr></table>';
354 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
355 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
356 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
361 print
"</table></div><br>";
438$parameters = array(
'user' => $user);
439$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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.