<?php
/* Smarty version 5.4.2, created on 2024-11-24 06:35:17
  from 'file:../default/employee_attendance.tpl' */

/* @var \Smarty\Template $_smarty_tpl */
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
  'version' => '5.4.2',
  'unifunc' => 'content_67430f75be5fd6_75486661',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    '66179c75182215e7f390d4691548ca28ddf41a1a' => 
    array (
      0 => '../default/employee_attendance.tpl',
      1 => 1730635717,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
))) {
function content_67430f75be5fd6_75486661 (\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
$_smarty_tpl->getInheritance()->init($_smarty_tpl, true);
?>

<?php 
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_145255208567430f75bcbd00_58574025', "content");
?>


<?php 
$_smarty_tpl->getInheritance()->instanceBlock($_smarty_tpl, 'Block_97745169967430f75be3fd5_69586157', 'script');
?>

<?php $_smarty_tpl->getInheritance()->endChild($_smarty_tpl, ((string)$_smarty_tpl->getValue('layouts_admin')), $_smarty_current_dir);
}
/* {block "content"} */
class Block_145255208567430f75bcbd00_58574025 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
?>




    <div class="row">
        <div class="col-md-12">
            <div class="panel">
                <div class="panel-hdr">
                    <h2><?php echo $_smarty_tpl->getValue('_L')['Attendance'];?>
</h2>
                    <div class="panel-toolbar">
                        <input class="form-control" id="inputDate" style="min-width: 200px;" name="date"
                               data-date-format="yyyy-mm-dd" data-auto-close="true"  value="<?php echo $_smarty_tpl->getValue('date');?>
">
                    </div>
                </div>
                <div class="panel-container">
                    <div class="panel-content">
                        <h3><?php echo $_smarty_tpl->getValue('_L')['Mark Attendance'];?>
</h3>
                        <p><?php echo $_smarty_tpl->getSmarty()->getModifierCallback('date')($_smarty_tpl->getValue('config')['df'],$_smarty_tpl->getSmarty()->getModifierCallback('strtotime')($_smarty_tpl->getValue('date')));?>
</p>
                        <div class="hr-line-dashed"></div>

                        <div class="col-md-12">


                            <table class="table table-bordered table-hover sys_table footable" data-filter="#foo_filter" data-page-size="50">
                                <thead>
                                <tr>
                                    <th width="200px;"><?php echo $_smarty_tpl->getValue('_L')['Name'];?>
</th>
                                    <th width="100px;"><?php echo $_smarty_tpl->getValue('_L')['Status'];?>
</th>
                                    <th><?php echo $_smarty_tpl->getValue('_L')['Note'];?>
</th>
                                </tr>
                                </thead>
                                <tbody>

                                <?php
$_from = $_smarty_tpl->getSmarty()->getRuntime('Foreach')->init($_smarty_tpl, $_smarty_tpl->getValue('employees'), 'employee');
$foreach0DoElse = true;
foreach ($_from ?? [] as $_smarty_tpl->getVariable('employee')->value) {
$foreach0DoElse = false;
?>
                                    <tr>
                                        <td><?php echo $_smarty_tpl->getValue('employee')->name;?>
 </td>
                                        <td>

                                            <label class="switch s-icons s-outline s-outline-primary">
                                                <input type="checkbox" id="attendance_<?php echo $_smarty_tpl->getValue('employee')->id;?>
" class="attendance_checkbox"
                                                <?php if ((null !== ($_smarty_tpl->getValue('attendances')[$_smarty_tpl->getValue('employee')->id] ?? null)) && $_smarty_tpl->getValue('attendances')[$_smarty_tpl->getValue('employee')->id]->is_present) {?>
                                                    checked
                                                <?php }?>
                                                >
                                                <span class="slider round"></span>
                                            </label>

                                        </td>
                                        <td>
                                            <div class="mb-3">
                                                <input class="form-control attendance_note" id="attendance_note_<?php echo $_smarty_tpl->getValue('employee')->id;?>
" <?php if ((null !== ($_smarty_tpl->getValue('attendances')[$_smarty_tpl->getValue('employee')->id] ?? null))) {?>
                                                value="<?php echo $_smarty_tpl->getValue('attendances')[$_smarty_tpl->getValue('employee')->id]->note;?>
"
                                                        <?php }?>>
                                            </div>
                                        </td>
                                    </tr>
                                <?php
}
$_smarty_tpl->getSmarty()->getRuntime('Foreach')->restore($_smarty_tpl, 1);?>

                                </tbody>


                            </table>

                        </div>

                    </div>






                </div>
            </div>
        </div>
    </div>



<?php
}
}
/* {/block "content"} */
/* {block 'script'} */
class Block_97745169967430f75be3fd5_69586157 extends \Smarty\Runtime\Block
{
public function callBlock(\Smarty\Template $_smarty_tpl) {
$_smarty_current_dir = '/Users/razib/Herd/suite/ui/theme/default';
?>

    <?php echo '<script'; ?>
>
        $(function () {

            var $inputDate = $('#inputDate');

            $inputDate.datepicker();

            $inputDate.on('change',function () {
                window.location = '<?php echo $_smarty_tpl->getValue('_url');?>
hrm/attendance/' + $inputDate.val()
            });

            $('.attendance_checkbox').on('change', function() {
                let employee_id = this.id;
                let present;
                if(this.checked){
                    present = 'yes';
                }
                else{
                    present = 'no';
                }

                $.post( base_url + "hrm/set-attendance", { employee_id: employee_id, present: present, date: $inputDate.val() })
                    .done(function( data ) {
                        toastr.success('<?php echo $_smarty_tpl->getValue('_L')['Updated'];?>
');
                    });
            });


            $('.attendance_note').on('change', function() {
                let employee_id = this.id;
                let note = $(this).val();

                $.post( base_url + "hrm/set-attendance-note", { employee_id: employee_id, note: note, date: $inputDate.val() })
                    .done(function( data ) {
                        toastr.success('<?php echo $_smarty_tpl->getValue('_L')['Updated'];?>
');
                    });
            });


        })
    <?php echo '</script'; ?>
>


<?php
}
}
/* {/block 'script'} */
}
