Add a time off history entry

@param string $employeeId
@param string $requestId
@param string $date
@param string $note

@return \BambooHR\Api\Response
4481
public function addHistoryEntry($employeeId, $requestId, string $date, string $note)
    {
        $xml = "
            <history>
                <date>{$date}</date>
                <eventType>used</eventType>
                <timeOffRequestId>{$requestId}</timeOffRequestId>
                <note>{$note}</note>
            </history>
        ";

        $this->put("employees/{$employeeId}/time_off/history", $xml);
    }
801863
protected void addUserDateCreated(CmsSetupDb dbCon) throws SQLException {

        System.out.println(new Exception().getStackTrace()[0].toString());
        // Add the column to the table if necessary
        if (!dbCon.hasTableOrColumn(CMS_USERS_TABLE, USER_DATECREATED)) {
            String addUserDateCreated = readQuery(QUERY_ADD_USER_DATECREATED_COLUMN);
            dbCon.updateSqlStatement(addUserDateCreated, null, null);

            String setUserDateCreated = readQuery(QUERY_SET_USER_DATECREATED);
            List<Object> param = new ArrayList<Object>();
            // Set the creation date to the current time
            param.add(new Long(System.currentTimeMillis()));

            dbCon.updateSqlStatement(setUserDateCreated, null, param);
        } else {
            System.out.println("column " + USER_DATECREATED + " in table " + CMS_USERS_TABLE + " already exists");
        }
    }
1219490
private function computeTimeForUserAndWorkspace($startDate, $userId, $workspaceId, $time)
    {
        // select first "out of this workspace event" (ie "workspace enter" on another workspace)
        $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid  AND date_log > :dateLog ORDER BY date_log ASC LIMIT 1";
        $stmt = $this->em->getConnection()->prepare($sql);
        $stmt->bindValue('uid', $userId);
        $stmt->bindValue('dateLog', $startDate);
        $stmt->execute();
        $action = $stmt->fetch();

        // if there is an action we can compute time
        if ($action['date_log']) {
            $t1 = strtotime($startDate);
            $t2 = strtotime($action['date_log']);
            $seconds = $t2 - $t1;

            // add time only if bewteen 30s and 2 hours <= totally arbitrary !
            if ($seconds > 5 && ($seconds / 60) <= 120) {
                $time += $seconds;
            }
            // get next "enter the requested workspace enter event"
            $sql = "SELECT date_log FROM claro_log WHERE action LIKE 'workspace-enter' AND doer_id = :uid AND date_log > :dateLog AND workspace_id = :wid ORDER BY date_log ASC LIMIT 1";
            $stmt = $this->em->getConnection()->prepare($sql);
            $stmt->bindValue('uid', $userId);
            $stmt->bindValue('dateLog', $action['date_log']);
            $stmt->bindValue('wid', $workspaceId);
            $stmt->execute();
            $nextEnterEvent = $stmt->fetch();
            // if there is an "enter-workspace" action after the current one recall the method
            if ($nextEnterEvent['date_log']) {
                return $this->computeTimeForUserAndWorkspace($nextEnterEvent['date_log'], $userId, $workspaceId, $time);
            } else {
                return $time;
            }
        }

        return $time;
    }
279169
protected function PostLoginHookMergeTemporaryNoticeListWithDatabaseHistory()
    {
        // merge current notice list with existing notice list
        $aNoticeList = $this->GetNoticeListArticles();
        $aTmpList = array_reverse($aNoticeList, true);
        foreach (array_keys($aTmpList) as $iArticleId) {
            if (is_null($aTmpList[$iArticleId]->id)) {
                // check if the user has such an item on the list... if he does, no change
                $oItem = TdbShopUserNoticeList::GetNewInstance();
                /** @var $oItem TdbShopUserNoticeList */
                if (!$oItem->LoadFromFields(array('data_extranet_user_id' => $this->id, 'shop_article_id' => $iArticleId))) {
                    $aData = $aTmpList[$iArticleId]->sqlData;
                    $aData['data_extranet_user_id'] = $this->id;
                    $aTmpList[$iArticleId]->LoadFromRow($aData);
                    $aTmpList[$iArticleId]->AllowEditByAll(true);
                    $aTmpList[$iArticleId]->Save();
                }
            }
        }
        $this->aNoticeList = null;
        $this->GetNoticeListArticles();
        // remove items from cookie...
        $domain = TCMSSmartURLData::GetActive()->sOriginalDomainName;
        if ('www.' == substr($domain, 0, 4)) {
            $domain = substr($domain, 4);
        }
        setcookie(TdbDataExtranetUser::COOKIE_NAME_NOTICELIST, '', time() - 3600, '/', '.'.$domain, false, true);
    }
