Exemplo n.º 1
0
 public function actionAdd($id, $access_code = null)
 {
     $session = new Session();
     if (!($ticket = Ticket::findOne($id))) {
         $session->addError(Yii::t('app', 'Ticket does not exist'));
         return $this->redirect('index');
     }
     if ($ticket->requires_access_code && (count($ticket->accessCodes) == 0 || $access_code == null)) {
         $session->addError(Yii::t('app', 'Access code required'));
         return $this->redirect('index');
     } else {
         if ($ticket->requires_access_code) {
             $code_match = false;
             foreach ($ticket->accessCodes as $code) {
                 if ($code->access_code == $access_code) {
                     $code_match = true;
                     break;
                 }
             }
             if (!$code_match) {
                 $session->addError(Yii::t('app', 'Valid access code required'));
                 return $this->redirect('index');
             }
         }
     }
     $cart = Cart::getCurrentCart();
     $cart->addItem($id);
     $session->addSuccess(Yii::t('app', 'Ticket added'));
     return $this->redirect('index');
 }
Exemplo n.º 2
0
 private function updateTicket($request)
 {
     $updated = false;
     $ticket = Ticket::find($request->get('ticket_id'));
     $status_id = $request->get('status_id');
     $priority_id = $request->get('priority_id');
     $ticket->status_id = $status_id;
     $ticket->priority_id = $priority_id;
     $updated = $ticket->isDirty();
     if ($updated) {
         $ticket->save();
         $history = new TicketHistory();
         $last_history = TicketHistory::where('ticket_id', $ticket->id)->orderBy("created_at", "DESC")->first();
         $history->previous_id = count($last_history) ? $last_history->id : NULL;
         $history->changer_id = Auth::user()->active_contact->id;
         $history->ticket_id = $ticket->id;
         $history->title = $ticket->title;
         $history->post = $ticket->post;
         $history->creator_id = $ticket->creator_id;
         $history->assignee_id = $ticket->assignee_id;
         $history->status_id = $ticket->status_id;
         $history->priority_id = $ticket->priority_id;
         $history->division_id = $ticket->division_id;
         $history->equipment_id = $ticket->equipment_id;
         $history->company_id = $ticket->company_id;
         $history->contact_id = $ticket->contact_id;
         $history->level_id = $ticket->level_id;
         $history->job_type_id = $ticket->job_type_id;
         $history->emails = $ticket->emails;
         $history->save();
     }
     return $updated;
 }
Exemplo n.º 3
0
 public function upload()
 {
     $uploader_id = Auth::user()->active_contact->id;
     if (Input::file('file')->isValid()) {
         if (Input::get('target') == "posts") {
             if (Input::get('target_action') == "create") {
                 $target = Post::where('author_id', $uploader_id)->where("status_id", "=", POST_DRAFT_STATUS_ID)->where("ticket_id", Input::get('target_id'))->first();
             } elseif (Input::get('target_action') == "edit") {
                 $target = Post::where("id", Input::get('target_id'))->first();
             }
         } elseif (Input::get('target') == "tickets") {
             if (Input::get('target_action') == "create") {
                 $target = Ticket::where('status_id', TICKET_DRAFT_STATUS_ID)->where('creator_id', $uploader_id)->first();
             } elseif (Input::get('target_action') == "edit") {
                 $target = Ticket::where("id", Input::get('target_id'))->first();
             }
         }
         $id = $target->id;
         $request['target_id'] = $id;
         $request['uploader_id'] = $uploader_id;
         $request['file'] = Input::file('file');
         $request['target'] = Input::get('target');
         $request['target_action'] = Input::get('target_action');
         $response = $this->repo->upload($request);
         $response = Response::json($response, 200);
         return $response;
     }
 }
Exemplo n.º 4
0
 protected function postUpdateProgress($ticketId, $progressId)
 {
     $ticket = Ticket::find($ticketId);
     //Loop through so that if any steps have been skipped we insert them as well.
     for ($i = $ticket->state_id + 1; $i <= (int) $progressId; $i++) {
         Progress::create(['state_id' => $i, 'ticket_id' => $ticketId, 'actioned_by' => Auth::user()->id]);
     }
     //Update the state on the ticket table
     $ticket->state_id = $progressId;
     $ticket->save();
     echo json_encode(['success' => 'true', 'message' => 'Progress updated']);
 }
Exemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Ticket::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['idTicket' => $this->idTicket, 'MotivoTicket_idMotivoTicket' => $this->MotivoTicket_idMotivoTicket, 'RRHH_idRRHH' => $this->RRHH_idRRHH, 'tiporrhh_idTipoRRHH' => $this->tiporrhh_idTipoRRHH, 'Transporte_idTransporte' => $this->Transporte_idTransporte, 'Transporte_TIpoTransporte_idTIpoTransporte' => $this->Transporte_TIpoTransporte_idTIpoTransporte, 'Transporte_RRHH_idRRHH' => $this->Transporte_RRHH_idRRHH, 'Transporte_tiporrhh_idTipoRRHH' => $this->Transporte_tiporrhh_idTipoRRHH, 'Fecha' => $this->Fecha, 'Hora' => $this->Hora]);
     $query->andFilterWhere(['like', 'Descripcion', $this->Descripcion]);
     return $dataProvider;
 }
Exemplo n.º 6
0
 /**
  * Define the application's command schedule.
  *
  * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
  * @return void
  */
 protected function schedule(Schedule $schedule)
 {
     /*$schedule->command('inspire')
       ->everyMinute();*/
     $schedule->call(function () {
         $reservas = Ticket::whereNotNull('reserve')->get();
         foreach ($reservas as $reserva) {
             $reserve_date = strtotime($reserva->created_at);
             $reserve_hours = DB::table('business')->where('id', 1)->first()->reserve_time;
             if ($reserve_date + 3600 * $reserve_hours <= time()) {
                 if ($reserva->event->place->rows != null) {
                     DB::table('slot_presentation')->where('sale_id', $reserva->id)->update(['status' => config('constants.seat_free')]);
                 } else {
                     DB::table('zone_presentation')->where('zone_id', $reserva->zone_id)->increment('slots_availables', $reserva->quantity);
                 }
                 $reserva->delete();
             }
         }
     })->everyMinute();
     $schedule->call(function () {
         $destacados = Highlight::where('start_date', '<=', Carbon::now())->get();
         if ($destacados && !empty($destacados)) {
             foreach ($destacados as $destacado) {
                 $tiempo = strtotime($destacado->start_date) + $destacado->days_active * 3600 * 24;
                 if ($tiempo > time()) {
                     $destacado->active = 1;
                     $destacado->save();
                 }
             }
         }
         $noDestacados = Highlight::where('active', '1')->get();
         if ($noDestacados && !empty($noDestacados)) {
             foreach ($noDestacados as $noDestacado) {
                 $tiempo = strtotime($noDestacado->start_date) + $noDestacado->days_active * 3600 * 24;
                 if ($tiempo <= time()) {
                     $noDestacado->active = 0;
                     $noDestacado->save();
                 }
             }
         }
     })->everyMinute();
 }
