dolibarr  9.0.0
list.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
24 require '../main.inc.php';
25 require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php';
26 
27 // Load translation files required by the page
28 $langs->loadLangs(array('bookmarks', 'admin'));
29 
30 $action=GETPOST('action','alpha');
31 $massaction=GETPOST('massaction','alpha');
32 $show_files=GETPOST('show_files','int');
33 $confirm=GETPOST('confirm','alpha');
34 $toselect = GETPOST('toselect', 'array');
35 
36 // Security check
37 if (! $user->rights->bookmark->lire) {
38  restrictedArea($user, 'bookmarks');
39 }
40 $optioncss = GETPOST('optioncss','alpha');
41 
42 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
43 $sortfield = GETPOST("sortfield",'alpha');
44 $sortorder = GETPOST("sortorder",'alpha');
45 $page = GETPOST("page",'int');
46 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
47 $offset = $limit * $page;
48 $pageprev = $page - 1;
49 $pagenext = $page + 1;
50 if (! $sortfield) $sortfield='position';
51 if (! $sortorder) $sortorder='ASC';
52 
53 $id = GETPOST("id",'int');
54 
55 
56 /*
57  * Actions
58  */
59 
60 if ($action == 'delete')
61 {
62  $bookmark=new Bookmark($db);
63  $res=$bookmark->remove($id);
64  if ($res > 0)
65  {
66  header("Location: ".$_SERVER["PHP_SELF"]);
67  exit;
68  }
69  else
70  {
71  setEventMessages($bookmark->error, $bookmark->errors, 'errors');
72  }
73 }
74 
75 
76 /*
77  * View
78  */
79 
80 $userstatic=new User($db);
81 
82 llxHeader('', $langs->trans("ListOfBookmarks"));
83 
84 $newcardbutton='';
85 if ($user->rights->bookmark->creer)
86 {
87  $newcardbutton='<a class="butActionNew" href="'.DOL_URL_ROOT.'/bookmarks/card.php?action=create"><span class="valignmiddle">'.$langs->trans('NewBookmark').'</span>';
88  $newcardbutton.= '<span class="fa fa-plus-circle valignmiddle"></span>';
89  $newcardbutton.= '</a>';
90 }
91 
92 print_barre_liste($langs->trans("ListOfBookmarks"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', -1, '', 'title_generic.png', 0, $newcardbutton);
93 
94 $sql = "SELECT b.rowid, b.dateb, b.fk_user, b.url, b.target, b.title, b.favicon, b.position,";
95 $sql.= " u.login, u.lastname, u.firstname";
96 $sql.= " FROM ".MAIN_DB_PREFIX."bookmark as b LEFT JOIN ".MAIN_DB_PREFIX."user as u ON b.fk_user=u.rowid";
97 $sql.= " WHERE 1=1";
98 $sql.= " AND b.entity = ".$conf->entity;
99 if (! $user->admin) $sql.= " AND (b.fk_user = ".$user->id." OR b.fk_user is NULL OR b.fk_user = 0)";
100 $sql.= $db->order($sortfield.", position",$sortorder);
101 $sql.= $db->plimit($limit, $offset);
102 
103 $resql=$db->query($sql);
104 if ($resql)
105 {
106  $num = $db->num_rows($resql);
107  $i = 0;
108  $param = "";
109  if ($optioncss != '') $param ='&optioncss='.$optioncss;
110 
111  $moreforfilter='';
112 
113  print '<div class="div-table-responsive">';
114  print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
115 
116  print "<tr class=\"liste_titre\">";
117  //print "<td>&nbsp;</td>";
118  print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"b.rowid","", $param,'align="left"',$sortfield,$sortorder);
119  print_liste_field_titre("Title",$_SERVER["PHP_SELF"],"b.title","", $param,'align="left"',$sortfield,$sortorder);
120  print_liste_field_titre("Link",$_SERVER["PHP_SELF"],"b.url","", $param,'align="left"',$sortfield,$sortorder);
121  print_liste_field_titre("Target",'','','','','align="center"');
122  print_liste_field_titre("Owner",$_SERVER["PHP_SELF"],"u.lastname","", $param,'align="center"',$sortfield,$sortorder);
123  print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"b.dateb","", $param,'align="center"',$sortfield,$sortorder);
124  print_liste_field_titre("Position",$_SERVER["PHP_SELF"],"b.position","", $param,'align="right"',$sortfield,$sortorder);
126  print "</tr>\n";
127 
128  while ($i < $num)
129  {
130  $obj = $db->fetch_object($resql);
131 
132  print '<tr class="oddeven">';
133 
134  // Id
135  print '<td align="left">';
136  print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowBookmark"),"bookmark").' '.$obj->rowid."</a>";
137  print '</td>';
138 
139  $linkintern=0;
140  $title=$obj->title;
141  $link=$obj->url;
142 
143  // Title
144  print "<td>";
145  $linkintern=1;
146  if ($linkintern) print "<a href=\"".$obj->url."\">";
147  print $title;
148  if ($linkintern) print "</a>";
149  print "</td>\n";
150 
151  // Url
152  print '<td class="tdoverflowmax200">';
153  if (! $linkintern) print '<a href="'.$obj->url.'"'.($obj->target?' target="newlink"':'').'>';
154  print $link;
155  if (! $linkintern) print '</a>';
156  print "</td>\n";
157 
158  // Target
159  print '<td align="center">';
160  if ($obj->target == 0) print $langs->trans("BookmarkTargetReplaceWindowShort");
161  if ($obj->target == 1) print $langs->trans("BookmarkTargetNewWindowShort");
162  print "</td>\n";
163 
164  // Author
165  print '<td align="center">';
166  if ($obj->fk_user)
167  {
168  $userstatic->id=$obj->fk_user;
169  $userstatic->lastname=$obj->login;
170  print $userstatic->getNomUrl(1);
171  }
172  else
173  {
174  print $langs->trans("Public");
175  }
176  print "</td>\n";
177 
178  // Date creation
179  print '<td align="center">'.dol_print_date($db->jdate($obj->dateb),'day')."</td>";
180 
181  // Position
182  print '<td align="right">'.$obj->position."</td>";
183 
184  // Actions
185  print '<td align="right" class="nowrap">';
186  if ($user->rights->bookmark->creer)
187  {
188  print "<a href=\"".DOL_URL_ROOT."/bookmarks/card.php?action=edit&id=".$obj->rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()."</a> ";
189  }
190  if ($user->rights->bookmark->supprimer)
191  {
192  print "<a href=\"".$_SERVER["PHP_SELF"]."?action=delete&id=$obj->rowid\">".img_delete()."</a>";
193  }
194  else
195  {
196  print "&nbsp;";
197  }
198  print "</td>";
199  print "</tr>\n";
200  $i++;
201  }
202  print "</table>";
203  print '</div>';
204 
205  $db->free($resql);
206 }
207 else
208 {
209  dol_print_error($db);
210 }
211 
212 // End of page
213 llxFooter();
214 $db->close();
215 
216 
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
Class to manage Dolibarr users.
Definition: user.class.php:41
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
llxHeader()
Empty header.
Definition: wrapper.php:44
if(GETPOST('cancel', 'alpha')) if(! GETPOST( 'confirmmassaction', 'alpha') &&$massaction !='presend' &&$massaction !='confirm_presend')
Draft customers invoices.
Definition: list.php:156
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
Class to manage bookmarks.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)