1252245
public function DismissAnnouncement($DiscussionID, $UserID) {
      $Count = $this->SQL
         ->Select('UserID')
         ->From('UserDiscussion')
         ->Where('DiscussionID', $DiscussionID)
         ->Where('UserID', $UserID)
         ->Get()
         ->NumRows();
         
      $CountComments = $this->SQL
         ->Select('CountComments')
         ->From('Discussion')
         ->Where('DiscussionID', $DiscussionID)
         ->Get()
         ->FirstRow()
         ->CountComments;
      
      if ($Count > 0) {
         $this->SQL
            ->Update('UserDiscussion')
            ->Set('CountComments', $CountComments)
            ->Set('DateLastViewed', Gdn_Format::ToDateTime())
            ->Set('Dismissed', '1')
            ->Where('DiscussionID', $DiscussionID)
            ->Where('UserID', $UserID)
            ->Put();
      } else {
         $this->SQL->Options('Ignore', TRUE);
         $this->SQL->Insert(
            'UserDiscussion',
            array(
               'UserID' => $UserID,
               'DiscussionID' => $DiscussionID,
               'CountComments' => $CountComments,
               'DateLastViewed' => Gdn_Format::ToDateTime(),
               'Dismissed' => '1'
            )
         );
      }
   }
83765
public static function updateNote(
        int $object_id, int $note_id, string $title = null, string $note = null)
    {

        $note_record = Note::where('object_type', __CLASS__)
            ->where('object_id', $object_id)
            ->where('id', $note_id)
            ->first();

        if (! is_null($title))
            $note_record->title = $title;

        if (! is_null($note))
            $note_record->note = $note;

        $note_record->save();

    }
1008277
def add_time_stamp(self, db_id, name):
        """"""
        with self.lock:
            self.cur.execute(
                'insert into "timestamps" ("job", "what")'
                'values (?, ?);', (db_id, name))
132783
public function performQuery(string $viewId, DateTime $startDate, DateTime $endDate, string $metrics, array $others = [])
    {
        $cacheName = $this->determineCacheName(func_get_args());

        if ($this->cacheLifeTimeInMinutes == 0) {
            $this->cache->forget($cacheName);
        }

        return $this->cache->remember($cacheName, $this->cacheLifeTimeInMinutes, function () use ($viewId, $startDate, $endDate, $metrics, $others) {
            $result = $this->service->data_ga->get(
                "ga:{$viewId}",
                $startDate->format('Y-m-d'),
                $endDate->format('Y-m-d'),
                $metrics,
                $others
            );

            while ($nextLink = $result->getNextLink()) {
                if (isset($others['max-results']) && count($result->rows) >= $others['max-results']) {
                    break;
                }

                $options = [];

                parse_str(substr($nextLink, strpos($nextLink, '?') + 1), $options);

                $response = $this->service->data_ga->call('get', [$options], 'Google_Service_Analytics_GaData');

                if ($response->rows) {
                    $result->rows = array_merge($result->rows, $response->rows);
                }

                $result->nextLink = $response->nextLink;
            }

            return $result;
        });
    }
160037
protected function get_graded_date($contextid, $userid, $checkfeedback = false) {
        if (empty($this->grades[$contextid][$userid])) {
            return false;
        }
        foreach ($this->grades[$contextid][$userid] as $gradeitemid => $gradeitem) {

            // We check that either feedback or the grade is set.
            if (($checkfeedback && $gradeitem->feedback) || $gradeitem->grade) {

                // Grab the first graded date.
                if ($gradeitem->dategraded && (empty($after) || $gradeitem->dategraded < $after)) {
                    $after = $gradeitem->dategraded;
                }
            }
        }

        if (!isset($after)) {
            // False if there are no graded items.
            return false;
        }

        return $after;
    }
1192919
public function addLog ( $keys, $received, $sent, $base_string, $notes, $user_id = null )
    {
        $args = array();
        $ps   = array();
        foreach ($keys as $key => $value)
        {
            $args[] = $value;
            $ps[]   = "olg_$key = '%s'";
        }

        if (!empty($_SERVER['REMOTE_ADDR']))
        {
            $remote_ip = $_SERVER['REMOTE_ADDR'];
        }
        else if (!empty($_SERVER['REMOTE_IP']))
        {
            $remote_ip = $_SERVER['REMOTE_IP'];
        }
        else
        {
            $remote_ip = '0.0.0.0';
        }

        // Build the SQL
        $ps['olg_received']    = "'%s'";                        $args[] = $this->makeUTF8($received);
        $ps['olg_sent']        = "'%s'";                        $args[] = $this->makeUTF8($sent);
        $ps['olg_base_string'] = "'%s'";                        $args[] = $base_string;
        $ps['olg_notes']       = "'%s'";                        $args[] = $this->makeUTF8($notes);
        $ps['olg_usa_id_ref'] = "NULLIF('%d', '0')";            $args[] = $user_id;
        $ps['olg_remote_ip']  = "NULLIF('%s','0.0.0.0')";        $args[] = $remote_ip;

        $this->query('
            INSERT INTO oauth_log ('.implode(',', array_keys($ps)) . ')
            VALUES(' . implode(',', $ps) . ')',
            $args
        );
    }
