<?php

// get the config file
include_once("../public/config.php");

//here the db files that include in the file
include("../public/include_dao.php");


//get the do the action
$do = $_GET['do'];

$langs = $_SESSION['erp_lang'];
include_once("../views/languages/$langs/success.php");
include_once("../views/languages/$langs/error.php");

//here the global templates
$smarty->assign("itIsMachine_NoLogin", 1);
$smarty->display("header-bill.html");
//$smarty->display("maintennanceHeader.html");
//here goes the instances and general variables
//Restaurantkitchenprint
require_once('../models/dao/RestaurantkitchenprintDAO.class.php');
require_once('../models/dto/Restaurantkitchenprint.class.php');
require_once('../models/mysql/RestaurantkitchenprintMySqlDAO.class.php');
require_once('../models/mysql/ext/RestaurantkitchenprintMySqlExtDAO.class.php');
//User
require_once('../models/dao/UserDAO.class.php');
require_once('../models/dto/User.class.php');
require_once('../models/mysql/UserMySqlDAO.class.php');
require_once('../models/mysql/ext/UserMySqlExtDAO.class.php');
//Programsetting
require_once('../models/dao/ProgramsettingsDAO.class.php');
require_once('../models/dto/Programsetting.class.php');
require_once('../models/mysql/ProgramsettingsMySqlDAO.class.php');
require_once('../models/mysql/ext/ProgramsettingsMySqlExtDAO.class.php');
//check and use the condetion that suite this action
//Restaurantkitchenprint
$restaurantkitchenprint = new Restaurantkitchenprint();
$restaurantkitchenprintDAO = new RestaurantkitchenprintMySqlDAO();
$restaurantkitchenprintEX = new RestaurantkitchenprintMySqlExtDAO();
//User
$user = new User();
$userDAO = new UserMySqlDAO();
$userEX = new UserMySqlExtDAO();
//Programsetting
$Programsetting = new Programsetting();
$ProgramsettingDAO = new ProgramsettingsMySqlDAO();
$ProgramsettingEX = new ProgramsettingsMySqlExtDAO();


if (empty($do)) {
    ##1- set db name as last db name in dbNames.txt
// Read in entire file
    $databsesNames = file_get_contents("../views/default/archiveview/dbNames.txt");
    $databsesNames = trim($databsesNames);
//print($databsesNames);
    $databases = array_reverse(explode(",", $databsesNames));
    $_SESSION['dbname'] = $databases[0]; //"erp2016_7"

    $programsettingsdata = $ProgramsettingDAO->load(1);
    $smarty->assign('programsettingsdata', $programsettingsdata);

    //
    $printer = $_GET['printer'];
    $smarty->assign('printer', $printer);

    $smarty->display("restaurantKitchenPrinter/printHome.html");
    //date
} elseif ($do == "sucess") {

    //here the smarty templates
    $smarty->display("succes.html");
} elseif ($do == "error") {

    //here the smarty templates
    $smarty->display("error.html");
}
$smarty->assign("restaurantKitchenPrinter", 1);
$smarty->display("footer.html");

////****************************  Functions  ********************///

/* ===============================
  function in this CONTROLLER
  ================================ */
?>