<?php $__env->startSection('body'); ?>
    <div class="wrapper-content animated fadeInRight form-horizontal">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins ">
                    <div class="ibox-content">
                        <h2 class="ibox-title">
                            Etapa machetare
                        </h2>
                    </div>

                    <?php if(isset($items) && count($items)): ?>

                        <?php echo $__env->make('searchForm', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>

                        <div class="ibox-content">
                            <div class="table-responsive">
                                <table class="table">
                                    <thead>
                                    <tr>
                                        <th><?php echo e(trans('e.serial')); ?></th>
                                        <th class="text-center">Nume colet</th>
                                        <th class="text-center">Nume client</th>
                                        <th class="text-right">Data crearii</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php foreach($items as $item): ?>
                                        <tr>
                                            <td class="serial-td"><?php echo e(isset($item->serial) ? $item->serial : ''); ?></td>
                                            <td class="text-center"><?php echo e($item->name); ?></td>
                                            <td class="text-center"><?php echo e(isset($item->client) ? $item->client->name : ''); ?></td>
                                            <td class="text-right"><?php echo e(date('d/m/Y H:i', strtotime($item->created_at))); ?></td>
                                        </tr>
                                        <?php if(!$item->projects->isEmpty()): ?>
                                            <tr>
                                                <td colspan="20" class="tr-with-table">
                                                    <table class="children-table">
                                                        <thead>
                                                        <tr>
                                                            <th>Schita proiect</th>
                                                            <th class="text-center">Nume proiect</th>
                                                            <th class="text-center">Etapa parcursa</th>
                                                            <th></th>
                                                            <th></th>
                                                        </tr>
                                                        </thead>
                                                        <tbody>
                                                        <?php foreach($item->projects as $project): ?>
                                                            <tr>
                                                                <td>
                                                                    <div class="img-block">
                                                                        <a href="<?php echo e(url('/'.(isset($project) ? $project->file  : ''))); ?>"
                                                                           data-fancybox="project-schema-<?php echo e($item->id); ?>"
                                                                           data-caption="<?php echo e(isset($item->serial) ? $item->serial : ''); ?>">
                                                                            <img src="<?php echo e(url('/'.(isset($project) ? $project->file  : ''))); ?>"
                                                                                 alt="">
                                                                        </a>
                                                                    </div>
                                                                </td>
                                                                <td class="text-center"><?php echo e(isset($project->name) ? $project->name : ''); ?></td>
                                                                <td class="text-center"><?php echo e(trans('e.'.$project->status)); ?></td>
                                                                <td class="text-right">
                                                                    <?php if($project->getEditableLayoutAttribute()): ?>
                                                                        <a href="<?php echo e(url('/layout/edit/'.$project->project_id)); ?>"
                                                                           type="button"
                                                                           class="btn btn-w-m btn-info no-float"><i
                                                                                    class="fa fa-pencil"></i>&nbsp;Editare</a>
                                                                    <?php endif; ?>
                                                                </td>
                                                                <td class="text-right">
                                                                    <?php if($project->getEditableLayoutAttribute()): ?>
                                                                        <div onclick="performStore(this)"
                                                                             data-project-id="<?php echo e($project->project_id); ?>"
                                                                             class="btn btn-w-m btn-danger no-float"><i
                                                                                    class="fa fa-flag"></i>Urmatorul pas
                                                                        </div>
                                                                    <?php endif; ?>
                                                                </td>
                                                            </tr>
                                                        <?php endforeach; ?>
                                                        </tbody>
                                                    </table>
                                                </td>
                                            </tr>
                                        <?php endif; ?>
                                    <?php endforeach; ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    <?php else: ?>
                        <div class="empty-list"><?php echo e(trans('e.empty_list')); ?></div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        function performStore(current) {

            var started = 'started';

            $.post('/layout/performStore', {project_id: $(current).data('project-id'), started: started})
                .then(function (resp) {
                    if (resp.msg)
                        toastr[resp.msg.type](resp.msg.e);
                    if (resp.status)
                        setTimeout(function () {
                            window.location.reload(true)
                        })
                })
        }
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('tpl', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>