dolibarr  19.0.0-dev
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 $action = GETPOST('action', 'aZ09');
35 $value = GETPOST('value', 'alpha');
36 
37 $error = 0;
38 
39 // Security check
40 if (!$user->admin) {
42 }
43 
44 
45 /*
46  * Actions
47  */
48 
49 $nomessageinsetmoduleoptions = 1;
50 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
51 
52 
53 if ($action == 'setting') {
54  require_once DOL_DOCUMENT_ROOT."/core/modules/modPartnership.class.php";
55 
56  $modulemenu = (GETPOST('PARTNERSHIP_IS_MANAGED_FOR', 'alpha') == 'member') ? 'member' : 'thirdparty';
57  $res = dolibarr_set_const($db, "PARTNERSHIP_IS_MANAGED_FOR", $modulemenu, 'chaine', 0, '', $conf->entity);
58 
59  $partnership = new modPartnership($db);
60 
61  $error += $partnership->delete_tabs();
62  $error += $partnership->insert_tabs();
63 
64  $error += $partnership->delete_menus();
65  $error += $partnership->insert_menus();
66 
67  if (GETPOSTISSET("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL")) {
68  dolibarr_set_const($db, "PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", GETPOST("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL", 'int'), 'chaine', 0, '', $conf->entity);
69  }
70 
71  dolibarr_set_const($db, "PARTNERSHIP_BACKLINKS_TO_CHECK", GETPOST("PARTNERSHIP_BACKLINKS_TO_CHECK"), 'chaine', 0, '', $conf->entity);
72 }
73 
74 if ($action) {
75  if (!$error) {
76  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
77  } else {
78  setEventMessages($langs->trans("SetupNotError"), null, 'errors');
79  }
80  header("Location: ".$_SERVER['PHP_SELF']);
81  exit;
82 }
83 
84 /*
85  * View
86  */
87 
88 $title = $langs->trans('PartnershipSetup');
89 
90 llxHeader('', $title);
91 
92 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
93 print load_fiche_titre($title, $linkback, 'title_setup');
94 
96 print dol_get_fiche_head($head, 'settings', $title, -1, 'partnership');
97 
98 $form = new Form($db);
99 
100 // Module to manage partnership / services code
101 $dirpartnership = array('/core/modules/partnership/');
102 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
103 
104 
105 /*
106  * Other conf
107  */
108 
109 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
110 print '<input type="hidden" name="token" value="'.newToken().'">';
111 print '<input type="hidden" name="action" value="setting">';
112 print '<input type="hidden" name="page_y" value="">';
113 
114 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
115 print '<table class="noborder centpercent">';
116 
117 print '<tr class="liste_titre">';
118 print '<td>'.$langs->trans("Setting").'</td>';
119 print '<td>'.$langs->trans("Value").'</td>';
120 print '<td>'.$langs->trans("Examples").'</td>';
121 print '</tr>';
122 
123 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_IS_MANAGED_FOR").'</td>';
124 print '<td>';
125 print '<select class="flat minwidth100" id="select_PARTNERSHIP_IS_MANAGED_FOR" name="PARTNERSHIP_IS_MANAGED_FOR">';
126 print '<option value="thirdparty" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'thirdparty') ? 'selected' : '').'>'.$langs->trans("ThirdParty").'</option>';
127 print '<option value="member" '.((getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR', 'thirdparty') == 'member') ? 'selected' : '').'>'.$langs->trans("Members").'</option>';
128 print '</select>';
129 print ajax_combobox('select_PARTNERSHIP_IS_MANAGED_FOR');
130 print '</td>';
131 print '<td><span class="opacitymedium">'.$langs->trans("partnershipforthirdpartyormember").'</span></td>';
132 print '</tr>';
133 
134 
135 //if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
136 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").'</td>';
137 print '<td>';
138 $dnbdays = '30';
139 $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays;
140 print '<input class="maxwidth50" type="text" name="PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL" value="'.$backlinks.'">';
141 print '</td>';
142 print '<td><span class="opacitymedium">'.$dnbdays.'</span></td>';
143 print '</tr>';
144 //}
145 
146 print '</table>';
147 print '</div>';
148 
149 print '<br>';
150 
151 
152 print load_fiche_titre($langs->trans("ReferingWebsiteCheck"), '', '');
153 
154 print '<span class="opacitymedium">'.$langs->trans("ReferingWebsiteCheckDesc").'</span><br>';
155 print '<br>';
156 
157 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
158 print '<table class="noborder centpercent">';
159 
160 print '<tr class="liste_titre">';
161 print '<td>'.$langs->trans("Setting").'</td>';
162 print '<td>'.$langs->trans("Value").'</td>';
163 print '<td>'.$langs->trans("Examples").'</td>';
164 print '</tr>';
165 
166 print '<tr class="oddeven"><td>'.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").'</td>';
167 print '<td>';
168 $backlinks = (empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) ? '' : $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK);
169 print '<input class="minwidth400" type="text" name="PARTNERSHIP_BACKLINKS_TO_CHECK" value="'.$backlinks.'">';
170 print '</td>';
171 print '<td><span class="opacitymedium">dolibarr.org|dolibarr.fr|dolibarr.es</span></td>';
172 print '</tr>';
173 
174 print '</table>';
175 print '</div>';
176 
177 
178 print '<div class="center">';
179 print '<input type="submit" class="button reposition" value="'.$langs->trans("Modify").'">';
180 print '</div>';
181 
182 print '</form>';
183 
184 // End of page
185 llxFooter();
186 $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_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:449
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.
Description and activation class for module Partnership This module is base on this specification : h...
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.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
partnershipAdminPrepareHead()
Prepare admin pages header.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.