28 require
'../../main.inc.php';
31 $socid =
GETPOST(
'socid',
'int');
32 if (isset($user->socid) && $user->socid > 0)
35 $socid = $user->socid;
39 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
44 $hookmanager->initHooks(array(
'proposalindex'));
47 $langs->loadLangs(array(
'propal',
'companies'));
55 $propalstatic =
new Propal($db);
56 $companystatic =
new Societe($db);
57 $form =
new Form($db);
59 $help_url =
"EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
61 llxHeader(
"", $langs->trans(
"ProspectionArea"), $help_url);
65 print '<div class="fichecenter">';
66 print
'<div class="fichethirdleft">';
69 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))
71 print
'<form method="post" action="'.DOL_URL_ROOT.
'/comm/propal/list.php">';
72 print
'<div class="div-table-responsive-no-min">';
73 print
'<input type="hidden" name="token" value="'.newToken().
'">';
74 print
'<table class="noborder nohover centpercent">';
76 print
'<tr class="liste_titre">';
77 print
'<td colspan="3">'.$langs->trans(
"Search").
'</td>';
80 print
'<tr class="oddeven">';
81 print
'<td>'.$langs->trans(
"Proposal").
':</td>';
82 print
'<td><input type="text" class="flat" name="sall" size=18></td>';
83 print
'<td><input type="submit" value="'.$langs->trans(
"Search").
'" class="button"></td>';
97 $sql =
"SELECT count(p.rowid) as nb, p.fk_statut as status";
98 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
99 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
100 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
101 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
102 $sql .=
" AND p.fk_soc = s.rowid";
103 if ($user->socid) $sql .=
' AND p.fk_soc = '.$user->socid;
104 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
105 $sql .=
" AND p.fk_statut IN (".implode(
" ,", $listofstatus).
")";
106 $sql .=
" GROUP BY p.fk_statut";
107 $resql = $db->query($sql);
110 $num = $db->num_rows(
$resql);
114 $dataseries = array();
115 $colorseries = array();
120 $obj = $db->fetch_object(
$resql);
123 $vals[$obj->status] = $obj->nb;
124 $totalinprocess += $obj->nb;
132 include_once DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
134 print
'<div class="div-table-responsive-no-min">';
135 print
'<table class="noborder nohover centpercent">';
137 print
'<tr class="liste_titre">';
138 print
'<td colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"Proposals").
'</td>';
141 foreach ($listofstatus as $status) {
142 $dataseries[] = array($propalstatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
149 if (empty($conf->use_javascript_ajax)) {
150 print
'<tr class="oddeven">';
151 print
'<td>'.$propalstatic->LibStatut($status, 0).
'</td>';
152 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
157 if ($conf->use_javascript_ajax) {
159 print
'<td align="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(
'idgraphthirdparties');
170 print $dolgraph->show($total ? 0 : 1);
184 print
'<tr class="liste_total">';
185 print
'<td>'.$langs->trans(
"Total").
'</td>';
186 print
'<td class="right">'.$total.
'</td>';
200 if (!empty($conf->propal->enabled)) {
201 $sql =
"SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc";
202 $sql .=
", s.rowid as socid, s.nom as name, s.client, s.canvas, s.code_client, s.email, s.entity, s.code_compta";
203 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as p";
204 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
205 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
206 $sql .=
" WHERE p.entity IN (".getEntity($propalstatic->element).
")";
207 $sql .=
" AND p.fk_soc = s.rowid";
208 $sql .=
" AND p.fk_statut =".Propal::STATUS_DRAFT;
209 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
210 if ($socid) $sql .=
" AND p.fk_soc = ".$socid;
212 $resql = $db->query($sql);
214 $num = $db->num_rows(
$resql);
215 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
222 while ($i < $nbofloop) {
223 $obj = $db->fetch_object(
$resql);
225 $propalstatic->id = $obj->rowid;
226 $propalstatic->ref = $obj->ref;
227 $propalstatic->ref_client = $obj->ref_client;
228 $propalstatic->total_ht = $obj->total_ht;
229 $propalstatic->total_tva = $obj->total_tva;
230 $propalstatic->total_ttc = $obj->total_ttc;
232 $companystatic->id = $obj->socid;
233 $companystatic->name = $obj->name;
234 $companystatic->client = $obj->client;
235 $companystatic->code_client = $obj->code_client;
236 $companystatic->code_fournisseur = $obj->code_fournisseur;
237 $companystatic->canvas = $obj->canvas;
238 $companystatic->entity = $obj->entity;
239 $companystatic->email = $obj->email;
240 $companystatic->code_compta = $obj->code_compta;
242 print
'<tr class="oddeven">';
243 print
'<td class="nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
244 print
'<td class="nowrap">'.$companystatic->getNomUrl(1,
'customer', 16).
'</td>';
245 print
'<td class="nowrap right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
249 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
263 print
'<div class="fichetwothirdright">';
264 print
'<div class="ficheaddleft">';
270 $sql =
"SELECT c.rowid, c.entity, c.ref, c.fk_statut, date_cloture as datec";
271 $sql .=
", s.nom as socname, s.rowid as socid, s.canvas, s.client";
272 $sql .=
" FROM ".MAIN_DB_PREFIX.
"propal as c";
273 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
274 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
275 $sql .=
" WHERE c.entity IN (".getEntity($propalstatic->element).
")";
276 $sql .=
" AND c.fk_soc = s.rowid";
278 if ($socid) $sql .=
" AND c.fk_soc = ".$socid;
279 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
280 $sql .=
" ORDER BY c.tms DESC";
281 $sql .= $db->plimit($max, 0);
283 $resql = $db->query($sql);
285 $num = $db->num_rows(
$resql);
291 $obj = $db->fetch_object(
$resql);
293 $propalstatic->id = $obj->rowid;
294 $propalstatic->ref = $obj->ref;
296 $companystatic->id = $obj->socid;
297 $companystatic->name = $obj->socname;
298 $companystatic->client = $obj->client;
299 $companystatic->canvas = $obj->canvas;
303 $urlsource =
$_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
305 print
'<tr class="oddeven">';
307 print
'<td width="20%" class="nowrap">';
308 print
'<table class="nobordernopadding">';
309 print
'<tr class="nocellnopadd">';
310 print
'<td width="96" class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
311 print
'<td width="16" class="nobordernopadding nowrap"></td>';
312 print
'<td width="16" class="nobordernopadding right">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
317 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
318 print
'<td>'.dol_print_date($db->jdate($obj->datec),
'day').
'</td>';
319 print
'<td class="right">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
337 if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
338 $sql =
"SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client";
339 $sql .=
", p.rowid as propalid, p.entity, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
340 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
341 $sql .=
", ".MAIN_DB_PREFIX.
"propal as p";
342 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
343 $sql .=
" WHERE p.fk_soc = s.rowid";
344 $sql .=
" AND p.entity IN (".getEntity($propalstatic->element).
")";
345 $sql .=
" AND p.fk_statut = ".Propal::STATUS_VALIDATED;
346 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
347 if ($socid) $sql .=
" AND s.rowid = ".$socid;
348 $sql .=
" ORDER BY p.rowid DESC";
350 $resql = $db->query($sql);
353 $num = $db->num_rows(
$resql);
354 $nbofloop = min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD));
359 while ($i < $nbofloop) {
360 $obj = $db->fetch_object(
$resql);
362 $propalstatic->id = $obj->propalid;
363 $propalstatic->ref = $obj->ref;
365 $companystatic->id = $obj->socid;
366 $companystatic->name = $obj->socname;
367 $companystatic->client = $obj->client;
368 $companystatic->canvas = $obj->canvas;
372 $urlsource =
$_SERVER[
'PHP_SELF'].
'?id='.$obj->propalid;
374 $warning = ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) ?
img_warning($langs->trans(
"Late")) :
'';
376 print
'<tr class="oddeven">';
379 print
'<td class="nowrap" width="140">';
380 print
'<table class="nobordernopadding">';
381 print
'<tr class="nocellnopadd">';
382 print
'<td class="nobordernopadding nowrap">'.$propalstatic->getNomUrl(1).
'</td>';
383 print
'<td width="18" class="nobordernopadding nowrap">'.$warning.
'</td>';
384 print
'<td width="16" align="center" class="nobordernopadding">'.$formfile->getDocumentsLink($propalstatic->element, $filename, $filedir).
'</td>';
389 print
'<td class="left">'.$companystatic->getNomUrl(1,
'customer', 44).
'</td>';
390 print
'<td class="right">'.dol_print_date($db->jdate($obj->dp),
'day').
'</td>';
391 print
'<td class="right">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).
'</td>';
392 print
'<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).
'</td>';
397 $total += (!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc);
562 $parameters = array(
'user' => $user);
563 $reshook = $hookmanager->executeHooks(
'dashboardPropals', $parameters, $object);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
addSummaryTableLine($tableColumnCount, $num, $nbofloop=0, $total=0, $noneWord="None", $extraRightColumn=false)
Add a summary line to the current open table ("None", "XMoreLines" or "Total xxx") ...
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
finishSimpleTable($addLineBreak=false)
Add the correct HTML close tags for "startSimpleTable(...)" (use after the last table line) ...
const STATUS_NOTSIGNED
Not signed quote.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
const STATUS_BILLED
Billed or processed quote.
const STATUS_SIGNED
Signed quote.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
print $_SERVER["PHP_SELF"]
Edit parameters.
const STATUS_DRAFT
Draft status.
print
Draft customers invoices.
startSimpleTable($header, $link="", $arguments="", $emptyRows=0, $number=-1)
Start a table with headers and a optinal clickable number (don't forget to use "finishSimpleTable()" ...
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
const STATUS_VALIDATED
Validated status.
Class to manage proposals.