dolibarr  7.0.0-beta
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 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.'/commande/class/commande.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
29 
30 $langs->load("orders");
31 $langs->load("sendings");
32 
33 /*
34  * View
35  */
36 
37 $orderstatic=new Commande($db);
38 $companystatic=new Societe($db);
39 $shipment=new Expedition($db);
40 
41 $helpurl='EN:Module_Shipments|FR:Module_Exp&eacute;ditions|ES:M&oacute;dulo_Expediciones';
42 llxHeader('',$langs->trans("Shipment"),$helpurl);
43 
44 print load_fiche_titre($langs->trans("SendingsArea"));
45 
46 
47 print '<div class="fichecenter"><div class="fichethirdleft">';
48 
49 
50 if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
51 {
52  print '<form method="post" action="list.php">';
53  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
54  print '<table class="noborder nohover" width="100%">';
55  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
56  print '<tr class="oddeven"><td>';
57  print $langs->trans("Shipment").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
58  print "</table></form><br>\n";
59 }
60 
61 /*
62  * Shipments to validate
63  */
64 $clause = " WHERE ";
65 
66 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
67 $sql.= " s.nom as name, s.rowid as socid,";
68 $sql.= " c.ref as commande_ref, c.rowid as commande_id";
69 $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
70 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping'";
71 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid";
72 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
73 if (!$user->rights->societe->client->voir && !$socid)
74 {
75  $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
76  $sql.= $clause." sc.fk_user = " .$user->id;
77  $clause = " AND ";
78 }
79 $sql.= $clause." e.fk_statut = 0";
80 $sql.= " AND e.entity IN (".getEntity('expedition').")";
81 if ($socid) $sql.= " AND c.fk_soc = ".$socid;
82 
83 $resql=$db->query($sql);
84 if ($resql)
85 {
86  $num = $db->num_rows($resql);
87  if ($num)
88  {
89  print '<table class="noborder" width="100%">';
90  print '<tr class="liste_titre">';
91  print '<th colspan="3">'.$langs->trans("SendingsToValidate").'</th></tr>';
92  $i = 0;
93  while ($i < $num)
94  {
95  $obj = $db->fetch_object($resql);
96 
97  $shipment->id=$obj->rowid;
98  $shipment->ref=$obj->ref;
99  $shipment->ref_customer=$obj->ref_customer;
100 
101  print '<tr class="oddeven"><td class="nowrap">';
102  print $shipment->getNomUrl(1);
103  print "</td>";
104  print '<td>';
105  print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
106  print '</td>';
107  print '<td>';
108  if ($obj->commande_id) print '<a href="'.DOL_URL_ROOT.'/commande/card.php?id='.$obj->commande_id.'">'.$obj->commande_ref.'</a>';
109  print '</td></tr>';
110  $i++;
111  }
112  print "</table><br>";
113  }
114 }
115 
116 
117 /*
118  * Commandes a traiter
119  */
120 $sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut, s.nom as name, s.rowid as socid";
121 $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
122 $sql.= " ".MAIN_DB_PREFIX."societe as s";
123 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
124 $sql.= " WHERE c.fk_soc = s.rowid";
125 $sql.= " AND c.entity = ".$conf->entity;
126 $sql.= " AND c.fk_statut = 1";
127 if ($socid) $sql.= " AND c.fk_soc = ".$socid;
128 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
129 $sql.= " ORDER BY c.rowid ASC";
130 
131 $resql=$db->query($sql);
132 if ($resql)
133 {
134  $num = $db->num_rows($resql);
135  if ($num)
136  {
137  $langs->load("orders");
138 
139  $i = 0;
140  print '<table class="noborder" width="100%">';
141  print '<tr class="liste_titre">';
142  print '<th colspan="3">'.$langs->trans("OrdersToProcess").'</th></tr>';
143  while ($i < $num)
144  {
145  $obj = $db->fetch_object($resql);
146 
147  $orderstatic->id=$obj->rowid;
148  $orderstatic->ref=$obj->ref;
149  $orderstatic->ref_customer=$obj->ref_customer;
150  $orderstatic->statut=$obj->fk_statut;
151  $orderstatic->facturee=0;
152 
153  $companystatic->name=$obj->name;
154  $companystatic->id=$obj->socid;
155 
156  print '<tr class="oddeven">';
157  print '<td class="nowrap">';
158  print $orderstatic->getNomUrl(1);
159  print '</td>';
160  print '<td>';
161  print $companystatic->getNomUrl(1,'customer',32);
162  print '</td>';
163  print '<td align="right">';
164  print $orderstatic->getLibStatut(3);
165  print '</td>';
166  print '</tr>';
167  $i++;
168  }
169  print "</table><br>";
170  }
171 }
172 
173 
174 //print '</td><td valign="top" width="70%">';
175 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
176 
177 
178 /*
179  * Commandes en traitement
180  */
181 $sql = "SELECT c.rowid, c.ref, c.ref_client as ref_customer, c.fk_statut as status, c.facture as billed, s.nom as name, s.rowid as socid";
182 $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,";
183 $sql.= " ".MAIN_DB_PREFIX."societe as s";
184 if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
185 $sql.= " WHERE c.fk_soc = s.rowid";
186 $sql.= " AND c.entity = ".$conf->entity;
187 $sql.= " AND c.fk_statut = 2";
188 if ($socid) $sql.= " AND c.fk_soc = ".$socid;
189 if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
190 
191 $resql = $db->query($sql);
192 if ( $resql )
193 {
194  $langs->load("orders");
195 
196  $num = $db->num_rows($resql);
197  if ($num)
198  {
199  $i = 0;
200  print '<table class="noborder" width="100%">';
201  print '<tr class="liste_titre">';
202  print '<th colspan="3">'.$langs->trans("OrdersInProcess").'</th></tr>';
203  while ($i < $num)
204  {
205  $obj = $db->fetch_object($resql);
206 
207  $orderstatic->id=$obj->rowid;
208  $orderstatic->ref=$obj->ref;
209  $orderstatic->ref_customer=$obj->ref_customer;
210  $orderstatic->statut=$obj->status;
211  $orderstatic->facturee=$obj->billed;
212 
213  $companystatic->name=$obj->name;
214  $companystatic->id=$obj->socid;
215 
216  print '<tr class="oddeven"><td>';
217  print $orderstatic->getNomUrl(1);
218  print '</td>';
219  print '<td>';
220  print $companystatic->getNomUrl(1,'customer');
221  print '</td>';
222  print '<td align="right">';
223  print $orderstatic->getLibStatut(3);
224  print '</td>';
225  print '</tr>';
226  $i++;
227  }
228  print "</table><br>";
229  }
230 }
231 else dol_print_error($db);
232 
233 
234 /*
235  * Last shipments
236  */
237 $sql = "SELECT e.rowid, e.ref, e.ref_customer,";
238 $sql.= " s.nom as name, s.rowid as socid,";
239 $sql.= " c.ref as commande_ref, c.rowid as commande_id";
240 $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
241 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
242 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
243 $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
244 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
245 $sql.= " WHERE e.entity IN (".getEntity('expedition').")";
246 if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND sc.fk_user = " .$user->id;
247 $sql.= " AND e.fk_statut = 1";
248 if ($socid) $sql.= " AND c.fk_soc = ".$socid;
249 $sql.= " ORDER BY e.date_delivery DESC";
250 $sql.= $db->plimit(5, 0);
251 
252 $resql = $db->query($sql);
253 if ($resql)
254 {
255  $num = $db->num_rows($resql);
256  if ($num)
257  {
258  $i = 0;
259  print '<table class="noborder" width="100%">';
260  print '<tr class="liste_titre">';
261  print '<th colspan="3">'.$langs->trans("LastSendings", $num).'</th></tr>';
262  while ($i < $num)
263  {
264  $obj = $db->fetch_object($resql);
265 
266  $shipment->id=$obj->rowid;
267  $shipment->ref=$obj->ref;
268  $shipment->ref_customer=$obj->ref_customer;
269 
270  print '<tr class="oddeven"><td>';
271  print $shipment->getNomUrl(1);
272  print '</td>';
273  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
274  print '<td>';
275  if ($obj->commande_id > 0)
276  {
277  $orderstatic->id=$obj->commande_id;
278  $orderstatic->ref=$obj->commande_ref;
279  print $orderstatic->getNomUrl(1);
280  }
281  else print '&nbsp;';
282  print '</td></tr>';
283  $i++;
284  }
285  print "</table><br>";
286  }
287  $db->free($resql);
288 }
289 else dol_print_error($db);
290 
291 
292 print '</div></div></div>';
293 
294 
295 llxFooter();
296 $db->close();
llxFooter()
Footer empty.
Definition: index.php:43
if(GETPOST('cancel','alpha')) if(!GETPOST('confirmmassaction','alpha')&&$massaction!= 'presend'&&$massaction!= 'confirm_presend')
Draft customers invoices.
Definition: list.php:147
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...)
llxHeader()
Header empty.
Definition: index.php:37
Class to manage shipments.
Class to manage customers orders.
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)
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