<?php
/**
 * The set basic 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 include '../../../sys/common/view/treeview.html.php';?>
<div class='main-row'>
  <div class='side-col'>
    <div class='panel panel-block'>
      <div class='panel-heading'><strong><?php echo $lang->dept->common;?></strong></div>
      <div class='panel-body'>
        <div id='treeMenuBox'><?php echo $treeMenu;?></div>
      </div>
    </div>
  </div>
  <div class='main-col'>
    <form id='ajaxForm' method='post'>
      <div class='panel'>
        <table class='table table-condensed table-bordered table-hover text-center text-middle'>
          <thead>
            <tr class='text-center'>
              <th rowspan='2' class='w-80px'><?php echo $lang->salary->account;?></th>
              <th rowspan='2' class='w-100px' id='basicTH'><?php echo $lang->salary->basic;?></th>
              <th rowspan='2' class='w-100px' id='performanceTH'><?php echo $lang->salary->performance;?></th>
              <th colspan='3' id='allowanceTH'><?php echo $lang->salary->allowance;?></th>
              <th colspan='1' id='exemptionTH'><?php echo $lang->salary->setExemption;?></th>
              <th colspan='2' id='ssfTH'><?php echo $lang->salary->setSSF;?></th>
              <th rowspan='2' class='w-70px'><?php echo $lang->salary->total;?></th>
              <th rowspan='2' class='w-80px'><?php echo $lang->actions;?></th>
            </tr>
            <tr class='text-center'>
              <th class='w-70px'><?php echo $lang->salary->allowanceList['hot'];?></th>
              <th class='w-70px'><?php echo $lang->salary->allowanceList['cold'];?></th>
              <th class='w-70px'><?php echo $lang->salary->allowanceList['baby'];?></th>
              <th class='w-80px' id='basicExemptionTH'><?php echo $lang->salary->exemptionList['basic'];?></th>
              <th class='w-50px'><?php echo $lang->salary->SSF;?></th>
              <th class='w-50px'><?php echo $lang->salary->HPF;?></th>
            </tr>
          </thead>
          <tbody>
            <?php
            foreach($users as $user):
            if(isset($basicList[$user->account]))
            {
                $basic = $basicList[$user->account];
            }
            else
            {
                $basic = new stdclass();
                $basic->basic       = '';
                $basic->performance = '';
                $basic->allowance   = new stdclass();
                $basic->exemption   = new stdclass();
                $basic->ssf         = new stdclass();
            }
            ?>
            <tr>
              <td>
                <?php echo $user->realname;?>
                <?php echo html::hidden("account[$user->id]", $user->account);?>
                <?php echo html::hidden("userID[$user->id]", $user->id);?>
              </td>
              <td>
                <?php 
                if($basic->basic)
                {
                    echo "<span class='basic basicItem'>" . $basic->basic . "</span>";
                    echo html::input("basic[$user->id]",   $basic->basic, "class='form-control amount basic basicItem' style='display:none'");
                }
                else
                {
                    echo html::input("basic[$user->id]",   $basic->basic, "class='form-control amount basic'");
                }
                ?>
              </td>
              <td>
                <?php 
                if($basic->performance)
                {
                    echo "<span class='performance basicItem'>" . $basic->performance. "</span>";
                    echo html::input("performance[$user->id]", $basic->performance, "class='form-control amount performance basicItem' style='display:none'");
                }
                else
                {
                    echo html::input("performance[$user->id]", $basic->performance, "class='form-control amount performance'");
                }
                ?>
              </td>
              <?php $checked = !empty($basic->allowance->hot) ? 'checked' : '';?>
              <td><input type='checkbox' name='allowance[<?php echo $user->id;?>][hot]' value='1' <?php echo $checked;?>/></td>
              <?php $checked = !empty($basic->allowance->cold) ? 'checked' : '';?>
              <td><input type='checkbox' name='allowance[<?php echo $user->id;?>][cold]' value='1' <?php echo $checked;?>/></td>
              <?php $checked = !empty($basic->allowance->baby) ? 'checked' : '';?>
              <td><input type='checkbox' name='allowance[<?php echo $user->id;?>][baby]' value='1' <?php echo $checked;?>/></td>
              <td>
                <?php 
                if(!empty($basic->exemption->basic))
                {
                    echo "<span class='exemption basicItem'>" . $basic->exemption->basic. "</span>";
                    echo html::input("exemption[$user->id][basic]", $basic->exemption->basic, "class='form-control amount exemption basicItem' style='display:none'");
                }
                else
                {
                    echo html::input("exemption[$user->id][basic]", '', "class='form-control amount exemption'");
                }
                ?>
              </td>
              <?php $checked = !empty($basic->ssf->ssf) ? 'checked' : '';?>
              <td><input type='checkbox' name='ssf[<?php echo $user->id;?>][ssf]' value='1' <?php echo $checked;?>/></td>
              <?php $checked = !empty($basic->ssf->hpf) ? 'checked' : '';?>
              <td><input type='checkbox' name='ssf[<?php echo $user->id;?>][hpf]' value='1' <?php echo $checked;?>/></td>
              <td class='text-middle' id='total'></td>
              <td class='text-left'>
                <?php echo html::a('javascript:;', "<i class='icon-remove'></i>", "class='btn btn-sm delItem'");?>
                <?php if($basic->basic) echo html::a('javascript:;', "<i class='icon-pencil'></i>", "class='btn btn-sm editItem'");?>
              </td>
            </tr>
            <?php endforeach;?>
            <tr class='text-center footer'>
              <th><?php echo $lang->salary->total;?></th>
              <th id='totalBasic'></th>
              <th id='totalPerformance'></th>
              <th></th>
              <th></th>
              <th></th>
              <th id='totalExemption'></th>
              <th></th>
              <th></th>
              <th id='totalMoney'></th>
              <th></th>
            </tr>
          </tbody>
        </table>
        <div class='table-footer'>
          <?php echo html::submitButton();?>
          <?php $pager->show();?>
        </div>
      </div>
    </form>
  </div>
</div>
<?php include '../../common/view/footer.html.php';?>
