31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/supplier_proposal/class/supplier_proposal.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/dashboard.lib.php';
45$hookmanager->initHooks(array(
'suppliersproposalsindex'));
48$langs->loadLangs(array(
'supplier_proposal',
'companies'));
52if (!empty($user->socid) && $user->socid > 0) {
54 $socid = $user->socid;
64$companystatic =
new Societe($db);
68$title = $langs->trans(
"SupplierProposalArea");
69$help_url =
"EN:Module_Ask_Price_Supplier|FR:Module_Demande_de_prix_fournisseur";
71llxHeader(
"", $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-supplierproposal page-index');
73print
load_fiche_titre($langs->trans(
"SupplierProposalArea"),
'',
'supplier_proposal');
75print
'<div class="fichecenter"><div class="fichethirdleft">';
79$sql =
"SELECT count(p.rowid), p.fk_statut";
80$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
81$sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
82if (!$user->hasRight(
'societe',
'client',
'voir')) {
83 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
85$sql .=
" WHERE p.fk_soc = s.rowid";
86$sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
88 $sql .=
' AND p.fk_soc = '.((int) $user->socid);
90if (!$user->hasRight(
'societe',
'client',
'voir')) {
91 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
93$sql .=
" AND p.fk_statut IN (0,1,2,3,4)";
94$sql .=
" GROUP BY p.fk_statut";
95$resql = $db->query($sql);
98 while ($row = $db->fetch_row($resql)) {
99 $vals[$row[1]] = $row[0];
104 $colorofstatus = array(
112 foreach (array(0, 1, 2, 3, 4) as $status) {
114 'label' => $supplier_proposalstatic->LibStatut($status, 1),
115 'labelnojs' => $supplier_proposalstatic->LibStatut($status, 0),
116 'nb' => (isset($vals[$status]) ? (
int) $vals[$status] : 0),
117 'color' => $colorofstatus[$status],
118 'url' =>
'list.php?search_status='.$status,
121 print
getStatusPieChart($langs->trans(
"Statistics").
' - '.$langs->trans(
"CommRequests"), $series);
123 dol_print_error($db);
131 $sql =
"SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
132 $sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
133 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
134 if (!$user->hasRight(
'societe',
'client',
'voir')) {
135 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
137 $sql .=
" WHERE c.fk_soc = s.rowid";
138 $sql .=
" AND c.entity = ".((int)
$conf->entity);
139 $sql .=
" AND c.fk_statut = 0";
141 $sql .=
" AND c.fk_soc = ".((int) $socid);
143 if (!$user->hasRight(
'societe',
'client',
'voir')) {
144 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
147 $resql = $db->query($sql);
149 print
'<div class="div-table-responsive-no-min">';
150 print
'<table class="noborder centpercent">';
151 print
'<tr class="liste_titre">';
152 print
'<th colspan="2">'.$langs->trans(
"DraftRequests").
'</th></tr>';
153 $langs->load(
"supplier_proposal");
154 $num = $db->num_rows($resql);
158 $obj = $db->fetch_object($resql);
160 print
'<tr class="oddeven">';
161 $supplier_proposalstatic->id = $obj->rowid;
162 $supplier_proposalstatic->ref = $obj->ref;
163 print
'<td class="nowrap">'.$supplier_proposalstatic->getNomUrl(1).
'</td>';
165 $companystatic->id = $obj->socid;
166 $companystatic->name = $obj->socname;
167 $companystatic->client = $obj->client;
168 $companystatic->canvas = $obj->canvas;
169 print
'<td>'.$companystatic->getNomUrl(1,
'customer', 24).
'</td>';
175 print
"</table></div><br>";
179print
'</div><div class="fichetwothirdright">';
188$sql =
"SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
189$sql .=
" date_cloture as datec";
190$sql .=
" FROM ".MAIN_DB_PREFIX.
"supplier_proposal as c";
191$sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
192if (!$user->hasRight(
'societe',
'client',
'voir')) {
193 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
195$sql .=
" WHERE c.fk_soc = s.rowid";
196$sql .=
" AND c.entity = ".((int)
$conf->entity);
199 $sql .=
" AND c.fk_soc = ".((int) $socid);
201if (!$user->hasRight(
'societe',
'client',
'voir')) {
202 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
204$sql .=
" ORDER BY c.tms DESC";
205$sql .= $db->plimit($max, 0);
207$resql = $db->query($sql);
209 print
'<div class="div-table-responsive-no-min">';
210 print
'<table class="noborder centpercent">';
211 print
'<tr class="liste_titre">';
212 print
'<th colspan="4">'.$langs->trans(
"LastModifiedRequests", $max).
'</th></tr>';
214 $num = $db->num_rows($resql);
218 $obj = $db->fetch_object($resql);
220 print
'<tr class="oddeven">';
221 print
'<td width="20%" class="nowrap">';
223 $supplier_proposalstatic->id = $obj->rowid;
224 $supplier_proposalstatic->ref = $obj->ref;
226 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
227 print
'<td width="96" class="nobordernopadding nowrap">';
228 print $supplier_proposalstatic->getNomUrl(1);
231 print
'<td width="16" class="nobordernopadding nowrap">';
235 print
'<td width="16" class="right nobordernopadding">';
238 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
239 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
240 print
'</td></tr></table>';
244 $companystatic->id = $obj->socid;
245 $companystatic->name = $obj->socname;
246 $companystatic->client = $obj->client;
247 $companystatic->canvas = $obj->canvas;
248 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
250 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
251 print
'<td class="right">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
256 print
"</table></div><br>";
258 dol_print_error($db);
265if (
isModEnabled(
'supplier_proposal') && $user->hasRight(
'supplier_proposal',
'lire')) {
266 $langs->load(
"supplier_proposal");
270 $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";
271 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
272 $sql .=
", ".MAIN_DB_PREFIX.
"supplier_proposal as p";
273 if (!$user->hasRight(
'societe',
'client',
'voir')) {
274 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
276 $sql .=
" WHERE p.fk_soc = s.rowid";
277 $sql .=
" AND p.entity IN (".getEntity(
'supplier_proposal').
")";
278 $sql .=
" AND p.fk_statut = 1";
279 if (!$user->hasRight(
'societe',
'client',
'voir')) {
280 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
283 $sql .=
" AND s.rowid = ".((int) $socid);
285 $sql .=
" ORDER BY p.rowid DESC";
287 $result = $db->query($sql);
290 $num = $db->num_rows($result);
293 print
'<div class="div-table-responsive-no-min">';
294 print
'<table class="noborder centpercent">';
295 print
'<tr class="liste_titre"><th colspan="5">'.$langs->trans(
"RequestsOpened");
296 print
' <a href="'.DOL_URL_ROOT.
'/supplier_proposal/list.php?search_status=1" alt="'.$langs->trans(
"GoOnList").
'"><span class="badge">'.$num.
'</span></a>';
300 while ($i < $nbofloop) {
301 $obj = $db->fetch_object($result);
303 print
'<tr class="oddeven">';
306 print
'<td class="nowrap" width="140">';
308 $supplier_proposalstatic->id = $obj->supplier_proposalid;
309 $supplier_proposalstatic->ref = $obj->ref;
311 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
312 print
'<td class="nobordernopadding nowrap">';
313 print $supplier_proposalstatic->getNomUrl(1);
315 print
'<td width="18" class="nobordernopadding nowrap">';
316 if (isset($obj->dfv) && $db->jdate($obj->dfv) < ($now -
$conf->supplier_proposal->cloture->warning_delay)) {
317 print img_warning($langs->trans(
"Late"));
320 print
'<td width="16" class="center nobordernopadding">';
323 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->supplier_proposalid;
324 print $formfile->getDocumentsLink($supplier_proposalstatic->element, $filename, $filedir);
325 print
'</td></tr></table>';
329 $companystatic->id = $obj->socid;
330 $companystatic->name = $obj->socname;
331 $companystatic->client = $obj->client;
332 $companystatic->canvas = $obj->canvas;
333 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>'.
"\n";
335 print
'<td class="right">';
337 print
'<td class="right">'.price($obj->total_ttc).
'</td>';
338 print
'<td class="center" width="14">'.$supplier_proposalstatic->LibStatut($obj->fk_statut, 3).
'</td>'.
"\n";
341 $total += $obj->total_ttc;
343 if ($num > $nbofloop) {
344 print
'<tr class="liste_total"><td colspan="5">'.$langs->trans(
"XMoreLines", ($num - $nbofloop)).
"</td></tr>";
345 } elseif ($total > 0) {
346 print
'<tr class="liste_total"><td colspan="3">'.$langs->trans(
"Total").
'</td><td class="right">'.
price($total).
"</td><td> </td></tr>";
348 print
"</table></div><br>";
351 dol_print_error($db);
357$parameters = array(
'user' => $user);
358$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.
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.
dol_now($mode='gmt')
Return date for now.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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).
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.