<?php
require_once('inc/logincheck.php');
CommTool::checkIncludeByAdminPhp();


if('3' == $module){$titlePage = $labelSystemParameterProductTitle; $startKey = 30;}
else if('4' == $module){$titlePage = $labelSystemParameterImgTitle; $startKey = 40;}
else if('5' == $module){$titlePage = $labelSystemParameterdownloadTitle; $startKey = 50;}
else if('11' == $module){$titlePage = $labelSystemParameterResumeTitle; $startKey = 110;}
else {$titlePage = '参数配置';}

if('modify' == $action)
{
  for($i = $startKey; $i < $startKey+10; $i++)    
  {
    $sortnum = 'sortnum'.$i;              
    $paraname = 'paraname'.$i;
    $enable = 'enable'.$i;
    $sortnum = $$sortnum;
    $paraname = $$paraname;
    $enable = $$enable;    
    if("" == $paraname && 1==$enable)      
    {
      promptMessage("index.php?lang={$kuWebsiteEditVersionLanguage}&path=system&menu=parameter&module=$module", $promptEmptyParameter);
    }
    if('' == $enable) {$enable = 0;}
    $strSql = "update {$configTableHead}para set paraname='$paraname', sortnum='$sortnum', enable='$enable' where id=$i and lang='{$kuWebsiteEditVersionLanguage}'";
    $dbInstance->query($strSql);
  }
  if($configIsLog)CommTool::writeLog("{$_SESSION['adminuser']} modify Parameter: {$startKey} - ".($startKey+10));         
  promptMessage("index.php?lang={$kuWebsiteEditVersionLanguage}&path=system&menu=parameter&module=$module", $promptUpdateParameter);
}
else                                      
{
  $strSql = "select * from {$configTableHead}para where paramodule={$module} and lang='{$kuWebsiteEditVersionLanguage}' order by sortnum";
  $result = $dbInstance->query($strSql);
  $listPara = array();
  while($row = $dbInstance->fetchArray($result))
  {
    $para['id'] = $row['id'];
    $para['paraname'] = $row['paraname'];
    $para['sortnum'] = $row['sortnum'];
    if(1 == intval($row['enable']))
    {
      $para['enable'] = 1;
      $para['labelEnable'] = "checked='checked'";
    }
    else
    {
      $para['enable'] = 1;
      $para['labelEnable'] = "";
    }
    $listPara[] = $para;
  }
}
include_once template('parameter.html', $adminTemplateName);
?>