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) 2019 Frédéric FRANCE <frederic.france@free.fr>
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 
28 // Libraries
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php';
31 
32 // Translations
33 $langs->loadLangs(array('admin', 'zapier'));
34 
35 // Access control
36 if (!$user->admin) {
38 }
39 
40 // Parameters
41 $action = GETPOST('action', 'aZ09');
42 $backtopage = GETPOST('backtopage', 'alpha');
43 
44 $arrayofparameters = array(
45 // 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
46 // 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
47 );
48 
49 if (!isModEnabled('zapier')) accessforbidden();
50 if (empty($user->admin)) accessforbidden();
51 
52 
53 /*
54  * Actions
55  */
56 
57 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
58 
59 /*
60  * View
61  */
62 
63 $page_name = 'ZapierForDolibarrSetup';
64 $help_url = 'EN:Module_Zapier';
65 llxHeader('', $langs->trans($page_name), $help_url);
66 
67 // Subheader
68 $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
69 
70 print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier');
71 
72 // Configuration header
73 $head = zapierAdminPrepareHead();
74 print dol_get_fiche_head($head, 'settings', '', -1, "zapier");
75 
76 
77 if ($action == 'edit') {
78  print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
79  print '<input type="hidden" name="token" value="'.newToken().'">';
80  print '<input type="hidden" name="action" value="update">';
81 
82  print '<table class="noborder centpercent">';
83  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
84 
85  foreach ($arrayofparameters as $key => $val) {
86  print '<tr class="oddeven"><td>';
87  print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
88  print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'"></td></tr>';
89  }
90  print '</table>';
91 
92  print '<br><div class="center">';
93  print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
94  print '</div>';
95 
96  print '</form>';
97  print '<br>';
98 } else {
99  if (!empty($arrayofparameters)) {
100  print '<table class="noborder centpercent">';
101  print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
102 
103  foreach ($arrayofparameters as $key => $val) {
104  print '<tr class="oddeven"><td>';
105  print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
106  print '</td><td>'.getDolGlobalString($key).'</td></tr>';
107  }
108 
109  print '</table>';
110 
111  print '<div class="tabsAction">';
112  print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
113  print '</div>';
114  } else {
115  // Setup page goes here
116  echo '<br><br><span class="opacitymediumdisabled">'.$langs->trans("ZapierSetupPage").'</span><br><br>';
117  //print '<br>'.$langs->trans("NothingToSetup");
118  }
119 }
120 
121 
122 // Page end
123 print dol_get_fiche_end();
124 
125 llxFooter();
126 $db->close();
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:118
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
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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
zapierAdminPrepareHead()
Prepare admin pages header.
Definition: zapier.lib.php:29