예제 #1
0
 /**
  * @param TimeCard $inTimeCard
  *
  * @return bool
  *
  * @internal param TimeCard $timeCard
  */
 public static function doesTimeCardExist(TimeCard &$inTimeCard)
 {
     $timeCard = self::where('iso_beginning_dow_date', '=', $inTimeCard->getIsoBeginningDowDate())->where('work_id', '=', $inTimeCard->getWorkId())->first();
     if (is_null($timeCard)) {
         return false;
     } else {
         $inTimeCard = $timeCard;
         return true;
     }
 }
예제 #2
0
 /**
  * @param $timeCardRows
  * @param $iso_beginning_dow_date
  *
  * @return array
  */
 public static function deriveTimeCardHoursWorkedFromBeginningAndEndingWeekDates($timeCardRows, $iso_beginning_dow_date)
 {
     $hoursWorkedPerWorkId = [];
     // populate the time_card_hours_worked data by $timeCardRow->id.
     foreach ($timeCardRows as $timeCardRow) {
         $hoursWorkedPerWorkId = TimeCard::getHoursWorkedForTimeCard($iso_beginning_dow_date, $timeCardRow, $hoursWorkedPerWorkId);
     }
     return $hoursWorkedPerWorkId;
 }
예제 #3
0
 /**
  * Register any other events for your application.
  *
  * @param  \Illuminate\Contracts\Events\Dispatcher  $events
  * @return void
  */
 public function boot(DispatcherContract $events)
 {
     parent::boot($events);
     // register the ProjectObserver class.
     Client::observe(new ClientObserver());
     // register the ProjectObserver class.
     Project::observe(new ProjectObserver());
     // register the WorkTypeObserver class.
     WorkType::observe(new WorkTypeObserver());
     // register the TimeCardFormatObserver class.
     TimeCardFormat::observe(new TimeCardFormatObserver());
     // register the WorkObserver class.
     Work::observe(new WorkObserver());
     // register the TimeCardObserver class.
     TimeCard::observe(new TimeCardObserver());
     // register the TimeCardHoursWorkedObserver class.
     TimeCardHoursWorked::observe(new TimeCardHoursWorkedObserver());
     // register the TaskTypeObserver class.
     TaskType::observe(new TaskTypeObserver());
     // register the TaskObserver class.
     Task::observe(new TaskObserver());
 }
예제 #4
0
 /**
  * @param $timeCardRange
  * @param $timeCardRequestAttributes
  *
  * @return TimeCard
  */
 protected function saveTimeCard($timeCardRange, $timeCardRequestAttributes)
 {
     $timeCard = new TimeCard();
     $timeCard->setIsoBeginningDowDate(appGlobals::getBeginningOfCurrentWeek($timeCardRange));
     $timeCard->setWorkId($this->getWorkIdViaWorkTypeId($timeCardRequestAttributes['workType']));
     $timeCard->setTimeCardFormatId($this->getTimeCardFormatId($this->getClientId($timeCardRequestAttributes['workType'])));
     if ($timeCard->rowExists()) {
         $timeCard = $timeCard->row;
     }
     $timeCard->save();
     return $timeCard;
 }
예제 #5
0
    $timeCardFormat = TimeCardFormat::where('description', '=', $description)->first();
    for ($j = 0; $j < appGlobals::DAYS_IN_WEEK_NUM; $j++) {
        $pos = $timeCardFormat->{"dow_0" . $j};
        echo "For {$pos} the hours worked are: " . $myArray[$pos] . "<br>";
    }
});
Route::get('task_fail', function () {
    $startTime = '17:00:00';
    $endTime = '12:00:00';
    $hoursWorked = 5.0;
    $notes = "error testing";
    if (is_null($task = Task::checkIfExists($startTime))) {
        // get $taskType->id
        $taskType = TaskType::where('type', '=', 'Code')->first();
        // get $timeCard->id
        $timeCard = TimeCard::where('date_worked', '=', '2015-11-12')->first();
        $task = new Task();
        $task->start_time = $startTime;
        $task->end_time = $endTime;
        $task->hours_worked = $hoursWorked;
        $task->notes = $notes;
        $task->task_type_id = $taskType->id;
        $task->time_card_id = $timeCard->id;
        try {
            $task->save();
        } catch (QueryException $e) {
            if ($e->getCode() == appGlobals::TBL_TASK_START_TIME_GT_END_TIME) {
                appGlobals::reportError($e, __FILE__, __LINE__);
            }
        }
    }