<?php
/**
 * The report 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 $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'>
    <?php if($companies):?>
    <div class='company dropdown'>
      <button type='button' class='btn btn-sm btn-default dropdown-toggle' data-toggle='dropdown'><?php echo $companies[$currentCompany];?> <span class='caret'></span></button>
      <ul class='dropdown-menu'>
        <?php foreach($companies as $companyID => $companyName):?>
        <li><?php echo html::a(helper::createLink('trade', 'invoice', "company=$companyID&date=$currentYear&unit=$currentUnit"), $companyName);?></li>
        <?php endforeach;?>
      </ul>
    </div>
    <?php endif;?>
    <?php if($tradeYears):?>
    <div class='date dropdown'>
      <button type='button' class='btn btn-sm btn-default dropdown-toggle' data-toggle='dropdown'><?php echo $currentYear . $lang->year;?> <span class="caret"></span></button>
      <ul class='dropdown-menu'>
        <?php foreach($tradeYears as $tradeYear):?>
        <li class='dropdown'>
          <?php echo html::a(helper::createLink('trade', 'invoice', "company=$currentCompany&date=$tradeYear&unit=$currentUnit"), $tradeYear);?>
        </li>
        <?php endforeach;?>
      </ul>
    </div>
    <?php endif;?>
    <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', 'invoice', "company=$currentCompany&date=$currentYear&unit=$key"), $unit);?></li>
        <?php endforeach;?>
      </ul>
    </div>
  </div>
  <div class='panel-body'>
    <table class='table table-borderless active-disabled'>
      <tr>
        <td colspan='3' class='invoice'>
          <div class='chart-wrapper text-center'>
            <h5><?php echo $currentYear . $lang->trade->report->invoice . '(' . zget($unitList, $currentUnit, zget($unitList, 1)) . ')';?></h5>
            <div class='chart-canvas'><canvas height='465' width='800' id='chart-invoice'></canvas></div>
          </div>
        </td>
        <td class='w-400px invoice'>
          <div style="overflow:auto;" class='table-wrapper'>
            <table id='lineChart' class='table table-condensed table-hover table-striped table-chart table-fixed-head' data-chart='bar' data-target='#myBarChart' data-animation='false'>
              <thead>
                <tr class='text-center'>
                  <th class='w-60px'><?php echo $lang->trade->month;?></th>
                  <th class='chart-label-has'><i class='chart-color-dot-has icon-circle'></i> <?php echo $lang->trade->hasInvoice;?></th>
                  <th class='chart-label-no'><i class='chart-color-dot-no icon-circle'></i> <?php echo $lang->trade->noInvoice;?></th>
                  <th class='chart-label-invoice'><i class='chart-color-dot-invoice icon-circle'></i> <?php echo $lang->trade->invoiceMoney;?></th>
                </tr>
              </thead>
              <tbody>
              <?php foreach($chartDatas as $month => $chartData):?>
              <tr class='text-right'>
                <td class='text-center chart-label'><?php echo $month == 'all' ? $lang->trade->total : $month;?></td>
                <td class='chart-value-has'><?php echo number_format($chartData['hasInvoice'], 2);?></td>
                <td class='chart-value-no'><?php echo number_format($chartData['noInvoice'], 2);?></td>
                <td class='chart-value-invoice'><?php echo number_format($chartData['invoice'], 2);?></td>
              </tr>
              <?php endforeach;?>
              </tbody>
            </table>
          </div>
        </td>
      </tr>
    </table>
  </div>
</div>
<?php include $app->getModuleRoot() . 'common/view/footer.html.php';?>
