<?php

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

//global varable
global $showoutside;



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

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


require_once('../models/dao/TypesupplierDAO.class.php');
require_once('../models/dto/Typesupplier.class.php');
require_once('../models/mysql/TypesupplierMySqlDAO.class.php');
require_once('../models/mysql/ext/TypesupplierMySqlExtDAO.class.php');


//Supplier
require_once('../models/dao/SupplierDAO.class.php');
require_once('../models/dto/Supplier.class.php');
require_once('../models/mysql/SupplierMySqlDAO.class.php');
require_once('../models/mysql/ext/SupplierMySqlExtDAO.class.php');

$ProgramsettingDAO = new ProgramsettingsMySqlDAO();


$type = new Typesupplier();
$TypeSupplierDAO = new TypesupplierMySqlDAO();
$TypeSupplierEX = new TypesupplierMySqlExtDAO();

//supplier
$supplier = new Supplier();
$supplierDAO = new SupplierMySqlDAO();
$supplierEX = new SupplierMySqlExtDAO();


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

  Controller Name :- clientsAndProductsReportController تقرير اقساط عملاء

  OPERTATION in Controller

  1- show report
  2- search with clients and products and date

  ======================== */
if ($do == "show" || empty($do)) {
    //here the permission check
    include_once("../public/authentication.php");

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


    $TypeSupplierData = getTypeclient();
    $smarty->assign("TypeSupplierData", $TypeSupplierData);


    $typesupplierId = $_REQUEST['typesupplierId'];


    $message = '';

    if ($typesupplierId != '' && $typesupplierId != '-1') {
        $TypeClientData = $TypeSupplierDAO->load($typesupplierId);
        $TypeClientName = $TypeClientData->typeName;
        $message .= " نوع الموردين: " . $TypeClientName;
        $allData = $supplierEX->getSupplierByType($typesupplierId);

    }





    $smarty->assign("allData", $allData);
    $smarty->assign("message", $message);

    //here the smarty templates
    $smarty->assign("clientPremium", 1);
    $smarty->display("typesupplierReportview/showNew.html");

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

/* ===============================
  function in this CONTROLLER
  ================================ */

function getTypeclient() {
    global $TypeSupplierEX;
    $TypeSupplierData = $TypeSupplierEX->queryAllsup();
    return $TypeSupplierData;
}





?>