Only check takepos configuration if a terminal is choosen, to prevent error message

This commit is contained in:
Laurent Dinclaux 2021-09-07 22:31:09 +11:00
parent 02f21d478a
commit a39f469a50

View File

@ -978,36 +978,39 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
<?php <?php
// TakePOS setup check // TakePOS setup check
$sql = "SELECT code, libelle FROM ".MAIN_DB_PREFIX."c_paiement"; if ( isset( $_SESSION["takeposterminal"] ) && $_SESSION["takeposterminal"] ) {
$sql .= " WHERE entity IN (".getEntity('c_paiement').")"; $sql = "SELECT code, libelle FROM " . MAIN_DB_PREFIX . "c_paiement";
$sql .= " AND active = 1"; $sql .= " WHERE entity IN (" . getEntity( 'c_paiement' ) . ")";
$sql .= " ORDER BY libelle"; $sql .= " AND active = 1";
$sql .= " ORDER BY libelle";
$resql = $db->query($sql); $resql = $db->query( $sql );
$paiementsModes = array(); $paiementsModes = array();
if ($resql) { if ( $resql ) {
while ($obj = $db->fetch_object($resql)) { while ( $obj = $db->fetch_object( $resql ) ) {
$paycode = $obj->code; $paycode = $obj->code;
if ($paycode == 'LIQ') { if ( $paycode == 'LIQ' ) {
$paycode = 'CASH'; $paycode = 'CASH';
} }
if ($paycode == 'CHQ') { if ( $paycode == 'CHQ' ) {
$paycode = 'CHEQUE'; $paycode = 'CHEQUE';
} }
$constantforkey = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"]; $constantforkey = "CASHDESK_ID_BANKACCOUNT_" . $paycode . $_SESSION["takeposterminal"];
//var_dump($constantforkey.' '.$conf->global->$constantforkey); //var_dump($constantforkey.' '.$conf->global->$constantforkey);
if (!empty($conf->global->$constantforkey) && $conf->global->$constantforkey > 0) { if ( ! empty( $conf->global->$constantforkey ) && $conf->global->$constantforkey > 0 ) {
array_push($paiementsModes, $obj); array_push( $paiementsModes, $obj );
}
} }
} }
if ( empty( $paiementsModes ) ) {
$langs->load( 'errors' );
setEventMessages( $langs->trans( "ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv( "TakePOS" ) ), null, 'errors' );
setEventMessages( $langs->trans( "ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"] ), null, 'errors' );
}
} }
if (empty($paiementsModes)) {
$langs->load('errors');
setEventMessages($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("TakePOS")), null, 'errors');
setEventMessages($langs->trans("ProblemIsInSetupOfTerminal", $_SESSION["takeposterminal"]), null, 'errors');
}
if (count($maincategories) == 0) { if (count($maincategories) == 0) {
if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) { if ($conf->global->TAKEPOS_ROOT_CATEGORY_ID > 0) {
$tmpcategory = new Categorie($db); $tmpcategory = new Categorie($db);