dolibarr 18.0.6
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// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
30
31// Load translation files required by the page
32$langs->load("propal");
33
34if ($user->socid > 0) {
35 $socid = $user->socid;
36}
37
38// Security check
39$socid = GETPOST('socid', 'int');
40if ($user->socid) {
41 $action = '';
42 $socid = $user->socid;
43}
44$result = restrictedArea($user, 'propal', $socid, '');
45
46
47
48/*
49 * View
50 */
51
52$companystatic = new Societe($db);
53
54llxHeader();
55
56print load_fiche_titre($langs->trans("ProspectionArea"));
57
58//print '<table border="0" width="100%" class="notopnoleftnoright">';
59//print '<tr><td valign="top" width="30%" class="notopnoleft">';
60print '<div class="fichecenter"><div class="fichethirdleft">';
61
62
63if (isModEnabled("propal")) {
64 $var = false;
65 print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/card.php">';
66 print '<input type="hidden" name="token" value="'.newToken().'">';
67 print '<table class="noborder nohover centpercent">';
68 print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
69 print '<tr class="oddeven"><td>';
70 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>';
71 print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
72 print '</tr>';
73 print "</table></form><br>\n";
74}
75
76/*
77 * Prospects par statut
78 *
79 */
80
81$sql = "SELECT count(*) as cc, st.libelle as stcomm, st.picto, st.id";
82$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
83$sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
84if (empty($user->rights->societe->client->voir) && !$socid) {
85 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
86}
87$sql .= " WHERE s.fk_stcomm = st.id";
88$sql .= " AND s.client IN (2, 3)";
89$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
90if (empty($user->rights->societe->client->voir) && !$socid) {
91 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
92}
93$sql .= " GROUP BY st.id";
94$sql .= " ORDER BY st.id";
95
96$resql = $db->query($sql);
97if ($resql) {
98 $num = $db->num_rows($resql);
99 $i = 0;
100 if ($num > 0) {
101 print '<table class="noborder centpercent">';
102 print '<tr class="liste_titre">';
103 print '<td colspan="2">'.$langs->trans("ProspectsByStatus").'</td></tr>';
104 while ($i < $num) {
105 $obj = $db->fetch_object($resql);
106
107 print '<tr class="oddeven"><td>';
108 print '<a href="prospects.php?page=0&amp;stcomm='.$obj->id.'">';
109 print img_action($langs->trans("Show"), $obj->id, $obj->picto).' ';
110 print $langs->trans("StatusProspect".$obj->id);
111 print '</a></td><td class="right">'.$obj->cc.'</td></tr>';
112 $i++;
113 }
114 print "</table><br>";
115 }
116}
117
118
119/*
120 * Liste des propal brouillons
121 */
122if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
123 $sql = "SELECT p.rowid, p.ref, p.price, s.nom as sname";
124 $sql .= " FROM ".MAIN_DB_PREFIX."propal as p";
125 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
126 if (empty($user->rights->societe->client->voir) && !$socid) {
127 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
128 }
129 $sql .= " WHERE p.fk_statut = 0";
130 $sql .= " AND p.fk_soc = s.rowid";
131 $sql .= " AND p.entity IN (".getEntity('propal').")";
132 if (empty($user->rights->societe->client->voir) && !$socid) {
133 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
134 }
135
136 $resql = $db->query($sql);
137 if ($resql) {
138 $total = 0;
139 $num = $db->num_rows($resql);
140 $i = 0;
141 if ($num > 0) {
142 print '<table class="noborder"" width="100%">';
143 print '<tr class="liste_titre">';
144 print '<td colspan="2">'.$langs->trans("ProposalsDraft").'</td></tr>';
145
146 while ($i < $num) {
147 $obj = $db->fetch_object($resql);
148
149 print '<tr class="oddeven"><td>';
150 print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a>';
151 print '</td><td class="right">';
152 print price($obj->price);
153 print "</td></tr>";
154 $i++;
155 $total += $obj->price;
156 }
157 if ($total > 0) {
158 print '<tr class="liste_total"><td>'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
159 }
160 print "</table><br>";
161 }
162 $db->free($resql);
163 }
164}
165
166
167print '</div><div class="fichetwothirdright">';
168
169
170/*
171 * Actions commerciales a faire
172 */
173if (isModEnabled('agenda')) {
175}
176
177/*
178 * Dernieres propales ouvertes
179 */
180if (isModEnabled("propal") && $user->hasRight('propal', 'lire')) {
181 $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas,";
182 $sql .= " p.rowid as propalid, p.total_ttc, p.ref, p.datep as dp, c.label as statut, c.id as statutid";
183 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
184 $sql .= ", ".MAIN_DB_PREFIX."propal as p";
185 $sql .= ", ".MAIN_DB_PREFIX."c_propalst as c";
186 if (empty($user->rights->societe->client->voir) && !$socid) {
187 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
188 }
189 $sql .= " WHERE p.fk_soc = s.rowid";
190 $sql .= " AND p.fk_statut = c.id";
191 $sql .= " AND p.fk_statut = 1";
192 $sql .= " AND p.entity IN (".getEntity('propal').")";
193 if (empty($user->rights->societe->client->voir) && !$socid) {
194 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
195 }
196 if ($socid) {
197 $sql .= " AND s.rowid = ".((int) $socid);
198 }
199 $sql .= " ORDER BY p.rowid DESC";
200 $sql .= $db->plimit(5, 0);
201
202 $resql = $db->query($sql);
203 if ($resql) {
204 $total = 0;
205 $num = $db->num_rows($resql);
206 $i = 0;
207 if ($num > 0) {
208 print '<table class="noborder centpercent">';
209 print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProposalsOpened").'</td></tr>';
210
211 while ($i < $num) {
212 $obj = $db->fetch_object($resql);
213
214 print '<tr class="oddeven"><td>';
215 print '<a href="../propal.php?id='.$obj->propalid.'">';
216 print img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a></td>';
217
218 print "<td>";
219 $companystatic->id = $obj->socid;
220 $companystatic->name = $obj->name;
221 $companystatic->client = $obj->client;
222 $companystatic->canvas = $obj->canvas;
223 print $companystatic->getNomUrl(1, '', 44);
224 print "</td>\n";
225 print "<td align=\"right\">";
226 print dol_print_date($db->jdate($obj->dp), 'day')."</td>\n";
227 print "<td align=\"right\">".price($obj->total_ttc)."</td></tr>\n";
228 $i++;
229 $total += $obj->price;
230 }
231 if ($total > 0) {
232 print '<tr class="liste_total"><td colspan="3" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td></tr>";
233 }
234 print "</table><br>";
235 }
236 } else {
237 dol_print_error($db);
238 }
239}
240
241/*
242 * Societes a contacter
243 *
244 */
245$sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
246$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
247if (empty($user->rights->societe->client->voir) && !$socid) {
248 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
249}
250$sql .= " WHERE s.fk_stcomm = 1";
251$sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
252if (empty($user->rights->societe->client->voir) && !$socid) {
253 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
254}
255$sql .= " ORDER BY s.tms ASC";
256$sql .= $db->plimit(15, 0);
257
258$resql = $db->query($sql);
259if ($resql) {
260 $num = $db->num_rows($resql);
261 $i = 0;
262 if ($num > 0) {
263 print '<table class="noborder centpercent">';
264 print '<tr class="liste_titre"><td>'.$langs->trans("ProspectToContact").'</td></tr>';
265
266 while ($i < $num) {
267 $obj = $db->fetch_object($resql);
268
269 print '<tr class="oddeven"><td width="12%">';
270 $companystatic->id = $obj->socid;
271 $companystatic->name = $obj->name;
272 $companystatic->client = $obj->client;
273 $companystatic->canvas = $obj->canvas;
274 print $companystatic->getNomUrl(1, 'prospect', 44);
275 print '</td></tr>';
276 $i++;
277 }
278 print "</table><br>";
279 }
280}
281
282
283print '</div></div>';
284
285// End of page
286llxFooter();
287$db->close();
show_array_actions_to_do($max=5)
Show actions to do array.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:56
llxFooter()
Empty footer.
Definition wrapper.php:70
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
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='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.