staffController.php
80 lines
| 2.6 KiB
| text/x-php
|
PhpLexer
|
r2 | <?php | |
class staffController extends ControllerBase{ | |||
public function dolist(){ | |||
require("components".DS."com_staff".DS."models".DS."staffModel.php"); | |||
$obj = new staffModel(); | |||
$lstObj = $obj->dolist(); | |||
if(count($lstObj) == 0){ | |||
$url = "index.php?option=com_staff&controller=staff&action=add"; | |||
header("location: ".$url); | |||
exit(0); | |||
} | |||
$data["lstObj"] = $lstObj; | |||
$data["lsTitle"] = "STAFF::::::::::::::"; | |||
$data["content"] = "components".DS."com_staff".DS."views".DS."dolist.php"; | |||
$data["title"] = "STAFF::::::::::::::"; | |||
$this->view->show("template.php", $data); | |||
} | |||
public function add(){ | |||
require_once("components".DS."com_areas".DS."models".DS."areasModel.php"); | |||
$objAreas = new areasModel(); | |||
$lstAreas = $objAreas->dolist(); | |||
require_once("components".DS."com_users".DS."models".DS."usersModel.php"); | |||
$objUsers = new usersModel(); | |||
$lstUsers = $objUsers->getAllUsers(); | |||
$data["lstAreas"] = $lstAreas; | |||
$data["lstUsers"] = $lstUsers; | |||
$data["frm_title"] = "AGREGAR STAFF::::::::::"; | |||
$data["content"] = "components".DS."com_staff".DS."views".DS."form.php"; | |||
$data["title"] = "Agregar Staff:::::::::::::"; | |||
$this->view->show("template.php", $data); | |||
} | |||
public function save(){ | |||
$area = $_POST['lstArea']; | |||
$user = $_POST['lstUser']; | |||
$desc = $_POST['description']; | |||
$message = ""; | |||
require("components".DS."com_staff".DS."models".DS."staffModel.php"); | |||
$obj = new staffModel(); | |||
$data_sql['idarea'] = $area; | |||
$data_sql['iduser'] = $user; | |||
$data_sql['description'] = $desc; | |||
$data_sql['date_create'] = date("Y-m-d H:i:s"); | |||
$data_sql['state'] = 1; | |||
list($query, $id, $message) = $obj->addItem($data_sql); | |||
$url = "index.php?option=com_staff&controller=staff&action=dolist"; | |||
header("location: ".$url); | |||
exit(); | |||
} | |||
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; | |||
} | |||
} | |||
?> |