32require
'../../main.inc.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/dashboard.lib.php';
48$langs->loadLangs(array(
"suppliers",
"orders"));
51$hookmanager->initHooks(array(
'orderssuppliersindex'));
58if ($user->isExternalUser()) {
59 $socid = $user->isExternalUser();
61$result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
68llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"),
'',
'', 0, 0,
'',
'',
'',
'mod-supplier-order page-stats');
71$userstatic =
new User($db);
74print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
76print
'<div class="fichecenter"><div class="fichethirdleft">';
82$sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
83$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
84$sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
85if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
86 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
88$sql .=
" WHERE cf.fk_soc = s.rowid";
89$sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
91 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
93if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
94 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
96$sql .=
" GROUP BY cf.fk_statut";
98$resql = $db->query($sql);
104 while ($obj = $db->fetch_object($resql)) {
110 $colorofstatus = array(
122 foreach (array(0, 1, 2, 3, 4, 5, 6, 9) as $status) {
124 'label' => $commandestatic->LibStatut($status, 1),
125 'labelnojs' => $commandestatic->LibStatut($status, 0),
126 'nb' => (isset($vals[$status]) ? (
int) $vals[$status] : 0),
127 'color' => $colorofstatus[$status],
128 'url' =>
'list.php?search_status='.$status,
131 print
getStatusPieChart($langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders"), $series);
133 dol_print_error($db);
141 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
142 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
143 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
144 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
145 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
147 $sql .=
" WHERE c.fk_soc = s.rowid";
148 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
149 $sql .=
" AND c.fk_statut = 0";
150 if (!empty($socid)) {
151 $sql .=
" AND c.fk_soc = ".((int) $socid);
153 if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
154 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
157 $resql = $db->query($sql);
159 print
'<div class="div-table-responsive-no-min">';
160 print
'<table class="noborder centpercent">';
161 print
'<tr class="liste_titre">';
162 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
163 $langs->load(
"orders");
164 $num = $db->num_rows($resql);
168 $obj = $db->fetch_object($resql);
170 print
'<tr class="oddeven">';
171 print
'<td class="nowrap">';
172 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
173 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>';
177 print
"</table></div><br>";
190$sql .=
" u.rowid, u.login, u.lastname, u.firstname, u.email, u.photo, u.statut";
191$sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
193 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
194 $sql .=
" WHERE ((ug.fk_user = u.rowid";
195 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
196 $sql .=
" OR u.entity = 0)";
198 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
200$sql .=
" AND u.fk_soc IS NULL";
202$resql = $db->query($sql);
204 $num = $db->num_rows($resql);
207 print
'<div class="div-table-responsive-no-min">';
208 print
'<table class="liste centpercent">';
209 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
212 print
'<tr class="oddeven">';
216 $obj = $db->fetch_object($resql);
218 $userstatic =
new User($db);
219 $userstatic->id = $obj->rowid;
220 $userstatic->loadRights(
'fournisseur');
222 if ($userstatic->hasRight(
'fournisseur',
'commande',
'approuver')) {
227 $userstatic->lastname = $obj->lastname;
228 $userstatic->firstname = $obj->firstname;
229 $userstatic->email = $obj->email;
230 $userstatic->login = $obj->login;
231 $userstatic->photo = $obj->photo;
232 $userstatic->status = $obj->statut;
234 print $userstatic->getNomUrl(-1);
240 print
'<span class="opacitymedium">'.$langs->trans(
"Nobody").
'</span>';
246 print
"</table></div><br>";
249 dol_print_error($db);
253print
'</div><div class="fichetwothirdright">';
260$sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
261$sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
262$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
263if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
264 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
266$sql .=
" WHERE c.fk_soc = s.rowid";
267$sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
270 $sql .=
" AND c.fk_soc = ".((int) $socid);
272if (!$user->hasRight(
"societe",
"client",
"voir") && !$socid) {
273 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
275$sql .=
" ORDER BY c.tms DESC";
276$sql .= $db->plimit($max, 0);
278$resql = $db->query($sql);
280 print
'<div class="div-table-responsive-no-min">';
281 print
'<table class="noborder centpercent">';
282 print
'<tr class="liste_titre">';
283 print
'<th colspan="4">'.$langs->trans(
"LastModifiedSupplierOrders", $max).
' ';
284 print
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
285 print
'<span class="badge">...</span>';
289 $num = $db->num_rows($resql);
293 $obj = $db->fetch_object($resql);
295 print
'<tr class="oddeven">';
296 print
'<td width="20%" class="nowrap">';
298 $commandestatic->id = $obj->rowid;
299 $commandestatic->ref = $obj->ref;
301 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
302 print
'<td width="96" class="nobordernopadding nowrap">';
303 print $commandestatic->getNomUrl(1);
306 print
'<td width="16" class="nobordernopadding nowrap">';
310 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
313 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
314 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
315 print
'</td></tr></table>';
319 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
320 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
321 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
326 print
"</table></div><br>";
328 dol_print_error($db);
403$parameters = array(
'user' => $user);
404$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.