setup.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. /**
  19. * \file zapier/admin/setup.php
  20. * \ingroup zapier
  21. * \brief Zapier setup page.
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. // Libraries
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php';
  28. // Translations
  29. $langs->loadLangs(array('admin', 'zapier'));
  30. // Access control
  31. if (!$user->admin) {
  32. accessforbidden();
  33. }
  34. // Parameters
  35. $action = GETPOST('action', 'aZ09');
  36. $backtopage = GETPOST('backtopage', 'alpha');
  37. $arrayofparameters = array(
  38. // 'ZAPIERFORDOLIBARR_MYPARAM1'=>array('css'=>'minwidth200', 'enabled'=>1),
  39. // 'ZAPIERFORDOLIBARR_MYPARAM2'=>array('css'=>'minwidth500', 'enabled'=>1)
  40. );
  41. if (empty($conf->zapier->enabled)) accessforbidden();
  42. if (empty($user->admin)) accessforbidden();
  43. /*
  44. * Actions
  45. */
  46. if ((float) DOL_VERSION >= 6) {
  47. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  48. }
  49. /*
  50. * View
  51. */
  52. $page_name = 'ZapierForDolibarrSetup';
  53. $help_url = 'EN:Module_Zapier';
  54. llxHeader('', $langs->trans($page_name), $help_url);
  55. // Subheader
  56. $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';
  57. print load_fiche_titre($langs->trans($page_name), $linkback, 'object_zapier');
  58. // Configuration header
  59. $head = zapierAdminPrepareHead();
  60. print dol_get_fiche_head($head, 'settings', '', -1, "zapier");
  61. if ($action == 'edit') {
  62. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
  63. print '<input type="hidden" name="token" value="'.newToken().'">';
  64. print '<input type="hidden" name="action" value="update">';
  65. print '<table class="noborder centpercent">';
  66. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  67. foreach ($arrayofparameters as $key => $val) {
  68. print '<tr class="oddeven"><td>';
  69. print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
  70. print '</td><td><input name="'.$key.'" class="flat '.(empty($val['css']) ? 'minwidth200' : $val['css']).'" value="'.getDolGlobalString($key).'"></td></tr>';
  71. }
  72. print '</table>';
  73. print '<br><div class="center">';
  74. print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
  75. print '</div>';
  76. print '</form>';
  77. print '<br>';
  78. } else {
  79. if (!empty($arrayofparameters)) {
  80. print '<table class="noborder centpercent">';
  81. print '<tr class="liste_titre"><td class="titlefield">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
  82. foreach ($arrayofparameters as $key => $val) {
  83. print '<tr class="oddeven"><td>';
  84. print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip'));
  85. print '</td><td>'.getDolGlobalString($key).'</td></tr>';
  86. }
  87. print '</table>';
  88. print '<div class="tabsAction">';
  89. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
  90. print '</div>';
  91. } else {
  92. // Setup page goes here
  93. echo '<br><br><span class="opacitymediumdisabled">'.$langs->trans("ZapierSetupPage").'</span><br><br>';
  94. //print '<br>'.$langs->trans("NothingToSetup");
  95. }
  96. }
  97. // Page end
  98. print dol_get_fiche_end();
  99. llxFooter();
  100. $db->close();