示例#1
0
 public function unscheduled()
 {
     // Get a list of all ticket IDs scheduled in the next 2 weeks
     $scheduled = Schedule::find()->joinWith('labors.note', false)->select(Note::tableName() . '.ticket_id')->between(new Expression('NOW()'), date('Y-m-d', strtotime('+14 days')));
     // return tickets not in that list
     $this->andWhere(['not in', Ticket::tableName() . '.id', $scheduled])->joinWith('invoice.location.client')->orderBy([Client::tableName() . '.name' => SORT_ASC, Location::tableName() . '.name' => SORT_ASC, Ticket::tableName() . '.id' => SORT_ASC]);
     return $this;
 }
示例#2
0
 /**
  * @param integer $tech_id
  * @param string $start
  * @param string $end
  * @return mixed
  *
  */
 public function actionAjaxEvents($tech_id, $start, $end)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $events = [];
     $schedules = Schedule::find()->tech($tech_id)->between($start, $end)->with(['invoice.location.client', 'labors.note.ticket', 'travel'])->all();
     foreach ($schedules as $schedule) {
         $event = $events[] = new Event();
         $event->id = $schedule->id;
         //$event->resourceId = $tech_id;
         $event->title = $schedule->invoice->location->fullName . "\n" . implode(', ', ArrayHelper::getColumn($schedule->labors, 'note.ticket.shortName'));
         $event->description = implode("\n", ArrayHelper::getColumn($schedule->labors, 'note.ticket.fullName')) . "\n\n" . $schedule->description;
         $event->start = $schedule->start_time;
         $event->end = $schedule->endTime;
         $event->url = Url::to(['schedule/view', 'id' => $schedule->id]);
         $event->className = ['showModalButton', $schedule->onSite ? 'on-site' : 'remote'];
         if ($schedule->future()) {
             $event->className[] = 'future';
             $event->startEditable = true;
             $event->durationEditable = true;
         } else {
             $event->className[] = $schedule->needsUpdate() ? 'overdue' : 'past';
         }
     }
     return $events;
 }
示例#3
0
<?php

use common\models\Relationship;
use kartik\datetime\DateTimePicker;
use kartik\select2\Select2;
$this->title = 'Lịch làm việc';
$this->params['breadcrumbs'][] = $this->title;
$listE = \common\models\Schedule::find()->where(['own_id' => Yii::$app->user->getId()])->asArray()->all();
$events = array();
foreach ($listE as $item) {
    $event = new \yii2fullcalendar\models\Event();
    $event->id = $item['id'];
    $event->title = $item['title'];
    $event->start = date($item['start']);
    $event->end = date($item['end']);
    $event->color = $item['color'];
    $events[] = $event;
}
$sql = 'SELECT * FROM relationship WHERE ((user_id_1=:user_id)
                  OR (user_id_2=:user_id)) AND status=1';
$arrRelationship = Relationship::findBySql($sql, [':user_id' => Yii::$app->user->getId()])->asArray()->all();
$arrUserName = array();
foreach ($arrRelationship as $rel) {
    if ($rel['user_id_1'] == Yii::$app->user->getId()) {
        $arrUserName[$rel['user_id_2']] = \common\models\User::findOne(['id' => $rel['user_id_2']])->username;
    } else {
        $arrUserName[$rel['user_id_1']] = \common\models\User::findOne(['id' => $rel['user_id_1']])->username;
    }
}
?>