dolibarr  16.0.5
setup.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 Dorian Laurent <i.merraha@sofimedmaroc.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
25 // Load Dolibarr environment
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
28 require_once '../lib/partnership.lib.php';
29 //require_once "../class/myclass.class.php";
30 
31 // Translations
32 $langs->loadLangs(array("admin", "partnership"));
33 
34 // Security check
35 if (!$user->admin) {
37 }
38 
39 $action = GETPOST('action', 'aZ09');
40 $value = GETPOST('value', 'alpha');
41 
42 
43 $error = 0;
44 
45 
46 /*
47  * Actions
48  */
49 
50 $nomessageinsetmoduleoptions = 1;
51 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
52 
53 
54 if ($action == 'setting') {
55  require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php";
56 
57  $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty';
58  $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity);
59 
60  $partnership = new modPartnership($db);
61 
62  $error += $partnership->delete_tabs();
63  $error += $partnership->insert_tabs();
64 
65  $error += $partnership->delete_menus();
66  $error += $partnership->insert_menus();
67 
68  if (GETPOSTISSET("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL")) {
69  dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity);
70  }
71 
72  dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity);
73 }
74 
75 if ($action) {
76  if (!$error) {
77  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
78  } else {
79  setEventMessages($langs->trans("SetupNotError"), null, 'errors');
80  }
81  header("Location: ".$_SERVER['PHP_SELF']);
82  exit;
83 }
84 
85 /*
86  * View
87  */
88 
89 $title = $langs->trans('PartnershipSetup');
90 
91 llxHeader('', $title);
92 
93 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
94 print load_fiche_titre($title, $linkback, 'title_setup');
95 
97 print dol_get_fiche_head($head, 'settings', $title, -1, 'partnership');
98 
99 $form = new Form($db);
100 
101 // Module to manage partnership / services code
102 $dirpartnership = array('/core/modules/partnership/');
103 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
104 
105 
106 /*
107  * Other conf
108  */
109 
110 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
111 print '<input type="hidden" name="token" value="'.newToken().'">';
112 print '<input type="hidden" name="action" value="setting">';
113 print '<input type="hidden" name="page_y" value="">';
114 
115 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
116 print '<table class="noborder centpercent">';
117 
118 print '<tr class="liste_titre">';
119 print '<td>'.$langs->trans("Setting").'</td>';
120 print '<td>'.$langs->trans("Value").'</td>';
121 print '<td>'.$langs->trans("Examples").'</td>';
122 print '</tr>';
123 
124 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").'</td>';
125 print '<td>';
126 print '<select class="flat minwidth100" id="select_PARTNERSHIP_IS_MANAGED_FOR" name="PARTNERSHIP_IS_MANAGED_FOR">';
127 print '<option value="thirdparty" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') ? 'selected' : '').'>'.$langs->trans("ThirdParty").'</option>';
128 print '<option value="member" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') ? 'selected' : '').'>'.$langs->trans("Members").'</option>';
129 print '</select>';
130 print ajax_combobox('select_PARTNERSHIP_IS_MANAGED_FOR');
131 print '</td>';
132 print '<td><span class="opacitymedium">'.$langs->trans("partnershipforthirdpartyormember").'</span></td>';
133 print '</tr>';
134 
135 
136 //if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
137 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").'</td>';
138 print '<td>';
139 $dnbdays = '30';
140 $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays;
141 print '<input class="maxwidth50" type="text" name="PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL" value="'.$backlinks.'">';
142 print '</td>';
143 print '<td><span class="opacitymedium">'.$dnbdays.'</span></td>';
144 print '</tr>';
145 //}
146 
147 print '</table>';
148 print '</div>';
149 
150 print '<br>';
151 
152 
153 print load_fiche_titre($langs->trans("ReferingWebsiteCheck"), '', '');
154 
155 print '<span class="opacitymedium">'.$langs->trans("ReferingWebsiteCheckDesc").'</span><br>';
156 print '<br>';
157 
158 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
159 print '<table class="noborder centpercent">';
160 
161 print '<tr class="liste_titre">';
162 print '<td>'.$langs->trans("Setting").'</td>';
163 print '<td>'.$langs->trans("Value").'</td>';
164 print '<td>'.$langs->trans("Examples").'</td>';
165 print '</tr>';
166 
167 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").'</td>';
168 print '<td>';
169 $backlinks = (empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) ? '' : $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK);
170 print '<input class="minwidth400" type="text" name="PARTNERSHIP_BACKLINKS_TO_CHECK" value="'.$backlinks.'">';
171 print '</td>';
172 print '<td><span class="opacitymedium">dolibarr.org|dolibarr.fr|dolibarr.es</span></td>';
173 print '</tr>';
174 
175 print '</table>';
176 print '</div>';
177 
178 
179 print '<div class="center">';
180 print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
181 print '</div>';
182 
183 print '</form>';
184 
185 // End of page
186 llxFooter();
187 $db->close();
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:438
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
partnershipAdminPrepareHead
partnershipAdminPrepareHead()
Prepare admin pages header.
Definition: partnership.lib.php:29
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
dolibarr_set_const
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:627
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
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 ...
Definition: security.lib.php:933
modPartnership
Description and activation class for module Partnership This module is base on this specification : h...
Definition: modPartnership.class.php:37
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59