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