<h7 class="col col-12 m-1 p-1"> <i class="text-info"> <?php echo e(__('settings.financial_hint')); ?> </i> </h7>

<ul class="nav nav-pills container" role="tablist">
    <?php for($i=3; $i<=12; $i++): ?>
    <li class="nav-item">
        <a class="nav-link <?php echo e($i == 3 ? 'active' : ''); ?>" data-toggle="tab" href="#group_<?php echo e($i); ?>"><?php echo e($i. str_plural(__('settings.month'))); ?></a>
    </li>
    <?php endfor; ?>
</ul>

<div class="alert alert-info col col-12 m-1 p-1">
    <?php echo e(__('settings.group_setting_error')); ?>

</div>
<div class="tab-content container ">
    <?php for($i=3; $i<=12; $i++): ?>
    <div id="group_<?php echo e($i); ?>" class="tab-pane  <?php echo e($i == 3 ? 'active' : ''); ?>"><br/>
        <?php
            $groupSettings= old('group_settings', $final_settings->group_settings ?? [$i=> ['period'=> $i, 'max_budget'=> 1000, 'months'=> [] ] ])[$i];
            $perfixName="group_settings[{$i}]";
            $name= $perfixName."[period]";
            $period= $i;

        ?>
        <input type="hidden" class="form-control <?php echo e($errors->has('group_settings') && !$period ? 'is-invalid' : ''); ?>" name='<?php echo e($name); ?>' placeholder="<?php echo e(__('settings.period')); ?>" value='<?php echo e($period); ?>'/>

        <fieldset class="col col-12 m-1 border p-2">
            <legend  class="w-auto"><?php echo e(__('settings.max_budget')); ?></legend>

            <div class="form-row">
                <div class="form-group col-lg-12">
                    <label><?php echo e(__('settings.max_budget')); ?></label>
                    <div class="input-group">
                        <?php
                            $name= $perfixName."[max_budget]";
                            $max_budget= (float) $groupSettings['max_budget'] ?? 0;
                        ?>
                        <input type="number" class="form-control <?php echo e($errors->has('group_settings') && !$max_budget ? 'is-invalid' : ''); ?>" name='<?php echo e($name); ?>' placeholder="<?php echo e(__('settings.max_budget')); ?>" value='<?php echo e($max_budget); ?>'/>
                        <div class="input-group-append">
                            <div class="input-group-text">SAR</div>
                        </div>
                    </div>
                    <small id="emailHelp" class="form-text text-muted"> <?php echo e(__('settings.max_budget_hint')); ?> </small>
                </div>

            </div>
        </fieldset>

        <?php for($j=0; $j< $i; $j++): ?>
        <fieldset class="col col-12 m-1 border p-2">
            <?php
                // algorithms
                $step= 1 / ($i - 1);
                $release = round(100 * $j * $step);
                $hold = 100 - $release;
                $fees = round($hold / ($i * 10)) * 2 + 1;

                $groupSettingsMonths= $groupSettings['months'][$j] ?? [
                    'hold'=> $hold,
                    'release'=> $release,
                    'fees'=> $fees,
                    'score'=> ($hold+1)*10
                ];

                $perfixName="group_settings[{$i}][months][{$j}]";

                $hold_name= $perfixName."[hold]";
                $release_name= $perfixName."[release]";
                $fees_name= $perfixName."[fees]";
                $score_name= $perfixName."[score]";

                $release= $j == 0 ? 0 : (float) $groupSettingsMonths['release'] ?? "";

                $hold= $i == $j+1 ? 0 : (float) $groupSettingsMonths['hold'] ?? "";

                $fees= (float) $groupSettingsMonths['fees'] ?? "";

                $score= (float) $groupSettingsMonths['score'] ?? "";
                //$score= ($hold * $i + 1 )*10;

            ?>
            <legend  class="w-auto"><?php echo e(__('settings.month') . ($j+1)); ?></legend>
            <div class="form-row">

                <div class="form-group col-lg-3">
                    <label><?php echo e(__('settings.hold')); ?></label>
                    <div class="input-group">
                        <input type="number" min="0" max="<?php echo e($i == $j+1 ? '0' : '100'); ?>" <?php echo e($i == $j+1 ? 'readonly' : ''); ?> class="form-control <?php echo e($errors->has('group_settings') && $hold < 0  ? 'is-invalid' : ''); ?>" name='<?php echo e($hold_name); ?>' placeholder="<?php echo e(__('settings.hold')); ?>" value='<?php echo e($hold); ?>'/>
                        <div class="input-group-append">
                            <div class="input-group-text">%</div>
                        </div>
                    </div>
                </div>

                <div class="form-group col-lg-3">
                    <label><?php echo e(__('settings.release')); ?></label>
                    <div class="input-group">
                        <input type="number" min="0" max="<?php echo e(0 == $j ? '0' : '100'); ?>" <?php echo e(0 == $j ? 'readonly' : ''); ?> class="form-control <?php echo e($errors->has('group_settings') && $release < 0  ? 'is-invalid' : ''); ?>" name='<?php echo e($release_name); ?>' placeholder="<?php echo e(__('settings.release')); ?>" value='<?php echo e($release); ?>'/>
                        <div class="input-group-append">
                            <div class="input-group-text">%</div>
                        </div>
                    </div>
                </div>

                <div class="form-group col-lg-3">
                    <label><?php echo e(__('settings.fees')); ?></label>
                    <div class="input-group">
                        <input type="number" class="form-control <?php echo e($errors->has('group_settings') && $fees < 0 ? 'is-invalid' : ''); ?>" name='<?php echo e($fees_name); ?>' placeholder="<?php echo e(__('settings.fees')); ?>" value='<?php echo e($fees); ?>'/>
                        <div class="input-group-append">
                            <div class="input-group-text">%</div>
                        </div>
                    </div>
                    <small id="emailHelp" class="form-text text-muted"> <?php echo e(__('settings.fees_hint')); ?> </small>
                </div>

                <div class="form-group col-lg-3">
                    <label><?php echo e(__('settings.minimum_score')); ?></label>
                    <input type="number" class="form-control <?php echo e($errors->has('group_settings') && $score < 0 ? 'is-invalid' : ''); ?>" name='<?php echo e($score_name); ?>' placeholder="<?php echo e(__('settings.score')); ?>" value='<?php echo e($score); ?>'/>
                </div>

            </div>
        </fieldset>
        <?php endfor; ?>
    </div>
    <?php endfor; ?>
</div>
<?php /**PATH D:\wamp64\www\gam3iea\resources\views/admin/settings/financial.blade.php ENDPATH**/ ?>