29require
'../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/resource.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
38$langs->loadLangs(array(
'resource',
'companies',
'other',
'main'));
42$action =
GETPOST(
'action',
'aZ09');
43$cancel =
GETPOST(
'cancel',
'alpha');
45$address =
GETPOST(
'address',
'alpha');
46$zip =
GETPOST(
'zipcode',
'alpha');
47$town =
GETPOST(
'town',
'alpha');
50$description =
GETPOST(
'description',
'restricthtml');
51$phone =
GETPOST(
'phone',
'alpha');
52$email =
GETPOST(
'email',
'alpha');
55$confirm =
GETPOST(
'confirm',
'aZ09');
56$fk_code_type_resource =
GETPOST(
'fk_code_type_resource',
'aZ09');
59if ($user->socid > 0) {
67$extrafields->fetch_name_optionals_label(
$object->table_element);
70include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
72$hookmanager->initHooks(array(
'resource',
'resource_card',
'globalcard'));
76$permissiontoadd = $user->hasRight(
'resource',
'write');
77$permissiontodelete = $user->hasRight(
'resource',
'delete');
84$parameters = array(
'resource_id' => $id);
85$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
92 if (!empty($backtopage)) {
93 header(
"Location: ".$backtopage);
96 if ($action ==
'add') {
97 header(
"Location: ".DOL_URL_ROOT.
'/resource/list.php');
103 if ($action ==
'add' && $permissiontoadd) {
108 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
115 $object->country_id = $country_id;
117 $object->description = $description;
120 $object->max_users = $max_users;
122 $object->fk_code_type_resource = $fk_code_type_resource;
125 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
130 $result =
$object->create($user);
134 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
143 header(
"Location: list.php");
148 if ($action ==
'update' && !$cancel && $permissiontoadd) {
152 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
163 $object->country_id = $country_id;
165 $object->description = $description;
168 $object->max_users = $max_users;
170 $object->fk_code_type_resource = $fk_code_type_resource;
173 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
178 $result =
$object->update($user);
180 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
197 if ($action ==
'confirm_delete_resource' && $permissiontodelete && $confirm ===
'yes') {
200 $result =
$object->delete($user);
204 header(
'Location: '.DOL_URL_ROOT.
'/resource/list.php');
220$title = $langs->trans($action ==
'create' ?
'AddResource' :
'ResourceSingular');
222llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-resource page-card');
224$form =
new Form($db);
227if ($action ==
'create' ||
$object->fetch($id, $ref) > 0) {
228 if ($action ==
'create') {
236 if ($action ==
'create' || $action ==
'edit') {
237 if (!$user->hasRight(
'resource',
'write')) {
241 if (!empty($conf->use_javascript_ajax)) {
242 print
'<script type="text/javascript">';
243 print
'$(document).ready(function () {
244 $("#selectcountry_id").change(function() {
245 console.log("selectcountry_id change");
246 document.formresource.action.value="create";
247 document.formresource.submit();
250 print
'</script>'.
"\n";
256 print
'<form enctype="multipart/form-data" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$id.
'" method="POST" name="formresource">';
257 print
'<input type="hidden" name="token" value="'.newToken().
'">';
258 print
'<input type="hidden" name="action" value="'.($action ==
"create" ?
"add" :
"update").
'">';
260 print
'<table class="border centpercent">';
263 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ResourceFormLabel_ref").
'</td>';
264 print
'<td><input class="minwidth200" name="ref" value="'.($ref ?:
$object->ref).
'" autofocus="autofocus"></td></tr>';
267 print
'<tr><td>'.$langs->trans(
"ResourceType").
'</td>';
269 $formresource->select_types_resource(
$object->fk_code_type_resource,
'fk_code_type_resource',
'', 2, 0, 0, 0, 1,
'minwidth200');
273 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
275 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
277 $doleditor->Create();
281 print
'<tr><td class="tdtop">'.$form->editfieldkey(
'Address',
'address',
'',
$object, 0).
'</td>';
282 print
'<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
285 print $form->widgetForTranslation(
"address",
$object, $permissiontoadd,
'textarea',
'alphanohtml',
'quatrevingtpercent');
289 print
'<tr><td>'.$form->editfieldkey(
'Zip',
'zipcode',
'',
$object, 0).
'</td><td>';
290 print $formresource->select_ziptown(GETPOSTISSET(
'zipcode') ?
GETPOST(
'zipcode') :
$object->zip,
'zipcode', array(
'town',
'selectcountry_id',
'state_id'), 0, 0,
'',
'maxwidth100');
296 print
'<td>'.$form->editfieldkey(
'Town',
'town',
'',
$object, 0).
'</td><td>';
297 print $formresource->select_ziptown(GETPOSTISSET(
'town') ?
GETPOST(
'town') :
$object->town,
'town', array(
'zipcode',
'selectcountry_id',
'state_id'));
298 print $form->widgetForTranslation(
"town",
$object, $permissiontoadd,
'string',
'alphanohtml',
'maxwidth100 quatrevingtpercent');
302 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td><td>';
303 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id,
'country_id');
305 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
310 $countryid = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id;
313 print
'<tr><td>'.$form->editfieldkey(
'Region-State',
'state_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone">';
315 print
'<tr><td>'.$form->editfieldkey(
'State',
'state_id',
'',
$object, 0).
'</td><td class="maxwidthonsmartphone">';
318 if ($country_id > 0) {
319 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
320 print $formresource->select_state($countryid, $country_id);
322 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorSetACountryFirst").
' ('.$langs->trans(
"SeeAbove").
')</span>';
328 print
'<td>'.$form->editfieldkey(
'Phone',
'phone',
'',
$object, 0).
'</td>';
330 print
img_picto(
'',
'object_phoning',
'class="pictofixedwidth"');
331 print
'<input type="tel" name="phone" id="phone" value="'.(GETPOSTISSET(
'phone') ?
GETPOST(
'phone',
'alpha') :
$object->phone).
'"></td>';
335 print
'<tr><td>'.$form->editfieldkey(
'EMail',
'email',
'',
$object, 0).
'</td>';
337 print
img_picto(
'',
'object_email',
'class="pictofixedwidth"');
338 print
'<input type="email" name="email" id="email" value="'.(GETPOSTISSET(
'email') ?
GETPOST(
'email',
'alpha') :
$object->
email).
'"></td>';
342 print
'<tr><td>'.$form->editfieldkey(
'MaxUsers',
'max_users',
'',
$object, 0).
'</td>';
344 print
img_picto(
'',
'object_user',
'class="pictofixedwidth"');
345 print
'<input type="text" class="width75 right" name="max_users" id="max_users" value="'.(GETPOSTISSET(
'max_users') ?
GETPOST(
'max_users',
'int') :
$object->max_users).
'"></td>';
349 print
'<tr><td>'.$form->editfieldkey(
'URL',
'url',
'',
$object, 0).
'</td>';
351 print
img_picto(
'',
'object_url',
'class="pictofixedwidth"');
352 print
'<input type="url" name="url" id="url" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url',
'alpha') :
$object->url).
'"></td>';
356 $parameters = array();
357 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
358 print $hookmanager->resPrint;
359 if (empty($reshook)) {
360 print
$object->showOptionals($extrafields,
'edit');
367 $button_label = ($action ==
"create" ?
"Create" :
"Modify");
368 print $form->buttonsSaveCancel($button_label);
377 if ($action ==
'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
378 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResource"),
"confirm_delete_resource",
'', 0,
"action-delete");
385 $linkback =
'<a href="'.DOL_URL_ROOT.
'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&id='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
387 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref');
390 print
'<div class="fichecenter">';
391 print
'<div class="underbanner clearboth"></div>';
393 print
'<table class="border tableforfield centpercent">';
397 print
'<td class="titlefield">'.$langs->trans(
"ResourceType").
'</td>';
405 print
'<td>'.$langs->trans(
"ResourceFormLabel_description").
'</td>';
413 print
'<td>'.$langs->trans(
"MaxUsers").
'</td>';
420 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
428 print
'<div class="clearboth"></div><br>';
437 print
'<div class="tabsAction">';
438 $parameters = array();
439 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
441 if (empty($reshook)) {
442 if ($action !=
"create" && $action !=
"edit") {
444 if ($user->hasRight(
'resource',
'write')) {
445 print
'<div class="inline-block divButAction">';
446 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$id.
'&action=edit&token='.
newToken().
'" class="butAction">'.$langs->trans(
'Modify').
'</a>';
450 if ($action !=
"create" && $action !=
"edit") {
451 $deleteUrl = $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken();
452 $buttonId =
'action-delete-no-ajax';
453 if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) {
455 $buttonId =
'action-delete';
457 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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage a WYSIWYG editor.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as p label as s rowid as s nom as s email
Sender: Who sends the email ("Sender" has sent emails on behalf of "From").
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
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.
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 a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
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...
div refaddress div address
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.