##// END OF EJS Templates
agregado el controlador staff y algunas funciones como agregar nuevo.
agregado el controlador staff y algunas funciones como agregar nuevo.

File last commit:

r0:1
r2:3
Show More
areasController.php
134 lines | 5.1 KiB | text/x-php | PhpLexer
arturo
creando directorios base para el desarrollo
r0 <?php
class areasController extends ControllerBase{
public function dolist(){
require("components".DS."com_areas".DS."models".DS."areasModel.php");
$obj = new areasModel();
$lstObj = $obj->dolist();
if(count($lstObj) == 0){
$url = "index.php?option=com_areas&controller=areas&action=add";
header("location: ".$url);
exit(0);
}
$data["lstObj"] = $lstObj;
$data["lsTitle"] = "AREAS::::::::::::::";
$data["content"] = "components".DS."com_areas".DS."views".DS."dolist.php";
$data["title"] = "AREAS::::::::::::::";
$this->view->show("template.php", $data);
}
public function add(){
$type = $_GET['ty'];
require_once("components".DS."com_areas".DS."models".DS."areasModel.php");
$objAreas = new areasModel();
$lstAreas = $objAreas->dolist();
$html_title = $this->setTitle($type);
$data["type"] = $type;
$data["frm_title"] = $html_title;
$data["lstAreas"] = $lstAreas;
$data["content"] = "components".DS."com_areas".DS."views".DS."form.php";
$data["title"] = "Add Report:::::::::::::";
$this->view->show("template.php", $data);
}
public function save(){
$ty = $_POST['type'];
$area = $_POST['lstArea'];
$title = $_POST['txtTitle'];
$desc = $_POST['description'];
$url = explode(DS, trim(SYS_ROOT));
array_pop($url);
array_pop($url);
array_pop($url);
$path = implode(DS, $url);
$path = $path.DS."files".DS;
$path_area = $path.DS.$area.DS;
if($_FILES['fpname']['tmp_name'] != ""){
if (is_uploaded_file($_FILES['fpname']['tmp_name'])){
$psize = $_FILES ['fpname']['size'];
$pname = $_FILES ['fpname']['name'];
$man_file = new filesManager($pname);
$type = $man_file->getExtension();
$name_file = $man_file->getName();
if($man_file->isDoc()){
$url_user = $name_file.".".$type;
$date_current = date("YmdHis");
$name_file_system = md5($name_file.$date_current);
$path_final = $name_file_system.".".$type;
$flag_add = false;
if(is_dir($path_area)){
if(is_writable($path)){
copy($_FILES['fpname']['tmp_name'], $path_area.$path_final);
$flag_add = true;
$tipo_msg = 1;
}else{ $message = "No se puede escribir."; }
}else{
mkdir($path_area,0777,true);
copy($_FILES['fpname']['tmp_name'], $path_area.$path_final);
$flag_add = true;
}
if($flag_add){
$message = "Added file";
require("components".DS."com_areas".DS."models".DS."areasModel.php");
$report = new areasModel();
$data_sql['idarea'] = $area;
$data_sql['title'] = $title;
$data_sql['description'] = $desc;
$data_sql['url_user'] = $pname;
$data_sql['url_system'] = $path_final;
$data_sql['type'] = $ty;
$data_sql['date_create'] = date("Y-m-d H:i:s");
$data_sql['state'] = 1;
list($query, $id, $message) = $report->addItem($data_sql);
}
}else{
$message .= "Uploaded failed: No file allowed.";
$flu_insertar = false;
$tipo_msg = 2;
}
}else{
// error por tamanio
$message .= "Uploaded failed: size exceeds the limit.";
$flu_insertar = false;
$tipo_msg = 3;
}
}else{
echo "Error: Uploaded failed.";
$flu_insertar = false;
$tipo_msg = 3;
}
$url = "index.php?option=com_areas&controller=reports&action=dolist&ty=".$ty;
header("location: ".$url);
exit (0);
}
public function setTitle($type){
$html_title = "";
switch ($type){
case 1: $html_title = "Lista de Informes";
break;
case 2: $html_title = "Lista de Reportes";
break;
default: $html_title = "Lista de Reportes";
break;
}
return $html_title;
}
}
?>