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