Viewing file: ci_moderar_clasificados.php (6.47 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
class ci_moderar_clasificados extends tdfonline_ci
{
//-----------------------------------------------------------------------------------
//---- cuadro -----------------------------------------------------------------------
//-----------------------------------------------------------------------------------
function conf__cuadro(tdfonline_ei_cuadro $cuadro)
{
if (isset($this->s__datos_filtro)) {
$this->s__datos = $this->dep('datos')->tabla('clasificados')->get_listado($this->s__datos_filtro);
} else {
$this->s__datos = $this->dep('datos')->tabla('clasificados')->get_listado();
}
$cuadro->set_datos($this->s__datos);
}
function evt__cuadro__seleccion($datos)
{
$this->s__id_clasificados = $datos['id_clasificados'];
$this->dep('datos')->cargar($datos);
$this->set_pantalla('pant_edicion');
}
function evt__cuadro__eliminar($datos)
{
$this->dep('datos')->resetear();
$this->dep('datos')->cargar($datos);
$this->dep('datos')->eliminar_todo();
$this->dep('datos')->resetear();
}
function evt__cuadro__aprobar($datos)
{
$this->dep('datos')->tabla('clasificados')->set_estado($datos['id_clasificados'],1); //aprobar
$this->resetear();
}
function evt__cuadro__rechazar($datos)
{
$this->dep('datos')->tabla('clasificados')->set_estado($datos['id_clasificados'],2); //rechazar
$this->resetear();
}
function evt__cuadro__cancelar($datos)
{
$this->dep('datos')->tabla('clasificados')->set_estado($datos['id_clasificados'],3); //cancelar
$this->resetear();
}
function conf_evt__cuadro__aprobar($evento, $fila)
{
switch($this->s__datos[$fila]['estado']){
//case 0: //Pendiente
// $evento->anular();
// break;
case 1: //Aprobado
$evento->anular();
break;
//case 2: //Rechazado
// $evento->anular();
// break;
//case 3: //Cancelado
// $evento->anular();
// break;
}
}
function conf_evt__cuadro__rechazar($evento, $fila)
{
switch($this->s__datos[$fila]['estado']){
//case 0: //Pendiente
// $evento->anular();
// break;
//case 1: //Aprobado
// $evento->anular();
// break;
case 2: //Rechazado
$evento->anular();
break;
//case 3: //Cancelado
// $evento->anular();
}
}
function conf_evt__cuadro__cancelar($evento, $fila)
{
switch($this->s__datos[$fila]['estado']){
//case 0: //Pendiente
// $evento->anular();
// break;
//case 1: //Aprobado
// $evento->anular();
// break;
//case 2: //Rechazado
// $evento->anular();
// break;
case 3: //Cancelado
$evento->anular();
}
}
//-----------------------------------------------------------------------------------
//---- Filtro -----------------------------------------------------------------------
//-----------------------------------------------------------------------------------
function conf__filtro(toba_ei_formulario $filtro)
{
if (isset($this->s__datos_filtro)) {
$filtro->set_datos($this->s__datos_filtro);
}
}
function evt__filtro__filtrar($datos)
{
$this->s__datos_filtro = $datos;
}
function evt__filtro__cancelar()
{
unset($this->s__datos_filtro);
}
//-----------------------------------------------------------------------------------
//---- formulario -------------------------------------------------------------------
//-----------------------------------------------------------------------------------
function conf__formulario(tdfonline_ei_formulario $form)
{
if ($this->dep('datos')->esta_cargada()) {//Entran a modificar
$datos = $this->dep('datos')->tabla('clasificados')->get();
$form->set_datos($datos);
}else{//Entran a dar alta
return $this->dep('datos')->tabla('clasificados')->get();
}
}
function evt__formulario__modificacion($datos)
{
//subimos archivo de adjunto
$folder_path = "../www/adjuntos/";
if (empty($this->s__id_clasificados)) { //agrega
//adjunto-------------------------------------------------------
if (isset($datos['adjunto']) and !empty($datos['adjunto']['name'])) {// Mover adjunto al servidor.
$nombre_adjunto = date("YmdHis").'_'.$datos['adjunto']['name'];
$destino= $folder_path.$nombre_adjunto;
move_uploaded_file($datos['adjunto']['tmp_name'], $destino ) ;
if ( is_file( $destino ) ){// Le asigno solo el nombre al adjunto para que se guarde en la base y no de error
$datos['adjunto'] = $nombre_adjunto;
}
}else{
$datos['adjunto'] = $datos['adjunto']['name'];
}
}else{ //modificacion
//adjunto ----------------------------------------------------------
if (isset($datos['adjunto']) and !empty($datos['adjunto']['name'])) {
$nombre_adjunto = date("YmdHis").'_'.$datos['adjunto']['name'];
$destino=$folder_path.$nombre_adjunto;
move_uploaded_file($datos['adjunto']['tmp_name'], $destino ) ;
if ( is_file( $destino ) ){
$datos['adjunto'] = $nombre_adjunto;
}
}elseif (isset($datos['adjunto']) and empty($datos['adjunto']['name'])) {
$datos['adjunto'] = $datos['adjunto']['name'];
}else{
//Mantener el valor anterior
$url= $this->dep('datos')->tabla('clasificados')->get_adjunto($this->s__id_clasificados);
if(empty($url['adjunto'])){
$datos['adjunto'] = $datos['adjunto']['name'];
}else{
$datos['adjunto'] = $url['adjunto'];
}
}
}
$datos['fecha_alta'] = date("Y-m-d H:i:s");
$datos['usuario_alta'] = toba::usuario()->get_id();
//ei_arbol($datos);
$this->dep('datos')->tabla('clasificados')->set($datos);
}
function resetear()
{
$this->dep('datos')->resetear();
$this->set_pantalla('pant_seleccion');
}
}
?>
|