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