<h4>Periode: <?php echo $period_label; ?></h4>
<hr>

<form class="form-horizontal" id="form_balance">
    <div class="form-group">
        <label class="control-label col-sm-2">User Produksi</label>
        <div class="col-sm-4">
            <select class="form-control" name="iduser" id="balance_iduser">
                <option value="">Pilih User</option>
                <?php foreach ($production_users->result() as $u) { ?>
                    <option value="<?php echo $u->iduser; ?>"><?php echo $u->name; ?></option>
                <?php } ?>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-sm-2">Saldo Awal</label>
        <div class="col-sm-4">
            <div class="input-group">
                <span class="input-group-addon">Rp</span>
                <input type="text" class="form-control format-number-decimal" name="opening_balance" id="balance_amount">
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-2"></div>
        <div class="col-sm-4">
            <button class="btn btn-primary" type="button" id="btn_save_balance"><i class="fa fa-save"></i> Simpan Saldo Awal</button>
        </div>
    </div>
</form>

<hr>
<h4>Daftar Saldo Awal Periode Ini:</h4>
<table class="table table-bordered table-condensed">
    <thead>
        <tr>
            <th width="10px">No</th>
            <th>User Produksi</th>
            <th width="200px">Saldo Awal</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $no = 0;
        foreach ($balances->result() as $bal) {
            $no++;
            $this->db->where('iduser', $bal->iduser);
            $user = $this->db->get('user')->row();
        ?>
        <tr>
            <td align="center"><?php echo $no; ?></td>
            <td><?php echo $user->name; ?></td>
            <td align="right">Rp <?php echo number_format($bal->opening_balance, 0, ',', '.'); ?></td>
        </tr>
        <?php } ?>
    </tbody>
</table>