Exemplo n.º 7
0
 private function query()
 {
     $raw1 = DB::raw("CASE \n                            WHEN tickets.created_at > posts.created_at OR posts.created_at IS NULL \n                            THEN tickets.created_at \n                            ELSE posts.created_at \n                         END as 'last_operation_date'");
     $raw2 = DB::raw("CASE \n                            WHEN tickets.created_at > posts.created_at OR posts.created_at IS NULL \n                            THEN tickets.creator_id ELSE posts.author_id \n                         END as 'last_operation_company_person_id'");
     $raw3 = DB::raw('(SELECT MAX(id) as post_id, ticket_id FROM posts GROUP BY ticket_id) as d1');
     $raw4 = DB::raw("(SELECT time.ticket_id, time.active_work, epe.event_id, epe.email_text,\n                            \n                            CASE WHEN t.status_id NOT IN (" . TICKET_SOLVED_STATUS_ID . "," . TICKET_CLOSED_STATUS_ID . ")\n                                THEN epe.delay_time - time.active_work \n                                ELSE NULL\n                            END as deadline\n\n                            FROM \n                            (SELECT d3.ticket_id, SUM(TIMESTAMPDIFF(SECOND, d3.from, d3.to)) as 'active_work' \n                            \n                            FROM (\n                                SELECT th1.ticket_id, th1.created_at as 'from', CASE WHEN th2.created_at IS NULL THEN NOW() ELSE th2.created_at END as 'to'\n                                FROM tickets_history as th1\n                                LEFT JOIN tickets_history th2 ON (th1.id = th2.previous_id)\n                                WHERE th1.status_id IN (" . str_replace(":", ",", TICKETS_ACTIVE_STATUS_IDS) . ")\n                            ) as d3\n                            \n                            LEFT JOIN (\n                                SELECT th1.ticket_id, MAX(th2.created_at) as 'last_important_update'\n                                FROM tickets_history as th1\n                                LEFT JOIN tickets_history th2 ON (th2.previous_id = th1.id)\n                                WHERE (th1.level_id != th2.level_id OR th1.priority_id != th2.priority_id)\n                                GROUP BY th1.ticket_id\n                            ) as d4 ON (d4.ticket_id = d3.ticket_id AND d4.last_important_update > d3.from)\n                            AND d4.ticket_id IS NULL\n\n                            GROUP BY d3.ticket_id\n                            ) as time\n\n                            LEFT JOIN tickets t ON t.id = time.ticket_id\n                            LEFT JOIN companies c ON c.id = t.company_id\n                            LEFT JOIN escalation_profiles ep ON c.escalation_profile_id = ep.id\n                            LEFT JOIN escalation_profile_event epe ON (epe.priority_id = t.priority_id AND epe.level_id = t.level_id AND epe.profile_id = c.escalation_profile_id)\n\n                        ) as final");
     $tickets = Ticket::select("tickets.*", $raw1, $raw2, 'statuses.allowed_statuses', 'final.active_work', 'final.deadline', 'final.event_id', 'final.email_text');
     $tickets->leftJoin('company_person as creator_contacts', 'tickets.creator_id', '=', 'creator_contacts.id');
     $tickets->leftJoin('company_person as assignee_contacts', 'tickets.assignee_id', '=', 'assignee_contacts.id');
     $tickets->leftJoin('people as assignees', 'assignee_contacts.person_id', '=', 'assignees.id');
     $tickets->leftJoin('people as creators', 'creator_contacts.person_id', '=', 'creators.id');
     $tickets->leftJoin('divisions', 'tickets.division_id', '=', 'divisions.id');
     $tickets->leftJoin('levels', 'tickets.level_id', '=', 'levels.id');
     $tickets->leftJoin('statuses', 'tickets.status_id', '=', 'statuses.id');
     $tickets->leftJoin('priorities', 'tickets.priority_id', '=', 'priorities.id');
     $tickets->leftJoin('companies', 'tickets.company_id', '=', 'companies.id');
     $tickets->leftJoin($raw3, 'd1.ticket_id', '=', 'tickets.id');
     $tickets->leftJoin('posts', 'd1.post_id', '=', 'posts.id');
     $tickets->leftJoin($raw4, 'final.ticket_id', '=', 'tickets.id');
     if (Auth::check() && !Auth::user()->active_contact->isE80()) {
         $tickets->where("tickets.company_id", "=", Auth::user()->active_contact->company_id);
     }
     return $tickets;
 }
Exemplo n.º 8
0
 public function cleanUp()
 {
     $items = $this->getItems()->all();
     $items_removed = false;
     foreach ($items as $item) {
         $ticket = Ticket::findOne($item->ticket_id);
         if (!$ticket->isAvailable()) {
             $this->removeItem($item->ticket_id);
             $items_removed = true;
         } else {
             if ($ticket->getAvailableQuantity() !== false && $item->quantity > $ticket->getAvailableQuantity()) {
                 $this->updateItem($item->ticket_id, $ticket->getAvailableQuantity());
                 $items_removed = true;
             }
         }
     }
     if ($items_removed) {
         $session = new Session();
         $session->addError(Yii::t('app', 'Unavailable tickets removed'));
     }
 }
