File: /home/mostafedeg/public_html/erp/controllers/propertyrightsreport.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");
//Transaction
include_once("../models/sql/Transaction.class.php");
//here the db files that include in the file
include("../public/include_dao.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');
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 :- accountstree
OPERTATION in Controller
1- display add form, add
2- add in tbl
3- display show and tempdelete
4- edit
5- update
======================== */
//here the global templates
$smarty->display("header.html");
//here goes the instances and general variables
//Client
$client = new Client();
$clientDAO = new ClientMySqlDAO();
$clientExt = new ClientMySqlExtDAO();
$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)) {
//here the permssion check
include_once("../public/authentication.php");
##
$smarty->assign("now", date('Y-m-d H:i:s'));
/* ---------------------------------------------------------------------- */
//العملاء
$totalClients = 0;
$clients = $clientDAO->queryByCondition(0);
foreach ($clients as $data) {
$totalClients+= $data->clientdebt;
}
$smarty->assign("totalClients", $totalClients);
/* ---------------------------------------------------------------------- */
//الماركة
$totalBrand = 0;
$smarty->assign("totalBrand", $totalBrand);
/* ---------------------------------------------------------------------- */
//شهرة
$totalFame = 0;
$smarty->assign("totalFame", $totalFame);
/* ---------------------------------------------------------------------- */
//الإشاعات
$totalRumors = 0;
$smarty->assign("totalRumors", $totalRumors);
/* ---------------------------------------------------------------------- */
//المنافسة
$totalCompetition = 0;
$smarty->assign("totalCompetition", $totalCompetition);
/* ---------------------------------------------------------------------- */
//صعوبات جغرافية
$totalGeographicalDifficulties = 0;
$smarty->assign("totalGeographicalDifficulties", $totalGeographicalDifficulties);
/* ---------------------------------------------------------------------- */
$totalDeptor = $totalClients + $totalBrand + $totalFame;
$totalCreditor = $totalRumors + $totalCompetition + $totalGeographicalDifficulties;
$smarty->assign("totalDeptor", $totalDeptor);
$smarty->assign("totalCreditor", $totalCreditor);
$gainLossMsg;
$netVal = $totalDeptor - $totalCreditor;
if ($netVal > 0) {
$gainLossMsg = 'القيمة المكتسبة : ' . $netVal;
} elseif ($netVal < 0) {
$netVal = abs($netVal);
$gainLossMsg = 'القيمة المفقودة : ' . $netVal;
}
$smarty->assign("gainLossMsg", $gainLossMsg);
$youtubes = $youtubeLinkDAO->queryAll();
$smarty->assign("youtubes", $youtubes);
//here the smarty templates
$smarty->display("propertyrightsreportview/add.html");
} elseif ($do == "sucess") {
//here the smarty templates
$smarty->display("succes.html");
} elseif ($do == "error") {
//here the smarty templates
$smarty->display("error.html");
}
//here the global templates
$smarty->display("footer.html");
/* ===============================
function in this CONTROLLER
================================ */
function getStartGoodsVal() {
//Storedetail
global $storeDetailEX;
$productsTotalValue = 0;
$storeData = loadStore();
foreach ($storeData as $value) {
$products = $storeDetailEX->queryWithStoreId($value->storeId);
foreach ($products as $pro) {
$productsTotalValue += $pro->productquantity * $pro->productBuyPrice;
}
}
$productsTotalValue = round($productsTotalValue, 2);
return $productsTotalValue;
}
//select all store data
function loadStore() {
//to use the variable out side the funcion
global $storeDAO;
//load all store data
$storeData = $storeDAO->queryByConditions(0);
return $storeData;
}
?>