/**
     * Update an application status model
     *
     * @param ApplicationStatusModel $model
     * @see ControllerBase::update()
     */
    public function update($model)
    {
        if ($model->validateForUpdate()) {
            try {
                $query = <<<SQL
UPDATE applicationStatus
   SET statusValue = ?
     , isActive = ?
     , sortKey = ?
     , style = ?
 WHERE id = ?
SQL;
                $id = $model->getId();
                $statusValue = $model->getStatusValue();
                $isActive = $model->getIsActive();
                $sortKey = $model->getSortKey();
                $style = $model->getStyle();
                $stmt = $this->_dbh->prepare($query);
                if (!$stmt) {
                    throw new ControllerException('Prepared statement failed for ' . $query);
                }
                if (!$stmt->bind_param('siisi', $statusValue, $isActive, $sortKey, $style, $id)) {
                    throw new ControllerException('Binding parameters for prepared statement failed.');
                }
                if (!$stmt->execute()) {
                    throw new ControllerException('Failed to execute UPDATE statement. (' . $this->_dbh->error . ')');
                }
                /**
                 * @SuppressWarnings checkAliases
                 */
                if (!$stmt->close()) {
                    throw new ControllerException('Something broke while trying to close the prepared statement.');
                }
                return $id;
            } catch (Exception $e) {
                throw new ControllerException($e->getMessage());
            }
        } else {
            throw new ControllerException("Invalid data.");
        }
    }
    /**
     * Return the display of an application status table row
     *
     * @param ApplicationStatusModel $applicationStatusModel
     * @param string $displayMode 'add', 'edit', 'delete', 'list'
     * @return string
     */
    public function displayApplicationStatusRow($applicationStatusModel, $displayMode)
    {
        $id = $applicationStatusModel->getId();
        $statusValue = $applicationStatusModel->getStatusValue();
        $style = $applicationStatusModel->getStyle();
        $isActive = $applicationStatusModel->getIsActive();
        $isActiveChecked = $isActive ? "checked=\"checked\"" : "";
        $isActiveDisplay = $isActive ? "Yes" : "No";
        $sortKey = $applicationStatusModel->getSortKey();
        $created = $applicationStatusModel->getCreated();
        $updated = $applicationStatusModel->getUpdated();
        switch ($displayMode) {
            case 'add':
                return <<<RETVAL
      <td><button type="button" id="SaveButtonix{$id}" onclick="saveAddApplicationStatus( '{$id}' )">Save</button>
          <button type="button" id="CancelButtonix{$id}" onclick="deleteRow( 'ix{$id}' )">Cancel</button>
      </td>
      <td><input type="text" id="statusValueix{$id}" value="{$statusValue}" /></td>
      <td><input type="text" id="styleix{$id}" value="{$style}" /></td>
      <td><input type="checkbox" id="isActiveix{$id}" {$isActiveChecked} /></td>
      <td><input type="text" id="sortKeyix{$id}" value="{$sortKey}" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>

RETVAL;
            case 'update':
                return <<<RETVAL
      <td><button type="button" id="SaveButton{$id}" onclick="saveUpdateApplicationStatus( '{$id}' )">Save</button>
          <button type="button" id="CancelButton{$id}" onclick="cancelUpdateApplicationStatusRow( '{$id}' )">Cancel</button>
      </td>
      <td><input type="text" id="statusValue{$id}" value="{$statusValue}" /></td>
      <td><input type="text" id="style{$id}" value="{$style}" /></td>
      <td><input type="checkbox" id="isActive{$id}" {$isActiveChecked} /></td>
      <td><input type="text" id="sortKey{$id}" value="{$sortKey}" /></td>
      <td>{$created}</td>
      <td>{$updated}</td>

RETVAL;
            case 'delete':
                return <<<RETVAL
      <td><button type="button" id="DeleteButton{$id}" onclick="doDeleteApplicationStatus( '{$id}' )">Confirm Delete</button>
          <button type="button" id="CancelButton{$id}" onclick="cancelUpdateApplicationStatusRow( '{$id}' )">Cancel</button>
      </td>
      <td>{$statusValue}</td>
      <td>{$style}</td>
      <td>{$isActiveDisplay}</td>
      <td>{$sortKey}</td>
      <td>{$created}</td>
      <td>{$updated}</td>

RETVAL;
            case 'list':
                return <<<RETVAL
      <td><button type="button" id="UpdateButton{$id}" onclick="updateApplicationStatus( '{$id}' )">Update</button>
          <button type="button" id="DeleteButton{$id}" onclick="deleteApplicationStatus( '{$id}' )">Delete</button>
      </td>
      <td style="{$style}">{$statusValue}</td>
      <td>{$style}</td>
      <td>{$isActiveDisplay}</td>
      <td>{$sortKey}</td>
      <td>{$created}</td>
      <td>{$updated}</td>

RETVAL;
        }
        return "";
    }