File: /home/mostafedeg/public_html/erp/controllers/associatedtag.php
<?php
include("../public/impOpreation.php");
include("../library/uploadImages.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');
$youtubeLink = new YoutubeLink();
$youtubeLinkDAO = new YoutubeLinkMySqlDAO();
$youtubeLinkEX = new YoutubeLinkMySqlExtDAO();
$do = $_GET['do'];
$today = date("Y-m-d H:i:s");
$date = date("Y-m-d");
if (empty($do)) {
$smarty->display("header.html");
$smarty->display("associatedtagview/add.html");
$smarty->display("footer.html");
} elseif ($do == "show") {
include_once("../public/authentication.php");
$associatedtags = R::getAll('SELECT associatedtags.* FROM `associatedtags` WHERE conditions = 0');
$smarty->assign('associatedtags', $associatedtags);
$smarty->display("header.html");
$smarty->display("associatedtagview/show.html");
$smarty->display("footer.html");
} elseif ($do == "edit") {
include_once("../public/authentication.php");
$id = filter_input(INPUT_GET, 'id');
$edit = R::load('associatedtags', $id);
$smarty->assign('edit', $edit);
$smarty->display("header.html");
$smarty->display("associatedtagview/edit.html");
$smarty->display("footer.html");
}else if ($do == 'add') {
$tagname = filter_input(INPUT_POST, 'tagname');
try {
$associatedtags = R::dispense('associatedtags');
$associatedtags->today = $today;
$associatedtags->conditions = 0;
$associatedtags->userid = $userid;
$associatedtags->tagname = $tagname;
R::store($associatedtags);
header("location:?do=sucess");
} catch (Exception $e) {
print_r($e);
header("location:?do=error");
}
}else if ($do == 'update') {
$tagname = filter_input(INPUT_POST, 'tagname');
$id = filter_input(INPUT_POST, 'id');
try {
$associatedtags = R::load('associatedtags',$id);
$associatedtags->today = $today;
$associatedtags->userid = $userid;
$associatedtags->tagname = $tagname;
R::store($associatedtags);
header("location:?do=sucess");
} catch (Exception $e) {
print_r($e);
header("location:?do=error");
}
}else if ($do == 'del') {
$id = filter_input(INPUT_GET, 'id');
try {
$associatedtags = R::load('associatedtags',$id);
$associatedtags->conditions = 1;
R::store($associatedtags);
header("location:?do=sucess");
} catch (Exception $e) {
print_r($e);
header("location:?do=error");
}
} elseif ($do == "sucess") {
$smarty->display("header.html");
$smarty->display("succes.html");
$smarty->display("footer.html");
} elseif ($do == "error") {
$smarty->display("header.html");
$smarty->display("error.html");
$smarty->display("footer.html");
}
?>