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