26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/resource.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
35$langs->loadLangs(array(
'resource',
'companies',
'other',
'main'));
39$action =
GETPOST(
'action',
'aZ09');
40$cancel =
GETPOST(
'cancel',
'alpha');
42$description =
GETPOST(
'description',
'restricthtml');
43$confirm =
GETPOST(
'confirm',
'aZ09');
44$fk_code_type_resource =
GETPOST(
'fk_code_type_resource',
'alpha');
45$country_id =
GETPOST(
'country_id',
'int');
48if ($user->socid > 0) {
56$extrafields->fetch_name_optionals_label($object->table_element);
59include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
62$result =
restrictedArea($user,
'resource', $object->id,
'resource');
64$permissiontoadd = $user->rights->resource->write;
65$permissiontodelete = $user->rights->resource->delete;
72$hookmanager->initHooks(array(
'resource',
'resource_card',
'globalcard'));
73$parameters = array(
'resource_id'=>$id);
74$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
81 if (!empty($backtopage)) {
82 header(
"Location: ".$backtopage);
85 if ($action ==
'add') {
86 header(
"Location: ".DOL_URL_ROOT.
'/resource/list.php');
92 if ($action ==
'add' && $user->rights->resource->write) {
97 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
101 $object->description = $description;
102 $object->fk_code_type_resource = $fk_code_type_resource;
103 $object->country_id = $country_id;
106 $ret = $extrafields->setOptionalsFromPost(
null, $object);
111 $result = $object->create($user);
114 setEventMessages($langs->trans(
'ResourceCreatedWithSuccess'),
null,
'mesgs');
115 Header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
124 Header(
"Location: list.php");
129 if ($action ==
'update' && !$cancel && $user->rights->resource->write) {
133 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")),
null,
'errors');
138 $res = $object->fetch($id);
141 $object->description = $description;
142 $object->fk_code_type_resource = $fk_code_type_resource;
143 $object->country_id = $country_id;
146 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
151 $result = $object->update($user);
153 Header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
170 if ($action ==
'confirm_delete_resource' && $user->rights->resource->delete && $confirm ===
'yes') {
171 $res = $object->fetch($id);
173 $result = $object->delete($id);
176 setEventMessages($langs->trans(
'RessourceSuccessfullyDeleted'),
null,
'mesgs');
177 Header(
'Location: '.DOL_URL_ROOT.
'/resource/list.php');
193$title = $langs->trans($action ==
'create' ?
'AddResource' :
'ResourceSingular');
196$form =
new Form($db);
199if ($action ==
'create' || $object->fetch($id, $ref) > 0) {
200 if ($action ==
'create') {
208 if ($action ==
'create' || $action ==
'edit') {
209 if (!$user->rights->resource->write) {
215 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
216 print
'<input type="hidden" name="token" value="'.newToken().
'">';
217 print
'<input type="hidden" name="action" value="'.($action ==
"create" ?
"add" :
"update").
'">';
219 print
'<table class="border centpercent">';
222 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ResourceFormLabel_ref").
'</td>';
223 print
'<td><input class="minwidth200" name="ref" value="'.($ref ? $ref : $object->ref).
'" autofocus="autofocus"></td></tr>';
226 print
'<tr><td>'.$langs->trans(
"ResourceType").
'</td>';
228 $formresource->select_types_resource($object->fk_code_type_resource,
'fk_code_type_resource',
'', 2);
232 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
234 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
235 $doleditor =
new DolEditor(
'description', ($description ? $description : $object->
description),
'',
'200',
'dolibarr_notes', false);
236 $doleditor->Create();
240 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td><td>';
241 print $form->select_country($object->country_id,
'country_id');
243 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
248 $parameters = array();
249 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
250 print $hookmanager->resPrint;
251 if (empty($reshook)) {
252 print $object->showOptionals($extrafields,
'edit');
259 $button_label = ($action ==
"create" ?
"Create" :
"Modify");
260 print $form->buttonsSaveCancel($button_label);
269 if ($action ==
'delete') {
270 $formconfirm = $form->formconfirm(
"card.php?&id=".$object->id, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResource"),
"confirm_delete_resource",
'',
'', 1);
277 $linkback =
'<a href="'.DOL_URL_ROOT.
'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&id='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
280 $morehtmlref =
'<div class="refidno">';
281 $morehtmlref .=
'</div>';
284 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
287 print
'<div class="fichecenter">';
288 print
'<div class="underbanner clearboth"></div>';
293 print
'<table class="border tableforfield centpercent">';
297 print
'<td class="titlefield">'.$langs->trans(
"ResourceType").
'</td>';
299 print $object->type_label;
305 print
'<td>'.$langs->trans(
"ResourceFormLabel_description").
'</td>';
307 print $object->description;
313 print
'<td>'.$langs->trans(
"CountryOrigin").
'</td>';
315 print
getCountry($object->country_id, 0, $db);
320 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
328 print
'<div class="clearboth"></div><br>';
337 print
'<div class="tabsAction">';
338 $parameters = array();
339 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
341 if (empty($reshook)) {
342 if ($action !=
"create" && $action !=
"edit") {
344 if ($user->rights->resource->write) {
345 print
'<div class="inline-block divButAction">';
346 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&action=edit&token='.newToken().
'" class="butAction">'.$langs->trans(
'Modify').
'</a>';
350 if ($action !=
"delete" && $action !=
"create" && $action !=
"edit") {
351 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 a WYSIWYG editor.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
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.
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.
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.
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.
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.