31require
'../../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/lib/dashboard.lib.php';
47$langs->loadLangs(array(
"suppliers",
"orders"));
50$hookmanager->initHooks(array(
'orderssuppliersindex'));
57if ($user->isExternalUser()) {
58 $socid = $user->isExternalUser();
60$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
67llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-supplier-order page-stats');
70$userstatic =
new User($db);
73print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
75print
'<div class="fichecenter"><div class="fichethirdleft">';
81$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
82$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
83$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
84if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
85 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
87$sql .=
" WHERE cf.fk_soc = s.rowid";
88$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
90 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
92if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
93 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
95$sql .=
" GROUP BY cf.fk_statut";
97$resql = $db->query($sql);
103 while ($obj = $db->fetch_object($resql)) {
109 $colorofstatus = array(
121 foreach (array(0, 1, 2, 3, 4, 5, 6, 9) as $status) {
123 'label' => $commandestatic->LibStatut($status, 1),
124 'labelnojs' => $commandestatic->LibStatut($status, 0),
125 'nb' => (isset($vals[$status]) ? (
int) $vals[$status] : 0),
126 'color' => $colorofstatus[$status],
127 'url' =>
'list.php?search_status='.$status,
130 print
getStatusPieChart($langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders"), $series);
132 dol_print_error($db);
140 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
141 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
142 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
143 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
144 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
146 $sql .=
" WHERE c.fk_soc = s.rowid";
147 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
148 $sql .=
" AND c.fk_statut = 0";
149 if (!empty($socid)) {
150 $sql .=
" AND c.fk_soc = ".((int) $socid);
152 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
153 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
156 $resql = $db->query($sql);
158 print
'<div class="div-table-responsive-no-min">';
159 print
'<table class="noborder centpercent">';
160 print
'<tr class="liste_titre">';
161 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
162 $langs->load(
"orders");
163 $num = $db->num_rows($resql);
167 $obj = $db->fetch_object($resql);
169 print
'<tr class="oddeven">';
170 print
'<td class="nowrap">';
171 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
172 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>';
176 print
"</table></div><br>";
189$sql .=
" u.rowid, u.login, u.lastname, u.firstname, u.email, u.photo, u.statut";
190$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
192 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
193 $sql .=
" WHERE ((ug.fk_user = u.rowid";
194 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
195 $sql .=
" OR u.entity = 0)";
197 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
199$sql .=
" AND u.fk_soc IS NULL";
201$resql = $db->query($sql);
203 $num = $db->num_rows($resql);
206 print
'<div class="div-table-responsive-no-min">';
207 print
'<table class="liste centpercent">';
208 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
211 print
'<tr class="oddeven">';
215 $obj = $db->fetch_object($resql);
217 $userstatic =
new User($db);
218 $userstatic->id = $obj->rowid;
219 $userstatic->loadRights(
'fournisseur');
221 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
226 $userstatic->lastname = $obj->lastname;
227 $userstatic->firstname = $obj->firstname;
228 $userstatic->email = $obj->email;
229 $userstatic->login = $obj->login;
230 $userstatic->photo = $obj->photo;
231 $userstatic->status = $obj->statut;
233 print $userstatic->getNomUrl(-1);
239 print
'<span class="opacitymedium">'.$langs->trans(
"Nobody").
'</span>';
245 print
"</table></div><br>";
248 dol_print_error($db);
252print
'</div><div class="fichetwothirdright">';
259$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
260$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
261$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
262if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
263 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
265$sql .=
" WHERE c.fk_soc = s.rowid";
266$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
269 $sql .=
" AND c.fk_soc = ".((int) $socid);
271if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
272 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
274$sql .=
" ORDER BY c.tms DESC";
275$sql .= $db->plimit($max, 0);
277$resql = $db->query($sql);
279 print
'<div class="div-table-responsive-no-min">';
280 print
'<table class="noborder centpercent">';
281 print
'<tr class="liste_titre">';
282 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
' ';
283 print
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
284 print
'<span class="badge">...</span>';
288 $num = $db->num_rows($resql);
292 $obj = $db->fetch_object($resql);
294 print
'<tr class="oddeven">';
295 print
'<td width="20%" class="nowrap">';
297 $commandestatic->id = $obj->rowid;
298 $commandestatic->ref = $obj->ref;
300 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
301 print
'<td width="96" class="nobordernopadding nowrap">';
302 print $commandestatic->getNomUrl(1);
305 print
'<td width="16" class="nobordernopadding nowrap">';
309 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
312 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
313 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
314 print
'</td></tr></table>';
318 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
319 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
320 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
325 print
"</table></div><br>";
327 dol_print_error($db);
402$parameters = array(
'user' => $user);
403$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.
getThemeBadgeStatusColors()
Return the colors of status badges defined by the current theme (theme_vars.inc.php)
getStatusPieChart($title, $series, $options=array())
Return the HTML table with a pie chart of values by status, as shown on the home page of a module.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getMultidirOutput($object, $module='', $forobject=0, $mode='output')
Return the full path of the directory where a module (or an object of a module) stores its files.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.