contract.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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."/lib/admin.lib.php");
  24. require_once(DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php');
  25. $langs->load("admin");
  26. $langs->load("bills");
  27. $langs->load("other");
  28. $langs->load("contracts");
  29. if (!$user->admin)
  30. accessforbidden();
  31. if (empty($conf->global->CONTRACT_ADDON))
  32. {
  33. $conf->global->CONTRACT_ADDON='mod_contract_serpis';
  34. }
  35. /*
  36. * Actions
  37. */
  38. if ($_POST["action"] == 'updateMask')
  39. {
  40. $maskconst=$_POST['maskconstcontract'];
  41. $maskvalue=$_POST['maskcontract'];
  42. if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
  43. }
  44. if ($_GET["action"] == 'setmod')
  45. {
  46. dolibarr_set_const($db, "CONTRACT_ADDON",$_GET["value"],'chaine',0,'',$conf->entity);
  47. }
  48. // constants of magre model
  49. if ($_POST["action"] == 'updateMatrice') dolibarr_set_const($db, "CONTRACT_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity);
  50. if ($_POST["action"] == 'updatePrefix') dolibarr_set_const($db, "CONTRACT_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity);
  51. if ($_POST["action"] == 'setOffset') dolibarr_set_const($db, "CONTRACT_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity);
  52. if ($_POST["action"] == 'setNumRestart') dolibarr_set_const($db, "CONTRACT_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity);
  53. /*
  54. * View
  55. */
  56. llxHeader();
  57. $dir=DOL_DOCUMENT_ROOT."/includes/modules/contract/";
  58. $html=new Form($db);
  59. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  60. print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup');
  61. print "<br>";
  62. print_titre($langs->trans("ContractsNumberingModules"));
  63. print '<table class="noborder" width="100%">';
  64. print '<tr class="liste_titre">';
  65. print '<td width="100">'.$langs->trans("Name").'</td>';
  66. print '<td>'.$langs->trans("Description").'</td>';
  67. print '<td>'.$langs->trans("Example").'</td>';
  68. print '<td align="center" width="60">'.$langs->trans("Status").'</td>';
  69. print '<td align="center" width="16">'.$langs->trans("Infos").'</td>';
  70. print "</tr>\n";
  71. clearstatcache();
  72. $dir = "../includes/modules/contract/";
  73. $handle = opendir($dir);
  74. if (is_resource($handle))
  75. {
  76. $var=true;
  77. while (($file = readdir($handle))!==false)
  78. {
  79. if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file)-3, 3) == 'php')
  80. {
  81. $file = substr($file, 0, dol_strlen($file)-4);
  82. require_once(DOL_DOCUMENT_ROOT ."/includes/modules/contract/".$file.".php");
  83. $module = new $file;
  84. // Show modules according to features level
  85. if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
  86. if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
  87. if ($module->isEnabled())
  88. {
  89. $var=!$var;
  90. print '<tr '.$bc[$var].'><td>'.$module->nom."</td>\n";
  91. print '<td>';
  92. print $module->info();
  93. print '</td>';
  94. // Show example of numbering module
  95. print '<td nowrap="nowrap">';
  96. $tmp=$module->getExample();
  97. if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp);
  98. else print $tmp;
  99. print '</td>'."\n";
  100. print '<td align="center">';
  101. if ($conf->global->CONTRACT_ADDON == "$file")
  102. {
  103. print img_picto($langs->trans("Activated"),'on');
  104. }
  105. else
  106. {
  107. print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
  108. print img_picto($langs->trans("Disabled"),'off');
  109. print '</a>';
  110. }
  111. print '</td>';
  112. $contract=new Contrat($db);
  113. $contract->initAsSpecimen();
  114. // Info
  115. $htmltooltip='';
  116. $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
  117. $facture->type=0;
  118. $nextval=$module->getNextValue($mysoc,$contract);
  119. if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
  120. {
  121. $htmltooltip.=''.$langs->trans("NextValue").': ';
  122. if ($nextval)
  123. {
  124. $htmltooltip.=$nextval.'<br>';
  125. }
  126. else
  127. {
  128. $htmltooltip.=$langs->trans($module->error).'<br>';
  129. }
  130. }
  131. print '<td align="center">';
  132. print $html->textwithpicto('',$htmltooltip,1,0);
  133. print '</td>';
  134. print '</tr>';
  135. }
  136. }
  137. }
  138. closedir($handle);
  139. }
  140. print '</table><br>';
  141. $db->close();
  142. llxFooter();
  143. ?>