Beispiel #1
0
 public function postInsert($data = array())
 {
     //Entrada
     $entrada = new Entrada($this->entradaId);
     //Tiene FIN?
     if ($entrada->entradaIdFin && !$data["force"]) {
         $evento = new Evento();
         $order = $this->order + 1;
         $evento->insert(array("fecha" => $data["fecha"], "entradaId" => $entrada->entradaIdFin, "order" => $order, "force" => $data["force"]));
     }
     //Log
     Log::add(LOG_ADD_EVENTO, $this, true);
 }
Beispiel #2
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));
 }