facture_situation.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?php
  2. /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
  5. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  6. * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
  7. * Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  22. */
  23. /**
  24. * \file htdocs/admin/facture.php
  25. * \ingroup facture
  26. * \brief Page to setup invoice module
  27. */
  28. require '../main.inc.php';
  29. // Libraries
  30. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  33. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
  34. // Load translation files required by the page
  35. $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
  36. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  37. $hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
  38. // Access control
  39. if (!$user->admin) {
  40. accessforbidden();
  41. }
  42. $action = GETPOST('action', 'aZ09');
  43. $backtopage = GETPOST('backtopage', 'alpha');
  44. $value = GETPOST('value', 'alpha');
  45. $label = GETPOST('label', 'alpha');
  46. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  47. $scandir = GETPOST('scan_dir', 'alpha');
  48. $type = 'invoice';
  49. $form = new Form($db);
  50. $formSetup = new FormSetup($db);
  51. // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style
  52. $formSetup->newItem('INVOICE_USE_SITUATION')
  53. ->setAsYesNo()
  54. ->nameText = $langs->trans('UseSituationInvoices');
  55. $item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
  56. ->setAsYesNo()
  57. ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
  58. //$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
  59. // ->setAsYesNo()
  60. // ->nameText = $langs->trans('Retainedwarranty');
  61. $item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
  62. $item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
  63. $arrayAvailableType = array(
  64. Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
  65. Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
  66. );
  67. if ($action == 'edit') {
  68. $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
  69. } else {
  70. $item->fieldOutputOverride= isset($arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY])?$arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY]:'';
  71. }
  72. //$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
  73. //$item->nameText = $langs->trans('RetainedwarrantyOnlyForSituation');
  74. $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
  75. ->setAsYesNo()
  76. ->nameText = $langs->trans('RetainedwarrantyOnlyForSituationFinal');
  77. $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
  78. $item->nameText = $langs->trans('RetainedwarrantyDefaultPercent');
  79. $item->fieldAttr = array(
  80. 'type' => 'number',
  81. 'step' => '0.01',
  82. 'min' => 0,
  83. 'max' => 100
  84. );
  85. // Conditions paiements
  86. $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
  87. $item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
  88. $form->load_cache_conditions_paiements();
  89. if (!empty($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID) && isset($form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'])) {
  90. $item->fieldOutputOverride = $form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'];
  91. }
  92. $item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
  93. /*
  94. * Actions
  95. */
  96. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  97. /*
  98. * View
  99. */
  100. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  101. llxHeader(
  102. "",
  103. $langs->trans("BillsSetup"),
  104. 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura'
  105. );
  106. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  107. print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
  108. $head = invoice_admin_prepare_head();
  109. print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
  110. print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
  111. /*
  112. * Numbering module
  113. */
  114. if ($action == 'edit') {
  115. print $formSetup->generateOutput(true);
  116. } else {
  117. print $formSetup->generateOutput();
  118. }
  119. if (count($formSetup->items) > 0) {
  120. if ($action != 'edit') {
  121. print '<div class="tabsAction">';
  122. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
  123. print '</div>';
  124. }
  125. } else {
  126. print '<br>'.$langs->trans("NothingToSetup");
  127. }
  128. print dol_get_fiche_end();
  129. // End of page
  130. llxFooter();
  131. $db->close();