<?php
	if(isset($_GET['showe'])){
		ini_set('display_errors', 1);
		ini_set('display_startup_errors', 1);
		error_reporting(E_ALL);
	}
	ob_start();
	define('APP_USER',1);
	include(__DIR__."/../class/general.php");
	include(__DIR__."/../class/db.php");
	include(__DIR__."/../class/somiti.php");
	include(__DIR__."/../class/acc.php");
	include(__DIR__."/../class/messages.php");
	include(__DIR__."/../class/mail.php");
	$general= new General();
	$db     = new DB($general);
	$smt    = new SMT($general,$db);
	$acc    = new ACC($general,$db,$smt);
	include(__DIR__."/../init.php");
	if(isset($_GET['ajax'])){
		include __DIR__.'/ajax/app.php';
	}
	else{
		if(isset($_GET['loginKey'])){
			$_SESSION[SU_LOGIN_SESSION_NAME]=$_GET['loginKey'];
			$general->redirect(APP_URL);
		}
		if(defined('LOGIN_SESSION_ID')){
			if(isset($_GET['logout'])){
				$db->logOut($lData,APP_URL.'/?needLogin=1');
			}
			include(__DIR__."/include/header.php");
			$include1="/include/dashboard.php";
            //$userData = $db->userInfoByID(USER_ID);
			if(isset($_GET[MODULE_URL])){
				$module=$_GET[MODULE_URL];
				$pUrl=APP_URL.'/?'.MODULE_URL.'='.$module;
				$requestProcess=[
                    'new-order'                         => '/order/new_order.php',
                    'order-list'                        => '/order/order_list.php',
                    'customer'                          => '/customer/customerList.php',
                    'customer-statement'                => '/customer/customer-statement.php',
					
                    'my-transactions'                   => '/account/my_transactions.php',
                    'receive-from-customer'             => '/account/receive_from_customer.php',
                    'doctor'                            => '/doctor/doctor.php',
                    'doctor-visit'                      => '/visit/doctor_visit.php',
                    'doctor-visit-list'                 => '/visit/doctor_visi_listt.php',
                    'doctor-visit-details'              => '/visit/doctor_visi_details.php',
                    'customer-visit'                    => '/visit/customer_visit.php',
                    'customer-visit-list'               => '/visit/customer_visit_list.php',
                    'customer-visit-details'            => '/visit/customer_visit_details.php',
                    'bazar-visit'                        => '/visit/bazar_visit.php',
                    'bazar-visit-list'                   => '/visit/bazar_visit_list.php',
                    'bazar-visit-details'                => '/visit/bazar_visit_details.php',
					'deposit'                           => '/account/deposit.php',
                    'paid-unpaid-report'				=> '/report/paid-and-unpaid-report.php',
				];
                
				foreach($requestProcess as $k=>$rp){
					if($k==$module){
						$include1=$rp;
						break;
					}
				}
			}
			include(__DIR__.$include1);
			include(__DIR__."/include/footer.php");    
		}
		else{
				$general->redirect(URL);
		}
	}
