<?php
/**
 * The incomeAndReceive view file of trade module of ZDOO.
 *
 * @copyright   Copyright 2009-2017 青岛易软天创网络科技有限公司(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 $app->getModuleRoot() . 'common/view/header.html.php';?>
<?php include '../../../../sys/common/view/chart.html.php';?>
<?php $unitList = $lang->trade->report->unitList;?>
<div class='panel panel-sm'>
  <div class='panel-heading'>
    <div class='date dropdown'>
      <?php echo $lang->trade->trace;?>
      <button type='button' class='btn btn-sm btn-default dropdown-toggle' data-toggle='dropdown'><?php echo $month;?> <span class="caret"></span></button>
      <ul class='dropdown-menu'>
        <?php for($i = 1; $i <= 12; $i++):?>
        <li><?php echo html::a(helper::createLink('trade', 'incomeandreceive', "month=$i&currency=$currentCurrency&unit=$currentUnit"), $i);?></li>
        <?php endfor;?>
      </ul>
      <?php echo $lang->month . $lang->trade->before;?>
    </div>
    <div class='currency dropdown'>
      <button type='button' class='btn btn-sm btn-default dropdown-toggle' data-toggle='dropdown'><?php echo $currencyList[$currentCurrency];?> <span class="caret"></span></button>
      <ul class='dropdown-menu'>
        <?php foreach($currencyList as $key => $currency):?>
        <li><?php echo html::a(helper::createLink('trade', 'incomeandreceive', "month=$month&currency=$key&unit=$currentUnit"), $currency);?></li>
        <?php endforeach;?>
      </ul>
    </div>
    <div class='unit dropdown'>
      <button type='button' class='btn btn-sm btn-default dropdown-toggle' data-toggle='dropdown'><?php echo zget($unitList, $currentUnit, zget($unitList, 1));?> <span class='caret'></span></button>
      <ul class='dropdown-menu'>
        <?php foreach($unitList as $key => $unit):?>
        <li><?php echo html::a(helper::createLink('trade', 'incomeandreceive', "month=$month&currency=$currentCurrency&unit=$key"), $unit);?></li>
        <?php endforeach;?>
      </ul>
    </div>
  </div>
  <div class='panel-body main-table has-padding-top' data-ride='table'>
    <table class='table table-condensed table-bordered table-wrapper' data-animation='false'>
      <thead>
        <tr class='text-center'>
          <th><?php echo $lang->trade->company;?></th>
          <th class='w-100px'><?php echo $lang->trade->paid;?></th>
          <?php if($currentCurrency == 'rmb'):?>
          <th class='w-120px'><?php echo $lang->trade->drawn4Return;?></th>
          <?php endif;?>
          <th class='w-100px'><?php echo $lang->trade->unpaid;?></th>
          <?php if($currentCurrency == 'rmb'):?>
          <th class='w-120px'><?php echo $lang->trade->drawn2Return;?></th>
          <th class='w-120px'><?php echo $lang->trade->difference . " <i class='icon icon-help-circle icon-md' data-toggle='tooltip' data-placement='bottom' title='{$lang->trade->differenceTip}'></i>";?></th>
          <?php endif;?>
          <th class='w-120px'><?php echo $lang->trade->profit;?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($companies as $companyID => $companyName):?>
        <tr class='text-right'>
          <td title="<?php echo $companyName;?>" class='text-left'><?php echo $companyName;?></td>
          <td><?php echo number_format($incomes[$companyID], 2);?></td>
          <?php if($currentCurrency == 'rmb'):?>
          <td><?php echo number_format($drawn4Returns[$companyID], 2);?></td>
          <?php endif;?>
          <td><?php echo number_format($unpaidContracts[$companyID], 2);?></td>
          <?php if($currentCurrency == 'rmb'):?>
          <td><?php echo number_format($drawn2Returns[$companyID], 2);?></td>
          <td><?php echo number_format($differences[$companyID], 2);?></td>
          <?php endif;?>
          <td><?php echo number_format($profits[$companyID], 2);?></td>
        </tr>
        <?php endforeach;?>
      </tbody>
    </table>
  </div>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>
