<?php
require_once DAO . 'ConditionDao.php';
require_once DAO . 'ContentDao.php';
require_once DAO . 'CompensationDao.php';
require_once DTO . 'OfferDto.php';
final class Preview extends Action {
  private $dto;
  public function __construct() {
    $this->checkAccess();
    $this->dto = new OfferDto();
  }
  protected function getDto() {
    return $this->dto;
  }
  public function index() {
    if (!empty($this->dto->condition[0])) {
      $dao = new ConditionDao();
      $result = $dao->getNameList(implode(',', $this->dto->condition));
      while ($row = mysql_fetch_assoc($result)) {
        $this->dto->conditionList .= $row['condition_name'] . '&nbsp;<span style="color: #0000FF;">／</span>&nbsp;';
        $this->dto->conditions[] = $row['condition_name'];
      }
    }
    if (!empty($this->dto->outline[0])) {
      $dao = new ContentDao();
      $result = $dao->getNameList(implode('),(', $this->dto->outline));
      while ($row = mysql_fetch_assoc($result)) {
        $this->dto->outlineList[$row['occupation_name']][$row['category_name']][] = $row['content_name'];
      }
    }
    if (!empty($this->dto->compensation[0])) {
      $dao = new CompensationDao();
      $result = $dao->getNameList(implode(',', $this->dto->compensation));
      while ($row = mysql_fetch_assoc($result)) {
        $this->dto->compensations[] = $row['compensation_name'];
      }
    }
    return new forward();
  }
}
// EOF.
