dolibarr/htdocs/resource/card.php

476 lines
16 KiB
PHP
Raw Permalink Normal View History

2014-03-23 22:12:48 +01:00
<?php
/* Copyright (C) 2013-2014 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
2014-03-23 22:12:48 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2014-03-23 22:12:48 +01:00
*/
/**
* \file resource/card.php
* \ingroup resource
* \brief Page to manage resource object
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2018-07-25 09:50:04 +02:00
require '../main.inc.php';
2014-03-23 22:12:48 +01:00
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
2016-10-19 22:14:51 +02:00
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
2014-03-23 22:12:48 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
2017-11-21 23:11:33 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
2016-10-19 22:14:51 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2014-03-23 22:12:48 +01:00
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
2018-05-26 18:41:16 +02:00
// Load translation files required by the page
$langs->loadLangs(array('resource', 'companies', 'other', 'main'));
2014-03-23 22:12:48 +01:00
// Get parameters
$id = GETPOSTINT('id');
2020-09-17 12:30:14 +02:00
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'alpha');
$ref = GETPOST('ref', 'alpha');
$address = GETPOST('address', 'alpha');
$zip = GETPOST('zipcode', 'alpha');
$town = GETPOST('town', 'alpha');
$country_id = GETPOSTINT('country_id');
$state_id = GETPOSTINT('state_id');
2020-09-17 12:30:14 +02:00
$description = GETPOST('description', 'restricthtml');
$phone = GETPOST('phone', 'alpha');
$email = GETPOST('email', 'alpha');
$max_users = GETPOSTINT('max_users');
2024-02-19 16:40:25 +01:00
$url = GETPOST('url', 'alpha');
2020-09-17 12:30:14 +02:00
$confirm = GETPOST('confirm', 'aZ09');
2024-01-18 12:16:40 +01:00
$fk_code_type_resource = GETPOST('fk_code_type_resource', 'aZ09');
2014-03-23 22:12:48 +01:00
// Protection if external user
2021-02-26 20:53:03 +01:00
if ($user->socid > 0) {
2014-03-23 22:12:48 +01:00
accessforbidden();
}
$object = new Dolresource($db);
2016-10-19 22:14:51 +02:00
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
2016-10-19 22:14:51 +02:00
2021-10-25 15:32:10 +02:00
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
2021-10-25 15:32:10 +02:00
$hookmanager->initHooks(array('resource', 'resource_card', 'globalcard'));
2021-10-25 15:32:10 +02:00
$result = restrictedArea($user, 'resource', $object->id, 'resource');
Fix #28071 - New branch to fix bad merge (#28083) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Qual: Introduce getDataToShowPhoto to prepare generic code * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix missing trans * Fix langs * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Remove useless files in web templates * Clean code * Fix duplicate translation key * Fix duplicate translation key * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix duplicate key * Fix $object * Debug v19 * WIP SMSing * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP EMAILINGS_SUPPORT_ALSO_SMS * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * WIP SMSing * Debug the "validate" feature * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Clean code * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Move rights->x->y into hasRight('x', 'y') * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Enhance rector to fix empty($user->rights->modulex->perm1) * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Fix template to use v19 dev rules * Fix use v19 dev rules * Fix phpunit * Debug v19 * Clean code * Use rector to convert user->rights into user->hasRight * Clean code * Use rector to convert user->rights into user->hasRight * Use rector to convert user->rights into user->hasRight * Clean code * Fix phpcs * add editorconfig for sql files (#27999) Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * add model_pdf field in llx_ticket-ticket.sql (#27996) * add model_pdf field in llx_ticket-ticket.sql * Update 19.0.0-20.0.0.sql * Update 19.0.0-20.0.0.sql * Improve wording in README (#27994) * fix phpstan (#27989) * fix phpstan * Update UserRightsToFunction.php --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> * Qual: Fix spelling/working in datapolicy translations (#28006) # Qual: Fix spelling/wording in datapolicy translations Fixed some spelling and wording in datapolicy translations. * qual: phpstan for htdocs/ticket/class/ticketstats.class.php (#27986) htdocs/ticket/class/ticketstats.class.php 98 Parameter #1 $year (string) of method TicketStats::getNbByMonth() should be compatible with parameter $year (int) of method Stats::getNbByMonth() * Merge branch '19.0' of git@github.com:Dolibarr/dolibarr.git into develop * Fix user with readonly perm on email template must be able to read. * Fix doc * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Better message * Add missing fields in merge of thirdparty * Debug v19 selection of ticket printer per terminal * Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop * Use constant * NEW: Adding a recipient on emails sent, change status to sent partialy. * fix travis (#28052) * fix travis * Update partnership.class.php * fix php doc (#28047) * fix undefined array key (#28048) * Add region and departament for Cuba (#28046) * Update llx_10_c_regions.sql Add Cuba Regions (id_country=77) * Update llx_20_c_departements.sql Add Provinces Cuba (id country=77) * Find the typo (#28050) * Find the typo * clean code * add last_main_doc field to product (#28045) * add las_main_doc field to product * add field fetch * NEW Add Categorie filter for ActionComm (#28041) * New Add Categorie filter for ActionComm New Add Categorie filter for ActionComm * Fix space errors Fix space errors * Fix space errors 2 Fix space errors 2 * Update cunits.class.php (#28056) FIX: error SQL when creating a Cunit * Update codespell-lines-ignore.txt to avoid PR merge conflict --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr> Co-authored-by: Frédéric FRANCE <frederic34@users.noreply.github.com> Co-authored-by: thibdrev <thibault.drevet@gmail.com> Co-authored-by: sonikf <93765174+sonikf@users.noreply.github.com> Co-authored-by: Ikarus <44511582+LeKarSol@users.noreply.github.com> Co-authored-by: Anthony Damhet <73399671+EchoLoGeek@users.noreply.github.com> Co-authored-by: Quentin-Seekness <72733832+Quentin-Seekness@users.noreply.github.com>
2024-02-09 15:58:49 +01:00
$permissiontoadd = $user->hasRight('resource', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->hasRight('resource', 'delete');
2017-11-22 11:54:02 +01:00
2019-11-02 00:17:08 +01:00
/*
* Actions
*/
2017-11-22 11:54:02 +01:00
2024-03-26 13:23:31 +01:00
$parameters = array('resource_id' => $id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
2021-02-26 20:53:03 +01:00
if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) {
if ($cancel) {
if (!empty($backtopage)) {
2017-11-22 11:54:02 +01:00
header("Location: ".$backtopage);
exit;
}
2024-08-31 19:15:14 +02:00
if ($action == 'add') { // Test on permission not required here
2017-11-22 11:54:02 +01:00
header("Location: ".DOL_URL_ROOT.'/resource/list.php');
exit;
}
$action = '';
2017-11-22 11:54:02 +01:00
}
2024-09-01 14:04:10 +02:00
if ($action == 'add' && $permissiontoadd) {
2021-02-26 20:53:03 +01:00
if (!$cancel) {
$error = '';
2021-02-26 20:53:03 +01:00
if (empty($ref)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
$action = 'create';
2020-05-21 15:05:19 +02:00
} else {
$object->ref = $ref;
$object->address = $address;
$object->zip = $zip;
$object->town = $town;
$object->country_id = $country_id;
2023-10-26 11:44:42 +02:00
$object->state_id = $state_id;
$object->description = $description;
$object->phone = $phone;
$object->email = $email;
$object->max_users = $max_users;
2024-02-19 16:40:25 +01:00
$object->url = $url;
$object->fk_code_type_resource = $fk_code_type_resource;
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
2021-02-26 20:53:03 +01:00
if ($ret < 0) {
$error++;
}
$result = $object->create($user);
2021-02-26 20:53:03 +01:00
if ($result > 0) {
// Creation OK
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null);
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
2020-05-21 15:05:19 +02:00
} else {
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
$action = 'create';
}
}
2020-05-21 15:05:19 +02:00
} else {
header("Location: list.php");
exit;
}
}
2014-03-23 22:12:48 +01:00
2024-09-01 14:04:10 +02:00
if ($action == 'update' && !$cancel && $permissiontoadd) {
$error = 0;
2014-03-23 22:12:48 +01:00
2021-02-26 20:53:03 +01:00
if (empty($ref)) {
2015-10-17 17:09:34 +02:00
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
$error++;
}
2021-02-26 20:53:03 +01:00
if (!$error) {
$res = $object->fetch($id);
2021-02-26 20:53:03 +01:00
if ($res > 0) {
$object->ref = $ref;
$object->address = $address;
$object->zip = $zip;
$object->town = $town;
2017-11-21 23:11:33 +01:00
$object->country_id = $country_id;
2023-10-26 11:44:42 +02:00
$object->state_id = $state_id;
$object->description = $description;
$object->phone = $phone;
$object->email = $email;
$object->max_users = $max_users;
2024-02-19 16:40:25 +01:00
$object->url = $url;
$object->fk_code_type_resource = $fk_code_type_resource;
2016-10-19 22:14:51 +02:00
// Fill array 'array_options' with data from add form
2021-12-06 11:19:12 +01:00
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
2016-10-19 22:14:51 +02:00
if ($ret < 0) {
$error++;
2016-10-19 22:14:51 +02:00
}
$result = $object->update($user);
2021-02-26 20:53:03 +01:00
if ($result > 0) {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
2020-05-21 15:05:19 +02:00
} else {
2015-12-20 10:36:20 +01:00
setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
2020-05-21 15:05:19 +02:00
} else {
2015-12-20 10:36:20 +01:00
setEventMessages($object->error, $object->errors, 'errors');
$error++;
2014-03-23 22:12:48 +01:00
}
}
2021-02-26 20:53:03 +01:00
if ($error) {
$action = 'edit';
2014-03-23 22:12:48 +01:00
}
}
2015-08-12 21:48:00 +02:00
2024-09-01 14:04:10 +02:00
if ($action == 'confirm_delete_resource' && $permissiontodelete && $confirm === 'yes') {
2015-08-12 21:48:00 +02:00
$res = $object->fetch($id);
2021-02-26 20:53:03 +01:00
if ($res > 0) {
$result = $object->delete($user);
2015-08-12 21:48:00 +02:00
2021-02-26 20:53:03 +01:00
if ($result >= 0) {
setEventMessages($langs->trans('RessourceSuccessfullyDeleted'), null);
2024-01-10 14:58:38 +01:00
header('Location: '.DOL_URL_ROOT.'/resource/list.php');
2015-08-12 21:48:00 +02:00
exit;
2020-05-21 15:05:19 +02:00
} else {
2015-12-20 10:36:20 +01:00
setEventMessages($object->error, $object->errors, 'errors');
2015-08-12 21:48:00 +02:00
}
2020-05-21 15:05:19 +02:00
} else {
2015-12-20 10:36:20 +01:00
setEventMessages($object->error, $object->errors, 'errors');
2015-08-12 21:48:00 +02:00
}
}
2014-03-23 22:12:48 +01:00
}
2015-05-31 01:06:51 +02:00
2019-11-02 00:17:08 +01:00
/*
* View
*/
2017-11-22 11:54:02 +01:00
$title = $langs->trans($action == 'create' ? 'AddResource' : 'ResourceSingular');
$help_url = '';
llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-resource page-card');
2014-03-23 22:12:48 +01:00
$form = new Form($db);
$formresource = new FormResource($db);
2021-02-26 20:53:03 +01:00
if ($action == 'create' || $object->fetch($id, $ref) > 0) {
if ($action == 'create') {
2020-04-13 04:14:28 +02:00
print load_fiche_titre($title, '', 'object_resource');
2024-03-26 13:23:31 +01:00
print dol_get_fiche_head();
2020-05-21 15:05:19 +02:00
} else {
$head = resource_prepare_head($object);
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'resource', $title, -1, 'resource');
}
2014-03-23 22:12:48 +01:00
2021-02-26 20:53:03 +01:00
if ($action == 'create' || $action == 'edit') {
2023-11-27 13:26:44 +01:00
if (!$user->hasRight('resource', 'write')) {
accessforbidden('', 0);
2021-02-26 20:53:03 +01:00
}
2014-03-23 22:12:48 +01:00
if (!empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript">';
print '$(document).ready(function () {
$("#selectcountry_id").change(function() {
console.log("selectcountry_id change");
document.formresource.action.value="create";
document.formresource.submit();
});
});';
print '</script>'."\n";
}
2017-11-22 11:54:02 +01:00
// Create/Edit object
print '<form enctype="multipart/form-data" action="'.$_SERVER["PHP_SELF"].'?id='.$id.'" method="POST" name="formresource">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="'.($action == "create" ? "add" : "update").'">';
2015-05-31 01:06:51 +02:00
2019-11-05 21:24:41 +01:00
print '<table class="border centpercent">';
2014-03-23 22:12:48 +01:00
// Ref
2016-06-06 12:29:15 +02:00
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("ResourceFormLabel_ref").'</td>';
print '<td><input class="minwidth200" name="ref" value="'.($ref ?: $object->ref).'" autofocus="autofocus"></td></tr>';
// Type
print '<tr><td>'.$langs->trans("ResourceType").'</td>';
print '<td>';
$formresource->select_types_resource($object->fk_code_type_resource, 'fk_code_type_resource', '', 2, 0, 0, 0, 1, 'minwidth200');
print '</td></tr>';
// Description
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
print '<td>';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor = new DolEditor('description', ($description ?: $object->description), '', 200, 'dolibarr_notes');
$doleditor->Create();
print '</td></tr>';
// Address
print '<tr><td class="tdtop">'.$form->editfieldkey('Address', 'address', '', $object, 0).'</td>';
2024-09-13 18:51:25 +02:00
print '<td><textarea name="address" id="address" class="quatrevingtpercent" rows="3" wrap="soft">';
print dol_escape_htmltag(GETPOSTISSET('address') ? GETPOST('address') : $object->address, 0, 1);
print '</textarea>';
print $form->widgetForTranslation("address", $object, (bool) $permissiontoadd, 'textarea', 'alphanohtml', 'quatrevingtpercent');
print '</td></tr>';
2024-09-13 18:51:25 +02:00
// Zip
print '<tr><td>'.$form->editfieldkey('Zip', 'zipcode', '', $object, 0).'</td><td>';
print $formresource->select_ziptown(GETPOSTISSET('zipcode') ? GETPOST('zipcode') : $object->zip, 'zipcode', array('town', 'selectcountry_id', 'state_id'), 0, 0, '', 'maxwidth100');
print '</td>';
2024-09-13 18:51:25 +02:00
print '</tr>';
// Town
print '<tr>';
print '<td>'.$form->editfieldkey('Town', 'town', '', $object, 0).'</td><td>';
print $formresource->select_ziptown(GETPOSTISSET('town') ? GETPOST('town') : $object->town, 'town', array('zipcode', 'selectcountry_id', 'state_id'));
print $form->widgetForTranslation("town", $object, (bool) $permissiontoadd, 'string', 'alphanohtml', 'maxwidth100 quatrevingtpercent');
print '</td></tr>';
// Origin country
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
print $form->select_country(GETPOSTISSET('country_id') ? (string) GETPOSTINT('country_id') : (string) $object->country_id, 'country_id');
if ($user->admin) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
print '</td></tr>';
2023-10-26 11:44:42 +02:00
// State
$countryid = GETPOSTISSET('country_id') ? GETPOSTINT('country_id') : $object->country_id;
if (!getDolGlobalString('SOCIETE_DISABLE_STATE') && $countryid > 0) {
2023-10-26 11:44:42 +02:00
if ((getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 1 || getDolGlobalInt('MAIN_SHOW_REGION_IN_STATE_SELECT') == 2)) {
2024-09-13 18:51:25 +02:00
print '<tr><td>'.$form->editfieldkey('Region-State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
2023-10-26 11:44:42 +02:00
} else {
2024-09-13 18:51:25 +02:00
print '<tr><td>'.$form->editfieldkey('State', 'state_id', '', $object, 0).'</td><td class="maxwidthonsmartphone">';
2023-10-26 11:44:42 +02:00
}
if ($country_id > 0) {
2023-10-26 11:44:42 +02:00
print img_picto('', 'state', 'class="pictofixedwidth"');
print $formresource->select_state($countryid, $country_id);
2023-10-26 11:44:42 +02:00
} else {
print '<span class="opacitymedium">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</span>';
2023-10-26 11:44:42 +02:00
}
print '</td></tr>';
}
// Phone
print '<td>'.$form->editfieldkey('Phone', 'phone', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_phoning', 'class="pictofixedwidth"');
print '<input type="tel" name="phone" id="phone" value="'.(GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : $object->phone).'"></td>';
print '</tr>';
// Email
print '<tr><td>'.$form->editfieldkey('EMail', 'email', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_email', 'class="pictofixedwidth"');
print '<input type="email" name="email" id="email" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alpha') : $object->email).'"></td>';
print '</tr>';
// Max users
print '<tr><td>'.$form->editfieldkey('MaxUsers', 'max_users', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_user', 'class="pictofixedwidth"');
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>';
print '</tr>';
2024-02-19 16:40:25 +01:00
// URL
print '<tr><td>'.$form->editfieldkey('URL', 'url', '', $object, 0).'</td>';
print '<td>';
print img_picto('', 'object_url', 'class="pictofixedwidth"');
print '<input type="url" name="url" id="url" value="'.(GETPOSTISSET('url') ? GETPOST('url', 'alpha') : $object->url).'"></td>';
print '</tr>';
2016-10-19 22:14:51 +02:00
// Other attributes
2022-12-09 15:30:12 +01:00
$parameters = array();
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
2021-02-26 20:53:03 +01:00
if (empty($reshook)) {
print $object->showOptionals($extrafields, 'edit');
2016-10-19 22:14:51 +02:00
}
2015-05-31 01:06:51 +02:00
print '</table>';
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2015-05-31 01:06:51 +02:00
$button_label = ($action == "create" ? "Create" : "Modify");
print $form->buttonsSaveCancel($button_label);
2015-05-31 01:06:51 +02:00
print '</div>';
2014-03-23 22:12:48 +01:00
print '</form>';
2020-05-21 15:05:19 +02:00
} else {
2017-05-23 13:38:48 +02:00
$formconfirm = '';
2017-06-07 16:44:04 +02:00
2015-05-31 01:06:51 +02:00
// Confirm deleting resource line
2023-11-28 10:33:06 +01:00
if ($action == 'delete' || ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile))) {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteResource"), $langs->trans("ConfirmDeleteResource"), "confirm_delete_resource", '', 0, "action-delete");
}
2014-03-23 22:12:48 +01:00
// Print form confirm
print $formconfirm;
2017-06-07 16:44:04 +02:00
$linkback = '<a href="'.DOL_URL_ROOT.'/resource/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&id='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
2017-06-07 16:44:04 +02:00
dol_banner_tab($object, 'ref', $linkback, 1, 'ref');
2017-06-07 16:44:04 +02:00
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
2017-06-07 16:44:04 +02:00
2019-06-05 12:16:55 +02:00
print '<table class="border tableforfield centpercent">';
2014-03-23 22:12:48 +01:00
// Resource type
print '<tr>';
print '<td class="titlefield">'.$langs->trans("ResourceType").'</td>';
print '<td>';
2014-03-23 22:12:48 +01:00
print $object->type_label;
print '</td>';
print '</tr>';
2014-03-23 22:12:48 +01:00
// Description
print '<tr>';
print '<td>'.$langs->trans("ResourceFormLabel_description").'</td>';
print '<td>';
2014-03-23 22:12:48 +01:00
print $object->description;
print '</td>';
print '</tr>';
// Max users
2017-11-21 23:11:33 +01:00
print '<tr>';
print '<td>'.$langs->trans("MaxUsers").'</td>';
2017-11-21 23:11:33 +01:00
print '<td>';
print $object->max_users;
2017-11-21 23:11:33 +01:00
print '</td>';
print '</tr>';
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
2017-11-21 23:11:33 +01:00
print '</tr>';
2014-03-23 22:12:48 +01:00
print '</table>';
2017-06-07 16:44:04 +02:00
2017-05-23 13:38:48 +02:00
print '</div>';
2017-06-07 16:44:04 +02:00
2017-05-23 13:38:48 +02:00
print '<div class="clearboth"></div><br>';
2017-06-07 16:44:04 +02:00
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end();
2014-03-23 22:12:48 +01:00
}
/*
* Boutons actions
2015-05-31 01:06:51 +02:00
*/
2014-03-23 22:12:48 +01:00
print '<div class="tabsAction">';
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
// modified by hook
2021-02-26 20:53:03 +01:00
if (empty($reshook)) {
if ($action != "create" && $action != "edit") {
2014-03-23 22:12:48 +01:00
// Edit resource
2023-11-27 13:26:44 +01:00
if ($user->hasRight('resource', 'write')) {
2014-03-23 22:12:48 +01:00
print '<div class="inline-block divButAction">';
2021-09-27 12:24:01 +02:00
print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$id.'&action=edit&token='.newToken().'" class="butAction">'.$langs->trans('Modify').'</a>';
2014-03-23 22:12:48 +01:00
print '</div>';
}
}
2023-11-28 10:33:06 +01:00
if ($action != "create" && $action != "edit") {
$deleteUrl = $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken();
$buttonId = 'action-delete-no-ajax';
if ($conf->use_javascript_ajax && empty($conf->dol_use_jmobile)) { // We can't use preloaded confirm form with jmobile
$deleteUrl = '';
$buttonId = 'action-delete';
}
print dolGetButtonAction('', $langs->trans("Delete"), 'delete', $deleteUrl, $buttonId, $permissiontodelete);
2014-05-11 12:12:17 +02:00
}
2014-03-23 22:12:48 +01:00
}
print '</div>';
2020-05-21 15:05:19 +02:00
} else {
2014-03-23 22:12:48 +01:00
dol_print_error();
}
// End of page
llxFooter();
$db->close();