dolibarr  16.0.5
mymoduleindex.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.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
28 $res = 0;
29 // Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
30 if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
31  $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
32 }
33 // Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
34 $tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME']; $tmp2 = realpath(__FILE__); $i = strlen($tmp) - 1; $j = strlen($tmp2) - 1;
35 while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
36  $i--; $j--;
37 }
38 if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
39  $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
40 }
41 if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
42  $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
43 }
44 // Try main.inc.php using relative path
45 if (!$res && file_exists("../main.inc.php")) {
46  $res = @include "../main.inc.php";
47 }
48 if (!$res && file_exists("../../main.inc.php")) {
49  $res = @include "../../main.inc.php";
50 }
51 if (!$res && file_exists("../../../main.inc.php")) {
52  $res = @include "../../../main.inc.php";
53 }
54 if (!$res) {
55  die("Include of main fails");
56 }
57 
58 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
59 
60 // Load translation files required by the page
61 $langs->loadLangs(array("mymodule@mymodule"));
62 
63 $action = GETPOST('action', 'aZ09');
64 
65 
66 // Security check
67 // if (! $user->rights->mymodule->myobject->read) {
68 // accessforbidden();
69 // }
70 $socid = GETPOST('socid', 'int');
71 if (isset($user->socid) && $user->socid > 0) {
72  $action = '';
73  $socid = $user->socid;
74 }
75 
76 $max = 5;
77 $now = dol_now();
78 
79 
80 /*
81  * Actions
82  */
83 
84 // None
85 
86 
87 /*
88  * View
89  */
90 
91 $form = new Form($db);
92 $formfile = new FormFile($db);
93 
94 llxHeader("", $langs->trans("MyModuleArea"));
95 
96 print load_fiche_titre($langs->trans("MyModuleArea"), '', 'mymodule.png@mymodule');
97 
98 print '<div class="fichecenter"><div class="fichethirdleft">';
99 
100 
101 /* BEGIN MODULEBUILDER DRAFT MYOBJECT
102 // Draft MyObject
103 if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
104 {
105  $langs->load("orders");
106 
107  $sql = "SELECT c.rowid, c.ref, c.ref_client, c.total_ht, c.tva as total_tva, c.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas";
108  $sql.= ", s.code_client";
109  $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
110  $sql.= ", ".MAIN_DB_PREFIX."societe as s";
111  if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
112  $sql.= " WHERE c.fk_soc = s.rowid";
113  $sql.= " AND c.fk_statut = 0";
114  $sql.= " AND c.entity IN (".getEntity('commande').")";
115  if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
116  if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
117 
118  $resql = $db->query($sql);
119  if ($resql)
120  {
121  $total = 0;
122  $num = $db->num_rows($resql);
123 
124  print '<table class="noborder centpercent">';
125  print '<tr class="liste_titre">';
126  print '<th colspan="3">'.$langs->trans("DraftMyObjects").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
127 
128  $var = true;
129  if ($num > 0)
130  {
131  $i = 0;
132  while ($i < $num)
133  {
134 
135  $obj = $db->fetch_object($resql);
136  print '<tr class="oddeven"><td class="nowrap">';
137 
138  $myobjectstatic->id=$obj->rowid;
139  $myobjectstatic->ref=$obj->ref;
140  $myobjectstatic->ref_client=$obj->ref_client;
141  $myobjectstatic->total_ht = $obj->total_ht;
142  $myobjectstatic->total_tva = $obj->total_tva;
143  $myobjectstatic->total_ttc = $obj->total_ttc;
144 
145  print $myobjectstatic->getNomUrl(1);
146  print '</td>';
147  print '<td class="nowrap">';
148  print '</td>';
149  print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
150  $i++;
151  $total += $obj->total_ttc;
152  }
153  if ($total>0)
154  {
155 
156  print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
157  }
158  }
159  else
160  {
161 
162  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
163  }
164  print "</table><br>";
165 
166  $db->free($resql);
167  }
168  else
169  {
170  dol_print_error($db);
171  }
172 }
173 END MODULEBUILDER DRAFT MYOBJECT */
174 
175 
176 print '</div><div class="fichetwothirdright">';
177 
178 
179 $NBMAX = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
180 $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
181 
182 /* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
183 // Last modified myobject
184 if (! empty($conf->mymodule->enabled) && $user->rights->mymodule->read)
185 {
186  $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
187  $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject as s";
188  //if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
189  $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
190  //if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
191  //if ($socid) $sql.= " AND s.rowid = $socid";
192  $sql .= " ORDER BY s.tms DESC";
193  $sql .= $db->plimit($max, 0);
194 
195  $resql = $db->query($sql);
196  if ($resql)
197  {
198  $num = $db->num_rows($resql);
199  $i = 0;
200 
201  print '<table class="noborder centpercent">';
202  print '<tr class="liste_titre">';
203  print '<th colspan="2">';
204  print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
205  print '</th>';
206  print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
207  print '</tr>';
208  if ($num)
209  {
210  while ($i < $num)
211  {
212  $objp = $db->fetch_object($resql);
213 
214  $myobjectstatic->id=$objp->rowid;
215  $myobjectstatic->ref=$objp->ref;
216  $myobjectstatic->label=$objp->label;
217  $myobjectstatic->status = $objp->status;
218 
219  print '<tr class="oddeven">';
220  print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
221  print '<td class="right nowrap">';
222  print "</td>";
223  print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
224  print '</tr>';
225  $i++;
226  }
227 
228  $db->free($resql);
229  } else {
230  print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
231  }
232  print "</table><br>";
233  }
234 }
235 */
236 
237 print '</div></div>';
238 
239 // End of page
240 llxFooter();
241 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormFile
Class to offer components to list and upload files.
Definition: html.formfile.class.php:36
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59