File: /home/mostafedeg/public_html/erp/controllers/projectKindController.php
<?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");
include_once("dailyentryfun.php");
//here the db files that include in the file
include("../public/include_dao.php");
//Projectkind
require_once('../models/dao/ProjectkindDAO.class.php');
require_once('../models/dto/Projectkind.class.php');
require_once('../models/mysql/ProjectkindMySqlDAO.class.php');
require_once('../models/mysql/ext/ProjectkindMySqlExtDAO.class.php');
require_once('../models/dao/YoutubeLinkDAO.class.php');
require_once('../models/dto/YoutubeLink.class.php');
require_once('../models/mysql/YoutubeLinkMySqlDAO.class.php');
require_once('../models/mysql/ext/YoutubeLinkMySqlExtDAO.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 :- clientDeficitController
OPERTATION in Controller
1- display add form
2- add in clientdebtchange tbl (subtracting or adding client debt)
3- update client dept in client tbl
======================== */
//here the global templates
$smarty->display("header.html");
//here goes the instances and general variables
//Projectkind
$myProjectkind = new Projectkind();
$myProjectkindRecord = new ProjectkindMySqlDAO();
$myProjectkindEx = new ProjectkindMySqlExtDAO();
$youtubeLink = new YoutubeLink();
$youtubeLinkDAO = new YoutubeLinkMySqlDAO();
$youtubeLinkEX = new YoutubeLinkMySqlExtDAO();
$today = date("Y-m-d");
//check and use the condition that suite this action
if (empty($do)) {
include_once("../public/authentication.php");
$smarty->display("projectkindview/add.html");
//$smarty->assign("customClientDeficit", 1);
} elseif ($do == "add") {
include_once("../public/authentication.php");
try {
add();
header("location:?do=sucess");
} catch (Exception $e) {
// print_r($e);
$mytransactions->rollback();
header("location:?do=error");
}
} elseif ($do == "show") {
include_once("../public/authentication.php");
$youtubes = $youtubeLinkDAO->queryAll();
$smarty->assign("youtubes", $youtubes);
$shownData = $myProjectkindRecord->queryAll();
$smarty->assign("shownData", $shownData);
$smarty->display("projectkindview/show.html");
}elseif ($do == "tempdelete") {
include_once("../public/authentication.php");
$projectkindid = $_GET['projectkindid'];
try {
R::exec("UPDATE `projectkind` SET `conditions`= 1 WHERE projectkindid = '".$projectkindid."' ");
header("location:?do=sucess");
} catch (Exception $e) {
header("location:?do=error");
}
} elseif ($do == "edit") {
include_once("../public/authentication.php");
$id = $_GET['id'];
$loadData = edit($id);
$smarty->assign("loadData", $loadData);
$smarty->display("projectkindview/edit.html");
} 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 clientdebtchange tbl
function add() {
global $myProjectkind;
global $myProjectkindRecord;
$projectkindname = $_POST["projectkindname"];
$projectkindcomment = $_POST["projectkindcomment"];
$myProjectkind->projectkindname = $projectkindname;
$myProjectkind->projectkindcomment = $projectkindcomment;
$myProjectkind->conditions = 0;
$myProjectkind->projectkinddate = date('Y-m-d H:i:s');
$myProjectkind->userid = $_SESSION['userid'];
$accountMovementId = $myProjectkindRecord->insert($myProjectkind);
return $accountMovementId;
}
function edit($id) {
global $myAccountmovementRecord;
global $myAccountmovementEx;
$data = $myAccountmovementEx->loadMovementEX($id);
return $data;
}
?>