25require
'../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/core/lib/hrm.lib.php';
27require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
41$langs->loadLangs(array(
'admin',
'hrm'));
45$action =
GETPOST(
'action',
'aZ09');
46$cancel =
GETPOST(
'cancel',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
51static $tmpstatus2label = array(
52 '0'=>
'CloseEtablishment',
53 '1'=>
'OpenEtablishment'
55$status2label = array(
'');
56foreach ($tmpstatus2label as $key => $val) {
57 $status2label[$key] = $langs->trans($val);
63include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
65$permissiontoread = $user->admin;
66$permissiontoadd = $user->admin;
67$permissiontodelete = $user->admin;
76if (!isModEnabled(
'hrm')) {
79if (empty($permissiontoread)) {
88if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
89 $result =
$object->delete($user);
91 header(
"Location: ../admin/admin_establishment.php");
96} elseif ($action ==
'add' && $permissiontoadd) {
102 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
112 $object->fk_user_author = $user->id;
119 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
128 header(
"Location: ../admin/admin_establishment.php");
131} elseif ($action ==
'update' && $permissiontoadd) {
136 $name =
GETPOST(
'label',
'alpha');
138 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label')),
null,
'errors');
148 $object->fk_user_mod = $user->id;
152 $result =
$object->update($user);
155 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
162 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
174$form =
new Form($db);
178if ($action ==
'create') {
181 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
182 print
'<input type="hidden" name="token" value="'.newToken().
'">';
183 print
'<input type="hidden" name="action" value="add">';
187 print
'<table class="border centpercent">';
191 print
'<td>'.$form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td>';
192 print
'<td><input name="label" id="label" value="'.GETPOST(
"label",
"alphanohtml").
'" autofocus></td>';
208 print
'<td>'.$form->editfieldkey(
'Address',
'address',
'',
$object, 0).
'</td>';
210 print
'<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST(
'address',
'alphanohtml').
'">';
216 print
'<td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td>';
218 print $formcompany->select_ziptown(
232 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td>';
234 print $formcompany->select_ziptown(GETPOSTISSET(
'town') ?
GETPOST(
'town',
'alpha') :
$object->town,
'town', array(
243 print
'<td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'',
$object, 0).
'</td>';
244 print
'<td class="maxwidthonsmartphone">';
245 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : (
$object->country_id ?
$object->country_id : $mysoc->country_id),
'country_id');
247 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
254 print
'<td>'.$form->editfieldkey(
'Status',
'status',
'',
$object, 0,
'string',
'', 1).
'</td>';
256 print $form->selectarray(
'status', $status2label, GETPOSTISSET(
'status') ?
GETPOST(
'status',
'alpha') : 1);
263 print
'<div class="center">';
264 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
265 print
' ';
266 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
273if ((!empty($id) || !empty($ref)) && $action ==
'edit') {
278 if ($action ==
'edit') {
281 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
282 print
'<input type="hidden" name="token" value="'.newToken().
'">';
283 print
'<input type="hidden" name="action" value="update">';
284 print
'<input type="hidden" name="id" value="'.$id.
'">';
286 print
'<table class="border centpercent">';
290 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
295 print
'<tr><td>'.$form->editfieldkey(
'Label',
'label',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
296 print
'<input name="label" id="label" class="flat" value="'.$object->label.
'">';
309 print
'<tr><td>'.$form->editfieldkey(
'Address',
'address',
'',
$object, 0).
'</td>';
311 print
'<input name="address" id="address" value="'.$object->address.
'">';
315 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td><td>';
316 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
320 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td><td>';
321 print $formcompany->select_ziptown(
$object->town,
'town', array(
327 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'',
$object, 0).
'</td>';
328 print
'<td class="maxwidthonsmartphone">';
329 print $form->select_country(
$object->country_id,
'country_id');
331 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
337 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'',
$object, 0,
'string',
'', 1).
'</td><td>';
338 print $form->selectarray(
'status', $status2label,
$object->status);
345 print $form->buttonsSaveCancel();
354if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
355 $res =
$object->fetch_optionals();
361 if ($action ==
'delete') {
362 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteEstablishment"), $langs->trans(
"ConfirmDeleteEstablishment"),
"confirm_delete");
369 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/admin/admin_establishment.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
371 $morehtmlref =
'<div class="refidno">';
372 $morehtmlref .=
'</div>';
374 dol_banner_tab(
$object,
'id', $linkback, 1,
'rowid',
'id', $morehtmlref);
377 print
'<div class="fichecenter">';
379 print
'<div class="underbanner clearboth"></div>';
380 print
'<table class="border centpercent">'.
"\n";
384 print
'<td class="titlefield">'.$langs->trans(
"Label").
'</td>';
385 print
'<td>'.$object->label.
'</td>';
399 print
'<td>'.$langs->trans(
"Address").
'</td>';
400 print
'<td>'.$object->address.
'</td>';
405 print
'<td>'.$langs->trans(
"Zip").
'</td>';
406 print
'<td>'.$object->zip.
'</td>';
411 print
'<td>'.$langs->trans(
"Town").
'</td>';
412 print
'<td>'.$object->town.
'</td>';
417 print
'<td>'.$langs->trans(
"Country").
'</td>';
421 print $img ? $img.
' ' :
'';
430 print
'<div class="clearboth"></div><br>';
437 print
'<div class="tabsAction">';
440 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'Modify').
'</a>';
443 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage establishments.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
establishment_prepare_head($object)
Return head table for establishment tabs screen.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.