<?php
/**
 * The browse view file of salary module of ZDOO.
 *
 * @copyright   Copyright 2009-2016 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
 * @license     商业软件，非开源软件
 * @author      Gang Liu <liugang@cnezsoft.com>
 * @package     salary
 * @version     $Id$
 * @link        http://www.zdoo.com
 */
?>
<?php include '../../common/view/header.html.php';?>
<?php js::set('mode', $mode);?>
<?php js::set('fromSetting', strpos($this->server->http_referer, $this->createLink('salary', 'setBasic')) !== false);?>
<li id='bysearchTab'><?php echo html::a('#', "<i class='icon-search icon'></i>" . $lang->search->common)?></li>
<div id='menuActions'>
  <?php if(commonModel::hasPriv('salary', 'export')):?>
  <button data-toggle="dropdown" class="btn btn-secondary dropdown-toggle" type="button"><?php echo $lang->exportIcon . $lang->export;?><span class="caret"></span></button>
  <ul class='dropdown-menu'>
    <li><?php echo html::a(inlink('export', "mode=basic&month=$currentYear$currentMonth"),  $lang->salary->exportBasic,  "class='iframe' data-width='700'");?></li>
    <li><?php echo html::a(inlink('export', "mode=detail&month=$currentYear$currentMonth"), $lang->salary->exportDetail, "class='iframe' data-width='700'");?></li>
  </ul>
  <?php endif;?>
  <?php commonModel::printLink('salary', 'batchCreate', '', "<i class='icon icon-plus'> </i>" . $lang->salary->batchCreate, "class='btn btn-primary jsoner'");?>
</div>
<?php $canBatchConfirm = commonModel::hasPriv('salary', 'batchConfirm');?>
<?php $canBatchDelete  = commonModel::hasPriv('salary', 'batchDelete');?>
<?php $canBatchAction  = ($type == 'company' && $salaryList && ($canBatchConfirm or $canBatchDelete));?>
<div class='panel main-table' data-ride='table'>
  <form id='ajaxForm' method='post'>
    <table class='table has-sort-head table-fixed'>
      <thead>
        <tr class='text-center'>
          <?php $vars = "&mode={$mode}&month=$currentYear$currentMonth&orderBy=%s";?>
          <th class='w-80px'>
            <?php if($canBatchAction):?>
            <div class='checkbox-primary check-all' title='<?php echo $this->lang->selectAll;?>'><label></label></div>
            <?php endif;?>
            <?php commonModel::printOrderLink('id', $orderBy, $vars, $lang->salary->id);?>
          </th>
          <th class='w-80px'><?php commonModel::printOrderLink('month',   $orderBy, $vars, $lang->salary->month);?></th>
          <th class='w-60px'><?php commonModel::printOrderLink('dept',    $orderBy, $vars, $lang->user->dept);?></th>
          <th class='w-80px'><?php commonModel::printOrderLink('account', $orderBy, $vars, $lang->salary->account);?></th>
          <th class='w-80px'><?php echo $lang->salary->basic;?></th>
          <th class='w-80px'><?php echo $lang->salary->performance;?></th>
          <?php foreach($config->salary->detailFields as $field):?>
          <?php if($field == 'exemption' or $field == 'revenue') continue;?>
          <th class='w-80px'><?php echo $lang->salary->$field;?></th>
          <?php endforeach;?>
          <th class='w-80px'><?php echo $lang->salary->deserved;?></th>
          <th class='w-80px'><?php echo $lang->salary->actual;?></th>
          <th class='w-80px'><?php echo $lang->salary->companyPay;?></th>
          <th><?php echo $lang->salary->desc;?></th>
          <th class='w-60px'><?php echo $lang->salary->status;?></th>
          <?php $class = $this->app->clientLang == 'en' ? 'w-180px' : 'w-150px';?>
          <th class='<?php echo $class;?>'><?php echo $lang->actions;?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($salaryList as $salary):?>
        <tr class='text-center'>
          <td class='text-left'>
            <?php if($canBatchAction):?>
            <div class='checkbox-primary'><input type='checkbox' name='salaryIDList[]' value="<?php echo $salary->id;?>" id="salaryIDList<?php echo $salary->id;?>">
              <label for="salaryIDList<?php echo $salary->id;?>"></label>
            </div>
            <?php endif;?>
            <?php echo $salary->id;?>
          </td>
          <td class='w-80px'><?php echo $salary->month;?></td>
          <td><?php echo zget($deptList, $salary->dept, '');?></td>
          <td><?php echo zget($userList, $salary->account);?></td>
          <td><?php echo formatMoney($salary->basic);?></td>
          <td><?php echo formatMoney($salary->performance);?></td>
          <?php foreach($config->salary->detailFields as $field):?>
          <?php if($field == 'exemption' or $field == 'revenue') continue;?>
          <td><?php echo formatMoney($salary->$field);?></td>
          <?php endforeach;?>
          <td><?php echo formatMoney($salary->deserved);?></td>
          <td><?php echo formatMoney($salary->actual);?></td>
          <td><?php echo formatMoney($salary->companySSF + $salary->companyHPF);?></td>
          <td title='<?php echo $salary->desc;?>'><?php echo $salary->desc;?></td>
          <td class='salary-<?php echo $salary->status;?>'><?php echo zget($this->lang->salary->statusList, $salary->status);?></td>
          <td>
            <?php
            echo html::a(inlink('view', "id={$salary->id}&type={$type}"), $lang->view);
            if($type == 'company')
            {
                if($salary->status == 'wait')
                {
                    commonModel::printLink('salary', 'edit', "id={$salary->id}", $lang->edit);
                    commonModel::printLink('salary', 'confirm', "id={$salary->id}", $lang->confirm, "class='jsoner'");
                }
                else
                {
                    echo html::a('javascript:;', $lang->edit, "class='disabled'");
                    echo html::a('javascript:;', $lang->confirm, "class='disabled'");
                }
                commonModel::printLink('salary', 'delete', "id={$salary->id}", $lang->delete, "class='deleter'");
            }
            ?>
          </td>
        </tr>
        <?php endforeach;?>
      </tbody>
    </table>
    <div class='table-footer'>
      <?php if($canBatchAction):?>
      <div class="checkbox-primary check-all"><label><?php echo $lang->selectAll?></label></div>
      <div class="table-actions btn-toolbar">
        <?php
        if($canBatchConfirm)
        {
            $confirmActionLink = inlink('batchConfirm');
            echo html::a('javascript:;', $lang->confirm, "class='btn' onclick=\"setFormAction('$confirmActionLink')\"");
        }
        if($canBatchDelete)
        {
            $deleteActionLink = inlink('batchDelete');
            echo html::a('javascript:;', $lang->delete, "class='btn' onclick=\"setFormAction('$deleteActionLink')\"");
        }
        ?>
      </div>
      <?php endif;?>
      <?php if($salaryList):?>
      <div class='table-statistic'>
        <?php $this->salary->countMoney($salaryList);?>
      </div>
      <?php endif;?>
      <?php $pager->show();?>
    </div>
  </form>
</div>
<?php include '../../common/view/footer.html.php';?>
