26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/lib/hrm.lib.php';
28require_once DOL_DOCUMENT_ROOT.
'/hrm/class/establishment.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42$langs->loadLangs(array(
'admin',
'hrm'));
46$action =
GETPOST(
'action',
'aZ09');
47$cancel =
GETPOST(
'cancel',
'alpha');
48$confirm =
GETPOST(
'confirm',
'alpha');
52static $tmpstatus2label = array(
53 '0' =>
'CloseEtablishment',
54 '1' =>
'OpenEtablishment'
56$status2label = array(
'');
57foreach ($tmpstatus2label as $key => $val) {
58 $status2label[$key] = $langs->trans($val);
64include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
66$permissiontoread = $user->admin;
67$permissiontoadd = $user->admin;
68$permissiontodelete = $user->admin;
80if (empty($permissiontoread)) {
89if ($action ==
'confirm_delete' && $confirm ==
"yes" && $permissiontodelete) {
91 $result =
$object->delete($user);
93 header(
"Location: ../admin/admin_establishment.php");
98} elseif ($action ==
'add' && $permissiontoadd) {
104 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")),
null,
'errors');
114 $object->fk_user_author = $user->id;
121 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
130 header(
"Location: ../admin/admin_establishment.php");
133} elseif ($action ==
'update' && $permissiontoadd) {
138 $name =
GETPOST(
'label',
'alpha');
140 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label')),
null,
'errors');
150 $object->fk_user_mod = $user->id;
154 $result =
$object->update($user);
157 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
164 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOSTINT(
'id'));
176$form =
new Form($db);
180if ($action ==
'create') {
183 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
184 print
'<input type="hidden" name="token" value="'.newToken().
'">';
185 print
'<input type="hidden" name="action" value="add">';
189 print
'<table class="border centpercent">';
193 print
'<td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td>';
194 print
'<td><input name="label" id="label" value="'.GETPOST(
"label",
"alphanohtml").
'" autofocus></td>';
210 print
'<td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
212 print
'<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST(
'address',
'alphanohtml').
'">';
218 print
'<td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td>';
220 print $formcompany->select_ziptown(
234 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td>';
245 print
'<td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
246 print
'<td class="maxwidthonsmartphone">';
249 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
256 print
'<td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td>';
258 print $form->selectarray(
'status', $status2label,
GETPOSTISSET(
'status') ?
GETPOST(
'status',
'alpha') : 1);
265 print
'<div class="center">';
266 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
267 print
' ';
268 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
275if ((!empty($id) || !empty($ref)) && $action ==
'edit') {
280 if ($action ==
'edit') {
283 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
285 print
'<input type="hidden" name="action" value="update">';
286 print
'<input type="hidden" name="id" value="'.$id.
'">';
288 print
'<table class="border centpercent">';
292 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
297 print
'<tr><td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
298 print
'<input name="label" id="label" class="flat" value="'.$object->label.
'">';
311 print
'<tr><td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
313 print
'<input name="address" id="address" value="'.$object->address.
'">';
317 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
318 print $formcompany->select_ziptown(
$object->zip,
'zipcode', array(
322 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
323 print $formcompany->select_ziptown(
$object->town,
'town', array(
329 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
330 print
'<td class="maxwidthonsmartphone">';
331 print $form->select_country((
string)
$object->country_id,
'country_id');
333 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
339 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td><td>';
340 print $form->selectarray(
'status', $status2label,
$object->status);
347 print $form->buttonsSaveCancel();
352 dol_print_error($db);
356if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
357 $res =
$object->fetch_optionals();
363 if ($action ==
'delete') {
364 print $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteEstablishment"), $langs->trans(
"ConfirmDeleteEstablishment"),
"confirm_delete");
371 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/admin/admin_establishment.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
373 $morehtmlref =
'<div class="refidno">';
374 $morehtmlref .=
'</div>';
376 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'id', $morehtmlref);
379 print
'<div class="fichecenter">';
381 print
'<div class="underbanner clearboth"></div>';
382 print
'<table class="border centpercent">'.
"\n";
386 print
'<td class="titlefield">'.$langs->trans(
"Label").
'</td>';
387 print
'<td>'.$object->label.
'</td>';
401 print
'<td>'.$langs->trans(
"Address").
'</td>';
402 print
'<td>'.$object->address.
'</td>';
407 print
'<td>'.$langs->trans(
"Zip").
'</td>';
408 print
'<td>'.$object->zip.
'</td>';
413 print
'<td>'.$langs->trans(
"Town").
'</td>';
414 print
'<td>'.$object->town.
'</td>';
419 print
'<td>'.$langs->trans(
"Country").
'</td>';
423 print $img ? $img.
' ' :
'';
432 print
'<div class="clearboth"></div><br>';
439 print
'<div class="tabsAction">';
442 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.
$id.
'">'.$langs->trans(
'Modify').
'</a>';
445 print dolGetButtonAction($langs->trans(
"Delete"), $langs->trans(
"Delete"),
'delete', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'delete', $permissiontodelete, array(
'attr' => array(
'class' =>
'reposition'))).
"\n";
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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.
dol_now($mode='gmt')
Return date for now.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_clone($srcobject, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.