<?php
/**
 * The invest view file of trade module of ZDOO.
 *
 * @copyright   Copyright 2009-2018 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     ZPL (http://zpl.pub/page/zplv12.html)
 * @author      Tingting Dai <daitingting@xirangit.com>
 * @package     trade
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('modeType', 'invest');?>
<?php js::set('type', $type);?>
<?php js::set('mainCurrency', $config->setting->mainCurrency);?>
<div class='panel'>
  <div class='panel-heading'>
    <strong><?php echo $lang->trade->typeList[$type];?></strong>
  </div>
  <div class='panel-body'>
    <form method='post' id='tradeForm'>
      <table class='table table-form w-p60'>
        <tr>
          <th class='w-100px'><?php echo $lang->trade->depositor;?></th>
          <td><?php echo html::select('depositor', $depositorList, '', "class='form-control chosen'");?></td>
        </tr>
        <tr class='trader'>
          <th><?php echo $lang->trade->traderList['invest'];?></th>
          <td>
            <?php $hasCreatePriv   = commonModel::hasPriv('provider', 'create');?>
            <?php $traderClass     = (count($traderList) > 1 or !$hasCreatePriv) ? '' : 'hide';?>
            <?php $traderNameClass = count($traderList) > 1 ? 'hide' : '';?>
            <div class='input-group'>
              <?php echo html::select('trader', $traderList, '', "class='form-control chosen {$traderClass}' data-no_results_text='" . $lang->searchMore . "'");?>
              <?php if($hasCreatePriv):?>
              <?php echo html::input('traderName', '', "class='form-control {$traderNameClass}'");?>
              <div class='input-group-addon'><?php echo html::checkbox('createTrader', array(1 => $lang->trade->newTrader), count($traderList) > 1 ? '' : 1);?></div>
              <?php endif;?>
            </div>
          </td>
        </tr>
        <tr class='investList'>
          <th><?php echo $lang->trade->invest;?></th>
          <td>
            <div class="required required-wrapper"></div>
            <?php echo html::select('investID', $investList, '', "class='form-control chosen'");?>
          </td>
        </tr>
        <tr>
          <th><?php echo $lang->trade->money;?></th>
          <td>
            <div class='input-group'>
              <?php echo html::input('money', '', "class='form-control'");?>
              <span class='input-group-addon '><?php echo $lang->trade->currency;?></span>
              <?php echo html::select('currencyLabel', $lang->currencyList, '', "class='form-control' disabled");?>
              <?php echo html::hidden('currency');?>
              <span class='input-group-addon exchangeRate'><?php echo $lang->trade->exchangeRate;?></span>
              <?php echo html::input('exchangeRate', 1, "class='form-control exchangeRate'");?>
            </div>
          </td>
        </tr>
        <tr class='category hide'>
          <th><?php echo $lang->trade->in;?></th>
          <td>
            <div class='input-group'>
              <?php echo html::select('investCategory', $investCategoryList, '', "class='form-control'");?>
              <span class="input-group-addon fix-padding"></span>
              <?php echo html::input('investMoney', '', "class='form-control'");?>
            </div>
          </td>
        </tr>
        <tr>
          <th><?php echo $lang->trade->dept;?></th>
          <td><?php echo html::select('dept', $deptList, '', "class='form-control chosen'");?></td>
        </tr>
        <tr>
          <th><?php echo $lang->trade->handlers;?></th>
          <td><?php echo html::select('handlers[]', $users, '', "class='form-control chosen' multiple");?></td>
        </tr>
        <tr>
          <th><?php echo $lang->trade->date;?></th>
          <td><?php echo html::input('date', date('Y-m-d'), "class='form-control form-date'");?></td>
        </tr>
        <?php if($type == 'invest'):?>
        <tr>
          <th><?php echo $lang->trade->deadline;?></th>
          <td><?php echo html::input('deadline', '', "class='form-control form-date'");?></td>
        </tr>
        <?php endif;?>
        <tr>
          <th><?php echo $lang->trade->desc;?></th>
          <td><?php echo html::textarea('desc','', "class='form-control' rows='3'");?></td>
        </tr>
        <?php if(commonModel::hasPriv('file', 'upload')):?>
        <tr>
          <th><?php echo $lang->trade->uploadFile;?></th>
          <td><?php echo $this->fetch('file', 'buildForm');?></td>
        </tr>
        <?php endif;?>
        <tr>
          <th></th>
          <td class='form-actions'>
            <?php echo html::submitButton() . html::backButton();?>
            <div id='duplicateError' class='hide'></div>
          </td>
        </tr>
      </table>
    </form>
  </div>
</div>
<div class='errorMessage hide'>
  <div class='alert alert-danger alert-dismissable'>
    <button aria-hidden='true' data-dismiss='alert' class='close' type='button'>×</button>
    <button type='button' class='btn btn-default' id='continueSubmit'><?php echo $lang->continueSave;?></button>
  </div>
</div>
<script>
<?php helper::import('../js/searchcustomer.js');?>
</script>
<?php include '../../common/view/footer.html.php';?>
