taxes.php 6.1 KB

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