dolibarr  19.0.0-dev
resource.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016 Florian HENRY <florian.henry@atm-consulting.fr>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  *
17  */
18 
25 // Load Dolibarr environment
26 require '../main.inc.php';
27 
28 // Class
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
33 
34 // Load translation files required by the page
35 $langs->loadLangs(array("admin", "resource"));
36 
37 // Security check
38 if (!$user->admin) {
40 }
41 
42 $action = GETPOST('action', 'aZ09');
43 
44 
45 /*
46  * Actions
47  */
48 
49 if ($action == 'updateoptions') {
50  if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT') != '') {
51  if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity)) {
52  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
53  } else {
54  setEventMessages($langs->trans("Error"), null, 'errors');
55  }
56  }
57 }
58 
59 /*
60  * View
61  */
62 
63 llxHeader('', $langs->trans('ResourceSetup'));
64 
65 $form = new Form($db);
66 
67 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
68 print load_fiche_titre($langs->trans('ResourceSetup'), $linkback, 'title_setup');
69 
71 
72 print dol_get_fiche_head($head, 'general', $langs->trans("ResourceSingular"), -1, 'action');
73 
74 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
75 print '<input type="hidden" name="token" value="'.newToken().'">';
76 print '<input type="hidden" name="action" value="updateoptions">';
77 
78 print '<div class="div-table-responsive-no-min">';
79 print '<table class="noborder centpercent">';
80 print '<tr class="liste_titre">';
81 print '<td>'.$langs->trans("Parameters").'</td>'."\n";
82 print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
83 print '<td></td>';
84 
85 
86 // Utilisation formulaire Ajax sur choix produit
87 print '<tr class="oddeven">';
88 print '<td width="80%">'.$langs->trans("UseSearchToSelectResource").'</td>';
89 if (empty($conf->use_javascript_ajax)) {
90  print '<td class="nowrap right" colspan="2">';
91  print $langs->trans("NotAvailableWhenAjaxDisabled");
92  print '</td>';
93 } else {
94  print '<td width="60" class="right">';
95  $arrval = array(
96  '0'=>$langs->trans("No"),
97  '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 1).')',
98  '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 2).')',
99  '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch", 3).')',
100  );
101  print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT", $arrval, $conf->global->RESOURCE_USE_SEARCH_TO_SELECT);
102  print '</td>';
103  print '<td class="right">';
104  print '<input type="submit" class="button small" name="RESOURCE_USE_SEARCH_TO_SELECT" value="'.$langs->trans("Modify").'">';
105  print '</td>';
106 }
107 print '</tr>';
108 
109 
110 print '<tr class="oddeven">';
111 print '<td>'.$langs->trans('EnableResourceUsedInEventCheck').'</td>';
112 print '<td class="right">';
113 echo ajax_constantonoff('RESOURCE_USED_IN_EVENT_CHECK');
114 print '</td>';
115 print '<td></td>';
116 print '</tr>';
117 
118 /*
119 print '<tr class="oddeven">';
120 print '<td>'.$langs->trans('DisabledResourceLinkUser').'</td>';
121 print '<td class="right">';
122 echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER');
123 print '</td>';
124 print '<td></td>';
125 print '</tr>';
126 
127 
128 print '<tr class="oddeven">';
129 print '<td>'.$langs->trans('DisabledResourceLinkContact').'</td>';
130 print '<td class="right">';
131 echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY');
132 print '</td>';
133 print '<td></td>';
134 print '</tr>';
135 */
136 
137 print '</table>';
138 print '</div>';
139 
140 print '</form>';
141 
142 
143 //RESOURCE_HIDE_ADD_CONTACT_USER
144 //RESOURCE_HIDE_ADD_CONTACT_THIPARTY
145 
146 print dol_get_fiche_end();
147 
148 // End of page
149 llxFooter();
150 $db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:638
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='', $morecss='inline-block')
On/off button for constant.
Definition: ajax.lib.php:630
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
resource_admin_prepare_head()
Prepare head for admin tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.