Exemplo n.º 9
0
 public function getReservesByDni(Request $request)
 {
     $dni = $request['dni'];
     if (strlen($dni) != 8 || !is_numeric($dni)) {
         return response()->json('El dni debe tener 8 digitos', 400);
     }
     $reservas = Ticket::where('designee', $dni)->whereNotNull('reserve')->lists('reserve')->unique();
     if ($reservas->isEmpty()) {
         return response()->json('No hay reservas con este dni', 400);
     }
     $arreglo = array();
     foreach ($reservas as $key => $value) {
         $tickets = Ticket::where('reserve', $value)->get();
         $arreglo[$key] = ['codigo' => $value, 'nombre' => $tickets->first()->event->name, 'cantidad' => $tickets->first()->quantity, 'zona' => $tickets->first()->zone->name, 'funcion' => date('d-m-Y', $tickets->first()->presentation->starts_at)];
     }
     return $arreglo;
 }
Exemplo n.º 10
0
 protected function create()
 {
     $params = Input::all();
     $ticket = Ticket::create($params);
     return $ticket;
 }
Exemplo n.º 11
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTickets()
 {
     return $this->hasMany(Ticket::className(), ['tiporrhh_idTipoRRHH' => 'idTipoRRHH']);
 }
Exemplo n.º 12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CancelledTicketRequest $request, $ticket_id)
 {
     $user_id = Auth::user()->id;
     $input = $request->all();
     if ($input['ticket_id'] != $ticket_id) {
         return redirect('salesman/devolutions');
     }
     $ticket = Ticket::findOrFail($input['ticket_id']);
     if ($ticket->cancelled == 1) {
         Session::flash('message', 'El ticket ya fue cancelado!');
         Session::flash('alert-class', 'alert-danger');
         return redirect('salesman/devolutions');
     }
     if ($ticket->presentation["cancelled"] == 0) {
         Session::flash('message', 'La presentation ' . $ticket->presentation_id . ' no fue cancelado, por lo tanto no se puede realizar devolución');
         Session::flash('alert-class', 'alert-danger');
         return redirect('/salesman/devolutions');
     }
     $module = Module::find(Auth::user()->module_id);
     if ($module->actual_cash < $ticket->total_price) {
         Session::flash('message', 'No tiene fondos en la caja para poder devolver');
         Session::flash('alert-class', 'alert-danger');
         return redirect('/salesman/devolutions');
     }
     $ticket->cancelled = 1;
     $ticket->save();
     $devolution = new Devolution();
     $devolution->ticket_id = $input['ticket_id'];
     $devolution->user_id = $user_id;
     $devolution->repayment = $ticket->total_price;
     if (isset($input['observation'])) {
         $devolution->observation = $input['observation'];
     }
     $devolution->save();
     Session::flash('message', 'Devolución realizado!');
     Session::flash('alert-class', 'alert-success');
     return redirect('/salesman/devolutions');
 }
Exemplo n.º 13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTickets()
 {
     return $this->hasMany(Ticket::className(), ['RRHH_idRRHH' => 'idRRHH']);
 }
