taxes.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. if (! empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
  29. $langs->load('admin');
  30. if (!$user->admin) accessforbidden();
  31. $action = GETPOST('action','alpha');
  32. // Other parameters ACCOUNTING_*
  33. $list = array (
  34. 'ACCOUNTING_VAT_PAY_ACCOUNT'
  35. );
  36. /*
  37. * Actions
  38. */
  39. // 0=normal, 1=option vat for services is on debit
  40. // TAX_MODE=0 (most cases):
  41. // Buy Sell
  42. // Product On delivery On delivery
  43. // Service On payment On payment
  44. // TAX_MODE=1 (option):
  45. // Buy Sell
  46. // Product On delivery On delivery
  47. // Service On invoice On invoice
  48. $tax_mode = empty($conf->global->TAX_MODE)?0:$conf->global->TAX_MODE;
  49. if ($action == 'update') {
  50. $error = 0;
  51. // Tax mode
  52. $tax_mode = GETPOST('tax_mode','alpha');
  53. $db->begin();
  54. $res = dolibarr_set_const($db, 'TAX_MODE', $tax_mode,'chaine',0,'',$conf->entity);
  55. if (! $res > 0) $error++;
  56. switch ($tax_mode)
  57. {
  58. case 0:
  59. $value = 'payment';
  60. break;
  61. case 1:
  62. $value = 'invoice';
  63. break;
  64. }
  65. $res = dolibarr_set_const($db, 'TAX_MODE_SELL_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
  66. if (! $res > 0) $error++;
  67. $res = dolibarr_set_const($db, 'TAX_MODE_BUY_PRODUCT', 'invoice','chaine',0,'',$conf->entity);
  68. if (! $res > 0) $error++;
  69. $res = dolibarr_set_const($db, 'TAX_MODE_SELL_SERVICE', $value,'chaine',0,'',$conf->entity);
  70. if (! $res > 0) $error++;
  71. $res = dolibarr_set_const($db, 'TAX_MODE_BUY_SERVICE', $value,'chaine',0,'',$conf->entity);
  72. if (! $res > 0) $error++;
  73. // Others options
  74. foreach ($list as $constname) {
  75. $constvalue = GETPOST($constname, 'alpha');
  76. if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
  77. $error++;
  78. }
  79. }
  80. if (! $error) {
  81. $db->commit();
  82. setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
  83. } else {
  84. $db->rollback();
  85. setEventMessages($langs->trans("Error"), null, 'errors');
  86. }
  87. }
  88. /*
  89. * View
  90. */
  91. llxHeader();
  92. $form=new Form($db);
  93. if (! empty($conf->accounting->enabled)) $formaccounting = New FormAccounting($db);
  94. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  95. print load_fiche_titre($langs->trans('TaxSetup'),$linkback,'title_setup');
  96. dol_fiche_head();
  97. if (empty($mysoc->tva_assuj))
  98. {
  99. print $langs->trans("YourCompanyDoesNotUseVAT").'<br>';
  100. }
  101. else
  102. {
  103. print '<table class="noborder" width="100%">';
  104. // Cas des parametres TAX_MODE_SELL/BUY_SERVICE/PRODUCT
  105. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  106. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  107. print '<input type="hidden" name="action" value="update">';
  108. print '<tr class="liste_titre">';
  109. print '<td colspan="2">'.$langs->trans('OptionVatMode').'</td><td>'.$langs->trans('Description').'</td>';
  110. print "</tr>\n";
  111. print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="0"'.($tax_mode != 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDefault').'</td>';
  112. print '<td colspan="2">'.nl2br($langs->trans('OptionVatDefaultDesc'));
  113. print "</td></tr>\n";
  114. print '<tr class="oddeven"><td width="200"><input type="radio" name="tax_mode" value="1"'.($tax_mode == 1 ? ' checked' : '').'> '.$langs->trans('OptionVATDebitOption').'</td>';
  115. print '<td colspan="2">'.nl2br($langs->trans('OptionVatDebitOptionDesc'))."</td></tr>\n";
  116. print "</table>\n";
  117. print '<br>';
  118. print load_fiche_titre($langs->trans("SummaryOfVatExigibilityUsedByDefault"),'','');
  119. //print ' ('.$langs->trans("CanBeChangedWhenMakingInvoice").')';
  120. print '<table class="noborder" width="100%">';
  121. print '<tr class="liste_titre"><td>&nbsp;</td><td>'.$langs->trans("Buy").'</td><td>'.$langs->trans("Sell").'</td></tr>';
  122. // Products
  123. print '<tr class="oddeven"><td>'.$langs->trans("Product").'</td>';
  124. print '<td>';
  125. print $langs->trans("OnDelivery");
  126. print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
  127. print '</td>';
  128. print '<td>';
  129. print $langs->trans("OnDelivery");
  130. print ' ('.$langs->trans("SupposedToBeInvoiceDate").')';
  131. print '</td></tr>';
  132. // Services
  133. print '<tr class="oddeven"><td>'.$langs->trans("Services").'</td>';
  134. print '<td>';
  135. if ($tax_mode == 0)
  136. {
  137. print $langs->trans("OnPayment");
  138. print ' ('.$langs->trans("SupposedToBePaymentDate").')';
  139. }
  140. if ($tax_mode == 1)
  141. {
  142. print $langs->trans("OnInvoice");
  143. print ' ('.$langs->trans("InvoiceDateUsed").')';
  144. }
  145. print '</td>';
  146. print '<td>';
  147. if ($tax_mode == 0)
  148. {
  149. print $langs->trans("OnPayment");
  150. print ' ('.$langs->trans("SupposedToBePaymentDate").')';
  151. }
  152. if ($tax_mode == 1)
  153. {
  154. print $langs->trans("OnInvoice");
  155. print ' ('.$langs->trans("InvoiceDateUsed").')';
  156. }
  157. print '</td></tr>';
  158. print '</table>';
  159. }
  160. print "<br>\n";
  161. /*
  162. * Others params
  163. */
  164. print '<table class="noborder" width="100%">';
  165. print '<tr class="liste_titre">';
  166. print '<td colspan="3">' . $langs->trans('OtherOptions') . '</td>';
  167. print "</tr>\n";
  168. foreach ($list as $key)
  169. {
  170. print '<tr class="oddeven value">';
  171. // Param
  172. $label = $langs->trans($key);
  173. print '<td><label for="'.$key.'">'.$label.'</label></td>';
  174. // Value
  175. print '<td>';
  176. if (! empty($conf->accounting->enabled))
  177. {
  178. print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1);
  179. }
  180. else
  181. {
  182. print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
  183. }
  184. print '</td></tr>';
  185. }
  186. print '</table>';
  187. dol_fiche_end();
  188. print '<div class="center">';
  189. print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '" name="button">';
  190. print '</div>';
  191. print '</form>';
  192. llxFooter();
  193. $db->close();