<?php if(!defined('PARENT')) { exit; } ?>

    <div class="row">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <ul class="nav nav-tabs">
          <li class="active"><a href="#one" data-toggle="tab"><i class="fa fa-money fa-fw"></i> <span class="hidden-xs"><?php echo $msw_adm_commissions_add; ?></span></a></li>
          <li><a href="#two" data-toggle="tab"><i class="fa fa-user fa-fw"></i> <span class="hidden-xs"><?php echo $msw_adm_commissions_add2; ?></span></a></li>
        </ul>
      </div>
    </div>

    <form method="post" action="#">
    <div class="row formarea">
      <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
        <div class="tab-content">
          <div class="tab-pane active in" id="one">
            <div class="panel panel-default">
              <div class="panel-body">
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add12; ?></label>
                  <div class="form-group input-group" style="margin-bottom:5px">
                    <span class="input-group-addon"><i class="fa fa-calendar fa-fw"></i></span>
                    <input type="text" class="form-control mswdatepicker" name="fm[ts]" value="<?php echo (isset($ED->ts) ? $DT->converter($ED->ts) : $DT->converter($DT->ts())); ?>">
                  </div>
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add3; ?></label>
                  <input type="text" class="form-control" name="fm[saletotal]" value="<?php echo (isset($ED->saletotal) ? mswSH($ED->saletotal) : '0.00'); ?>" onkeyup="mswFormat('decimal', this)">
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add4; ?></label>
                  <input type="text" class="form-control" name="fm[commtotal]" value="<?php echo (isset($ED->commtotal) ? mswSH($ED->commtotal) : '0.00'); ?>" onkeyup="mswFormat('decimal', this)">
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add5; ?></label>
                  <select name="fm[product]" class="form-control">
                  <option value="0">- - - - - -</option>
                  <?php
                  $Q = $DB->db_query("SELECT `id`,`name` FROM `" . DB_PREFIX . "products` WHERE `en` = 'yes' ORDER BY `name`");
                  while ($P = $DB->db_object($Q)) {
                  ?>
                  <option value="<?php echo $P->id; ?>"<?php echo (isset($ED->product) && $ED->product == $P->id ? ' selected="selected"' : ''); ?>><?php echo mswCD($P->name); ?></option>
                  <?php
                  }
                  ?>
                  </select>
                </div>
              </div>
            </div>
          </div>
          <div class="tab-pane fade" id="two">
            <div class="panel panel-default">
              <div class="panel-body">
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add6; ?></label>
                  <input type="text" class="form-control"<?php echo (isset($AFL->id) ? ' readonly="readonly"' : ''); ?>name="fm[affid]" value="<?php echo (isset($ED->id,$AF->id) ? mswSH($AF->fname . ' ' . $AF->lname . ' (' . $AF->email . ')') : (isset($AFL->id) ? mswSH($AFL->fname . ' ' . $AFL->lname . ' (' . $AFL->email . ')') : '')); ?>">
                </div>
                <div class="form-group">
                  <label><?php echo $msw_adm_commissions_add7; ?></label>
                  <textarea class="form-control" name="fm[notes]"><?php echo (isset($ED->notes) ? mswSH($ED->notes) : ''); ?></textarea>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="act-button">
      <button type="button" class="btn btn-success" onclick="mswAction('<?php echo $cmd . (isset($ED->id) ? '-edit' : ''); ?>')"><i class="fa fa-<?php echo (isset($ED->id) ? 'check' : 'plus'); ?> fa-fw"></i> <span class="hidden-xs"><?php echo (isset($ED->id) ? $msw_common5 : $msw_adm_commissions_add8); ?></span></button>
      <?php
      if (isset($AFL->id) && !isset($_GET['rdr'])) {
      ?>
      <input type="hidden" name="fm[aff_id]" value="<?php echo $AFL->id; ?>">
      <input type="hidden" name="fm[id]" value="<?php echo (isset($ED->id) ? $ED->id : '0'); ?>">
      <button type="button" class="btn btn-default left_20" onclick="mswWin('aff-commissions&amp;id=<?php echo $AFL->id; ?>')"><i class="fa fa-arrow-left fa-fw"></i> <span class="hidden-xs"><?php echo $msw_common6; ?></span></button>
      <?php
      } else {
      if (isset($ED->id)) {
      ?>
      <input type="hidden" name="fm[aff_id]" value="<?php echo (isset($ED->id,$AF->id) ? $AF->id : '0'); ?>">
      <input type="hidden" name="fm[id]" value="<?php echo $ED->id; ?>">
      <button type="button" class="btn btn-default left_20" onclick="mswWin('<?php echo (isset($_GET['rdr']) ? mswSH($_GET['rdr']) : 'commissions-manage'); ?>')"><i class="fa fa-arrow-left fa-fw"></i> <span class="hidden-xs"><?php echo $msw_common6; ?></span></button>
      <?php
      } else {
      ?>
      <input type="hidden" name="fm[aff_id]" value="0">
      <?php
      }
      }
      ?>
    </div>
    </form>