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];
118 include DOL_DOCUMENT_ROOT.
'/theme/'.
$conf->theme.
'/theme_vars.inc.php';
120 print
'<div class="div-table-responsive-no-min">';
121 print
'<table class="noborder centpercent">';
122 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"CommRequests").
'</th></tr>'.
"\n";
123 $listofstatus = array(0, 1, 2, 3, 4);
124 foreach ($listofstatus as $status) {
125 $dataseries[] = array($supplier_proposalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
127 $colorseries[$status] =
'-'.$badgeStatus0;
130 $colorseries[$status] = $badgeStatus1;
133 $colorseries[$status] = $badgeStatus4;
136 $colorseries[$status] = $badgeStatus9;
139 $colorseries[$status] = $badgeStatus6;
142 if (empty(
$conf->use_javascript_ajax)) {
143 print
'<tr class="oddeven">';
144 print
'<td>'.$supplier_proposalstatic->LibStatut($status, 0).
'</td>';
145 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
149 if (
$conf->use_javascript_ajax) {
150 print
'<tr><td class="center" colspan="2">';
152 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
154 $dolgraph->SetData($dataseries);
155 $dolgraph->SetDataColor(array_values($colorseries));
156 $dolgraph->setShowLegend(2);
157 $dolgraph->setShowPercent(1);
158 $dolgraph->SetType(array(
'pie'));
159 $dolgraph->setHeight(
'200');
160 $dolgraph->draw(
'idgraphstatus');
161 print $dolgraph->show($total ? 0 : 1);
166 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
167 print
"</table></div><br>";
176if (isModEnabled(
'supplier_proposal')) {
177 $sql =
"SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
178 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
179 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
180 if (!$user->hasRight(
'societe',
'client',
'voir')) {
181 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
183 $sql .=
" WHERE c.fk_soc = s.rowid";
184 $sql .=
" AND c.entity = ".$conf->entity;
185 $sql .=
" AND c.fk_statut = 0";
187 $sql .=
" AND c.fk_soc = ".((int) $socid);
189 if (!$user->hasRight(
'societe',
'client',
'voir')) {
190 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
193 $resql = $db->query($sql);
195 print
'<div class="div-table-responsive-no-min">';
196 print
'<table class="noborder centpercent">';
197 print
'<tr class="liste_titre">';
198 print
'<th colspan="2">'.$langs->trans(
"DraftRequests").
'</th></tr>';
199 $langs->load(
"supplier_proposal");
200 $num = $db->num_rows($resql);
204 $obj = $db->fetch_object($resql);
206 print
'<tr class="oddeven">';
207 $supplier_proposalstatic->id = $obj->rowid;
208 $supplier_proposalstatic->ref = $obj->ref;
209 print
'<td class="nowrap">'.$supplier_proposalstatic->getNomUrl(1).
'</td>';
211 $companystatic->id = $obj->socid;
212 $companystatic->name = $obj->socname;
213 $companystatic->client = $obj->client;
214 $companystatic->canvas = $obj->canvas;
215 print
'<td>'.$companystatic->getNomUrl(1,
'customer', 24).
'</td>';
221 print
"</table></div><br>";
225print
'</div><div class="fichetwothirdright">';
234$sql =
"SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
235$sql .=
" date_cloture as datec";
236$sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
237$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
238if (!$user->hasRight(
'societe',
'client',
'voir')) {
239 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
241$sql .=
" WHERE c.fk_soc = s.rowid";
242$sql .=
" AND c.entity = ".$conf->entity;
245 $sql .=
" AND c.fk_soc = ".((int) $socid);
247if (!$user->hasRight(
'societe',
'client',
'voir')) {
248 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
250$sql .=
" ORDER BY c.tms DESC";
251$sql .= $db->plimit($max, 0);
253$resql = $db->query($sql);
255 print
'<div class="div-table-responsive-no-min">';
256 print
'<table class="noborder centpercent">';
257 print
'<tr class="liste_titre">';
258 print
'<th colspan="4">'.$langs->trans(
"LastModifiedRequests", $max).
'</th></tr>';
260 $num = $db->num_rows($resql);
264 $obj = $db->fetch_object($resql);
266 print
'<tr class="oddeven">';
267 print
'<td width="20%" class="nowrap">';
269 $supplier_proposalstatic->id = $obj->rowid;
270 $supplier_proposalstatic->ref = $obj->ref;
272 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
273 print
'<td width="96" class="nobordernopadding nowrap">';
274 print $supplier_proposalstatic->getNomUrl(1);
277 print
'<td width="16" class="nobordernopadding nowrap">';
281 print
'<td width="16" class="right nobordernopadding">';
284 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
285 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
286 print
'</td></tr></table>';
290 $companystatic->id = $obj->socid;
291 $companystatic->name = $obj->socname;
292 $companystatic->client = $obj->client;
293 $companystatic->canvas = $obj->canvas;
294 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
296 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
297 print
'<td class="right">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
302 print
"</table></div><br>";
311if (isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
312 $langs->load(
"supplier_proposal");
316 $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";
317 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
318 $sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
319 if (!$user->hasRight(
'societe',
'client',
'voir')) {
320 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
322 $sql .=
" WHERE p.fk_soc = s.rowid";
323 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
324 $sql .=
" AND p.fk_statut = 1";
325 if (!$user->hasRight(
'societe',
'client',
'voir')) {
326 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
329 $sql .=
" AND s.rowid = ".((int) $socid);
331 $sql .=
" ORDER BY p.rowid DESC";
333 $result = $db->query($sql);
336 $num = $db->num_rows($result);
339 print
'<div class="div-table-responsive-no-min">';
340 print
'<table class="noborder centpercent">';
341 print
'<tr class="liste_titre"><th colspan="5">'.$langs->trans(
"RequestsOpened");
342 print
' <a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status=1" alt="'.$langs->trans(
"GoOnList").
'"><span class="badge">'.$num.
'</span></a>';
345 $nbofloop = min($num, (!
getDolGlobalString(
'MAIN_MAXLIST_OVERLOAD') ? 500 :
$conf->global->MAIN_MAXLIST_OVERLOAD));
346 while ($i < $nbofloop) {
347 $obj = $db->fetch_object($result);
349 print
'<tr class="oddeven">';
352 print
'<td class="nowrap" width="140">';
354 $supplier_proposalstatic->id = $obj->supplier_proposalid;
355 $supplier_proposalstatic->ref = $obj->ref;
357 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
358 print
'<td class="nobordernopadding nowrap">';
359 print $supplier_proposalstatic->getNomUrl(1);
361 print
'<td width="18" class="nobordernopadding nowrap">';
362 if ($db->jdate($obj->dfv) < ($now -
$conf->supplier_proposal->cloture->warning_delay)) {
366 print
'<td width="16" class="center nobordernopadding">';
369 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->supplier_proposalid;
370 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
371 print
'</td></tr></table>';
375 $companystatic->id = $obj->socid;
376 $companystatic->name = $obj->socname;
377 $companystatic->client = $obj->client;
378 $companystatic->canvas = $obj->canvas;
379 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>'.
"\n";
381 print
'<td class="right">';
383 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
384 print
'<td class="center" width="14">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>'.
"\n";
387 $total += $obj->total_ttc;
389 if ($num > $nbofloop) {
390 print
'<tr class="liste_total"><td colspan="5">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
"</td></tr>";
391 } elseif ($total > 0) {
392 print
'<tr class="liste_total"><td colspan="3">'.$langs->trans(
"Total").
'</td><td class="right">'.
price($total).
"</td><td> </td></tr>";
394 print
"</table></div><br>";
403$parameters = array(
'user' => $user);
404$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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.