facture_situation.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. // Load Dolibarr environment
  29. require '../main.inc.php';
  30. // Libraries
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  32. require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
  33. require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php';
  35. // Load translation files required by the page
  36. $langs->loadLangs(array('admin', 'errors', 'other', 'bills'));
  37. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  38. $hookmanager->initHooks(array('situationinvoicesetup', 'globalsetup'));
  39. // Access control
  40. if (!$user->admin) {
  41. accessforbidden();
  42. }
  43. $action = GETPOST('action', 'aZ09');
  44. $backtopage = GETPOST('backtopage', 'alpha');
  45. $value = GETPOST('value', 'alpha');
  46. $label = GETPOST('label', 'alpha');
  47. $modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
  48. $scandir = GETPOST('scan_dir', 'alpha');
  49. $type = 'invoice';
  50. $form = new Form($db);
  51. $formSetup = new FormSetup($db);
  52. // Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style
  53. $formSetup->newItem('INVOICE_USE_SITUATION')
  54. ->setAsYesNo()
  55. ->nameText = $langs->trans('UseSituationInvoices');
  56. $item = $formSetup->newItem('INVOICE_USE_SITUATION_CREDIT_NOTE')
  57. ->setAsYesNo()
  58. ->nameText = $langs->trans('UseSituationInvoicesCreditNote');
  59. //$item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY')
  60. // ->setAsYesNo()
  61. // ->nameText = $langs->trans('Retainedwarranty');
  62. $item = $formSetup->newItem('INVOICE_USE_RETAINED_WARRANTY');
  63. $item->nameText = $langs->trans('AllowedInvoiceForRetainedWarranty');
  64. $arrayAvailableType = array(
  65. Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
  66. Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
  67. );
  68. if ($action == 'edit') {
  69. $item->fieldInputOverride = $form->selectarray('INVOICE_USE_RETAINED_WARRANTY', $arrayAvailableType, $conf->global->INVOICE_USE_RETAINED_WARRANTY, 1);
  70. } else {
  71. $item->fieldOutputOverride= isset($arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY])?$arrayAvailableType[$conf->global->INVOICE_USE_RETAINED_WARRANTY]:'';
  72. }
  73. //$item = $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_SITUATION')->setAsYesNo();
  74. //$item->nameText = $langs->trans('RetainedwarrantyOnlyForSituation');
  75. $formSetup->newItem('INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION')
  76. ->setAsYesNo()
  77. ->nameText = $langs->trans('RetainedwarrantyOnlyForSituationFinal');
  78. $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_PERCENT');
  79. $item->nameText = $langs->trans('RetainedwarrantyDefaultPercent');
  80. $item->fieldAttr = array(
  81. 'type' => 'number',
  82. 'step' => '0.01',
  83. 'min' => 0,
  84. 'max' => 100
  85. );
  86. // Conditions paiements
  87. $item = $formSetup->newItem('INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID');
  88. $item->nameText = $langs->trans('PaymentConditionsShortRetainedWarranty');
  89. $form->load_cache_conditions_paiements();
  90. 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'])) {
  91. $item->fieldOutputOverride = $form->cache_conditions_paiements[$conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID]['label'];
  92. }
  93. $item->fieldInputOverride = $form->getSelectConditionsPaiements($conf->global->INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID, 'INVOICE_SITUATION_DEFAULT_RETAINED_WARRANTY_COND_ID', -1, 1);
  94. /*
  95. * Actions
  96. */
  97. include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
  98. /*
  99. * View
  100. */
  101. $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
  102. $help_yrl = 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura';
  103. llxHeader("", $langs->trans("BillsSetup"), $help_url);
  104. $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
  105. print load_fiche_titre($langs->trans("BillsSetup"), $linkback, 'title_setup');
  106. $head = invoice_admin_prepare_head();
  107. print dol_get_fiche_head($head, 'situation', $langs->trans("InvoiceSituation"), -1, 'invoice');
  108. print '<span class="opacitymedium">'.$langs->trans("InvoiceFirstSituationDesc").'</span><br><br>';
  109. /*
  110. * Numbering module
  111. */
  112. if ($action == 'edit') {
  113. print $formSetup->generateOutput(true);
  114. } else {
  115. print $formSetup->generateOutput();
  116. }
  117. if (count($formSetup->items) > 0) {
  118. if ($action != 'edit') {
  119. print '<div class="tabsAction">';
  120. print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'">'.$langs->trans("Modify").'</a>';
  121. print '</div>';
  122. }
  123. } else {
  124. print '<br>'.$langs->trans("NothingToSetup");
  125. }
  126. print dol_get_fiche_end();
  127. // End of page
  128. llxFooter();
  129. $db->close();