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'));
57 $socid = $user->socid;
59$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
66llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-supplier-order page-stats');
69$userstatic =
new User($db);
72print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
74print
'<div class="fichecenter"><div class="fichethirdleft">';
80$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
81$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
82$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
83if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
84 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
86$sql .=
" WHERE cf.fk_soc = s.rowid";
87$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
89 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
91if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
92 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
94$sql .=
" GROUP BY cf.fk_statut";
96$resql = $db->query($sql);
98 $num = $db->num_rows($resql);
102 $dataseries = array();
103 $colorseries = array();
109 $obj = $db->fetch_object($resql);
119 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
127 print
'<div class="div-table-responsive-no-min">';
128 print
'<table class="noborder nohover centpercent">';
129 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders").
'</th></tr>';
131 $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
132 foreach ($listofstatus as $status) {
133 $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
135 $colorseries[$status] =
'-'.$badgeStatus0;
138 $colorseries[$status] =
'-'.$badgeStatus1;
141 $colorseries[$status] = $badgeStatus1;
144 $colorseries[$status] = $badgeStatus9;
147 $colorseries[$status] = $badgeStatus4;
150 $colorseries[$status] =
'-'.$badgeStatus4;
153 $colorseries[$status] = $badgeStatus6;
156 $colorseries[$status] = $badgeStatus9;
159 if (!
$conf->use_javascript_ajax) {
160 print
'<tr class="oddeven">';
161 print
'<td>'.$commandestatic->LibStatut($status, 0).
'</td>';
162 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
166 if (
$conf->use_javascript_ajax) {
167 print
'<tr class="impair"><td class="center" colspan="2">';
169 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
171 $dolgraph->SetData($dataseries);
172 $dolgraph->SetDataColor(array_values($colorseries));
173 $dolgraph->setShowLegend(2);
174 $dolgraph->setShowPercent(1);
175 $dolgraph->SetType(array(
'pie'));
176 $dolgraph->setHeight(
'200');
177 $dolgraph->draw(
'idgraphstatus');
178 print $dolgraph->show($total ? 0 : 1);
184 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
186 print
"</table></div><br>";
195if (isModEnabled(
"supplier_order")) {
196 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
197 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
198 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
199 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
200 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
202 $sql .=
" WHERE c.fk_soc = s.rowid";
203 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
204 $sql .=
" AND c.fk_statut = 0";
205 if (!empty($socid)) {
206 $sql .=
" AND c.fk_soc = ".((int) $socid);
208 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
209 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
212 $resql = $db->query($sql);
214 print
'<div class="div-table-responsive-no-min">';
215 print
'<table class="noborder centpercent">';
216 print
'<tr class="liste_titre">';
217 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
218 $langs->load(
"orders");
219 $num = $db->num_rows($resql);
223 $obj = $db->fetch_object($resql);
225 print
'<tr class="oddeven">';
226 print
'<td class="nowrap">';
227 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".
img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
228 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>';
232 print
"</table></div><br>";
242if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
245$sql .=
" u.rowid, u.lastname, u.firstname, u.email, u.statut";
246$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
247if (isModEnabled(
'multicompany') &&
getDolGlobalString(
'MULTICOMPANY_TRANSVERSE_MODE')) {
248 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
249 $sql .=
" WHERE ((ug.fk_user = u.rowid";
250 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
251 $sql .=
" OR u.entity = 0)";
253 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
255$sql .=
" AND u.fk_soc IS NULL";
257$resql = $db->query($sql);
259 $num = $db->num_rows($resql);
262 print
'<div class="div-table-responsive-no-min">';
263 print
'<table class="liste centpercent">';
264 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
268 $obj = $db->fetch_object($resql);
270 $userstatic =
new User($db);
271 $userstatic->id = $obj->rowid;
272 $userstatic->loadRights(
'fournisseur');
274 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
275 print
'<tr class="oddeven">';
277 $userstatic->lastname = $obj->lastname;
278 $userstatic->firstname = $obj->firstname;
279 $userstatic->email = $obj->email;
280 $userstatic->status = $obj->statut;
281 print $userstatic->getNomUrl(1);
288 print
"</table></div><br>";
295print
'</div><div class="fichetwothirdright">';
302$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
303$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
304$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
305if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
306 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
308$sql .=
" WHERE c.fk_soc = s.rowid";
309$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
312 $sql .=
" AND c.fk_soc = ".((int) $socid);
314if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
315 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
317$sql .=
" ORDER BY c.tms DESC";
318$sql .= $db->plimit($max, 0);
320$resql = $db->query($sql);
322 print
'<div class="div-table-responsive-no-min">';
323 print
'<table class="noborder centpercent">';
324 print
'<tr class="liste_titre">';
325 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
' ';
326 print
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
327 print
'<span class="badge">...</span>';
331 $num = $db->num_rows($resql);
335 $obj = $db->fetch_object($resql);
337 print
'<tr class="oddeven">';
338 print
'<td width="20%" class="nowrap">';
340 $commandestatic->id = $obj->rowid;
341 $commandestatic->ref = $obj->ref;
343 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
344 print
'<td width="96" class="nobordernopadding nowrap">';
345 print $commandestatic->getNomUrl(1);
348 print
'<td width="16" class="nobordernopadding nowrap">';
352 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
355 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
356 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
357 print
'</td></tr></table>';
361 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
362 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
363 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
368 print
"</table></div><br>";
445$parameters = array(
'user' => $user);
446$reshook = $hookmanager->executeHooks(
'dashboardOrdersSuppliers', $parameters, $object);
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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)
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.
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.