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 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
30 $langs->loadLangs(array(
'admin',
'hrm'));
34 $action =
GETPOST(
'action',
'aZ09');
35 $cancel =
GETPOST(
'cancel',
'alpha');
36 $confirm =
GETPOST(
'confirm',
'alpha');
40 static $tmpstatus2label = array(
41 '0'=>
'CloseEtablishment',
42 '1'=>
'OpenEtablishment'
44 $status2label = array(
'');
45 foreach ($tmpstatus2label as $key => $val) {
46 $status2label[$key] = $langs->trans($val);
52 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
54 $permissiontoread = $user->admin;
55 $permissiontoadd = $user->admin;
56 $upload_dir = $conf->hrm->multidir_output[isset($object->entity) ? $object->entity : 1];
71 if ($action ==
'confirm_delete' && $confirm ==
"yes") {
72 $result = $object->delete($id);
74 header(
"Location: ../admin/admin_establishment.php");
79 } elseif ($action ==
'add') {
83 $object->label =
GETPOST(
'label',
'alpha');
84 if (empty($object->label)) {
85 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
90 $object->address =
GETPOST(
'address',
'alpha');
91 $object->zip =
GETPOST(
'zipcode',
'alpha');
92 $object->town =
GETPOST(
'town',
'alpha');
93 $object->country_id =
GETPOST(
"country_id",
'int');
94 $object->status =
GETPOST(
'status',
'int');
95 $object->fk_user_author = $user->id;
97 $object->entity =
GETPOST(
'entity',
'int') > 0 ?
GETPOST(
'entity',
'int') : $conf->entity;
99 $id = $object->create($user);
102 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
111 header(
"Location: ../admin/admin_establishment.php");
114 } elseif ($action ==
'update') {
119 $name =
GETPOST(
'label',
'alpha');
121 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentitiesnoconv(
'Label')), null,
'errors');
126 $object->label =
GETPOST(
'label',
'alphanohtml');
127 $object->address =
GETPOST(
'address',
'alpha');
128 $object->zip =
GETPOST(
'zipcode',
'alpha');
129 $object->town =
GETPOST(
'town',
'alpha');
130 $object->country_id =
GETPOST(
'country_id',
'int');
131 $object->fk_user_mod = $user->id;
132 $object->status =
GETPOST(
'status',
'int');
133 $object->entity =
GETPOST(
'entity',
'int') > 0 ?
GETPOST(
'entity',
'int') : $conf->entity;
135 $result = $object->update($user);
138 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
145 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
GETPOST(
'id',
'int'));
162 if ($action ==
'create') {
165 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
166 print
'<input type="hidden" name="token" value="'.newToken().
'">';
167 print
'<input type="hidden" name="action" value="add">';
171 print
'<table class="border centpercent">';
175 print
'<td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td>';
176 print
'<td><input name="label" id="label" value="'.GETPOST(
"label",
"alphanohtml").
'" autofocus></td>';
192 print
'<td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
194 print
'<input name="address" id="address" class="qutrevingtpercent" value="'.GETPOST(
'address',
'alphanohtml').
'">';
200 print
'<td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td>';
202 print $formcompany->select_ziptown(
216 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td>';
218 print $formcompany->select_ziptown(
GETPOSTISSET(
'town') ?
GETPOST(
'town',
'alpha') : $object->town,
'town', array(
227 print
'<td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
228 print
'<td class="maxwidthonsmartphone">';
229 print
$form->select_country(
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : ($object->country_id ? $object->country_id : $mysoc->country_id),
'country_id');
231 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
238 print
'<td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td>';
247 print
'<div class="center">';
248 print
'<input class="button button-save" type="submit" value="'.$langs->trans(
"Save").
'">';
249 print
' ';
250 print
'<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
257 if (($id || $ref) && $action ==
'edit') {
258 $result = $object->fetch($id);
262 if ($action ==
'edit') {
263 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Establishment"), 0, $object->picto);
265 print
'<form name="update" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">'.
"\n";
266 print
'<input type="hidden" name="token" value="'.newToken().
'">';
267 print
'<input type="hidden" name="action" value="update">';
268 print
'<input type="hidden" name="id" value="'.$id.
'">';
270 print
'<table class="border centpercent">';
274 print
'<td class="titlefield">'.$langs->trans(
"Ref").
'</td><td>';
279 print
'<tr><td>'.$form->editfieldkey(
'Label',
'label',
'', $object, 0,
'string',
'', 1).
'</td><td>';
280 print
'<input name="label" id="label" class="flat" value="'.$object->label.
'">';
293 print
'<tr><td>'.$form->editfieldkey(
'Address',
'address',
'', $object, 0).
'</td>';
295 print
'<input name="address" id="address" value="'.$object->address.
'">';
299 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'', $object, 0).
'</td><td>';
300 print $formcompany->select_ziptown($object->zip,
'zipcode', array(
304 print
'<tr><td>'.$form->editfieldkey(
'Town',
'town',
'', $object, 0).
'</td><td>';
305 print $formcompany->select_ziptown($object->town,
'town', array(
311 print
'<tr><td>'.$form->editfieldkey(
'Country',
'selectcountry_id',
'', $object, 0).
'</td>';
312 print
'<td class="maxwidthonsmartphone">';
313 print
$form->select_country($object->country_id,
'country_id');
315 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
321 print
'<tr><td>'.$form->editfieldkey(
'Status',
'status',
'', $object, 0,
'string',
'', 1).
'</td><td>';
322 print
$form->selectarray(
'status', $status2label, $object->status);
329 print
$form->buttonsSaveCancel();
338 if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
339 $res = $object->fetch_optionals();
342 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Establishment"), -1, $object->picto);
345 if ($action ==
'delete') {
346 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$id, $langs->trans(
"DeleteEstablishment"), $langs->trans(
"ConfirmDeleteEstablishment"),
"confirm_delete");
353 $linkback =
'<a href="'.DOL_URL_ROOT.
'/hrm/admin/admin_establishment.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
355 $morehtmlref =
'<div class="refidno">';
356 $morehtmlref .=
'</div>';
358 dol_banner_tab($object,
'id', $linkback, 1,
'rowid',
'id', $morehtmlref);
361 print
'<div class="fichecenter">';
363 print
'<div class="underbanner clearboth"></div>';
364 print
'<table class="border centpercent">'.
"\n";
368 print
'<td class="titlefield">'.$langs->trans(
"Label").
'</td>';
369 print
'<td>'.$object->label.
'</td>';
383 print
'<td>'.$langs->trans(
"Address").
'</td>';
384 print
'<td>'.$object->address.
'</td>';
389 print
'<td>'.$langs->trans(
"Zip").
'</td>';
390 print
'<td>'.$object->zip.
'</td>';
395 print
'<td>'.$langs->trans(
"Town").
'</td>';
396 print
'<td>'.$object->town.
'</td>';
401 print
'<td>'.$langs->trans(
"Country").
'</td>';
403 if ($object->country_id > 0) {
405 print $img ? $img.
' ' :
'';
406 print
getCountry($object->getCountryCode(), 0, $db);
414 print
'<div class="clearboth"></div><br>';
421 print
'<div class="tabsAction">';
422 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'Modify').
'</a>';
423 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$id.
'">'.$langs->trans(
'Delete').
'</a>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
dol_now($mode= 'auto')
Return date for now.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= 'hideonsmartphone', $textfordropdown= '')
Show information for admin users or standard users.
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 ...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
establishment_prepare_head($object)
Return head table for establishment tabs screen.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.