You are here

function _weather_es_main in Weather_es 7

Main weather_es_page. Show the cities you want to know the weather if there're selected...

@author jmsirvent

1 string reference to '_weather_es_main'
weather_es_menu in ./weather_es.module
hook_menu

File

./weather_es.module, line 747

Code

function _weather_es_main($wid) {
  $path = _weather_es_redirect($wid);

  // Table header
  $header = array(
    array(
      'data' => t('City'),
      'field' => 'cit_nam',
    ),
    //TODO

    //array('data' => t('Languaje')),
    array(
      'data' => t('Operation'),
    ),
  );

  //TODO

  //$sql = "SELECT wed.cit_nam, wed.cit_cod, wec.lan FROM {weather_es_data} wed INNER JOIN {weather_es_conf} wec ON (wec.cit_cod = wed.cit_cod) WHERE wec.wid = :wid";
  $sql = "SELECT wed.cit_nam, wed.cit_cod FROM {weather_es_data} wed INNER JOIN {weather_es_conf} wec ON (wec.cit_cod = wed.cit_cod) WHERE wec.wid = :wid";

  //->orderByHeader($header)
  $result = db_query($sql, array(
    ':wid' => $wid,
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  while ($row = $result
    ->fetchAssoc()) {
    $rows[] = array(
      'cit_nam' => $row['cit_nam'],
      //TODO

      //'lan' => $row['lan'],
      'ope' => l(t('edit'), $path . '/modify/' . $row['cit_cod'] . '/' . $row['cit_nam']) . '/' . l(t('delete'), $path . '/delete/' . $row['cit_cod'] . '/' . $row['cit_nam']),
    );
  }

  //if (count($rows) == 0) {

  //if (!$rows) {
  if (!isset($rows)) {
    $rows[] = array(
      array(
        'data' => '<em>' . t('There are currently no locations.') . '</em>',
        'colspan' => 2,
      ),
    );
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));

  // Create a new location
  $output .= '<p>' . l(t('Create a new configuration or add a new location to an exisiting configuration.'), $path . '/edit') . '</p>';
  return $output;
}