<?php 
/**
 * The create result view file of product module of ZDOO.
 *
 * @copyright   Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     商业软件，非开源软件
 * @author      Xiying Guan <guanxiying@xirangit.com>
 * @package     product 
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../../common/view/header.modal.html.php';?>
<form method='post' id='ajaxForm' action='<?php echo inlink('editResult', "actionID={$action->id}&key=$key");?>'>
  <table class='table table-form'>
    <tr>
      <td class='w-60px'></td>
      <td class='w-80px'></td>
      <td class='w-140px'></td>
      <td class='w-110px'></td>
      <td></td>
      <td class='w-100px'></td>
    </tr>
    <tr>
      <th><?php echo $lang->product->field->field;?></th>
      <td colspan='2'><?php echo html::select("field", $inputFields, $action->results[$key]->field, "class='form-control'");?></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
    <?php $i = 1;?>
    <?php foreach($action->results[$key]->conditions as $condition):?>
    <tr>
      <th><?php if($i == 1) echo $lang->product->action->conditions;?></th>
      <td <?php if($i == 1) echo "colspan='2'";?>>
      <?php if($i == 1):?>
        <?php echo html::select("conditions[logicalOperator][$i]", $lang->order->logicalOperators, $condition->logicalOperator, "id='logicalOperator$i' class='hidden'");?>
      <?php else:?>
        <?php echo html::select("conditions[logicalOperator][$i]", $lang->order->logicalOperators, $condition->logicalOperator, "id='logicalOperator$i' class='form-control'");?>
      </td>
      <td>
      <?php endif;?>
        <?php echo html::select("conditions[field][$i]", $conditionFields, $condition->field, "class='form-control'");?>
      </td>
      <td><?php echo html::select("conditions[operater][$i]", $lang->order->operaterList, $condition->operator, "class='form-control'");?></td>
      <td><?php echo html::input("conditions[param][$i]", $condition->param, "class='form-control'");?></td>
      <td>
        <a href='javascript:;' class='btn addItem'><i class="icon-plus"></i></a>
        <?php if($i > 1):?>
        <a href='javascript:;' class='btn delItem'><i class="icon-remove"></i></a>
        <?php endif;?>
      </td>
    </tr>
    <?php $i++;?>
    <?php endforeach;?>
    <tr>
      <th><?php echo $lang->product->action->results;?></th>
      <td colspan='2'>
        <?php $result = $action->results[$key]->result;?>
        <?php $result = isset($lang->order->resultsOptions[$result]) ? $result : 'userdefined';?>
        <?php echo html::select("result", $lang->order->resultsOptions, $result, "class='form-control'");?>
      </td>
      <td colspan='2'>
        <?php $resultValue = $result == 'userdefined' ? $action->results[$key]->result : '';?>
        <?php echo html::input('resultValue', $resultValue, "class='form-control'");?>
      </td>
      <td></td>
    </tr>
    <tr><td class='text-center form-actions' colspan='6'><?php echo html::submitButton();?></td></tr>
  </table>
</form>
<?php /* Hidden condation group. */ ?>
<table id='conditionGroup' class='hide'>
  <tbody>
    <tr>
      <th></th>
      <td><?php echo html::select("conditions[logicalOperator][key]", $lang->order->logicalOperators, '', "id='logicalOperatorkey' class='form-control'");?></td>
      <td><?php echo html::select("conditions[field][key]", $conditionFields, '', "class='form-control'");?></td>
      <td><?php echo html::select("conditions[operater][key]", $lang->order->operaterList, '', "class='form-control'");?></td>
      <td><?php echo html::input("conditions[param][key]", '', "class='form-control'");?></td>
      <td>
        <a href='javascript:;' class='btn addItem'><i class="icon-plus"></i></a>
        <a href='javascript:;' class='btn delItem'><i class="icon-remove"></i></a>
      </td>
    </tr>
  </tbody>
</table>
<?php js::set('key', $i);?>
<?php include '../../../common/view/footer.modal.html.php';?>
