28require
'../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
35$hookmanager->initHooks(array(
'suppliersproposalsindex'));
38$langs->loadLangs(array(
'supplier_proposal',
'companies'));
41$socid =
GETPOST(
'socid',
'int');
42if (isset($user->socid) && $user->socid > 0) {
44 $socid = $user->socid;
54$companystatic =
new Societe($db);
57$help_url =
"EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
59llxHeader(
"", $langs->trans(
"SupplierProposalArea"), $help_url);
61print
load_fiche_titre($langs->trans(
"SupplierProposalArea"),
'',
'supplier_proposal');
63print
'<div class="fichecenter"><div class="fichethirdleft">';
67$sql =
"SELECT count(p.rowid), p.fk_statut";
68$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
69$sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
70if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
71 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
73$sql .=
" WHERE p.fk_soc = s.rowid";
74$sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
76 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
78if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
79 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
81$sql .=
" AND p.fk_statut IN (0,1,2,3,4)";
82$sql .=
" GROUP BY p.fk_statut";
83$resql = $db->query($sql);
85 $num = $db->num_rows($resql);
90 $dataseries = array();
91 $colorseries = array();
95 $row = $db->fetch_row($resql);
99 $vals[$row[1]] = $row[0];
100 $totalinprocess += $row[0];
108 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
110 print
'<div class="div-table-responsive-no-min">';
111 print
'<table class="noborder centpercent">';
112 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CommRequests").
'</th></tr>'.
"\n";
113 $listofstatus = array(0, 1, 2, 3, 4);
114 foreach ($listofstatus as $status) {
115 $dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
117 $colorseries[$status] =
'-'.$badgeStatus0;
120 $colorseries[$status] = $badgeStatus1;
123 $colorseries[$status] = $badgeStatus4;
126 $colorseries[$status] = $badgeStatus9;
129 $colorseries[$status] = $badgeStatus6;
132 if (empty($conf->use_javascript_ajax)) {
133 print
'<tr class="oddeven">';
134 print
'<td>'.$supplier_proposalstatic->LibStatut($status, 0).
'</td>';
135 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
139 if ($conf->use_javascript_ajax) {
140 print
'<tr><td class="center" colspan="2">';
142 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
144 $dolgraph->SetData($dataseries);
145 $dolgraph->SetDataColor(array_values($colorseries));
146 $dolgraph->setShowLegend(2);
147 $dolgraph->setShowPercent(1);
148 $dolgraph->SetType(array(
'pie'));
149 $dolgraph->setHeight(
'200');
150 $dolgraph->draw(
'idgraphstatus');
151 print $dolgraph->show($total ? 0 : 1);
156 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
157 print
"</table></div><br>";
166if (isModEnabled(
'supplier_proposal')) {
167 $sql =
"SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
168 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
169 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
170 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
171 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
173 $sql .=
" WHERE c.fk_soc = s.rowid";
174 $sql .=
" AND c.entity = ".$conf->entity;
175 $sql .=
" AND c.fk_statut = 0";
177 $sql .=
" AND c.fk_soc = ".((int) $socid);
179 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
180 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
183 $resql = $db->query($sql);
185 print
'<div class="div-table-responsive-no-min">';
186 print
'<table class="noborder centpercent">';
187 print
'<tr class="liste_titre">';
188 print
'<th colspan="2">'.$langs->trans(
"DraftRequests").
'</th></tr>';
189 $langs->load(
"supplier_proposal");
190 $num = $db->num_rows($resql);
194 $obj = $db->fetch_object($resql);
196 print
'<tr class="oddeven">';
197 $supplier_proposalstatic->id = $obj->rowid;
198 $supplier_proposalstatic->ref = $obj->ref;
199 print
'<td class="nowrap">'.$supplier_proposalstatic->getNomUrl(1).
'</td>';
201 $companystatic->id = $obj->socid;
202 $companystatic->name = $obj->socname;
203 $companystatic->client = $obj->client;
204 $companystatic->canvas = $obj->canvas;
205 print
'<td>'.$companystatic->getNomUrl(1,
'customer', 24).
'</td>';
211 print
"</table></div><br>";
215print
'</div><div class="fichetwothirdright">';
224$sql =
"SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
225$sql .=
" date_cloture as datec";
226$sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
227$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
228if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
229 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
231$sql .=
" WHERE c.fk_soc = s.rowid";
232$sql .=
" AND c.entity = ".$conf->entity;
235 $sql .=
" AND c.fk_soc = ".((int) $socid);
237if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
238 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
240$sql .=
" ORDER BY c.tms DESC";
241$sql .= $db->plimit($max, 0);
243$resql = $db->query($sql);
245 print
'<div class="div-table-responsive-no-min">';
246 print
'<table class="noborder centpercent">';
247 print
'<tr class="liste_titre">';
248 print
'<th colspan="4">'.$langs->trans(
"LastModifiedRequests", $max).
'</th></tr>';
250 $num = $db->num_rows($resql);
254 $obj = $db->fetch_object($resql);
256 print
'<tr class="oddeven">';
257 print
'<td width="20%" class="nowrap">';
259 $supplier_proposalstatic->id = $obj->rowid;
260 $supplier_proposalstatic->ref = $obj->ref;
262 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
263 print
'<td width="96" class="nobordernopadding nowrap">';
264 print $supplier_proposalstatic->getNomUrl(1);
267 print
'<td width="16" class="nobordernopadding nowrap">';
271 print
'<td width="16" class="right nobordernopadding">';
274 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
275 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
276 print
'</td></tr></table>';
280 $companystatic->id = $obj->socid;
281 $companystatic->name = $obj->socname;
282 $companystatic->client = $obj->client;
283 $companystatic->canvas = $obj->canvas;
284 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
286 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
287 print
'<td class="right">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
292 print
"</table></div><br>";
301if (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
302 $langs->load(
"supplier_proposal");
306 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as supplier_proposalid, p.total_ttc, p.total_tva, p.total_ht, p.ref, p.fk_statut, p.datec as dp";
307 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
308 $sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
309 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
310 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
312 $sql .=
" WHERE p.fk_soc = s.rowid";
313 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
314 $sql .=
" AND p.fk_statut = 1";
315 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
316 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
319 $sql .=
" AND s.rowid = ".((int) $socid);
321 $sql .=
" ORDER BY p.rowid DESC";
323 $result = $db->query($sql);
326 $num = $db->num_rows($result);
329 print
'<div class="div-table-responsive-no-min">';
330 print
'<table class="noborder centpercent">';
331 print
'<tr class="liste_titre"><th colspan="5">'.$langs->trans(
"RequestsOpened").
' <a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status=1"><span class="badge">'.$num.
'</span></a></th></tr>';
333 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
334 while ($i < $nbofloop) {
335 $obj = $db->fetch_object($result);
337 print
'<tr class="oddeven">';
340 print
'<td class="nowrap" width="140">';
342 $supplier_proposalstatic->id = $obj->supplier_proposalid;
343 $supplier_proposalstatic->ref = $obj->ref;
345 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
346 print
'<td class="nobordernopadding nowrap">';
347 print $supplier_proposalstatic->getNomUrl(1);
349 print
'<td width="18" class="nobordernopadding nowrap">';
350 if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) {
354 print
'<td width="16" class="center nobordernopadding">';
357 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->supplier_proposalid;
358 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
359 print
'</td></tr></table>';
363 $companystatic->id = $obj->socid;
364 $companystatic->name = $obj->socname;
365 $companystatic->client = $obj->client;
366 $companystatic->canvas = $obj->canvas;
367 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>'.
"\n";
369 print
'<td class="right">';
371 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
372 print
'<td class="center" width="14">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>'.
"\n";
375 $total += $obj->total_ttc;
377 if ($num > $nbofloop) {
378 print
'<tr class="liste_total"><td colspan="5">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
"</td></tr>";
379 } elseif ($total > 0) {
380 print
'<tr class="liste_total"><td colspan="3">'.$langs->trans(
"Total").
'</td><td class="right">'.
price($total).
"</td><td> </td></tr>";
382 print
"</table></div><br>";
391$parameters = array(
'user' => $user);
392$reshook = $hookmanager->executeHooks(
'dashboardSupplierProposal', $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 third parties objects (customers, suppliers, prospects...)
Class to manage price ask supplier.
const STATUS_NOTSIGNED
Not signed quote, canceled.
const STATUS_DRAFT
Draft status.
const STATUS_VALIDATED
Validated status.
const STATUS_SIGNED
Signed quote.
const STATUS_CLOSE
Billed or closed/processed quote.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
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.
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.