29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
36$hookmanager->initHooks(array(
'suppliersproposalsindex'));
39$langs->loadLangs(array(
'supplier_proposal',
'companies'));
43if (isset($user->socid) && $user->socid > 0) {
45 $socid = $user->socid;
55$companystatic =
new Societe($db);
59$title = $langs->trans(
"SupplierProposalArea");
60$help_url =
"EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
62llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-index');
64print
load_fiche_titre($langs->trans(
"SupplierProposalArea"),
'',
'supplier_proposal');
66print
'<div class="fichecenter"><div class="fichethirdleft">';
70$sql =
"SELECT count(p.rowid), p.fk_statut";
71$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
72$sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
73if (!$user->hasRight(
'societe',
'client',
'voir')) {
74 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
76$sql .=
" WHERE p.fk_soc = s.rowid";
77$sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
79 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
81if (!$user->hasRight(
'societe',
'client',
'voir')) {
82 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
84$sql .=
" AND p.fk_statut IN (0,1,2,3,4)";
85$sql .=
" GROUP BY p.fk_statut";
86$resql = $db->query($sql);
88 $num = $db->num_rows($resql);
93 $dataseries = array();
94 $colorseries = array();
98 $row = $db->fetch_row($resql);
102 $vals[$row[1]] = $row[0];
103 $totalinprocess += $row[0];
111 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
113 print
'<div class="div-table-responsive-no-min">';
114 print
'<table class="noborder centpercent">';
115 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CommRequests").
'</th></tr>'.
"\n";
116 $listofstatus = array(0, 1, 2, 3, 4);
117 foreach ($listofstatus as $status) {
118 $dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
120 $colorseries[$status] =
'-'.$badgeStatus0;
123 $colorseries[$status] = $badgeStatus1;
126 $colorseries[$status] = $badgeStatus4;
129 $colorseries[$status] = $badgeStatus9;
132 $colorseries[$status] = $badgeStatus6;
135 if (empty($conf->use_javascript_ajax)) {
136 print
'<tr class="oddeven">';
137 print
'<td>'.$supplier_proposalstatic->LibStatut($status, 0).
'</td>';
138 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
142 if ($conf->use_javascript_ajax) {
143 print
'<tr><td class="center" colspan="2">';
145 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
147 $dolgraph->SetData($dataseries);
148 $dolgraph->SetDataColor(array_values($colorseries));
149 $dolgraph->setShowLegend(2);
150 $dolgraph->setShowPercent(1);
151 $dolgraph->SetType(array(
'pie'));
152 $dolgraph->setHeight(
'200');
153 $dolgraph->draw(
'idgraphstatus');
154 print $dolgraph->show($total ? 0 : 1);
159 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
160 print
"</table></div><br>";
169if (isModEnabled(
'supplier_proposal')) {
170 $sql =
"SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
171 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
172 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
173 if (!$user->hasRight(
'societe',
'client',
'voir')) {
174 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
176 $sql .=
" WHERE c.fk_soc = s.rowid";
177 $sql .=
" AND c.entity = ".$conf->entity;
178 $sql .=
" AND c.fk_statut = 0";
180 $sql .=
" AND c.fk_soc = ".((int) $socid);
182 if (!$user->hasRight(
'societe',
'client',
'voir')) {
183 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
186 $resql = $db->query($sql);
188 print
'<div class="div-table-responsive-no-min">';
189 print
'<table class="noborder centpercent">';
190 print
'<tr class="liste_titre">';
191 print
'<th colspan="2">'.$langs->trans(
"DraftRequests").
'</th></tr>';
192 $langs->load(
"supplier_proposal");
193 $num = $db->num_rows($resql);
197 $obj = $db->fetch_object($resql);
199 print
'<tr class="oddeven">';
200 $supplier_proposalstatic->id = $obj->rowid;
201 $supplier_proposalstatic->ref = $obj->ref;
202 print
'<td class="nowrap">'.$supplier_proposalstatic->getNomUrl(1).
'</td>';
204 $companystatic->id = $obj->socid;
205 $companystatic->name = $obj->socname;
206 $companystatic->client = $obj->client;
207 $companystatic->canvas = $obj->canvas;
208 print
'<td>'.$companystatic->getNomUrl(1,
'customer', 24).
'</td>';
214 print
"</table></div><br>";
218print
'</div><div class="fichetwothirdright">';
227$sql =
"SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
228$sql .=
" date_cloture as datec";
229$sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
230$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
231if (!$user->hasRight(
'societe',
'client',
'voir')) {
232 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
234$sql .=
" WHERE c.fk_soc = s.rowid";
235$sql .=
" AND c.entity = ".$conf->entity;
238 $sql .=
" AND c.fk_soc = ".((int) $socid);
240if (!$user->hasRight(
'societe',
'client',
'voir')) {
241 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
243$sql .=
" ORDER BY c.tms DESC";
244$sql .= $db->plimit($max, 0);
246$resql = $db->query($sql);
248 print
'<div class="div-table-responsive-no-min">';
249 print
'<table class="noborder centpercent">';
250 print
'<tr class="liste_titre">';
251 print
'<th colspan="4">'.$langs->trans(
"LastModifiedRequests", $max).
'</th></tr>';
253 $num = $db->num_rows($resql);
257 $obj = $db->fetch_object($resql);
259 print
'<tr class="oddeven">';
260 print
'<td width="20%" class="nowrap">';
262 $supplier_proposalstatic->id = $obj->rowid;
263 $supplier_proposalstatic->ref = $obj->ref;
265 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
266 print
'<td width="96" class="nobordernopadding nowrap">';
267 print $supplier_proposalstatic->getNomUrl(1);
270 print
'<td width="16" class="nobordernopadding nowrap">';
274 print
'<td width="16" class="right nobordernopadding">';
277 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
278 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
279 print
'</td></tr></table>';
283 $companystatic->id = $obj->socid;
284 $companystatic->name = $obj->socname;
285 $companystatic->client = $obj->client;
286 $companystatic->canvas = $obj->canvas;
287 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
289 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
290 print
'<td class="right">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
295 print
"</table></div><br>";
304if (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
305 $langs->load(
"supplier_proposal");
309 $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";
310 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
311 $sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
312 if (!$user->hasRight(
'societe',
'client',
'voir')) {
313 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
315 $sql .=
" WHERE p.fk_soc = s.rowid";
316 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
317 $sql .=
" AND p.fk_statut = 1";
318 if (!$user->hasRight(
'societe',
'client',
'voir')) {
319 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
322 $sql .=
" AND s.rowid = ".((int) $socid);
324 $sql .=
" ORDER BY p.rowid DESC";
326 $result = $db->query($sql);
329 $num = $db->num_rows($result);
332 print
'<div class="div-table-responsive-no-min">';
333 print
'<table class="noborder centpercent">';
334 print
'<tr class="liste_titre"><th colspan="5">'.$langs->trans(
"RequestsOpened");
335 print
' <a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status=1" alt="'.$langs->trans(
"GoOnList").
'"><span class="badge">'.$num.
'</span></a>';
338 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
339 while ($i < $nbofloop) {
340 $obj = $db->fetch_object($result);
342 print
'<tr class="oddeven">';
345 print
'<td class="nowrap" width="140">';
347 $supplier_proposalstatic->id = $obj->supplier_proposalid;
348 $supplier_proposalstatic->ref = $obj->ref;
350 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
351 print
'<td class="nobordernopadding nowrap">';
352 print $supplier_proposalstatic->getNomUrl(1);
354 print
'<td width="18" class="nobordernopadding nowrap">';
355 if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) {
359 print
'<td width="16" class="center nobordernopadding">';
362 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->supplier_proposalid;
363 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
364 print
'</td></tr></table>';
368 $companystatic->id = $obj->socid;
369 $companystatic->name = $obj->socname;
370 $companystatic->client = $obj->client;
371 $companystatic->canvas = $obj->canvas;
372 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>'.
"\n";
374 print
'<td class="right">';
376 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
377 print
'<td class="center" width="14">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>'.
"\n";
380 $total += $obj->total_ttc;
382 if ($num > $nbofloop) {
383 print
'<tr class="liste_total"><td colspan="5">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
"</td></tr>";
384 } elseif ($total > 0) {
385 print
'<tr class="liste_total"><td colspan="3">'.$langs->trans(
"Total").
'</td><td class="right">'.
price($total).
"</td><td> </td></tr>";
387 print
"</table></div><br>";
396$parameters = array(
'user' => $user);
397$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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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...
getDolGlobalString($key, $default='')
Return a 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.