<?php

//the global file operation
include("../public/impOpreation.php");

//global varable
global $showoutside;

//to check if the page from .htacess
//$showoutside = $_GET['sn'];
// get the config file
include_once("../public/config.php");

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

//Sellbilldetailoffer
require_once('../models/dao/SellbilldetailofferDAO.class.php');
require_once('../models/dto/Sellbilldetailoffer.class.php');
require_once('../models/mysql/SellbilldetailofferMySqlDAO.class.php');
require_once('../models/mysql/ext/SellbilldetailofferMySqlExtDAO.class.php');
//Sellbilloffer
require_once('../models/dao/SellbillofferDAO.class.php');
require_once('../models/dto/Sellbilloffer.class.php');
require_once('../models/mysql/SellbillofferMySqlDAO.class.php');
require_once('../models/mysql/ext/SellbillofferMySqlExtDAO.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');

//Product
require_once('../models/dao/ProductDAO.class.php');
require_once('../models/dto/Product.class.php');
require_once('../models/mysql/ProductMySqlDAO.class.php');
require_once('../models/mysql/ext/ProductMySqlExtDAO.class.php');


//Client
require_once('../models/dao/ClientDAO.class.php');
require_once('../models/dto/Client.class.php');
require_once('../models/mysql/ClientMySqlDAO.class.php');
require_once('../models/mysql/ext/ClientMySqlExtDAO.class.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");


/* ======================

  Controller Name :- productionOrderController

  OPERTATION in Controller///////////////////////////////////////////////////

  1-display add form
  2- add in productCat tble
  4-display sucess or error
  5-display show and delete
  6-delete from productCat tbl
  7-display edit
  8- update productCat tbl
  ======================== */






//here the global templates
$smarty->display("header.html");







//here goes the instances and general variables
//Programsetting
$ProgramsettingDAO = new ProgramsettingsMySqlDAO();

//Sellbilldetailoffer
$sellBillDetailOffer = new Sellbilldetailoffer();
$sellBillDetailOfferDAO = new SellbilldetailofferMySqlDAO();
$sellBillDetailOfferEX = new SellbilldetailofferMySqlExtDAO();

//Sellbilloffer
$sellBillOffer = new Sellbilloffer();
$sellBillOfferDAO = new SellbillofferMySqlDAO();
$sellBillOfferEX = new SellbillofferMySqlExtDAO();


//Product
$product = new Product();
$productDAO = new ProductMySqlDAO();
$productExt = new ProductMySqlExtDAO();

//Client
$client = new Client();
$clientDAO = new ClientMySqlDAO();
$clientExt = new ClientMySqlExtDAO();


//check and use the condition that suite this action
if (empty($do)) {
    //here the permssion check
    include_once("../public/authentication.php");

    $Programsettingdata = $ProgramsettingDAO->load(1);
    $smarty->assign("Programsettingdata", $Programsettingdata);

     $clientid = $_POST["clientid"];
     $from = $_POST["from"];
     $to = $_POST["to"];

      $queryString = " ";
      if (!empty($clientid)) {
            $queryString .= " and sellbilloffer.sellbillclientid = '" . $clientid . "' ";
      }
      if (!empty($from)) {
            $queryString .= " and date(sellbilloffer.sellbillsysdate) >= '" . $from . "' ";
      }

      if (!empty($to)) {
            $queryString .= " and date(sellbilloffer.sellbillsysdate) <= '" . $to . "' ";
      }


    $alldata = $sellBillOfferEX->getalldata($queryString);
    $smarty->assign("alldata", $alldata);

    $clientsData = getClients(); //undeleted clients
    $smarty->assign("clientsData", $clientsData);

    //js for unit is with footer
    $smarty->display("reportquotationview/show.html");
} elseif ($do == "sucess") {
    //here the smarty templates
    $smarty->display("succes.html");
} elseif ($do == "error") {
    //here the smarty templates
    $smarty->display("error.html");
}


$smarty->display("footer.html");


function getClients()
{
    global $clientDAO;
    $clientsData = $clientDAO->queryByCondition(0);
    return $clientsData;
}




?>