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 <http://www.gnu.org/licenses/>. 17 */ 18 19/** 20 * \file zapier/admin/setup.php 21 * \ingroup zapier 22 * \brief Zapier setup page. 23 */ 24 25// Load Dolibarr environment 26require '../../main.inc.php'; 27 28// Libraries 29require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; 30require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php'; 31 32// Translations 33$langs->loadLangs(array("admin", "zapier")); 34 35// Access control 36if (!$user->admin) { 37 accessforbidden(); 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 49if (empty($conf->zapier->enabled)) accessforbidden(); 50if (empty($user->admin)) accessforbidden(); 51 52 53/* 54 * Actions 55 */ 56 57if ((float) DOL_VERSION >= 6) { 58 include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; 59} 60 61 62/* 63 * View 64 */ 65 66$page_name = "ZapierForDolibarrSetup"; 67$help_url = 'EN:Module_Zapier'; 68llxHeader('', $langs->trans($page_name), $help_url); 69 70// Subheader 71$linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>'; 72 73print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier'); 74 75// Configuration header 76$head = zapierAdminPrepareHead(); 77print dol_get_fiche_head($head, 'settings', '', -1, "zapier"); 78 79 80if ($action == 'edit') { 81 print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; 82 print '<input type="hidden" name="token" value="'.newToken().'">'; 83 print '<input type="hidden" name="action" value="update">'; 84 85 print '<table class="noborder centpercent">'; 86 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; 87 88 foreach ($arrayofparameters as $key => $val) { 89 print '<tr class="oddeven"><td>'; 90 print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); 91 print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.$conf->global->$key.'"></td></tr>'; 92 } 93 print '</table>'; 94 95 print '<br><div class="center">'; 96 print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">'; 97 print '</div>'; 98 99 print '</form>'; 100 print '<br>'; 101} else { 102 if (!empty($arrayofparameters)) { 103 print '<table class="noborder centpercent">'; 104 print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; 105 106 foreach ($arrayofparameters as $key => $val) { 107 print '<tr class="oddeven"><td>'; 108 print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); 109 print '</td><td>'.$conf->global->$key.'</td></tr>'; 110 } 111 112 print '</table>'; 113 114 print '<div class="tabsAction">'; 115 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>'; 116 print '</div>'; 117 } else { 118 // Setup page goes here 119 echo '<br><br><span class="opacitymediumdisabled">'.$langs->trans("ZapierSetupPage").'</span><br><br>'; 120 //print '<br>'.$langs->trans("NothingToSetup"); 121 } 122} 123 124 125// Page end 126print dol_get_fiche_end(); 127 128llxFooter(); 129$db->close(); 130