568052
public function assignedPolicies($employeeId)
    {
        $this->bamboo->options['version'] = 'v1_1';

        $response = $this->get("employees/{$employeeId}/time_off/policies");

        $this->bamboo->options['version'] = 'v1';

        return $response;
    }
357206
public function addComment(EntityInterface $entity, string $comment, string $userId = null): ModelHistory
    {
        $add = $this->add($entity, ModelHistory::ACTION_COMMENT, $userId, [
            'data' => [
                'comment' => $comment
            ]
        ]);

        return $add;
    }
651075
public function listMethod($employee_id)
    {
        $result = $this->listMethodInternal(compact('employee_id'));
        $statusCode = (int)$result[ 'statusCode' ];

        if ($statusCode === 200) {
            return $this->getResultAsArrayWithoutStatusCode($result);
        }

        $this->reportUnexpectedResponse($result, 1541006346);
    }
425216
public function getEmployee($employeeId)
    {
        $result = null;
        $this->addHeader();
        try {
            $employee = $this->getSoap()->GetAcsEmployee([
                'id' => $employeeId
            ]);
            if (isset($employee->GetAcsEmployeeResult)) {
                $result = new Employee((array)$employee->GetAcsEmployeeResult);
            }
        } catch (\SoapFault $ex) {
            $result = false;
            $this->logError();
        }
        return $result;
    }
995233
function _doVoid($oID, $note = '') {
    global $db, $messageStack;

    $new_order_status = (int)MODULE_PAYMENT_AUTHORIZENET_AIM_REFUNDED_ORDER_STATUS_ID;
    if ($new_order_status == 0) $new_order_status = 1;
    $voidNote = strip_tags(zen_db_input($_POST['voidnote'] . $note));
    $voidAuthID = trim(strip_tags(zen_db_input($_POST['voidauthid'])));
    $proceedToVoid = true;
    if (isset($_POST['ordervoid']) && $_POST['ordervoid'] == MODULE_PAYMENT_AUTHORIZENET_AIM_ENTRY_VOID_BUTTON_TEXT) {
      if (isset($_POST['voidconfirm']) && $_POST['voidconfirm'] != 'on') {
        $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_VOID_CONFIRM_ERROR, 'error');
        $proceedToVoid = false;
      }
    }
    if ($voidAuthID == '') {
      $messageStack->add_session(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_TRANS_ID_REQUIRED_ERROR, 'error');
      $proceedToVoid = false;
    }
    // Populate an array that contains all of the data to be sent to gateway
    $submit_data = array('x_type' => 'VOID',
                         'x_trans_id' => trim($voidAuthID) );
    /**
     * Submit void request to Gateway
     */
    if ($proceedToVoid) {
      $response = $this->_sendRequest($submit_data);
      $response_code = $response[0];
      $response_text = $response[3];
      $response_alert = $response_text . ($this->commError == '' ? '' : ' Communications Error - Please notify webmaster.');
      $this->reportable_submit_data['Note'] = $voidNote;
      $this->_debugActions($response);

      if ($response_code != '1' || ($response[0]==1 && $response[2] == 310) ) {
        $messageStack->add_session($response_alert, 'error');
      } else {
        // Success, so save the results
        $sql_data_array = array('orders_id' => (int)$oID,
                                'orders_status_id' => (int)$new_order_status,
                                'date_added' => 'now()',
                                'comments' => 'VOIDED. Trans ID: ' . $response[6] . ' ' . $response[4] . "\n" . $voidNote,
                                'customer_notified' => 0
                             );
        zen_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array);
        $db->Execute("update " . TABLE_ORDERS  . "
                      set orders_status = '" . (int)$new_order_status . "'
                      where orders_id = '" . (int)$oID . "'");
        $messageStack->add_session(sprintf(MODULE_PAYMENT_AUTHORIZENET_AIM_TEXT_VOID_INITIATED, $response[6], $response[4]), 'success');
        return true;
      }
    }
    return false;
  }
794143
public function getHistory(int $userId, int $id = null)
    {
        $params = $this->getQueryParams();
        $uriAppend = "history/{$userId}" . (!is_null($id) ? "/{$id}" : '');
        $response = $this->handler->handle('GET', false, $uriAppend, $params);

        return $this->make($response, true, new OrdersMaker());
    }
1259569
public static function get_user_dates($contextid, $contextlevel, $instanceid, $timestamps) {
        $params = self::validate_parameters(
            self::get_user_dates_parameters(),
            [
                'contextid' => $contextid,
                'contextlevel' => $contextlevel,
                'instanceid' => $instanceid,
                'timestamps' => $timestamps,
            ]
        );

        $context = self::get_context_from_params($params);
        self::validate_context($context);

        $formatteddates = array_map(function($timestamp) {
            return userdate($timestamp['timestamp'], $timestamp['format']);
        }, $params['timestamps']);

        return ['dates' => $formatteddates];
    }