示例#1
0
 public function fileEventSave()
 {
     View::select(null, null);
     $data = null;
     if (Input::hasPost('fechaSelect')) {
         $upload = new DwUpload('archivo', 'img/upload/eventos/');
         //$upload->setAllowedTypes('png|jpg|gif|jpeg|png');
         $upload->setEncryptName(TRUE);
         $this->data = $upload->save();
         if (!$this->data) {
             //retorna un array('path'=>'ruta', 'name'=>'nombre.ext');
             $data = array('error' => TRUE, 'message' => $upload->getError());
         } else {
             $fecha = Input::post('fechaSelect');
             $hora = Input::post('hora');
             $id = Input::post('id');
             $evento = new Evento();
             if (is_numeric($id) && $evento->find_first($id)) {
                 $evento->urlFile = "img/upload/eventos/{$this->data['name']}";
                 $evento->update();
                 $data = array('success' => true);
                 $data = $evento;
                 $data->networks = json_decode($data->networks);
             } else {
                 $return = array("start" => $fecha, "urlFile" => "img/upload/eventos/{$this->data['name']}", "constraint" => "", "author" => "", "hour" => $hora, "networks" => array("facebook" => "false", "twitter" => "false", "instagram" => "false", "linkedin" => "false", "pinterest" => "false", "youtube" => "false", "plus" => "false"));
                 $data = Evento::setEvento('create', $return, Session::get('id'));
                 $data->networks = json_decode($data->networks);
             }
         }
     }
     $this->data = $data;
     View::json();
 }
?>
">Gerenciar Negócio - Eventos</a></li>
                        <li class="active">Alterar Evento</li>
                    </ol>
                    <?php 
//Condicional que recebe os parâmetros para atualizar o registro.
if ($_POST) {
    $evento->cd_ambiente = $_POST['cd_ambiente'];
    $evento->cd_tipo_evento = $_POST['cd_tipo_evento'];
    $evento->ds_evento = $_POST['ds_evento'];
    $evento->dt_inicio_evento = $_POST['dt_inicio_evento'];
    $evento->hr_inicio_evento = $_POST['hr_inicio_evento'];
    $evento->dt_fim_evento = $_POST['dt_fim_evento'];
    $evento->hr_fim_evento = $_POST['hr_fim_evento'];
    //Função que atualiza o registro baseado na instância criada.
    if ($evento->update()) {
        $url .= '&sucesso=true';
        echo "aqui1";
    } else {
        $url .= '&sucesso=false';
        echo "aqui2";
    }
    header('Location:' . $url);
}
?>
                    <!-- Título da Página -->
                    <h1>Alterar Evento</h1>
                    <br/>
                    <!-- Formulário de criação -->
                    <div class="row margin-bottom-30">
                        <div class="row" style="margin: 0px;">
示例#3
0
 public function json()
 {
     $date = date("Y-m-d", strtotime($_REQUEST["date"]));
     $hour = $_REQUEST["hour"];
     $action = $_REQUEST["action"];
     if (is_numeric($_REQUEST["order"]) && (int) $_REQUEST["order"] > 0) {
         $orden = (int) $_REQUEST["order"];
     }
     if ($_REQUEST["toPosition"] && $_REQUEST["fromPosition"]) {
         $action = "order";
     }
     switch ($action) {
         //Order
         case "order":
             $evento = new Evento($_REQUEST["id"]);
             $evento->order($date, $_REQUEST["toPosition"], $hour);
             //Log
             Log::add(LOG_MOVE_EVENTO, $_REQUEST);
             break;
             //Hour update
         //Hour update
         case "updateHour":
             Evento::actualizarFechas($date, $hour);
             //Log
             Log::add(LOG_UPDATE_HOUR_PARRILLA, $_REQUEST);
             break;
             //Mosca2 add
         //Mosca2 add
         case "addMosca2":
             $evento = new Evento($_REQUEST['eventoId']);
             if ($evento->id) {
                 $mosca2 = new Mosca($_REQUEST['moscaId2']);
                 $evento->logo2 = $mosca2->codigo;
                 $evento->delay = $_REQUEST['delay'];
                 $evento->update();
                 //Log
                 Log::add(LOG_UPDATE_MOSCA2_PARRILLA, $_REQUEST);
             }
             break;
             //New
         //New
         case "new":
             $evento = new Evento();
             $evento->entradaId = $_REQUEST["entradaId"];
             $evento->insert(array("fecha" => $date, "hora" => $hour, "order" => $orden));
             //Log
             Log::add(LOG_ADD_EVENTO, $_REQUEST);
             break;
             //Import
         //Import
         case "import":
             $order = $_REQUEST["order"];
             if (count($_REQUEST["eventosId"])) {
                 foreach ($_REQUEST["eventosId"] as $eventoId) {
                     $evento = new Evento($eventoId);
                     $evento->insert(array("fecha" => $date, "hora" => $hour, "order" => $order, "force" => true));
                     $order++;
                 }
             }
             //Log
             Log::add(LOG_IMPORT_EVENTOS, $_REQUEST);
             break;
             //Delete
         //Delete
         case "delete":
             $evento = new Evento($_REQUEST["id"]);
             $evento->delete();
             //Actualizamos el orden
             Evento::actualizarOrden($date);
             //Actualizamos las fechas
             Evento::actualizarFechas($date, $hour);
             //Log
             Log::add(LOG_DELETE_EVENTO, $_REQUEST);
             break;
     }
     //Select
     $eventos = Evento::select(array("fecha" => $date));
     //Data
     $data = array();
     if (count($eventos)) {
         foreach ($eventos as $evento) {
             $data[] = $evento->getDataTablesJson();
         }
     }
     echo json_encode(array("aaData" => $data));
 }