28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/resource.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
37 $langs->loadLangs(array(
'resource',
'companies',
'other',
'main'));
41 $action =
GETPOST(
'action',
'aZ09');
42 $cancel =
GETPOST(
'cancel',
'alpha');
44 $address =
GETPOST(
'address',
'alpha');
45 $zip =
GETPOST(
'zipcode',
'alpha');
46 $town =
GETPOST(
'town',
'alpha');
49 $description =
GETPOST(
'description',
'restricthtml');
50 $phone =
GETPOST(
'phone',
'alpha');
51 $email =
GETPOST(
'email',
'alpha');
54 $confirm =
GETPOST(
'confirm',
'aZ09');
55 $fk_code_type_resource =
GETPOST(
'fk_code_type_resource',
'aZ09');
58 if ($user->socid > 0) {
66 $extrafields->fetch_name_optionals_label(
$object->table_element);
69 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
74 $permissiontoadd = $user->hasRight(
'resource',
'write');
75 $permissiontodelete = $user->hasRight(
'resource',
'delete');
82 $hookmanager->initHooks(array(
'resource',
'resource_card',
'globalcard'));
89 if (empty($reshook)) {
91 if (!empty($backtopage)) {
92 header(
"Location: ".$backtopage);
95 if ($action ==
'add') {
96 header(
"Location: ".DOL_URL_ROOT.
'/resource/list.php');
102 if ($action ==
'add' && $user->hasRight(
'resource',
'write')) {
107 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
114 $object->country_id = $country_id;
116 $object->description = $description;
119 $object->max_users = $max_users;
121 $object->fk_code_type_resource = $fk_code_type_resource;
124 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
129 $result =
$object->create($user);
133 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
142 header(
"Location: list.php");
147 if ($action ==
'update' && !$cancel && $user->hasRight(
'resource',
'write')) {
151 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
162 $object->country_id = $country_id;
164 $object->description = $description;
167 $object->max_users = $max_users;
169 $object->fk_code_type_resource = $fk_code_type_resource;
172 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
177 $result =
$object->update($user);
179 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
196 if ($action ==
'confirm_delete_resource' && $user->hasRight(
'resource',
'delete') && $confirm ===
'yes') {
199 $result =
$object->delete($user);
203 header(
'Location: '.DOL_URL_ROOT.
'/resource/list.php');
219 $title = $langs->trans($action ==
'create' ?
'AddResource' :
'ResourceSingular');
225 if ($action ==
'create' ||
$object->fetch($id, $ref) > 0) {
226 if ($action ==
'create') {
234 if ($action ==
'create' || $action ==
'edit') {
235 if (!$user->hasRight(
'resource',
'write')) {
241 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
242 print
'<input type="hidden" name="token" value="'.newToken().
'">';
243 print
'<input type="hidden" name="action" value="'.($action ==
"create" ?
"add" :
"update").
'">';
245 print
'<table class="border centpercent">';
248 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ResourceFormLabel_ref").
'</td>';
249 print
'<td><input class="minwidth200" name="ref" value="'.($ref ?:
$object->ref).
'" autofocus="autofocus"></td></tr>';
252 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'',
$object, 0).
'</td>';
253 print
'<td colspan="3"><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
256 print
$form->widgetForTranslation(
"address",
$object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
260 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
261 print $formresource->select_ziptown(
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
263 if ($conf->browser->layout ==
'phone') {
266 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td><td'.($conf->browser->layout ==
'phone' ?
' colspan="3"' :
'').
'>';
267 print $formresource->select_ziptown(
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
268 print
$form->widgetForTranslation(
"town",
$object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
272 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td><td>';
275 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
282 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
284 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'',
$object, 0).
'</td><td colspan="3" class="maxwidthonsmartphone">';
288 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
289 print $formresource->select_state(
$object->state_id,
$object->country_code);
291 print $langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')';
297 print
'<tr><td>'.$langs->trans(
"ResourceType").
'</td>';
299 $formresource->select_types_resource(
$object->fk_code_type_resource,
'fk_code_type_resource',
'', 2);
303 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
305 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
306 $doleditor =
new DolEditor(
'description', ($description ?:
$object->description),
'',
'200',
'dolibarr_notes',
false);
307 $doleditor->Create();
311 print
'<td>'.$form->editfieldkey(
'Phone',
'phone',
'',
$object, 0).
'</td>';
313 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
314 print
'<input type="tel" name="phone" id="phone" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'"></td>';
318 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'',
$object, 0).
'</td>';
320 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
321 print
'<input type="email" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->email).
'"></td>';
325 print
'<tr><td>'.$form->editfieldkey(
'MaxUsers',
'max_users',
'',
$object, 0).
'</td>';
327 print
img_picto(
'',
'object_user',
'class="pictofixedwidth"');
328 print
'<input type="number" name="max_users" id="max_users" value="'.(GETPOSTISSET(
'max_users') ?
GETPOSTINT(
'max_users') :
$object->max_users).
'"></td>';
332 print
'<tr><td>'.$form->editfieldkey(
'URL',
'url',
'',
$object, 0).
'</td>';
334 print
img_picto(
'',
'object_url',
'class="pictofixedwidth"');
335 print
'<input type="url" name="url" id="url" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') :
$object->url).
'"></td>';
340 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters,
$object, $action);
341 print $hookmanager->resPrint;
342 if (empty($reshook)) {
343 print
$object->showOptionals($extrafields,
'edit');
350 $button_label = ($action ==
"create" ?
"Create" :
"Modify");
351 print
$form->buttonsSaveCancel($button_label);
360 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
361 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResource"),
"confirm_delete_resource",
'', 0,
"action-delete");
368 $linkback =
'<a href="'.DOL_URL_ROOT.
'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&id='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
370 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref');
373 print
'<div class="fichecenter">';
374 print
'<div class="underbanner clearboth"></div>';
379 print
'<table class="border tableforfield centpercent">';
383 print
'<td class="titlefield">'.$langs->trans(
"ResourceType").
'</td>';
391 print
'<td>'.$langs->trans(
"ResourceFormLabel_description").
'</td>';
399 print
'<td>'.$langs->trans(
"MaxUsers").
'</td>';
406 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
414 print
'<div class="clearboth"></div><br>';
423 print
'<div class="tabsAction">';
425 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters,
$object, $action);
427 if (empty($reshook)) {
428 if ($action !=
"create" && $action !=
"edit") {
430 if ($user->hasRight(
'resource',
'write')) {
431 print
'<div class="inline-block divButAction">';
432 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
'Modify').
'</a>';
436 if ($action !=
"create" && $action !=
"edit") {
437 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
438 $buttonId =
'action-delete-no-ajax';
439 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
441 $buttonId =
'action-delete';
443 print
dolGetButtonAction(
'', $langs->trans(
"Delete"),
'delete', $deleteUrl, $buttonId, $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()
Empty header.
Class to manage a WYSIWYG editor.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information in HTML for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
$formconfirm
if ($action == 'delbookkeepingyear') {
resource_prepare_head($object)
Prepare head for tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.