dolibarr  13.0.2
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 
34 if ($user->socid > 0)
35 {
36  $socid = $user->socid;
37 }
38 
39 
40 
41 /*
42  * View
43  */
44 
45 $companystatic = new Societe($db);
46 
47 llxHeader();
48 
49 print load_fiche_titre($langs->trans("ProspectionArea"));
50 
51 //print '<table border="0" width="100%" class="notopnoleftnoright">';
52 //print '<tr><td valign="top" width="30%" class="notopnoleft">';
53 print '<div class="fichecenter"><div class="fichethirdleft">';
54 
55 
56 if (!empty($conf->propal->enabled))
57 {
58  $var = false;
59  print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/card.php">';
60  print '<input type="hidden" name="token" value="'.newToken().'">';
61  print '<table class="noborder nohover centpercent">';
62  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
63  print '<tr class="oddeven"><td>';
64  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>';
65  print '<tr class="oddeven"><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
66  print '</tr>';
67  print "</table></form><br>\n";
68 }
69 
70 /*
71  * Prospects par statut
72  *
73  */
74 
75 $sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id";
76 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
77 $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
78 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
79 $sql .= " WHERE s.fk_stcomm = st.id";
80 $sql .= " AND s.client IN (2, 3)";
81 $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
82 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
83 $sql .= " GROUP BY st.id";
84 $sql .= " ORDER BY st.id";
85 
86 $resql = $db->query($sql);
87 if ($resql)
88 {
89  $num = $db->num_rows($resql);
90  $i = 0;
91  if ($num > 0)
92  {
93  print '<table class="noborder centpercent">';
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, $obj->picto).' ';
103  print $langs->trans("StatusProspect".$obj->id);
104  print '</a></td><td class="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  $total = 0;
130  $num = $db->num_rows($resql);
131  $i = 0;
132  if ($num > 0)
133  {
134  print '<table class="noborder"" width="100%">';
135  print '<tr class="liste_titre">';
136  print '<td colspan="2">'.$langs->trans("ProposalsDraft").'</td></tr>';
137 
138  while ($i < $num)
139  {
140  $obj = $db->fetch_object($resql);
141 
142  print '<tr class="oddeven"><td>';
143  print '<a href="'.DOL_URL_ROOT.'/comm/propal/card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowPropal"), "propal").' '.$obj->ref.'</a>';
144  print '</td><td class="right">';
145  print price($obj->price);
146  print "</td></tr>";
147  $i++;
148  $total += $obj->price;
149  }
150  if ($total > 0) {
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 centpercent">';
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" class="right">'.$langs->trans("Total")."</td><td class=\"right\">".price($total)."</td></tr>";
224  }
225  print "</table><br>";
226  }
227  } else {
228  dol_print_error($db);
229  }
230 }
231 
232 /*
233  * Societes a contacter
234  *
235  */
236 $sql = "SELECT s.nom as name, s.rowid as socid, s.client, s.canvas";
237 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
238 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
239 $sql .= " WHERE s.fk_stcomm = 1";
240 $sql .= " AND s.entity IN (".getEntity($companystatic->element).")";
241 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
242 $sql .= " ORDER BY s.tms ASC";
243 $sql .= $db->plimit(15, 0);
244 
245 $resql = $db->query($sql);
246 if ($resql)
247 {
248  $num = $db->num_rows($resql);
249  $i = 0;
250  if ($num > 0)
251  {
252  print '<table class="noborder centpercent">';
253  print '<tr class="liste_titre"><td>'.$langs->trans("ProspectToContact").'</td></tr>';
254 
255  while ($i < $num)
256  {
257  $obj = $db->fetch_object($resql);
258 
259  print '<tr class="oddeven"><td width="12%">';
260  $companystatic->id = $obj->socid;
261  $companystatic->name = $obj->name;
262  $companystatic->client = $obj->client;
263  $companystatic->canvas = $obj->canvas;
264  print $companystatic->getNomUrl(1, 'prospect', 44);
265  print '</td></tr>';
266  $i++;
267  }
268  print "</table><br>";
269  }
270 }
271 
272 
273 //print '</td></tr></table>';
274 print '</div></div></div>';
275 
276 // End of page
277 llxFooter();
278 $db->close();
img_action($titlealt, $numaction, $picto= '')
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
show_array_actions_to_do($max=5)
Show actions to do array.
Definition: agenda.lib.php:158
llxFooter()
Empty footer.
Definition: wrapper.php:59