public function actionPrint($ticket_id) { $this->layout = 'clean'; $ticket = tickets::find()->where(['id' => $ticket_id, 'open_user_id' => Yii::$app->user->id])->one(); if ($ticket) { return $this->render('print', ['ticket' => $ticket]); } else { echo 'Неверный номер заявки'; } }
public function actionGetTickets($date) { if (!$date || $date == date('Y-m-d')) { $date = date('Y-m-d'); //echo $date; $tickets = tickets::find()->where(['close_date' => $date, 'closed' => 1])->orWhere(['closed' => 0])->orderBy('closed DESC')->all(); } else { $tickets = tickets::find()->where(['close_date' => $date, 'closed' => 1])->orWhere(['closed' => 0])->orderBy('closed DESC')->addOrderBy('open_date DESC')->all(); } // ---------------------------------- новая заявка --------------------------------------------------------------------- echo '<div class="panel panel-default" id = "add_ticket_panel"> <div class="panel-heading" data-toggle="collapse" data-parent="#tickets" href="#collapseAddTicketPanel"> <table style = "width : 100%;"> <tr> <td style = "width : 25%; text-align : center;"> Добавить заявку </td> </tr> </table> </div> <div id="collapseAddTicketPanel" class="panel-collapse collapse"> <div class="panel-body"> <table style = "width : 100%"> <tr> <td>Текст заявки</td> </tr> <tr> <td> <textarea class = "form-control" id = "add_ticket_text"></textarea> </td> </tr> <tr> <td colspan = "2" style = "text-align : center"> <div class="btn-group" role = "group" style = "margin-top : 15px;"> <button class = "btn btn-default" id = "add_ticket_button">Добавить</button> </div> </td> </tr> </table> </div> </div> </div>'; // ---------------------------------- новая заявка (КОНЕЦ) --------------------------------------------------------------------- //-------------------------------- Список заявок ---------------------------------------------------------- foreach ($tickets as $ticket) { switch ($ticket->closed) { case 0: $panel_class = 'panel-warning'; $close_text = 'Открыта'; $close_user = ''; $close_date = ''; break; case 1: $panel_class = 'panel-success'; $close_text = 'Закрыта'; $close_user = $ticket->closeusername->name; $close_date = $ticket->close_date; break; } echo ' <div class="panel ' . $panel_class . '" id = "' . $ticket->id . '"> <div class="panel-heading" data-toggle="collapse" data-parent="#tickets" href="#collapse' . $ticket->id . '"> <table style = "width : 100%;"> <tr> <td style = "width : 25%"> <div>№ ' . $ticket->id . '</div> <div>' . $ticket->open_date . '</div> <div>' . $ticket->openusername->name . '</div> </td> <td style = "width : 50%"> <div>' . $ticket->open_text . '</div> </td> <td> <div>' . $close_text . '</div> <div>' . $close_user . '</div> <div>' . $close_date . '</div> </td> </tr> </table> </div> <div id="collapse' . $ticket->id . '" class="panel-collapse collapse"> <div class="panel-body"> <table style = "width : 100%"> <tr> <td>Текст заявки</td> <td>Комментарий</td> </tr> <tr> <td> <textarea class = "form-control">' . $ticket->open_text . '</textarea> </td> <td> <textarea id = "ticket_comment_' . $ticket->id . '" class = "form-control">' . $ticket->close_text . '</textarea> </td> </tr> <tr> <td>' . $ticket->openusername->name . '</td> <td>' . $close_user . '</td> </tr> <tr> <td colspan = "2" style = "text-align : center"> <div class="btn-group" role = "group" style = "margin-top : 15px;"> <button class = "btn btn-default" onClick = "save_ticket_comment(' . $ticket->id . ')">Сохранить комментарий</button> <button class = "btn btn-default" onClick = "save_ticket(' . $ticket->id . ')">Изменить статус</button> </div> </td> </tr> </table> </div> </div> </div>'; } }