24require
'../../main.inc.php';
25require_once DOL_DOCUMENT_ROOT.
'/core/lib/hrm.lib.php';
26require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
31$langs->loadLangs(array(
'admin',
'hrm'));
35$action =
GETPOST(
'action',
'aZ09');
36$cancel =
GETPOST(
'cancel',
'alpha');
37$confirm =
GETPOST(
'confirm',
'alpha');
41static $tmpstatus2label = array(
42 '0'=>
'CloseEtablishment',
43 '1'=>
'OpenEtablishment'
45$status2label = array(
'');
46foreach ($tmpstatus2label as $key => $val) {
47 $status2label[$key] = $langs->trans($val);
53include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
55$permissiontoread = $user->admin;
56$permissiontoadd = $user->admin;
57$permissiontodelete = $user->admin;
58$upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1];
73if ($action ==
'confirm_delete' && $confirm ==
"yes") {
74 $result = $object->delete($id);
76 header(
"Location: ../admin/admin_establishment.php");
81} elseif ($action ==
'add') {
85 $object->label =
GETPOST(
'label',
'alpha');
86 if (empty($object->label)) {
87 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
92 $object->address =
GETPOST(
'address',
'alpha');
93 $object->zip =
GETPOST(
'zipcode',
'alpha');
94 $object->town =
GETPOST(
'town',
'alpha');
95 $object->country_id =
GETPOST(
"country_id",
'int');
96 $object->status =
GETPOST(
'status',
'int');
97 $object->fk_user_author = $user->id;
99 $object->entity =
GETPOST(
'entity',
'int') > 0 ?
GETPOST(
'entity',
'int') : $conf->entity;
101 $id = $object->create($user);
104 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
113 header(
"Location: ../admin/admin_establishment.php");
116} elseif ($action ==
'update') {
121 $name =
GETPOST(
'label',
'alpha');
123 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label')),
null,
'errors');
128 $object->label =
GETPOST(
'label',
'alphanohtml');
129 $object->address =
GETPOST(
'address',
'alpha');
130 $object->zip =
GETPOST(
'zipcode',
'alpha');
131 $object->town =
GETPOST(
'town',
'alpha');
132 $object->country_id =
GETPOST(
'country_id',
'int');
133 $object->fk_user_mod = $user->id;
134 $object->status =
GETPOST(
'status',
'int');
135 $object->entity =
GETPOST(
'entity',
'int') > 0 ?
GETPOST(
'entity',
'int') : $conf->entity;
137 $result = $object->update($user);
140 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
147 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
158$form =
new Form($db);
164if ($action ==
'create') {
167 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
168 print
'<input type="hidden" name="token" value="'.newToken().
'">';
169 print
'<input type="hidden" name="action" value="add">';
173 print
'<table class="border centpercent">';
177 print
'<td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td>';
178 print
'<td><input name="label" id="label" value="'.GETPOST(
"label",
"alphanohtml").
'" autofocus></td>';
194 print
'<td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
196 print
'<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST(
'address',
'alphanohtml').
'">';
202 print
'<td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td>';
204 print $formcompany->select_ziptown(
218 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td>';
220 print $formcompany->select_ziptown(GETPOSTISSET(
'town') ?
GETPOST(
'town',
'alpha') : $object->town,
'town', array(
229 print
'<td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
230 print
'<td class="maxwidthonsmartphone">';
231 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : ($object->country_id ? $object->country_id : $mysoc->country_id),
'country_id');
233 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
240 print
'<td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td>';
242 print $form->selectarray(
'status', $status2label, GETPOSTISSET(
'status') ?
GETPOST(
'status',
'alpha') : 1);
249 print
'<div class="center">';
250 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
251 print
' ';
252 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
259if ((!empty($id) || !empty($ref)) && $action ==
'edit') {
260 $result = $object->fetch($id);
264 if ($action ==
'edit') {
265 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Establishment"), 0, $object->picto);
267 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
268 print
'<input type="hidden" name="token" value="'.newToken().
'">';
269 print
'<input type="hidden" name="action" value="update">';
270 print
'<input type="hidden" name="id" value="'.$id.
'">';
272 print
'<table class="border centpercent">';
276 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
281 print
'<tr><td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
282 print
'<input name="label" id="label" class="flat" value="'.$object->label.
'">';
295 print
'<tr><td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
297 print
'<input name="address" id="address" value="'.$object->address.
'">';
301 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
302 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
306 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
307 print $formcompany->select_ziptown($object->town,
'town', array(
313 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
314 print
'<td class="maxwidthonsmartphone">';
315 print $form->select_country($object->country_id,
'country_id');
317 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
323 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td><td>';
324 print $form->selectarray(
'status', $status2label, $object->status);
331 print $form->buttonsSaveCancel();
340if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
341 $res = $object->fetch_optionals();
344 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Establishment"), -1, $object->picto);
347 if ($action ==
'delete') {
348 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteEstablishment"), $langs->trans(
"ConfirmDeleteEstablishment"),
"confirm_delete");
355 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/admin/admin_establishment.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
357 $morehtmlref =
'<div class="refidno">';
358 $morehtmlref .=
'</div>';
360 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'id', $morehtmlref);
363 print
'<div class="fichecenter">';
365 print
'<div class="underbanner clearboth"></div>';
366 print
'<table class="border centpercent">'.
"\n";
370 print
'<td class="titlefield">'.$langs->trans(
"Label").
'</td>';
371 print
'<td>'.$object->label.
'</td>';
385 print
'<td>'.$langs->trans(
"Address").
'</td>';
386 print
'<td>'.$object->address.
'</td>';
391 print
'<td>'.$langs->trans(
"Zip").
'</td>';
392 print
'<td>'.$object->zip.
'</td>';
397 print
'<td>'.$langs->trans(
"Town").
'</td>';
398 print
'<td>'.$object->town.
'</td>';
403 print
'<td>'.$langs->trans(
"Country").
'</td>';
405 if ($object->country_id > 0) {
407 print $img ? $img.
' ' :
'';
408 print
getCountry($object->getCountryCode(), 0, $db);
416 print
'<div class="clearboth"></div><br>';
423 print
'<div class="tabsAction">';
426 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
429 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $permissiontodelete);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage establishments.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $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.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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_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.
dol_now($mode='auto')
Return date for now.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.