PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/admin/contract.php

https://github.com/asterix14/dolibarr
PHP | 192 lines | 119 code | 37 blank | 36 comment | 29 complexity | 7e2e286d3ab981b5bdffa157d13ddbd2 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /**
  18. * \file htdocs/admin/contract.php
  19. * \ingroup contract
  20. * \brief Setup page of module Contracts
  21. */
  22. require("../main.inc.php");
  23. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  24. require_once(DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php');
  25. $langs->load("admin");
  26. $langs->load("errors");
  27. if (!$user->admin) accessforbidden();
  28. $action = GETPOST("action");
  29. $value = GETPOST("value");
  30. if (empty($conf->global->CONTRACT_ADDON))
  31. {
  32. $conf->global->CONTRACT_ADDON='mod_contract_serpis';
  33. }
  34. /*
  35. * Actions
  36. */
  37. if ($action == 'updateMask')
  38. {
  39. $maskconst=$_POST['maskconstcontract'];
  40. $maskvalue=$_POST['maskcontract'];
  41. if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
  42. if (! $res > 0) $error++;
  43. if (! $error)
  44. {
  45. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  46. }
  47. else
  48. {
  49. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  50. }
  51. }
  52. if ($action == 'setmod')
  53. {
  54. dolibarr_set_const($db, "CONTRACT_ADDON",$value,'chaine',0,'',$conf->entity);
  55. }
  56. /*
  57. // constants of magre model
  58. if ($action == 'updateMatrice') dolibarr_set_const($db, "CONTRACT_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity);
  59. if ($action == 'updatePrefix') dolibarr_set_const($db, "CONTRACT_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity);
  60. if ($action == 'setOffset') dolibarr_set_const($db, "CONTRACT_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity);
  61. if ($action == 'setNumRestart') dolibarr_set_const($db, "CONTRACT_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity);
  62. */
  63. /*
  64. * View
  65. */
  66. llxHeader();
  67. $dir=DOL_DOCUMENT_ROOT."/core/modules/contract/";
  68. $form=new Form($db);
  69. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  70. print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup');
  71. print "<br>";
  72. print_titre($langs->trans("ContractsNumberingModules"));
  73. print '<table class="noborder" width="100%">';
  74. print '<tr class="liste_titre">';
  75. print '<td width="100">'.$langs->trans("Name").'</td>';
  76. print '<td>'.$langs->trans("Description").'</td>';
  77. print '<td>'.$langs->trans("Example").'</td>';
  78. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  79. print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
  80. print "</tr>\n";
  81. clearstatcache();
  82. $dir = "../core/modules/contract/";
  83. $handle = opendir($dir);
  84. if (is_resource($handle))
  85. {
  86. $var=true;
  87. while (($file = readdir($handle))!==false)
  88. {
  89. if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php')
  90. {
  91. $file = substr($file, 0, dol_strlen($file)-4);
  92. require_once(DOL_DOCUMENT_ROOT ."/core/modules/contract/".$file.".php");
  93. $module = new $file;
  94. // Show modules according to features level
  95. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
  96. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
  97. if ($module->isEnabled())
  98. {
  99. $var=!$var;
  100. print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
  101. print '<td>';
  102. print $module->info();
  103. print '</td>';
  104. // Show example of numbering module
  105. print '<td nowrap="nowrap">';
  106. $tmp=$module->getExample();
  107. if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>'; }
  108. elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
  109. else print $tmp;
  110. print '</td>'."\n";
  111. print '<td align="center">';
  112. if ($conf->global->CONTRACT_ADDON == "$file")
  113. {
  114. print img_picto($langs->trans("Activated"),'switch_on');
  115. }
  116. else
  117. {
  118. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
  119. print img_picto($langs->trans("Disabled"),'switch_off');
  120. print '</a>';
  121. }
  122. print '</td>';
  123. $contract=new Contrat($db);
  124. $contract->initAsSpecimen();
  125. // Info
  126. $htmltooltip='';
  127. $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  128. $facture->type=0;
  129. $nextval=$module->getNextValue($mysoc,$contract);
  130. if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
  131. {
  132. $htmltooltip.=''.$langs->trans("NextValue").': ';
  133. if ($nextval)
  134. {
  135. $htmltooltip.=$nextval.'<br>';
  136. }
  137. else
  138. {
  139. $htmltooltip.=$langs->trans($module->error).'<br>';
  140. }
  141. }
  142. print '<td align="center">';
  143. print $form->textwithpicto('',$htmltooltip,1,0);
  144. print '</td>';
  145. print '</tr>';
  146. }
  147. }
  148. }
  149. closedir($handle);
  150. }
  151. print '</table><br>';
  152. dol_htmloutput_mesg($mesg);
  153. $db->close();
  154. llxFooter();
  155. ?>