dolibarr  16.0.5
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2020 Open-Dsi <support@open-dsi.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 require '../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
29 
30 // Load translation files required by the page
31 $langs->load("propal");
32 
33 if ($user->socid > 0) {
34  $socid = $user->socid;
35 }
36 
37 // Security check
38 $socid = GETPOST('socid', 'int');
39 if ($user->socid) {
40  $action = '';
41  $socid = $user->socid;
42 }
43 $result = restrictedArea($user, 'propal', $socid, '');
44 
45 
46 
47 /*
48  * View
49  */
50 
51 $companystatic = new Societe($db);
52 
53 llxHeader();
54 
55 print load_fiche_titre($langs->trans("ProspectionArea"));
56 
57 //print '<table border="0" width="100%" class="notopnoleftnoright">';
58 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
59 print '<div class="fichecenter"><div class="fichethirdleft">';
60 
61 
62 if (!empty($conf->propal->enabled)) {
63  $var = false;
64  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/card.php">';
65  print '<input type="hidden" name="token" value="'.newToken().'">';
66  print '<table class="noborder nohover centpercent">';
67  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
68  print '<tr class="oddeven"><td>';
69  print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
70  print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
71  print '</tr>';
72  print "</table></form><br>\n";
73 }
74 
75 /*
76  * Prospects par statut
77  *
78  */
79 
80 $sql = "SELECT count(*) as cc, st.libelle as stcomm, st.picto, st.id";
81 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
82 $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
83 if (empty($user->rights->societe->client->voir) && !$socid) {
84  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
85 }
86 $sql .= " WHERE s.fk_stcomm = st.id";
87 $sql .= " AND s.client IN (2, 3)";
88 $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
89 if (empty($user->rights->societe->client->voir) && !$socid) {
90  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
91 }
92 $sql .= " GROUP BY st.id";
93 $sql .= " ORDER BY st.id";
94 
95 $resql = $db->query($sql);
96 if ($resql) {
97  $num = $db->num_rows($resql);
98  $i = 0;
99  if ($num > 0) {
100  print '<table class="noborder centpercent">';
101  print '<tr class="liste_titre">';
102  print '<td colspan="2">'.$langs->trans("ProspectsByStatus").'</td></tr>';
103  while ($i < $num) {
104  $obj = $db->fetch_object($resql);
105 
106  print '<tr class="oddeven"><td>';
107  print '<a href="prospects.php?page=0&amp;stcomm='.$obj->id.'">';
108  print img_action($langs->trans("Show"), $obj->id, $obj->picto).' ';
109  print $langs->trans("StatusProspect".$obj->id);
110  print '</a></td><td class="right">'.$obj->cc.'</td></tr>';
111  $i++;
112  }
113  print "</table><br>";
114  }
115 }
116 
117 
118 /*
119  * Liste des propal brouillons
120  */
121 if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
122  $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname";
123  $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
124  $sql .= ", ".MAIN_DB_PREFIX."societe as s";
125  if (empty($user->rights->societe->client->voir) && !$socid) {
126  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
127  }
128  $sql .= " WHERE p.fk_statut = 0";
129  $sql .= " AND p.fk_soc = s.rowid";
130  $sql .= " AND p.entity IN (".getEntity('propal').")";
131  if (empty($user->rights->societe->client->voir) && !$socid) {
132  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
133  }
134 
135  $resql = $db->query($sql);
136  if ($resql) {
137  $total = 0;
138  $num = $db->num_rows($resql);
139  $i = 0;
140  if ($num > 0) {
141  print '<table class="noborder"" width="100%">';
142  print '<tr class="liste_titre">';
143  print '<td colspan="2">'.$langs->trans("ProposalsDraft").'</td></tr>';
144 
145  while ($i < $num) {
146  $obj = $db->fetch_object($resql);
147 
148  print '<tr class="oddeven"><td>';
149  print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a>';
150  print '</td><td class="right">';
151  print price($obj->price);
152  print "</td></tr>";
153  $i++;
154  $total += $obj->price;
155  }
156  if ($total > 0) {
157  print '<tr class="liste_total"><td>'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
158  }
159  print "</table><br>";
160  }
161  $db->free($resql);
162  }
163 }
164 
165 
166 print '</div><div class="fichetwothirdright">';
167 
168 
169 /*
170  * Actions commerciales a faire
171  */
172 if (isModEnabled('agenda')) {
174 }
175 
176 /*
177  * Dernieres propales ouvertes
178  */
179 if (!empty($conf->propal->enabled) && $user->rights->propale->lire) {
180  $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,";
181  $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
182  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
183  $sql .= ", ".MAIN_DB_PREFIX."propal as p";
184  $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c";
185  if (empty($user->rights->societe->client->voir) && !$socid) {
186  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
187  }
188  $sql .= " WHERE p.fk_soc = s.rowid";
189  $sql .= " AND p.fk_statut = c.id";
190  $sql .= " AND p.fk_statut = 1";
191  $sql .= " AND p.entity IN (".getEntity('propal').")";
192  if (empty($user->rights->societe->client->voir) && !$socid) {
193  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
194  }
195  if ($socid) {
196  $sql .= " AND s.rowid = ".((int) $socid);
197  }
198  $sql .= " ORDER BY p.rowid DESC";
199  $sql .= $db->plimit(5, 0);
200 
201  $resql = $db->query($sql);
202  if ($resql) {
203  $total = 0;
204  $num = $db->num_rows($resql);
205  $i = 0;
206  if ($num > 0) {
207  print '<table class="noborder centpercent">';
208  print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProposalsOpened").'</td></tr>';
209 
210  while ($i < $num) {
211  $obj = $db->fetch_object($resql);
212 
213  print '<tr class="oddeven"><td>';
214  print '<a href="../propal.php?id='.$obj->propalid.'">';
215  print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a></td>';
216 
217  print "<td>";
218  $companystatic->id = $obj->socid;
219  $companystatic->name = $obj->name;
220  $companystatic->client = $obj->client;
221  $companystatic->canvas = $obj->canvas;
222  print $companystatic->getNomUrl(1, '', 44);
223  print "</td>\n";
224  print "<td align=\"right\">";
225  print dol_print_date($db->jdate($obj->dp), 'day')."</td>\n";
226  print "<td align=\"right\">".price($obj->total_ttc)."</td></tr>\n";
227  $i++;
228  $total += $obj->price;
229  }
230  if ($total > 0) {
231  print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td></tr>";
232  }
233  print "</table><br>";
234  }
235  } else {
236  dol_print_error($db);
237  }
238 }
239 
240 /*
241  * Societes a contacter
242  *
243  */
244 $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
245 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
246 if (empty($user->rights->societe->client->voir) && !$socid) {
247  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
248 }
249 $sql .= " WHERE s.fk_stcomm = 1";
250 $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
251 if (empty($user->rights->societe->client->voir) && !$socid) {
252  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
253 }
254 $sql .= " ORDER BY s.tms ASC";
255 $sql .= $db->plimit(15, 0);
256 
257 $resql = $db->query($sql);
258 if ($resql) {
259  $num = $db->num_rows($resql);
260  $i = 0;
261  if ($num > 0) {
262  print '<table class="noborder centpercent">';
263  print '<tr class="liste_titre"><td>'.$langs->trans("ProspectToContact").'</td></tr>';
264 
265  while ($i < $num) {
266  $obj = $db->fetch_object($resql);
267 
268  print '<tr class="oddeven"><td width="12%">';
269  $companystatic->id = $obj->socid;
270  $companystatic->name = $obj->name;
271  $companystatic->client = $obj->client;
272  $companystatic->canvas = $obj->canvas;
273  print $companystatic->getNomUrl(1, 'prospect', 44);
274  print '</td></tr>';
275  $i++;
276  }
277  print "</table><br>";
278  }
279 }
280 
281 
282 print '</div></div>';
283 
284 // End of page
285 llxFooter();
286 $db->close();
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
img_action
img_action($titlealt, $numaction, $picto='')
Show logo action.
Definition: functions.lib.php:4296
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
price
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.
Definition: functions.lib.php:5541
show_array_actions_to_do
show_array_actions_to_do($max=5)
Show actions to do array.
Definition: agenda.lib.php:147