PageRenderTime 62ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/cashdesk/admin/cashdesk.php

https://github.com/asterix14/dolibarr
PHP | 160 lines | 99 code | 29 blank | 32 comment | 10 complexity | f419e5855554e11aedd0e70993486ce6 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/cashdesk/admin/cashdesk.php
  20. * \ingroup cashdesk
  21. * \brief Setup page for cashdesk module
  22. */
  23. require("../../main.inc.php");
  24. require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
  25. require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
  26. // If socid provided by ajax company selector
  27. if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id']))
  28. {
  29. $_GET['CASHDESK_ID_THIRDPARTY'] = $_GET['CASHDESK_ID_THIRDPARTY_id'];
  30. $_POST['CASHDESK_ID_THIRDPARTY'] = $_POST['CASHDESK_ID_THIRDPARTY_id'];
  31. $_REQUEST['CASHDESK_ID_THIRDPARTY'] = $_REQUEST['CASHDESK_ID_THIRDPARTY_id'];
  32. }
  33. // Security check
  34. if (!$user->admin)
  35. accessforbidden();
  36. $langs->load("admin");
  37. $langs->load("cashdesk");
  38. /*
  39. * Actions
  40. */
  41. if (GETPOST("action") == 'set')
  42. {
  43. $db->begin();
  44. if (GETPOST("socid") < 0) $_POST["socid"]='';
  45. /*if (GETPOST("CASHDESK_ID_BANKACCOUNT") < 0) $_POST["CASHDESK_ID_BANKACCOUNT"]='';
  46. if (GETPOST("CASHDESK_ID_WAREHOUSE") < 0) $_POST["CASHDESK_ID_WAREHOUSE"]='';*/
  47. $res = dolibarr_set_const($db,"CASHDESK_ID_THIRDPARTY",GETPOST("socid"),'chaine',0,'',$conf->entity);
  48. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CASH",GETPOST("CASHDESK_ID_BANKACCOUNT_CASH"),'chaine',0,'',$conf->entity);
  49. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CHEQUE",GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE"),'chaine',0,'',$conf->entity);
  50. $res = dolibarr_set_const($db,"CASHDESK_ID_BANKACCOUNT_CB",GETPOST("CASHDESK_ID_BANKACCOUNT_CB"),'chaine',0,'',$conf->entity);
  51. $res = dolibarr_set_const($db,"CASHDESK_ID_WAREHOUSE",GETPOST("CASHDESK_ID_WAREHOUSE"),'chaine',0,'',$conf->entity);
  52. $res = dolibarr_set_const($db,"CASHDESK_SERVICES", GETPOST("CASHDESK_SERVICES"),'chaine',0,'',$conf->entity);
  53. dol_syslog("admin/cashdesk: level ".GETPOST("level"));
  54. if (! $res > 0) $error++;
  55. if (! $error)
  56. {
  57. $db->commit();
  58. $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
  59. }
  60. else
  61. {
  62. $db->rollback();
  63. $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
  64. }
  65. }
  66. /*
  67. * View
  68. */
  69. $form=new Form($db);
  70. $formproduct=new FormProduct($db);
  71. llxHeader('',$langs->trans("CashDeskSetup"));
  72. $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
  73. print_fiche_titre($langs->trans("CashDeskSetup"),$linkback,'setup');
  74. print '<br>';
  75. // Mode
  76. $var=true;
  77. print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
  78. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  79. print '<input type="hidden" name="action" value="set">';
  80. print '<table class="noborder" width="100%">';
  81. print '<tr class="liste_titre">';
  82. print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
  83. print "</tr>\n";
  84. $var=!$var;
  85. print '<tr '.$bc[$var].'><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
  86. print '<td colspan="2">';
  87. print $form->select_societes($conf->global->CASHDESK_ID_THIRDPARTY,'socid','s.client in (1,3)',1,1);
  88. print '</td></tr>';
  89. if ($conf->banque->enabled)
  90. {
  91. $var=!$var;
  92. print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
  93. print '<td colspan="2">';
  94. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH,'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",1);
  95. print '</td></tr>';
  96. $var=!$var;
  97. print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
  98. print '<td colspan="2">';
  99. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE,'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",1);
  100. print '</td></tr>';
  101. $var=!$var;
  102. print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
  103. print '<td colspan="2">';
  104. $form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB,'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",1);
  105. print '</td></tr>';
  106. }
  107. if ($conf->stock->enabled)
  108. {
  109. $var=!$var;
  110. print '<tr '.$bc[$var].'><td>'.$langs->trans("CashDeskIdWareHouse").'</td>';
  111. print '<td colspan="2">';
  112. print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE,'CASHDESK_ID_WAREHOUSE','',1);
  113. print '</td></tr>';
  114. }
  115. if ($conf->service->enabled)
  116. {
  117. $var=! $var;
  118. print '<tr '.$bc[$var].'><td>';
  119. print $langs->trans("CashdeskShowServices");
  120. print '<td colspan="2">';;
  121. print $form->selectyesno("CASHDESK_SERVICES",$conf->global->CASHDESK_SERVICES,1);
  122. print "</td></tr>\n";
  123. }
  124. print '</table>';
  125. print '<br>';
  126. print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
  127. print "</form>\n";
  128. dol_htmloutput_mesg($mesg);
  129. $db->close();
  130. llxFooter();
  131. ?>