dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) ---Replace with your own copyright and developer email---
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30$res = 0;
31// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
32if (!$res && !empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
33 $res = @include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php";
34}
35// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME
36$tmp = empty($_SERVER['SCRIPT_FILENAME']) ? '' : $_SERVER['SCRIPT_FILENAME'];
37$tmp2 = realpath(__FILE__);
38$i = strlen($tmp) - 1;
39$j = strlen($tmp2) - 1;
40while ($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i] == $tmp2[$j]) {
41 $i--;
42 $j--;
43}
44if (!$res && $i > 0 && file_exists(substr($tmp, 0, ($i + 1))."/main.inc.php")) {
45 $res = @include substr($tmp, 0, ($i + 1))."/main.inc.php";
46}
47if (!$res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php")) {
48 $res = @include dirname(substr($tmp, 0, ($i + 1)))."/main.inc.php";
49}
50// Try main.inc.php using relative path
51if (!$res && file_exists("../main.inc.php")) {
52 $res = @include "../main.inc.php";
53}
54if (!$res && file_exists("../../main.inc.php")) {
55 $res = @include "../../main.inc.php";
56}
57if (!$res && file_exists("../../../main.inc.php")) {
58 $res = @include "../../../main.inc.php";
59}
60if (!$res) {
61 die("Include of main fails");
62}
63
64require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
65
74// Load translation files required by the page
75$langs->loadLangs(array("mymodule@mymodule"));
76
77$action = GETPOST('action', 'aZ09');
78
79$now = dol_now();
80$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
81
82// Security check - Protection if external user
83$socid = GETPOSTINT('socid');
84if (!empty($user->socid) && $user->socid > 0) {
85 $action = '';
86 $socid = $user->socid;
87}
88
89// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
90//$hookmanager->initHooks(array($object->element.'index'));
91
92// Security check (enable the most restrictive one)
93//if ($user->socid > 0) accessforbidden();
94//if ($user->socid > 0) $socid = $user->socid;
95//if (!isModEnabled('mymodule')) {
96// accessforbidden('Module not enabled');
97//}
98//if (! $user->hasRight('mymodule', 'myobject', 'read')) {
99// accessforbidden();
100//}
101//restrictedArea($user, 'mymodule', 0, 'mymodule_myobject', 'myobject', '', 'rowid');
102//if (empty($user->admin)) {
103// accessforbidden('Must be admin');
104//}
105
106
107/*
108 * Actions
109 */
110
111// None
112
113
114/*
115 * View
116 */
117
118$form = new Form($db);
119$formfile = new FormFile($db);
120
121llxHeader("", $langs->trans("MyModuleArea"), '', '', 0, 0, '', '', '', 'mod-mymodule page-index');
122
123print load_fiche_titre($langs->trans("MyModuleArea"), '', 'mymodule.png@mymodule');
124
125print '<div class="fichecenter"><div class="fichethirdleft">';
126
127
128/* BEGIN MODULEBUILDER DRAFT MYOBJECT
129// Draft MyObject
130if (isModEnabled('mymodule') && $user->hasRight('mymodule', 'read')) {
131 $langs->load("orders");
132
133 $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";
134 $sql.= ", s.code_client";
135 $sql.= " FROM ".MAIN_DB_PREFIX."commande as c";
136 $sql.= ", ".MAIN_DB_PREFIX."societe as s";
137 $sql.= " WHERE c.fk_soc = s.rowid";
138 $sql.= " AND c.fk_statut = 0";
139 $sql.= " AND c.entity IN (".getEntity('commande').")";
140 if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
141
142 $resql = $db->query($sql);
143 if ($resql)
144 {
145 $total = 0;
146 $num = $db->num_rows($resql);
147
148 print '<table class="noborder centpercent">';
149 print '<tr class="liste_titre">';
150 print '<th colspan="3">'.$langs->trans("DraftMyObjects").($num?'<span class="badge marginleftonlyshort">'.$num.'</span>':'').'</th></tr>';
151
152 $var = true;
153 if ($num > 0)
154 {
155 $i = 0;
156 while ($i < $num)
157 {
158
159 $obj = $db->fetch_object($resql);
160 print '<tr class="oddeven"><td class="nowrap">';
161
162 $myobjectstatic->id=$obj->rowid;
163 $myobjectstatic->ref=$obj->ref;
164 $myobjectstatic->ref_client=$obj->ref_client;
165 $myobjectstatic->total_ht = $obj->total_ht;
166 $myobjectstatic->total_tva = $obj->total_tva;
167 $myobjectstatic->total_ttc = $obj->total_ttc;
168
169 print $myobjectstatic->getNomUrl(1);
170 print '</td>';
171 print '<td class="nowrap">';
172 print '</td>';
173 print '<td class="right" class="nowrap">'.price($obj->total_ttc).'</td></tr>';
174 $i++;
175 $total += $obj->total_ttc;
176 }
177 if ($total>0)
178 {
179
180 print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td colspan="2" class="right">'.price($total)."</td></tr>";
181 }
182 }
183 else
184 {
185
186 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("NoOrder").'</td></tr>';
187 }
188 print "</table><br>";
189
190 $db->free($resql);
191 }
192 else
193 {
194 dol_print_error($db);
195 }
196}
197END MODULEBUILDER DRAFT MYOBJECT */
198
199
200print '</div><div class="fichetwothirdright">';
201
202
203/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
204// Last modified myobject
205if (isModEnabled('mymodule') && $user->hasRight('mymodule', 'read')) {
206 $sql = "SELECT s.rowid, s.ref, s.label, s.date_creation, s.tms";
207 $sql.= " FROM ".MAIN_DB_PREFIX."mymodule_myobject as s";
208 $sql.= " WHERE s.entity IN (".getEntity($myobjectstatic->element).")";
209 //if ($socid) $sql.= " AND s.rowid = $socid";
210 $sql .= " ORDER BY s.tms DESC";
211 $sql .= $db->plimit($max, 0);
212
213 $resql = $db->query($sql);
214 if ($resql)
215 {
216 $num = $db->num_rows($resql);
217 $i = 0;
218
219 print '<table class="noborder centpercent">';
220 print '<tr class="liste_titre">';
221 print '<th colspan="2">';
222 print $langs->trans("BoxTitleLatestModifiedMyObjects", $max);
223 print '</th>';
224 print '<th class="right">'.$langs->trans("DateModificationShort").'</th>';
225 print '</tr>';
226 if ($num)
227 {
228 while ($i < $num)
229 {
230 $objp = $db->fetch_object($resql);
231
232 $myobjectstatic->id=$objp->rowid;
233 $myobjectstatic->ref=$objp->ref;
234 $myobjectstatic->label=$objp->label;
235 $myobjectstatic->status = $objp->status;
236
237 print '<tr class="oddeven">';
238 print '<td class="nowrap">'.$myobjectstatic->getNomUrl(1).'</td>';
239 print '<td class="right nowrap">';
240 print "</td>";
241 print '<td class="right nowrap">'.dol_print_date($db->jdate($objp->tms), 'day')."</td>";
242 print '</tr>';
243 $i++;
244 }
245
246 $db->free($resql);
247 } else {
248 print '<tr class="oddeven"><td colspan="3" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
249 }
250 print "</table><br>";
251 }
252}
253*/
254
255print '</div></div>';
256
257// End of page
258llxFooter();
259$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.