index.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <?php
  2. /* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
  3. * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
  4. * Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/cashdesk/index.php
  21. * \ingroup cashdesk
  22. * \brief File to login to point of sales
  23. */
  24. // Set and init common variables
  25. // This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects
  26. require_once '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
  28. // Load translation files required by the page
  29. $langs->loadLangs(array("admin","cashdesk"));
  30. // Test if user logged
  31. if ( $_SESSION['uid'] > 0 )
  32. {
  33. header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php');
  34. exit;
  35. }
  36. $usertxt=GETPOST('user','',1);
  37. $err=GETPOST("err");
  38. // Instantiate hooks of thirdparty module only if not already define
  39. $hookmanager->initHooks(array('cashdeskloginpage'));
  40. /*
  41. * View
  42. */
  43. $form=new Form($db);
  44. $formproduct=new FormProduct($db);
  45. $arrayofcss=array('/cashdesk/css/style.css');
  46. top_htmlhead('','',0,0,'',$arrayofcss);
  47. // Execute hook getLoginPageOptions (for table)
  48. $parameters=array('entity' => GETPOST('entity','int'));
  49. $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks.
  50. if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) {
  51. $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility
  52. } else {
  53. $morelogincontent = $hookmanager->resPrint;
  54. }
  55. ?>
  56. <body>
  57. <div class="conteneur">
  58. <div class="conteneur_img_gauche">
  59. <div class="conteneur_img_droite">
  60. <div class="menu_principal hideonsmartphone">
  61. <div class="logo">
  62. <?php
  63. if (! empty($mysoc->logo_small))
  64. {
  65. print '<img class="logopos" alt="Logo company" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
  66. }
  67. else
  68. {
  69. print '<div class="logopos">'.$mysoc->name.'</div>';
  70. }
  71. ?>
  72. </div>
  73. </div>
  74. <div class="contenu">
  75. <div class="inline-block" style="vertical-align: top">
  76. <div class="principal_login">
  77. <?php if ($err) print dol_escape_htmltag($err)."<br><br>\n"; ?>
  78. <fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Identification"); ?></legend>
  79. <form id="frmLogin" method="POST" action="index_verif.php">
  80. <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
  81. <table>
  82. <tr>
  83. <td class="label1"><?php echo $langs->trans("Login"); ?></td>
  84. <td><input name="txtUsername" class="texte_login" type="text" value="<?php echo $usertxt; ?>" /></td>
  85. </tr>
  86. <tr>
  87. <td class="label1"><?php echo $langs->trans("Password"); ?></td>
  88. <td><input name="pwdPassword" class="texte_login" type="password" value="" /></td>
  89. </tr>
  90. <?php
  91. if (! empty($morelogincontent)) {
  92. if (is_array($morelogincontent)) {
  93. foreach ($morelogincontent as $format => $option)
  94. {
  95. if ($format == 'table') {
  96. echo '<!-- Option by hook -->';
  97. echo $option;
  98. }
  99. }
  100. }
  101. else {
  102. echo '<!-- Option by hook -->';
  103. echo $morelogincontent;
  104. }
  105. }
  106. ?>
  107. <tr>
  108. <td colspan="2">
  109. &nbsp;
  110. </td>
  111. </tr>
  112. <?php
  113. print "<tr>";
  114. print '<td class="label1">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
  115. print '<td>';
  116. $disabled=0;
  117. $langs->load("companies");
  118. if (! empty($conf->global->CASHDESK_ID_THIRDPARTY)) $disabled=1; // If a particular third party is defined, we disable choice
  119. print $form->select_company(GETPOST('socid','int')?GETPOST('socid','int'):$conf->global->CASHDESK_ID_THIRDPARTY, 'socid', 's.client in (1,3) AND s.status = 1', !$disabled, $disabled, 1);
  120. //print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
  121. print '</td>';
  122. print "</tr>\n";
  123. if (! empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK))
  124. {
  125. $langs->load("stocks");
  126. print "<tr>";
  127. print '<td class="label1">'.$langs->trans("Warehouse").'</td>';
  128. print '<td>';
  129. $disabled=0;
  130. if ($conf->global->CASHDESK_ID_WAREHOUSE > 0) $disabled=1; // If a particular stock is defined, we disable choice
  131. print $formproduct->selectWarehouses((GETPOST('warehouseid')?GETPOST('warehouseid','int'):(empty($conf->global->CASHDESK_ID_WAREHOUSE)?'ifone':$conf->global->CASHDESK_ID_WAREHOUSE)),'warehouseid','',!$disabled,$disabled);
  132. print '</td>';
  133. print "</tr>\n";
  134. }
  135. print "<tr>";
  136. print '<td class="label1">'.$langs->trans("CashDeskBankAccountForSell").'</td>';
  137. print '<td>';
  138. $defaultknown=0;
  139. if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) $defaultknown=1; // If a particular stock is defined, we disable choice
  140. print $form->select_comptes(((GETPOST('bankid_cash') > 0)?GETPOST('bankid_cash'):$conf->global->CASHDESK_ID_BANKACCOUNT_CASH),'CASHDESK_ID_BANKACCOUNT_CASH',0,"courant=2",($defaultknown?0:2));
  141. print '</td>';
  142. print "</tr>\n";
  143. print "<tr>";
  144. print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
  145. print '<td>';
  146. $defaultknown=0;
  147. if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) $defaultknown=1; // If a particular stock is defined, we disable choice
  148. print $form->select_comptes(((GETPOST('bankid_cheque') > 0)?GETPOST('bankid_cheque'):$conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE),'CASHDESK_ID_BANKACCOUNT_CHEQUE',0,"courant=1",($defaultknown?0:2));
  149. print '</td>';
  150. print "</tr>\n";
  151. print "<tr>";
  152. print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCB").'</td>';
  153. print '<td>';
  154. $defaultknown=0;
  155. if (! empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) $defaultknown=1; // If a particular stock is defined, we disable choice
  156. print $form->select_comptes(((GETPOST('bankid_cb') > 0)?GETPOST('bankid_cb'):$conf->global->CASHDESK_ID_BANKACCOUNT_CB),'CASHDESK_ID_BANKACCOUNT_CB',0,"courant=1",($defaultknown?0:2));
  157. print '</td>';
  158. print "</tr>\n";
  159. ?>
  160. <tr>
  161. <td colspan="2">
  162. &nbsp;
  163. </td>
  164. </tr>
  165. </table>
  166. <br>
  167. <div align="center"><span class="bouton_login"><input class="button" name="sbmtConnexion" type="submit" value=<?php echo $langs->trans("Connection"); ?> /></span></div>
  168. </form>
  169. </fieldset>
  170. <?php
  171. if ($_GET['err'] < 0)
  172. {
  173. echo ('<script type="text/javascript">');
  174. echo (' document.getElementById(\'frmLogin\').pwdPassword.focus();');
  175. echo ('</script>');
  176. }
  177. else
  178. {
  179. echo ('<script type="text/javascript">');
  180. echo (' document.getElementById(\'frmLogin\').txtUsername.focus();');
  181. echo ('</script>');
  182. }
  183. ?>
  184. </div>
  185. </div>
  186. </div>
  187. <?php include 'affPied.php'; ?></div>
  188. </div>
  189. </div>
  190. </body>
  191. <?php
  192. print '</html>';