Exemplo n.º 14
0
 /**
  * Display the specified resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function showSales()
 {
     $events = Event::all();
     $tickets = Ticket::all();
     $eventInformation = [];
     foreach ($events as $event) {
         // pueden ser muchos eventos. Necesito información para llenar la tabla
         $eventsDate = Presentation::where('event_id', '=', $event->id)->where('cancelled', '=', 0)->get();
         foreach ($eventsDate as $eventDate) {
             $tickets = Ticket::where('presentation_id', '=', $eventDate->id)->get();
             $onlineTickets = 0;
             $presentialTicket = 0;
             $subTotalOnline = 0;
             $subTotalPresential = 0;
             foreach ($tickets as $ticket) {
                 if ($ticket->cancelled != 1) {
                     if (empty($ticket->salesman_id)) {
                         $onlineTickets = $onlineTickets + $ticket->quantity;
                         $subTotalPresential = $subTotalPresential + $ticket->total_price;
                     } else {
                         $presentialTicket = $presentialTicket + $ticket->quantity;
                         $subTotalOnline = $subTotalOnline + $ticket->total_price;
                     }
                 }
             }
             array_push($eventInformation, array($event->name, $eventDate->id, date("d/m/Y", $eventDate->starts_at), $onlineTickets, $subTotalPresential, $presentialTicket, $subTotalOnline, $subTotalPresential + $subTotalOnline));
         }
     }
     //
     //return $eventInformation;
     return view('internal.admin.reports.sales', compact('eventInformation'));
 }
 /**
  * Finds the Ticket model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $idTicket
  * @param integer $MotivoTicket_idMotivoTicket
  * @param integer $RRHH_idRRHH
  * @param integer $tiporrhh_idTipoRRHH
  * @param integer $Transporte_idTransporte
  * @param integer $Transporte_TIpoTransporte_idTIpoTransporte
  * @param integer $Transporte_RRHH_idRRHH
  * @param integer $Transporte_tiporrhh_idTipoRRHH
  * @return Ticket the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($idTicket, $MotivoTicket_idMotivoTicket, $RRHH_idRRHH, $tiporrhh_idTipoRRHH, $Transporte_idTransporte, $Transporte_TIpoTransporte_idTIpoTransporte, $Transporte_RRHH_idRRHH, $Transporte_tiporrhh_idTipoRRHH)
 {
     if (($model = Ticket::findOne(['idTicket' => $idTicket, 'MotivoTicket_idMotivoTicket' => $MotivoTicket_idMotivoTicket, 'RRHH_idRRHH' => $RRHH_idRRHH, 'tiporrhh_idTipoRRHH' => $tiporrhh_idTipoRRHH, 'Transporte_idTransporte' => $Transporte_idTransporte, 'Transporte_TIpoTransporte_idTIpoTransporte' => $Transporte_TIpoTransporte_idTIpoTransporte, 'Transporte_RRHH_idRRHH' => $Transporte_RRHH_idRRHH, 'Transporte_tiporrhh_idTipoRRHH' => $Transporte_tiporrhh_idTipoRRHH])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 16
0
 public static function sendTicketUpdate($id)
 {
     $ticket = Ticket::find($id);
     self::setSubject("Ticket Update | Ticket #" . $ticket->id . " | " . $ticket->anchestor(0)->changer->person->name());
     self::$view = "emails/ticket_update";
     self::$data['title'] = "Ticket #" . $ticket->id . " details changed by " . $ticket->anchestor(0)->changer->person->name();
     self::$data['ticket'] = $ticket;
     self::add('to', $ticket->assignee->email);
     $additional_emails = explode(",", $ticket->emails);
     foreach ($additional_emails as $email) {
         self::add('to', $email);
     }
     self::send();
     Activity::log("Email Ticket Update Send", self::$data);
 }
Exemplo n.º 17
0
 public function repay(Request $request)
 {
     $input = $request->all();
     $ticketId = $input['ticket_id'];
     $ticket = Ticket::find($ticketId);
     if ($ticket == null) {
         Session::flash('message', 'Este ticket no existe');
         return redirect('salesman/devolutions');
     }
     return redirect('salesman/devolutions/new/' . $ticketId);
 }
Exemplo n.º 18
0
 public function getTickets()
 {
     return $this->hasMany(Ticket::className(), ['type_id' => 'id']);
 }
Exemplo n.º 19
0
 /**
  * Finds the Ticket model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Ticket the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Ticket::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 20
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTickets()
 {
     return $this->hasMany(Ticket::className(), ['Transporte_idTransporte' => 'idTransporte', 'Transporte_TIpoTransporte_idTIpoTransporte' => 'TIpoTransporte_idTIpoTransporte', 'Transporte_RRHH_idRRHH' => 'RRHH_idRRHH', 'Transporte_tiporrhh_idTipoRRHH' => 'tiporrhh_idTipoRRHH']);
 }
Exemplo n.º 21
0
 public function getTicket()
 {
     return $this->hasOne(Ticket::className(), ['id' => 'ticket_id']);
 }
Exemplo n.º 22
0
 protected function tickets()
 {
     return Ticket::select(['*', DB::raw('id_user_assigned AS assigned_to_name'), DB::raw('status AS status_name')])->get();
 }