dolibarr  13.0.2
admin_establishment.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Alexandre Spangaro <aspangaro@open-dsi.fr>
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 <https://www.gnu.org/licenses/>.
16  */
17 
23 require '../../main.inc.php';
24 require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
25 require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
26 
27 // Load translation files required by the page
28 $langs->loadLangs(array('admin', 'hrm'));
29 
30 if (!$user->admin)
32 
33 $error = 0;
34 
35 
36 /*
37  * Actions
38  */
39 
40 // None
41 
42 
43 /*
44  * View
45  */
46 
47 $form = new Form($db);
48 $establishmenttmp = new Establishment($db);
49 
50 llxHeader('', $langs->trans("Establishments"));
51 
52 $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
53 $sortorder = GETPOST("sortorder", 'alpha');
54 $sortfield = GETPOST("sortfield", 'alpha');
55 if (!$sortorder) $sortorder = "DESC";
56 if (!$sortfield) $sortfield = "e.rowid";
57 
58 if (empty($page) || $page == -1) {
59  $page = 0;
60 }
61 
62 $offset = $limit * $page;
63 $pageprev = $page - 1;
64 $pagenext = $page + 1;
65 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
66 
67 // Subheader
68 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
69 print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
70 
71 // Configuration header
72 $head = hrm_admin_prepare_head();
73 print dol_get_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user");
74 
75 $sql = "SELECT e.rowid, e.label, e.address, e.zip, e.town, e.status";
76 $sql .= " FROM ".MAIN_DB_PREFIX."establishment as e";
77 $sql .= " WHERE e.entity IN (".getEntity('establishment').')';
78 $sql .= $db->order($sortfield, $sortorder);
79 $sql .= $db->plimit($limit + 1, $offset);
80 
81 $result = $db->query($sql);
82 if ($result)
83 {
84  $num = $db->num_rows($result);
85  $i = 0;
86 
87  // Load attribute_label
88  print '<table class="noborder centpercent">';
89  print '<tr class="liste_titre">';
90  print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref", "", "", "", $sortfield, $sortorder);
91  print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "e.label", "", "", "", $sortfield, $sortorder);
92  print_liste_field_titre("Address", $_SERVER["PHP_SELF"], "e.address", "", "", "", $sortfield, $sortorder);
93  print_liste_field_titre("Zip", $_SERVER["PHP_SELF"], "e.zip", "", "", "", $sortfield, $sortorder);
94  print_liste_field_titre("Town", $_SERVER["PHP_SELF"], "e.town", "", "", "", $sortfield, $sortorder);
95  print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "e.status", "", "", '', $sortfield, $sortorder, 'right ');
96  print "</tr>\n";
97 
98  if ($num > 0)
99  {
100  $establishmentstatic = new Establishment($db);
101 
102  while ($i < min($num, $limit))
103  {
104  $obj = $db->fetch_object($result);
105 
106  $establishmentstatic->id = $obj->rowid;
107  $establishmentstatic->ref = $obj->ref;
108  $establishmentstatic->label = $obj->label;
109  $establishmentstatic->status = $obj->status;
110 
111 
112  print '<tr class="oddeven">';
113  print '<td>'.$establishmentstatic->getNomUrl(1).'</td>';
114  print '<td>'.$obj->label.'</td>';
115  print '<td class="left">'.$obj->address.'</td>';
116  print '<td class="left">'.$obj->zip.'</td>';
117  print '<td class="left">'.$obj->town.'</td>';
118  print '<td class="right">';
119  print $establishmentstatic->getLibStatut(5);
120  print '</td>';
121  print "</tr>\n";
122 
123  $i++;
124  }
125  } else {
126  print '<tr class="oddeven"><td colspan="7" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
127  }
128 
129  print '</table>';
130 } else {
131  dol_print_error($db);
132 }
133 
135 
136 // Buttons
137 print '<div class="tabsAction">';
138 print '<a class="butAction" href="'.DOL_URL_ROOT.'/hrm/establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
139 print '</div>';
140 
141 // End of page
142 llxFooter();
143 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
hrm_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: hrm.lib.php:65
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage establishments.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
llxFooter()
Empty footer.
Definition: wrapper.php:59