taxes.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
  6. * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/admin/taxes.php
  23. * \ingroup tax
  24. * \brief Page de configuration du module tax
  25. */
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  28. $langs->load('admin');
  29. if (!$user->admin) accessforbidden();
  30. $action = GETPOST('action','alpha');
  31. // Other parameters ACCOUNTING_*
  32. $list = array (
  33. 'ACCOUNTING_VAT_PAY_ACCOUNT'
  34. );
  35. /*
  36. * Actions
  37. */
  38. // 0=normal, 1=option vat for services is on debit
  39. // TAX_MODE=0 (most cases):
  40. // Buy Sell
  41. // Product On delivery On delivery
  42. // Service On payment On payment
  43. // TAX_MODE=1 (option):
  44. // Buy Sell
  45. // Product On delivery On delivery
  46. // Service On invoice On invoice
  47. $tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE;
  48. if ($action == 'update') {
  49. $error = 0;
  50. // Tax mode
  51. $tax_mode = GETPOST('tax_mode','alpha');
  52. $db->begin();
  53. $res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode,'chaine',0,'',$conf->entity);
  54. if (! $res > 0) $error++;
  55. switch ($tax_mode)
  56. {
  57. case 0:
  58. $value = 'payment';
  59. break;
  60. case 1:
  61. $value = 'invoice';
  62. break;
  63. }
  64. $res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
  65. if (! $res > 0) $error++;
  66. $res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
  67. if (! $res > 0) $error++;
  68. $res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $value,'chaine',0,'',$conf->entity);
  69. if (! $res > 0) $error++;
  70. $res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
  71. if (! $res > 0) $error++;
  72. // Others options
  73. foreach ($list as $constname) {
  74. $constvalue = GETPOST($constname, 'alpha');
  75. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  76. $error++;
  77. }
  78. }
  79. if (! $error) {
  80. $db->commit();
  81. setEventMessage($langs->trans("SetupSaved"));
  82. } else {
  83. $db->rollback();
  84. setEventMessage($langs->trans("Error"),'errors');
  85. }
  86. }
  87. /*
  88. * View
  89. */
  90. llxHeader();
  91. $form=new Form($db);
  92. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  93. print_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
  94. dol_fiche_head();
  95. if (empty($mysoc->tva_assuj))
  96. {
  97. print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
  98. }
  99. else
  100. {
  101. print '<table class="noborder" width="100%">';
  102. // Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
  103. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  104. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  105. print '<input type="hidden" name="action" value="update">';
  106. print '<tr class="liste_titre">';
  107. print '<td colspan="2">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
  108. print "</tr>\n";
  109. print '<tr '.$bc[false].'><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
  110. print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
  111. print "</td></tr>\n";
  112. print '<tr '.$bc[true].'><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
  113. print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
  114. print "</table>\n";
  115. print '<br>';
  116. print_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
  117. //print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
  118. print '<table class="noborder" width="100%">';
  119. print '<tr class="liste_titre"><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
  120. // Products
  121. print '<tr '.$bc[false].'><td>'.$langs->trans("Product").'</td>';
  122. print '<td>';
  123. print $langs->trans("OnDelivery");
  124. print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
  125. print '</td>';
  126. print '<td>';
  127. print $langs->trans("OnDelivery");
  128. print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
  129. print '</td></tr>';
  130. // Services
  131. print '<tr '.$bc[true].'><td>'.$langs->trans("Services").'</td>';
  132. print '<td>';
  133. if ($tax_mode == 0)
  134. {
  135. print $langs->trans("OnPayment");
  136. print ' ('.$langs->trans("SupposedToBePaymentDate").')';
  137. }
  138. if ($tax_mode == 1)
  139. {
  140. print $langs->trans("OnInvoice");
  141. print ' ('.$langs->trans("InvoiceDateUsed").')';
  142. }
  143. print '</td>';
  144. print '<td>';
  145. if ($tax_mode == 0)
  146. {
  147. print $langs->trans("OnPayment");
  148. print ' ('.$langs->trans("SupposedToBePaymentDate").')';
  149. }
  150. if ($tax_mode == 1)
  151. {
  152. print $langs->trans("OnInvoice");
  153. print ' ('.$langs->trans("InvoiceDateUsed").')';
  154. }
  155. print '</td></tr>';
  156. print '</table>';
  157. }
  158. print "<br>\n";
  159. /*
  160. * Others params
  161. */
  162. print '<table class="noborder" width="100%">';
  163. print '<tr class="liste_titre">';
  164. print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
  165. print "</tr>\n";
  166. foreach ($list as $key)
  167. {
  168. $var=!$var;
  169. print '<tr '.$bc[$var].' class="value">';
  170. // Param
  171. $label = $langs->trans($key);
  172. print '<td><label for="'.$key.'">'.$label.'</label></td>';
  173. // Value
  174. print '<td>';
  175. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
  176. print '</td></tr>';
  177. }
  178. print '</table>';
  179. dol_fiche_end();
  180. print '<div class="center">';
  181. print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="button">';
  182. print '</div>';
  183. print '</form>';
  184. $db->close();
  185. llxFooter();