granularity.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <?php
  2. /* Copyright (C) 2022 Regis Houssin <regis.houssin@inodbox.com>
  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 3 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, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18. /**
  19. * \file /multicompany/admin/granularity.php
  20. * \ingroup multicompany
  21. * \brief Management of sharings by element
  22. */
  23. $res=@include("../../main.inc.php"); // For root directory
  24. if (empty($res) && file_exists($_SERVER['DOCUMENT_ROOT']."/main.inc.php")) {
  25. $res=@include($_SERVER['DOCUMENT_ROOT']."/main.inc.php"); // Use on dev env only
  26. }
  27. if (empty($res)) {
  28. $res=@include("../../../main.inc.php"); // For "custom" directory
  29. }
  30. require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';
  31. dol_include_once('/multicompany/class/actions_multicompany.class.php', 'ActionsMulticompany');
  32. $langs->loadLangs(array('admin', 'multicompany@multicompany'));
  33. // Security check
  34. if (empty($conf->global->MULTICOMPANY_SHARING_BYELEMENT_ENABLED) || empty($user->admin) || !empty($user->entity)) {
  35. accessforbidden();
  36. }
  37. $action = GETPOST('action','alpha');
  38. $object = new ActionsMulticompany($db);
  39. /*
  40. * Action
  41. */
  42. /*
  43. * View
  44. */
  45. $extrajs = array(
  46. '/multicompany/core/js/lib_head.js'
  47. );
  48. $help_url='EN:Module_MultiCompany|FR:Module_MultiSoci&eacute;t&eacute;';
  49. llxHeader('', $langs->trans("MultiCompanySharingsByElementSetup"), $help_url,'','','',$extrajs);
  50. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  51. print load_fiche_titre($langs->trans("MultiCompanySetup"),$linkback,'multicompany@multicompany',0,'multicompany_title');
  52. $head = multicompany_prepare_head();
  53. dol_fiche_head($head, 'granularity', $langs->trans("ModuleSetup"), -1);
  54. $level = checkMultiCompanyVersion();
  55. if ($level === -1) { // shouldn't happen
  56. print '<div class="multicompany_checker">';
  57. dol_htmloutput_mesg($langs->trans("DolibarrIsOlderThanMulticompany"), '', 'warning', 1);
  58. print '</div>';
  59. }
  60. $form = new Form($db);
  61. print '<table class="noborder" width="100%">';
  62. print '<tr class="liste_titre">';
  63. print '<td>'.$langs->trans("Parameters").'</td>'."\n";
  64. print '<td align="center" width="20">&nbsp;</td>';
  65. $text = img_picto('', 'info','class="linkobject"');
  66. $htmltext = $langs->trans("ShareAllByDefaultInfo");
  67. print '<td align="center" width="200">'.$langs->trans("ShareAllByDefault").' '.$form->textwithtooltip('', $htmltext, 2, 1, $text).'</td>'."\n";
  68. print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
  69. print '</tr>';
  70. /*
  71. * System parameters
  72. */
  73. // Thirdparty granularity sharing
  74. print '<tr id="thirdpartygranularity" class="oddeven">';
  75. print '<td><span class="fa fa-building"></span><span class="multiselect-title">'.$langs->trans("EnableGranularityForThirdparties").'</span></td>';
  76. print '<td align="center" width="20">&nbsp;</td>';
  77. print '<td align="center" width="200">';
  78. print '<div id="thirdpartyshareallbydefault"'.(empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED) ? ' style="display:none;"' : '').'>';
  79. $input = array(
  80. 'hide' => array(
  81. 'del_MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT'
  82. ),
  83. 'hideshow' => array(
  84. 'set_MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT'
  85. ),
  86. 'del' => array(
  87. 'MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT'
  88. )
  89. );
  90. print ajax_mcconstantonoff('MULTICOMPANY_THIRDPARTY_SHARE_ALL_BY_DEFAULT', $input, 0);
  91. print '</div';
  92. print '</td>';
  93. print '<td align="center" width="100">';
  94. $input = array(
  95. 'showhide' => array(
  96. '#thirdpartyshareallbydefault',
  97. '#contactgranularity'
  98. ),
  99. 'hide' => array(
  100. '#contactshareallbydefault'
  101. ),
  102. 'set' => array(
  103. 'MULTICOMPANY_THIRDPARTY_SHARING_ENABLED'
  104. ),
  105. 'del' => array(
  106. 'MULTICOMPANY_THIRDPARTY_SHARE_ALL_BY_DEFAULT',
  107. 'MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED',
  108. 'MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT'
  109. )
  110. );
  111. print ajax_mcconstantonoff('MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED', $input, 0);
  112. print '</td></tr>';
  113. // Contact granularity sharing
  114. print '<tr id="contactgranularity" class="oddeven"'.(empty($conf->global->MULTICOMPANY_THIRDPARTY_SHARING_BYELEMENT_ENABLED) ? ' style="display:none;"' : '').'>';
  115. print '<td><span class="fa fa-users"></span><span class="multiselect-title">'.$langs->trans("EnableGranularityForContacts").'</span></td>';
  116. print '<td align="center" width="20">&nbsp;</td>';
  117. print '<td align="center" width="200">';
  118. print '<div id="contactshareallbydefault"'.(empty($conf->global->MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED) ? ' style="display:none;"' : '').'>';
  119. $input = array(
  120. 'show' => array(
  121. 'del_MULTICOMPANY_THIRDPARTY_SHARE_ALL_BY_DEFAULT'
  122. ),
  123. 'hideshow' => array(
  124. 'set_MULTICOMPANY_THIRDPARTY_SHARE_ALL_BY_DEFAULT'
  125. ),
  126. 'set' => array(
  127. 'MULTICOMPANY_THIRDPARTY_SHARE_ALL_BY_DEFAULT'
  128. )
  129. );
  130. print ajax_mcconstantonoff('MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT', $input, 0);
  131. print '</div';
  132. print '</td>';
  133. print '<td align="center" width="100">';
  134. $input = array(
  135. 'showhide' => array(
  136. '#contactshareallbydefault'
  137. ),
  138. 'del' => array(
  139. 'MULTICOMPANY_CONTACT_SHARE_ALL_BY_DEFAULT'
  140. )
  141. );
  142. print ajax_mcconstantonoff('MULTICOMPANY_CONTACT_SHARING_BYELEMENT_ENABLED', $input, 0);
  143. print '</td></tr>';
  144. // Product/Service granularity sharing
  145. print '<tr id="productgranularity" class="oddeven">';
  146. print '<td><span class="fa fa-cube"></span><span class="multiselect-title">'.$langs->trans("EnableGranularityForProducts").'</span></td>';
  147. print '<td align="center" width="20">&nbsp;</td>';
  148. print '<td align="center" width="200">';
  149. print '<div id="productshareallbydefault"'.(empty($conf->global->MULTICOMPANY_PRODUCT_SHARING_BYELEMENT_ENABLED) ? ' style="display:none;"' : '').'>';
  150. print ajax_mcconstantonoff('MULTICOMPANY_PRODUCT_SHARE_ALL_BY_DEFAULT', '', 0);
  151. print '</div';
  152. print '</td>';
  153. print '<td align="center" width="100">';
  154. $input = array(
  155. 'showhide' => array(
  156. '#productshareallbydefault'
  157. ),
  158. 'set' => array(
  159. 'MULTICOMPANY_PRODUCT_SHARING_ENABLED'
  160. ),
  161. 'del' => array(
  162. 'MULTICOMPANY_PRODUCT_SHARE_ALL_BY_DEFAULT'
  163. )
  164. );
  165. print ajax_mcconstantonoff('MULTICOMPANY_PRODUCT_SHARING_BYELEMENT_ENABLED', $input, 0);
  166. print '</td></tr>';
  167. // Category granularity sharing
  168. /*print '<tr id="categorygranularity" class="oddeven">';
  169. print '<td><span class="fa fa-users"></span><span class="multiselect-title">'.$langs->trans("EnableGranularityForCategories").'</span></td>';
  170. print '<td align="center" width="20">&nbsp;</td>';
  171. print '<td align="center" width="200">';
  172. print '<div id="categoryshareallbydefault"'.(empty($conf->global->MULTICOMPANY_CATEGORY_SHARING_BYELEMENT_ENABLED) ? ' style="display:none;"' : '').'>';
  173. print ajax_mcconstantonoff('MULTICOMPANY_CATEGORY_SHARE_ALL_BY_DEFAULT', '', 0);
  174. print '</div';
  175. print '</td>';
  176. print '<td align="center" width="100">';
  177. $input = array(
  178. 'showhide' => array(
  179. '#categoryshareallbydefault'
  180. ),
  181. 'set' => array(
  182. 'MULTICOMPANY_CATEGORY_SHARING_ENABLED'
  183. ),
  184. 'del' => array(
  185. 'MULTICOMPANY_CATEGORY_SHARE_ALL_BY_DEFAULT'
  186. )
  187. );
  188. print ajax_mcconstantonoff('MULTICOMPANY_CATEGORY_SHARING_BYELEMENT_ENABLED', $input, 0);
  189. print '</td></tr>';*/
  190. print '</table>';
  191. // Card end
  192. dol_fiche_end();
  193. // Footer
  194. llxFooter();
  195. // Close database handler
  196. $db->close();