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