30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
43$hookmanager->initHooks(array(
'suppliersproposalsindex'));
46$langs->loadLangs(array(
'supplier_proposal',
'companies'));
50if (!empty($user->socid) && $user->socid > 0) {
52 $socid = $user->socid;
62$companystatic =
new Societe($db);
66$title = $langs->trans(
"SupplierProposalArea");
67$help_url =
"EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
69llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-index');
71print
load_fiche_titre($langs->trans(
"SupplierProposalArea"),
'',
'supplier_proposal');
73print
'<div class="fichecenter"><div class="fichethirdleft">';
77$sql =
"SELECT count(p.rowid), p.fk_statut";
78$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
79$sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
80if (!$user->hasRight(
'societe',
'client',
'voir')) {
81 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
83$sql .=
" WHERE p.fk_soc = s.rowid";
84$sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
86 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
88if (!$user->hasRight(
'societe',
'client',
'voir')) {
89 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
91$sql .=
" AND p.fk_statut IN (0,1,2,3,4)";
92$sql .=
" GROUP BY p.fk_statut";
93$resql = $db->query($sql);
95 $num = $db->num_rows($resql);
100 $dataseries = array();
101 $colorseries = array();
105 $row = $db->fetch_row($resql);
109 $vals[$row[1]] = $row[0];
110 $totalinprocess += $row[0];
127 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
129 print
'<div class="div-table-responsive-no-min">';
130 print
'<table class="noborder centpercent">';
131 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CommRequests").
'</th></tr>'.
"\n";
132 $listofstatus = array(0, 1, 2, 3, 4);
133 foreach ($listofstatus as $status) {
134 $dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
136 $colorseries[$status] =
'-'.$badgeStatus0;
139 $colorseries[$status] = $badgeStatus1;
142 $colorseries[$status] = $badgeStatus4;
145 $colorseries[$status] = $badgeStatus9;
148 $colorseries[$status] = $badgeStatus6;
151 if (empty($conf->use_javascript_ajax)) {
152 print
'<tr class="oddeven">';
153 print
'<td>'.$supplier_proposalstatic->LibStatut($status, 0).
'</td>';
154 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
158 if ($conf->use_javascript_ajax) {
159 print
'<tr><td class="center" colspan="2">';
161 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
163 $dolgraph->SetData($dataseries);
164 $dolgraph->SetDataColor(array_values($colorseries));
165 $dolgraph->setShowLegend(2);
166 $dolgraph->setShowPercent(1);
167 $dolgraph->SetType(array(
'pie'));
168 $dolgraph->setHeight(
'200');
169 $dolgraph->draw(
'idgraphstatus');
170 print $dolgraph->show($total ? 0 : 1);
175 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
176 print
"</table></div><br>";
186 $sql =
"SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
187 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
188 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
189 if (!$user->hasRight(
'societe',
'client',
'voir')) {
190 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
192 $sql .=
" WHERE c.fk_soc = s.rowid";
193 $sql .=
" AND c.entity = ".$conf->entity;
194 $sql .=
" AND c.fk_statut = 0";
196 $sql .=
" AND c.fk_soc = ".((int) $socid);
198 if (!$user->hasRight(
'societe',
'client',
'voir')) {
199 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
202 $resql = $db->query($sql);
204 print
'<div class="div-table-responsive-no-min">';
205 print
'<table class="noborder centpercent">';
206 print
'<tr class="liste_titre">';
207 print
'<th colspan="2">'.$langs->trans(
"DraftRequests").
'</th></tr>';
208 $langs->load(
"supplier_proposal");
209 $num = $db->num_rows($resql);
213 $obj = $db->fetch_object($resql);
215 print
'<tr class="oddeven">';
216 $supplier_proposalstatic->id = $obj->rowid;
217 $supplier_proposalstatic->ref = $obj->ref;
218 print
'<td class="nowrap">'.$supplier_proposalstatic->getNomUrl(1).
'</td>';
220 $companystatic->id = $obj->socid;
221 $companystatic->name = $obj->socname;
222 $companystatic->client = $obj->client;
223 $companystatic->canvas = $obj->canvas;
224 print
'<td>'.$companystatic->getNomUrl(1,
'customer', 24).
'</td>';
230 print
"</table></div><br>";
234print
'</div><div class="fichetwothirdright">';
243$sql =
"SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
244$sql .=
" date_cloture as datec";
245$sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
246$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
247if (!$user->hasRight(
'societe',
'client',
'voir')) {
248 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
250$sql .=
" WHERE c.fk_soc = s.rowid";
251$sql .=
" AND c.entity = ".$conf->entity;
254 $sql .=
" AND c.fk_soc = ".((int) $socid);
256if (!$user->hasRight(
'societe',
'client',
'voir')) {
257 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
259$sql .=
" ORDER BY c.tms DESC";
260$sql .= $db->plimit($max, 0);
262$resql = $db->query($sql);
264 print
'<div class="div-table-responsive-no-min">';
265 print
'<table class="noborder centpercent">';
266 print
'<tr class="liste_titre">';
267 print
'<th colspan="4">'.$langs->trans(
"LastModifiedRequests", $max).
'</th></tr>';
269 $num = $db->num_rows($resql);
273 $obj = $db->fetch_object($resql);
275 print
'<tr class="oddeven">';
276 print
'<td width="20%" class="nowrap">';
278 $supplier_proposalstatic->id = $obj->rowid;
279 $supplier_proposalstatic->ref = $obj->ref;
281 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
282 print
'<td width="96" class="nobordernopadding nowrap">';
283 print $supplier_proposalstatic->getNomUrl(1);
286 print
'<td width="16" class="nobordernopadding nowrap">';
290 print
'<td width="16" class="right nobordernopadding">';
293 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
294 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
295 print
'</td></tr></table>';
299 $companystatic->id = $obj->socid;
300 $companystatic->name = $obj->socname;
301 $companystatic->client = $obj->client;
302 $companystatic->canvas = $obj->canvas;
303 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
305 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
306 print
'<td class="right">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
311 print
"</table></div><br>";
320if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
321 $langs->load(
"supplier_proposal");
325 $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";
326 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
327 $sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
328 if (!$user->hasRight(
'societe',
'client',
'voir')) {
329 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
331 $sql .=
" WHERE p.fk_soc = s.rowid";
332 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
333 $sql .=
" AND p.fk_statut = 1";
334 if (!$user->hasRight(
'societe',
'client',
'voir')) {
335 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
338 $sql .=
" AND s.rowid = ".((int) $socid);
340 $sql .=
" ORDER BY p.rowid DESC";
342 $result = $db->query($sql);
345 $num = $db->num_rows($result);
348 print
'<div class="div-table-responsive-no-min">';
349 print
'<table class="noborder centpercent">';
350 print
'<tr class="liste_titre"><th colspan="5">'.$langs->trans(
"RequestsOpened");
351 print
' <a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status=1" alt="'.$langs->trans(
"GoOnList").
'"><span class="badge">'.$num.
'</span></a>';
355 while ($i < $nbofloop) {
356 $obj = $db->fetch_object($result);
358 print
'<tr class="oddeven">';
361 print
'<td class="nowrap" width="140">';
363 $supplier_proposalstatic->id = $obj->supplier_proposalid;
364 $supplier_proposalstatic->ref = $obj->ref;
366 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
367 print
'<td class="nobordernopadding nowrap">';
368 print $supplier_proposalstatic->getNomUrl(1);
370 print
'<td width="18" class="nobordernopadding nowrap">';
371 if ($db->jdate($obj->dfv) < ($now - $conf->supplier_proposal->cloture->warning_delay)) {
375 print
'<td width="16" class="center nobordernopadding">';
378 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->supplier_proposalid;
379 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
380 print
'</td></tr></table>';
384 $companystatic->id = $obj->socid;
385 $companystatic->name = $obj->socname;
386 $companystatic->client = $obj->client;
387 $companystatic->canvas = $obj->canvas;
388 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>'.
"\n";
390 print
'<td class="right">';
392 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
393 print
'<td class="center" width="14">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>'.
"\n";
396 $total += $obj->total_ttc;
398 if ($num > $nbofloop) {
399 print
'<tr class="liste_total"><td colspan="5">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
"</td></tr>";
400 } elseif ($total > 0) {
401 print
'<tr class="liste_total"><td colspan="3">'.$langs->trans(
"Total").
'</td><td class="right">'.
price($total).
"</td><td> </td></tr>";
403 print
"</table></div><br>";
412$parameters = array(
'user' => $user);
413$reshook = $hookmanager->executeHooks(
'dashboardSupplierProposal', $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 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.
dol_now($mode='gmt')
Return date for now.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.