<?php
    $indent = $level * 30;
    $hasChildren = $account->children->count() > 0;
?>

<tr class="account-row">
    <td style="padding-left: <?php echo e($indent); ?>px;">
        <strong><?php echo e($account->code); ?></strong>
        <?php if($account->is_system): ?>
            <span class="badge bg-secondary badge-type">সিস্টেম</span>
        <?php endif; ?>
    </td>
    <td>
        <?php if($hasChildren): ?>
            <i class="fas fa-folder text-warning"></i>
        <?php endif; ?>
        <?php echo e($account->name); ?>

        <?php if($account->description): ?>
            <br><small class="text-muted"><?php echo e(Str::limit($account->description, 50)); ?></small>
        <?php endif; ?>
    </td>
    <td class="text-end">
        <?php if(!$hasChildren): ?>
            <span class="<?php echo e($account->current_balance >= 0 ? 'text-success' : 'text-danger'); ?>">
                <?php echo e(number_format($account->current_balance, 2)); ?>

            </span>
            <br>
            <small class="text-muted"><?php echo e($account->normal_balance); ?></small>
        <?php else: ?>
            <span class="text-primary">
                <?php echo e(number_format($account->children->sum('current_balance'), 2)); ?>

            </span>
        <?php endif; ?>
    </td>
    <td>
        <div class="btn-group btn-group-sm">
            <a href="<?php echo e(route('accounts.show', $account->id)); ?>" class="btn btn-info" title="দেখুন">
                <i class="fas fa-eye"></i>
            </a>
            <?php if(!$account->is_system && (auth()->user()->user_type == 'admin' || auth()->user()->user_type == 'committee')): ?>
            <a href="<?php echo e(route('accounts.edit', $account->id)); ?>" class="btn btn-primary" title="সম্পাদনা">
                <i class="fas fa-edit"></i>
            </a>
            <?php endif; ?>
            <?php if(!$hasChildren && !$account->is_system && (auth()->user()->user_type == 'admin' || auth()->user()->user_type == 'committee')): ?>
            <form action="<?php echo e(route('accounts.destroy', $account->id)); ?>" method="POST" class="d-inline">
                <?php echo csrf_field(); ?>
                <?php echo method_field('DELETE'); ?>
                <button type="submit" class="btn btn-danger" title="ডিলিট" 
                        onclick="return confirm('আপনি কি এই অ্যাকাউন্ট ডিলিট করতে চান?')">
                    <i class="fas fa-trash"></i>
                </button>
            </form>
            <?php endif; ?>
        </div>
    </td>
</tr>

<?php if($hasChildren): ?>
    <?php $__currentLoopData = $account->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <?php echo $__env->make('accounts.partials.account-row', ['account' => $child, 'level' => $level + 1], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php endif; ?><?php /**PATH /home/naowarin/somoti.naowarinternational.my.id/resources/views/accounts/partials/account-row.blade.php ENDPATH**/ ?>