25 require
'../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/resource/class/dolresource.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/resource/class/html.formresource.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/resource.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
34 $langs->loadLangs(array(
'resource',
'companies',
'other',
'main'));
38 $action =
GETPOST(
'action',
'aZ09');
39 $cancel =
GETPOST(
'cancel',
'alpha');
41 $description =
GETPOST(
'description',
'restricthtml');
42 $confirm =
GETPOST(
'confirm',
'aZ09');
43 $fk_code_type_resource =
GETPOST(
'fk_code_type_resource',
'alpha');
44 $country_id =
GETPOST(
'country_id',
'int');
52 if (!$user->rights->resource->read)
62 $extrafields->fetch_name_optionals_label($object->table_element);
70 $hookmanager->initHooks(array(
'resource',
'resource_card',
'globalcard'));
71 $parameters = array(
'resource_id'=>$id);
72 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
73 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
79 if (!empty($backtopage))
81 header(
"Location: ".$backtopage);
86 header(
"Location: ".DOL_URL_ROOT.
'/resource/list.php');
92 if ($action ==
'add' && $user->rights->resource->write)
100 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")), null,
'errors');
104 $object->description = $description;
105 $object->fk_code_type_resource = $fk_code_type_resource;
106 $object->country_id = $country_id;
109 $ret = $extrafields->setOptionalsFromPost(null, $object);
110 if ($ret < 0) $error++;
112 $result = $object->create($user);
116 setEventMessages($langs->trans(
'ResourceCreatedWithSuccess'), null,
'mesgs');
117 Header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
126 Header(
"Location: list.php");
131 if ($action ==
'update' && !$cancel && $user->rights->resource->write)
137 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Ref")), null,
'errors');
143 $res = $object->fetch($id);
147 $object->description = $description;
148 $object->fk_code_type_resource = $fk_code_type_resource;
149 $object->country_id = $country_id;
152 $ret = $extrafields->setOptionalsFromPost(null, $object);
157 $result = $object->update($user);
160 Header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
178 if ($action ==
'confirm_delete_resource' && $user->rights->resource->delete && $confirm ===
'yes')
180 $res = $object->fetch($id);
183 $result = $object->delete($id);
187 setEventMessages($langs->trans(
'RessourceSuccessfullyDeleted'), null,
'mesgs');
188 Header(
'Location: '.DOL_URL_ROOT.
'/resource/list.php');
204 $title = $langs->trans($action ==
'create' ?
'AddResource' :
'ResourceSingular');
207 $form =
new Form($db);
210 if ($action ==
'create' || $object->fetch($id, $ref) > 0)
212 if ($action ==
'create')
221 if ($action ==
'create' || $action ==
'edit')
227 print '<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
228 print '<input type="hidden" name="token" value="'.newToken().
'">';
229 print '<input type="hidden" name="action" value="'.($action ==
"create" ?
"add" :
"update").
'">';
231 print '<table class="border centpercent">';
234 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ResourceFormLabel_ref").
'</td>';
235 print
'<td><input class="minwidth200" name="ref" value="'.($ref ? $ref : $object->ref).
'" autofocus="autofocus"></td></tr>';
238 print
'<tr><td>'.$langs->trans(
"ResourceType").
'</td>';
240 $ret = $formresource->select_types_resource($object->fk_code_type_resource,
'fk_code_type_resource',
'', 2);
244 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
246 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
247 $doleditor =
new DolEditor(
'description', ($description ? $description : $object->description),
'',
'200',
'dolibarr_notes',
false);
248 $doleditor->Create();
252 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td><td>';
253 print $form->select_country($object->country_id,
'country_id');
254 if ($user->admin) print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
258 $parameters = array(
'objectsrc' => $objectsrc);
259 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
260 print $hookmanager->resPrint;
263 print $object->showOptionals($extrafields,
'edit');
270 print
'<div class="center">';
271 print
'<input type="submit" class="button" name="save" value="'.$langs->trans($action ==
"create" ?
"Create" :
"Modify").
'">';
272 print
' ';
273 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
282 if ($action ==
'delete')
284 $formconfirm = $form->formconfirm(
"card.php?&id=".$object->id, $langs->trans(
"DeleteResource"), $langs->trans(
"ConfirmDeleteResource"),
"confirm_delete_resource",
'',
'', 1);
291 $linkback =
'<a href="'.DOL_URL_ROOT.
'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&id='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
294 $morehtmlref =
'<div class="refidno">';
295 $morehtmlref .=
'</div>';
298 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
301 print
'<div class="fichecenter">';
302 print
'<div class="underbanner clearboth"></div>';
307 print
'<table class="border tableforfield centpercent">';
311 print
'<td class="titlefield">'.$langs->trans(
"ResourceType").
'</td>';
313 print $object->type_label;
319 print
'<td>'.$langs->trans(
"ResourceFormLabel_description").
'</td>';
321 print $object->description;
325 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
331 print
'<td>'.$langs->trans(
"CountryOrigin").
'</td>';
333 print
getCountry($object->country_id, 0, $db);
341 print
'<div class="clearboth"></div><br>';
350 print
'<div class="tabsAction">';
351 $parameters = array();
352 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
356 if ($action !=
"create" && $action !=
"edit")
359 if ($user->rights->resource->write)
361 print
'<div class="inline-block divButAction">';
362 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&action=edit" class="butAction">'.$langs->trans(
'Modify').
'</a>';
366 if ($action !=
"delete" && $action !=
"create" && $action !=
"edit")
369 if ($user->rights->resource->delete)
371 print
'<div class="inline-block divButAction">';
372 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$id.
'&action=delete&token='.
newToken().
'" class="butActionDelete">'.$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.
resource_prepare_head($object)
Prepare head for tabs.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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 ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
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.
Class to manage a WYSIWYG editor.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.