예제 #1
0
 /**
  * Lists all tickets and travels for currentInvoice model.
  * @param integer $id
  * @return mixed
  */
 public function actionInvoice($id)
 {
     $model = $this->findModel($id);
     $tickets = new ActiveDataProvider(['query' => $model->currentInvoice->getTickets()->closed(true)->totals(), 'pagination' => false, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     $travels = new ActiveDataProvider(['query' => $model->currentInvoice->getTravels()->before()->fee()->with('schedule.tech'), 'key' => 'schedule_id', 'pagination' => false, 'sort' => ['attributes' => ['schedule.start_time' => ['asc' => [Schedule::tableName() . '.start_time' => SORT_ASC], 'desc' => [Schedule::tableName() . '.start_time' => SORT_DESC]]], 'defaultOrder' => ['schedule.start_time' => SORT_ASC]]]);
     Url::remember();
     return $this->render('invoice', ['model' => $model, 'tickets' => $tickets, 'travels' => $travels, 'laborTotal' => Labor::find()->ticket($tickets->keys)->total(), 'billableLaborTotal' => Labor::find()->ticket($tickets->keys)->hourly()->total(true), 'purchaseTotal' => PurchasedItem::find()->ticket($tickets->keys)->total(), 'travelFeeTotal' => Travel::find()->invoice($id)->before()->totalFee(), 'travelMilesTotal' => Travel::find()->invoice($id)->before()->totalMiles()]);
 }
예제 #2
0
 public function actionTest($id)
 {
     $model = self::findModel($id);
     $tickets = new ActiveDataProvider(['query' => $model->getTickets()->closed()->totals()->with(['notes.labor', 'notes.author']), 'pagination' => false, 'sort' => false]);
     $travels = new ActiveDataProvider(['query' => $model->getTravels()->fee()->with('schedule.tech'), 'pagination' => false, 'sort' => false]);
     $mPDF = new Pdf(['destination' => Pdf::DEST_BROWSER]);
     $mPDF->content = $this->renderPartial('_pdf-template', ['model' => $model, 'tickets' => $tickets, 'travels' => $travels, 'billableLaborTotal' => Labor::find()->ticket($tickets->keys)->hourly()->total(true), 'purchaseTotal' => PurchasedItem::find()->ticket($tickets->keys)->total(), 'travelFeeTotal' => Travel::find()->invoice($id)->totalFee(), 'mPDF' => $mPDF]);
     Yii::$app->response->format = Response::FORMAT_RAW;
     Yii::$app->response->headers->set('Content-Type', 'application/pdf');
     return $mPDF->render();
 }