dolibarr  7.0.0-beta
admin_establishment.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
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 
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 $langs->load("admin");
28 $langs->load('hrm');
29 
30 if (! $user->admin)
32 
33 $error=0;
34 
35 // List of statut
36 static $tmpstatus2label=array(
37  '0'=>'OpenEtablishment',
38  '1'=>'CloseEtablishment'
39 );
40 $status2label=array('');
41 foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val);
42 
43 /*
44  * Actions
45  */
46 
47 /*
48  * View
49  */
50 llxHeader('', $langs->trans("Establishments"));
51 
52 $sortorder = GETPOST("sortorder");
53 $sortfield = GETPOST("sortfield");
54 if (!$sortorder) $sortorder="DESC";
55 if (!$sortfield) $sortfield="e.rowid";
56 
57 if ($page == -1) {
58  $page = 0 ;
59 }
60 
61 $offset = $conf->liste_limit * $page;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
64 $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit;
65 
66 $form = new Form($db);
67 $establishmenttmp=new Establishment($db);
68 
69 dol_htmloutput_mesg($mesg);
70 
71 // Subheader
72 $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
73 print load_fiche_titre($langs->trans("HRMSetup"), $linkback);
74 
75 // Configuration header
76 $head = hrm_admin_prepare_head();
77 dol_fiche_head($head, 'establishments', $langs->trans("HRM"), -1, "user");
78 
79 $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status";
80 $sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
81 $sql.= " WHERE e.entity = ".$conf->entity;
82 $sql.= $db->order($sortfield,$sortorder);
83 $sql.= $db->plimit($limit+1, $offset);
84 
85 $result = $db->query($sql);
86 if ($result)
87 {
88  $num = $db->num_rows($result);
89  $i = 0;
90 
91  // Load attribute_label
92  print '<table class="noborder" width="100%">';
93  print '<tr class="liste_titre">';
94  print_liste_field_titre("Name",$_SERVER["PHP_SELF"],"e.name","","","",$sortfield,$sortorder);
95  print_liste_field_titre("Address",$_SERVER["PHP_SELF"],"e.address","","","",$sortfield,$sortorder);
96  print_liste_field_titre("Zipcode",$_SERVER["PHP_SELF"],"e.zip","","","",$sortfield,$sortorder);
97  print_liste_field_titre("Town",$_SERVER["PHP_SELF"],"e.town","","","",$sortfield,$sortorder);
98  print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"e.status","","",'align="right"',$sortfield,$sortorder);
99  print "</tr>\n";
100 
101  $var=true;
102 
103  if ($num > 0)
104  {
105  $establishmentstatic=new Establishment($db);
106 
107  while ($i < min($num,$limit))
108  {
109  $obj = $db->fetch_object($result);
110 
111  $establishmentstatic->id=$obj->rowid;
112  $establishmentstatic->name=$obj->name;
113  $establishmentstatic->status=$obj->status;
114 
115 
116  print '<tr class="oddeven">';
117  print '<td>'.$establishmentstatic->getNomUrl(1).'</td>';
118  print '<td align="left">'.$obj->address.'</td>';
119  print '<td align="left">'.$obj->zip.'</td>';
120  print '<td align="left">'.$obj->town.'</td>';
121 
122  print '<td align="right">';
123  print $establishmentstatic->getLibStatut(5);
124  print '</td>';
125  print "</tr>\n";
126 
127  $i++;
128  }
129 
130  }
131  else
132  {
133  print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
134  }
135 
136  print '</table>';
137 }
138 else
139 {
140  dol_print_error($db);
141 }
142 
143 dol_fiche_end();
144 
145 // Buttons
146 print '<div class="tabsAction">';
147 print '<a class="butAction" href="../establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
148 print '</div>';
149 
150 llxFooter();
151 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
hrm_admin_prepare_head()
Return array head with list of tabs to view object informations.
Definition: hrm.lib.php:64
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
dol_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
Class to manage establishments.
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
print
Draft customers invoices.
Definition: index.php:91
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.