<?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
// GOES HERE ....................
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");


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

  Controller Name :- saveCTRL اضافة وتعديل وعرض الخزن

  OPERTATION in Controller

  1-display add form
  2- add in Save tbl
  3-insert into savedaily tbl
  4-display sucess or error
  5-display show form
  6-edit in Save data

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


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


//here goes the instances and general variables
//check and use the condetion that suite this action
if (empty($do)) {

    //$smarty->assign("breadCrumb",$breadCrumb);
    //here the smarty templates
    //$smarty->display("saveview/add.html");
} elseif ($do == "add") {

    //here the permssion check
    include_once("../public/authentication.php");

    try {
        // here the function that do the action
        add();
        header("location:?do=sucess");
    } catch (Exception $e) {
        header("location:?do=error");
    }
} elseif ($do == "show") {

    //here the permssion check
    include_once("../public/authentication.php");


    // here the function that do the action
    $saveData = show();
    $smarty->assign("saveData", $saveData);


    //breadcrumb
    $breadcrumbObject->add('الادارة><a href="saveController.php?do=show"> الخزن </a> > عرض الخزن', 'saveController.php', 0);
    //Now output the navigation.
    $breadCrumb = $breadcrumbObject->output();
    $smarty->assign("breadCrumb", $breadCrumb);





    //here the smarty templates
    $smarty->display("saveview/show.html");

    $smarty->assign("customCheck", 1);
} elseif ($do == "delete") {
    //here the permssion check
    include_once("../public/authentication.php");

    try {
        // here the function that do the action
        delete();
        header("location:?do=sucess");
    } catch (Exception $e) {
        header("location:?do=error");
    }
} elseif ($do == "deleteFinaly") {
    //here the permssion check
    include_once("../public/authentication.php");

    try {
        // here the function that do the action
        deleteFinaly();

        header("location:?do=sucess");
    } catch (Exception $e) {

        header("location:?do=error");
    }
} elseif ($do == "editprint") {
    //here the permssion check
    include_once("../public/authentication.php");

    $loadData = editprint();
    $smarty->assign("loadData", $loadData);



    //breadcrumb
    $breadcrumbObject->add('الادارة><a href="saveController.php?do=show"> الخزن </a> > عرض خزنة', 'saveController.php', 0);
    //Now output the navigation.
    $breadCrumb = $breadcrumbObject->output();
    $smarty->assign("breadCrumb", $breadCrumb);






    //here the smarty templates
    $smarty->display("saveview/editprint.html");

    $smarty->assign("customPrint", 1);
} elseif ($do == "edit") {
    //here the permssion check
    include_once("../public/authentication.php");

    $loadData = edit();
    $smarty->assign("loadData", $loadData);


    //breadcrumb
    $breadcrumbObject->add('الادارة><a href="saveController.php?do=show"> الخزن </a> > تعديل خزنة', 'saveController.php', 0);
    //Now output the navigation.
    $breadCrumb = $breadcrumbObject->output();
    $smarty->assign("breadCrumb", $breadCrumb);




    //here the smarty templates
    $smarty->display("saveview/edit.html");
} elseif ($do == "update") {
    //here the permssion check
    include_once("../public/authentication.php");

    try {

        // here the function that do the action
        update();
        header("location:?do=sucess");
    } catch (Exception $e) {

        header("location:?do=error");
    }
} elseif ($do == "sucess") {

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

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




$smarty->assign("customValidation", 1);

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

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

// add in Save tbl
function add() {

}

// show the form
function show() {

}

//update condition in Save tbl
function delete() {

}

//finaly deleted from Save tbl
function deleteFinaly() {

}

// edit in table
function edit() {

}

// edit in table
function editprint() {

}

// update table
function update() {

}

?>