29 include
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/cashdesk/include/environnement.php';
31 require_once DOL_DOCUMENT_ROOT.
'/cashdesk/class/Auth.class.php';
34 $langs->loadLangs(array(
"main",
"admin",
"cashdesk"));
36 $username =
GETPOST(
"txtUsername");
37 $password =
GETPOST(
"pwdPassword");
38 $thirdpartyid = (
GETPOST(
'socid',
'int') > 0) ?
GETPOST(
'socid',
'int') : $conf->global->CASHDESK_ID_THIRDPARTY;
39 $warehouseid = (
GETPOST(
"warehouseid") > 0) ?
GETPOST(
"warehouseid",
'int') : $conf->global->CASHDESK_ID_WAREHOUSE;
40 $bankid_cash = (
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CASH") > 0) ?
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CASH",
'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
41 $bankid_cheque = (
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0) ?
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CHEQUE",
'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
42 $bankid_cb = (
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CB") > 0) ?
GETPOST(
"CASHDESK_ID_BANKACCOUNT_CB",
'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB;
47 $retour = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Login"));
48 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/index.php?err='.urlencode($retour).
'&user='.$username.
'&socid='.$thirdpartyid.
'&warehouseid='.$warehouseid.
'&bankid_cash='.$bankid_cash.
'&bankid_cheque='.$bankid_cheque.
'&bankid_cb='.$bankid_cb);
52 if (!($thirdpartyid > 0))
54 $retour = $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"CashDeskThirdPartyForSell"));
55 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/index.php?err='.urlencode($retour).
'&user='.$username.
'&socid='.$thirdpartyid.
'&warehouseid='.$warehouseid.
'&bankid_cash='.$bankid_cash.
'&bankid_cheque='.$bankid_cheque.
'&bankid_cb='.$bankid_cb);
60 if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0))
62 $retour = $langs->trans(
"CashDeskYouDidNotDisableStockDecease");
63 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/index.php?err='.urlencode($retour).
'&user='.$username.
'&socid='.$thirdpartyid.
'&warehouseid='.$warehouseid.
'&bankid_cash='.$bankid_cash.
'&bankid_cheque='.$bankid_cheque.
'&bankid_cb='.$bankid_cb);
68 if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username))
70 $testuser =
new User($db);
71 $testuser->fetch(0, $username);
72 $testuser->getrights(
'stock');
73 if (empty($testuser->rights->stock->creer))
75 $retour = $langs->trans(
"UserNeedPermissionToEditStockToUsePos");
76 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/index.php?err='.urlencode($retour).
'&user='.$username.
'&socid='.$thirdpartyid.
'&warehouseid='.$warehouseid.
'&bankid_cash='.$bankid_cash.
'&bankid_cheque='.$bankid_cheque.
'&bankid_cb='.$bankid_cb);
83 $auth =
new Auth($db);
84 $retour = $auth->verif($username, $password);
90 $sql =
"SELECT rowid, lastname, firstname";
91 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user";
92 $sql .=
" WHERE login = '".$db->escape($username).
"'";
93 $sql .=
" AND entity IN (0,".$conf->entity.
")";
95 $result = $db->query($sql);
98 $tab = $db->fetch_array($res);
100 foreach ($tab as $key => $value)
102 $return[$key] = $value;
105 $_SESSION[
'uid'] = $tab[
'rowid'];
106 $_SESSION[
'uname'] = $username;
107 $_SESSION[
'lastname'] = $tab[
'lastname'];
108 $_SESSION[
'firstname'] = $tab[
'firstname'];
109 $_SESSION[
'CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid :
'');
110 $_SESSION[
'CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid :
'');
112 $_SESSION[
'CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash :
'');
113 $_SESSION[
'CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque :
'');
114 $_SESSION[
'CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb :
'');
117 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV');
124 $langs->loadLangs(array(
"other",
"errors"));
125 $retour = $langs->trans(
"ErrorBadLoginPassword");
126 header(
'Location: '.DOL_URL_ROOT.
'/cashdesk/index.php?err='.urlencode($retour).
'&user='.$username.
'&socid='.$thirdpartyid.
'&warehouseid='.$warehouseid);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class ot manage authentication for pos module (cashdesk)
Class to manage Dolibarr users.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...