<style>
.pointer{
    cursor:pointer;
}
</style>
<section class="container" style="padding-bottom: 2rem;">
    <div class="row">
		
        <div class="col-12 col-md-3">
			<div id="navCard" class="card bg-light-transparent">
				<div class="card-header bg-light">
					<h5 class="card-title">Menu</h5>
				</div>
				<div class="card-body">
					<div class="card no-shadow">
						<div class="card-body">
							<div class="nav flex-column nav-pills" id="tab" role="tablist" aria-orientation="vertical">
								<a class="nav-link active" id="forms-tab" data-toggle="pill" href="#forms" role="tab" aria-controls="forms" aria-selected="false">Forms</a>
								<a class="nav-link" id="policies-tab" data-toggle="pill" href="#policies" role="tab" aria-controls="policies" aria-selected="false">SOP</a>
								<a class="nav-link" id="tnc-tab" data-toggle="pill" href="#tnc" role="tab" aria-controls="tnc" aria-selected="false">Employee Handbooks</a>
                                <a class="nav-link" id="manual-tab" data-toggle="pill" href="#manual" role="tab" aria-controls="manual" aria-selected="false">Manual Guide</a>
								<hr <?php if(strtolower($this->logged_module['role'])!='admin') echo 'hidden'; ?>>
								<a <?php if(strtolower($this->logged_module['role'])!='admin') echo 'hidden'; ?> class="nav-link" id="settings-tab" data-toggle="pill" href="#settings" role="tab" aria-controls="settings" aria-selected="false">Settings</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

        <div class="col-12 col-md-9">
            <div class="tab-content" id="tabContent">

                <div class="tab-pane fade show active" id="forms" role="tabpanel" aria-labelledby="forms-tab">
                    <div class="card bg-light-transparent" style="margin-bottom: 2rem;">
                        <div class="card-header bg-light">
                            <div class="float-left">
                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                    <button onclick="openFormModal();" type="button" class="btn btn-outline-dark btn-sm"><i class="fa fa-plus"></i> Add Form</button>
                                <?php endif; ?>
                                <!-- <button id="btnShowFormFilters" type="button" class="btn btn-outline-dark btn-sm" data-toggle="collapse" data-target="#collapseFormFilter"><i class="fas fa-filter"></i> Show Filters</button> -->
                            </div>
                            <div class="float-right">
                                <nav>
                                    <div class="nav nav-tabs btn-group btn-group-sm" role="tablist">
                                        <a class="btn btn-outline-dark active" id="table-view-tab" data-toggle="tab" href="#formTableView" role="tab" aria-controls="nav-table" aria-selected="true" data-tooltip="tooltip" title="Show List View"><i class="fas fa-list"></i></a>
                                        <a class="btn btn-outline-dark" id="card-view-tab" data-toggle="tab" href="#formCardView" role="tab" aria-controls="nav-card" aria-selected="false" data-tooltip="tooltip" title="Show Card View"><i class="fas fa-th-large"></i></a>
                                    </div>
                                </nav>
                            </div>
                        </div>
                        
                        <div class="tab-content">

                            <div class="tab-pane fade show active" id="formTableView" role="tabpanel" aria-labelledby="nav-table-tab">
                                <div class="card-body">
                                    <!-- <div class="card no-shadow"> -->
                                        <?php foreach($categories as $index => $cat): ?>
                                            <div class="card no-shadow bg-dark-transparent mb-3">
                                                <div class="card-header bg-dark text-white pointer" data-toggle="collapse" data-target="#form_collapse_list_<?php echo $index; ?>">
                                                    <h5 class="card-title"><?php echo $cat['category']; ?> <span class="forms_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                                    
                                                </div>
                                                <div class="card-body bg-dark-transparent collapse" id="form_collapse_list_<?php echo $index; ?>">
                                                    <div class="table-responsive bg-white p-3">
                                                        <table id="table_forms" class="table table-bordered table-hover">
                                                            <thead>
                                                                <th class="text-center">Code</th>
                                                                <th>Title</th>
                                                                <th>Description</th>
                                                                <th></th>
                                                            </thead>
                                                            <tbody>
                                                            <?php if(isset($forms)): ?>
                                                                <?php $document_no = 0; ?>
                                                                <?php foreach($forms as $form): ?>
                                                                
                                                                    <?php if($form['category'] == $cat['category']): $document_no++; ?>
                                                                    <tr>
                                                                        <td class="text-center"><?php echo $form['code']; ?></td>
                                                                        <td><a target="_blank" href="<?php echo base_url($form['file_location'].$form['file_name']); ?>"><?php echo $form['title']; ?></a></td>
                                                                        <td><?php echo $form['description']; ?></td>
                                                                        <td class="text-center">
                                                                            <div class="btn-group btn-group-sm" role="group">
                                                                                <a download href="<?php echo base_url($form['file_location'].$form['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Form"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="openFormModal(<?php echo $form['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Form"><i class="far fa-edit"></i></button>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="deleteForm(<?php echo $form['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Form"><i class="far fa-trash-alt"></i></button>
                                                                                <?php endif; ?>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                    <?php endif; ?>
                                                                    
                                                                <?php endforeach; ?>
                                                            <?php endif; ?>
                                                            </tbody>
                                                        </table>
                                                        <input 
                                                            type="hidden" 
                                                            value="<?php echo $document_no; ?>" 
                                                            class="collapse_setter_doc_no"
                                                            data-collapsetarget=".forms_<?php echo $index;?>"
                                                        >
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endforeach; ?>
                                    <!-- </div> -->
                                </div>
                            </div>

                            <div class="tab-pane fade" id="formCardView" role="tabpanel" aria-labelledby="nav-card-tab">
                                <div class="card-body"> 
								<?php //var_dump($categories); ?>
									<?php foreach($categories as $index => $cat){ ?>
                                    <div class="card no-shadow bg-dark-transparent mb-3">
                                        <div class="card-header bg-dark text-white pointer" data-toggle="collapse" data-target="#form_collapse_card_<?php echo $index; ?>">
                                            <h5 class="card-title"><?php echo $cat['category']; ?><span class="forms_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                        </div>
                                        <div class="card-body collapse" id="form_collapse_card_<?php echo $index; ?>">
                                    <?php  if($forms){ ?>
											<div class="row">
												<?php $count = 0; $others =0; ?>
												<?php foreach($forms as $form){  ?>
													<?php	if($form['category_id'] == $cat['id']){ 
																if($form['category_id'] == '') $others++; ?> 
														<?php if($count==3){ echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; } ?>
														<?php $count++; ?>
														<div class="col-4">
															<div class="card no-shadow">
																<div class="card-header">
																	<div class="float-left">
																		<h5 class="card-title"><a target="_blank" href="<?php echo base_url($form['file_location'].$form['file_name']); ?>"><?php echo $form['title']; ?></a></h5>
																	</div>
																	<div class="float-right">
																		<div class="btn-group btn-group-sm" role="group">
																			<a download href="<?php echo base_url($form['file_location'].$form['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Form"><i class="far fa-arrow-alt-circle-down"></i></a>
																			<?php if($this->logged_module['role'] == 'admin'): ?>
																				<button type="button" class="btn btn-outline-dark" onclick="openFormModal(<?php echo $form['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Form"><i class="far fa-edit"></i></button>
																				<button type="button" class="btn btn-outline-dark" onclick="deleteForm(<?php echo $form['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Form"><i class="far fa-trash-alt"></i></button>
																			<?php endif; ?>
																		</div>
																	</div>
																</div>
																<div class="card-body">
																	<p class="card-text"><?php echo $form['description']; ?></p>
																</div>
															</div>
														</div>
													<?php } ?>	
												<?php } //endforeach form ?>
											</div>
									<?php } //endif;  ?>
										</div>	
									</div>	
									<?php } //endforeach categories;  ?>
                                </div>
                            </div>

                        </div>

                    </div>
                </div>

                <div class="tab-pane fade" id="policies" role="tabpanel" aria-labelledby="policies-tab">
                    <div class="card bg-light-transparent">
                        <div class="card-header bg-light" >
                            <div class="float-left">
                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                    <button onclick="openPolicyModal();" type="button" class="btn btn-outline-dark btn-sm"><i class="fa fa-plus"></i> Add Policy</button>
                                <?php endif; ?>
                                <!-- <button id="btnShowPolicyFilters" type="button" class="btn btn-outline-dark btn-sm" data-toggle="collapse" data-target="#collapsePolicyFilter"><i class="fas fa-filter"></i> Show Filters</button> -->
                            </div>
                            <div class="float-right">
                                <nav>
                                    <div class="nav nav-tabs btn-group btn-group-sm" role="tablist">
                                        <a class="btn btn-outline-dark active" id="table-view-tab" data-toggle="tab" href="#policyTableView" role="tab" aria-controls="nav-table" aria-selected="true" data-tooltip="tooltip" title="Show List View"><i class="fas fa-list"></i></a>
                                        <a class="btn btn-outline-dark" id="card-view-tab" data-toggle="tab" href="#policyCardView" role="tab" aria-controls="nav-card" aria-selected="false" data-tooltip="tooltip" title="Show Card View"><i class="fas fa-th-large"></i></a>
                                    </div>
                                </nav>
                            </div>
                        </div>
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="policyTableView" role="tabpanel" aria-labelledby="nav-table-tab">
                                <div class="card-body">

                                    <?php foreach($categories as $index => $cat): ?>
                                        <?php $document_no = 0; ?>
                                        <div class="card no-shadow bg-dark-transparent mb-3">
                                            <div class="card-header bg-dark text-white pointer" data-toggle="collapse" data-target="#sop_collapse_list_<?php echo $index; ?>">
                                                <h5 class="card-title"><?php echo $cat['category']; ?><span class="sop_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                            </div>
                                            <div class="card-body collapse" id="sop_collapse_list_<?php echo $index; ?>">
                                                <div class="card no-shadow">
                                                    <div class="card-body">
                                                        <div class="table-responsive">
                                                            <table id="table_forms" class="table table-bordered table-hover">
                                                                <thead>
                                                                    <th>Title</th>
                                                                    <th>Description</th>
                                                                    <th>Category</th>
                                                                    <th></th>
                                                                </thead>
                                                                <tbody>
                                                                <?php if($policies): ?>
                                                                    <?php foreach($policies as $policy): ?>
                                                                        <?php if($policy['category'] == $cat['category']): $document_no++; ?>
                                                                        <tr>
                                                                            <td><a target="_blank" href="<?php echo base_url($policy['file_location'].$policy['file_name']); ?>"><?php echo $policy['title']; ?></a></td>
                                                                            <td><?php echo $policy['description']; ?></td>
                                                                            <td><?php echo $policy['category']; ?></td>
                                                                            <td class="text-center">
                                                                                <div class="btn-group btn-group-sm" role="group">
                                                                                    <a download href="<?php echo base_url($policy['file_location'].$policy['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Policy"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                    <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="openPolicyModal(<?php echo $policy['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Policy"><i class="far fa-edit"></i></button>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="deletePolicy(<?php echo $policy['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Policy"><i class="far fa-trash-alt"></i></button>
                                                                                    <?php endif; ?>
                                                                                </div>
                                                                            </td>
                                                                        </tr>
                                                                        <?php endif; ?>
                                                                    <?php endforeach; ?>
                                                                <?php endif; ?>
                                                                </tbody>
                                                            </table>
                                                            <input 
                                                            type="hidden" 
                                                            value="<?php echo $document_no; ?>" 
                                                            class="collapse_setter_doc_no"
                                                            data-collapsetarget=".sop_<?php echo $index;?>"
                                                        >
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        
                                    <?php endforeach; ?>
                                </div>
                                
                                
                            </div>
                            <div class="tab-pane fade" id="policyCardView" role="tabpanel" aria-labelledby="nav-card-tab">
                                <div class="card-body">
                                <?php foreach($categories as $index => $cat): ?>
                                    <div class="card no-shadow bg-dark-transparent">
                                        <div class="card-header bg-dark text-white pointer" data-toggle="collapse" data-target="#sop_collapse_card_<?php echo $index; ?>">
                                            <h5 class="card-title"><?php echo $cat['category']; ?><span class="sop_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                        </div>
                                        <div class="card-body collapse" id="sop_collapse_card_<?php echo $index; ?>">
                                            <?php if($policies): ?>
                                                <div class="row">
                                                    <?php $count = 0; ?>
                                                    <?php foreach($policies as $policy): ?>
                                                        <?php if($policy['category_id'] == $cat['id']): ?> 
                                                            <?php if($count==3): echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; endif; ?>
                                                            <?php $count++; ?>
                                                            <div class="col-4">
                                                                <div class="card">
                                                                    <div class="card-header">
                                                                        <div class="float-left">
                                                                            <h5 class="card-title"><a target="_blank" href="<?php echo base_url($policy['file_location'].$policy['file_name']); ?>"><?php echo $policy['title']; ?></a></h5>
                                                                        </div>
                                                                        <div class="float-right">
                                                                            <div class="btn-group btn-group-sm" role="group">
                                                                                <a download href="<?php echo base_url($policy['file_location'].$policy['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Form"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="openFormModal(<?php echo $policy['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Form"><i class="far fa-edit"></i></button>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="deleteForm(<?php echo $policy['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Form"><i class="far fa-trash-alt"></i></button>
                                                                                <?php endif; ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="card-body">
                                                                        <p class="card-text"><?php echo $policy['description']; ?></p>
                                                                        <!-- <p class="card-text"><?php echo $policy['dept_name'].' ('.$policy['dept_branch_name'].')'; ?></p> -->
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </div>
                                    <div class="w-100" style="padding-top: 0.75rem; padding-bottom: 0.75rem;"></div>
                                <?php endforeach; ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="tab-pane fade" id="tnc" role="tabpanel" aria-labelledby="tnc-tab">
                    <div class="card bg-light-transparent">
                        <div class="card-header bg-light" >
                            <div class="float-left">
                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                    <button onclick="openTncModal();" type="button" class="btn btn-outline-dark btn-sm"><i class="fa fa-plus"></i> Add Employee Handbook</button>
                                <?php endif; ?>
                                <!-- <button id="btnShowTncFilters" type="button" class="btn btn-outline-dark btn-sm" data-toggle="collapse" data-target="#collapseTncFilter"><i class="fas fa-filter"></i> Show Filters</button> -->
                            </div>
                            <div class="float-right">
                                <nav>
                                    <div class="nav nav-tabs btn-group btn-group-sm" role="tablist">
                                        <a class="btn btn-outline-dark active" id="table-view-tab" data-toggle="tab" href="#tncTableView" role="tab" aria-controls="nav-table" aria-selected="true" data-tooltip="tooltip" title="Show List View"><i class="fas fa-list"></i></a>
                                        <a class="btn btn-outline-dark" id="card-view-tab" data-toggle="tab" href="#tncCardView" role="tab" aria-controls="nav-card" aria-selected="false" data-tooltip="tooltip" title="Show Card View"><i class="fas fa-th-large"></i></a>
                                    </div>
                                </nav>
                            </div>
                        </div>
                        
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="tncTableView" role="tabpanel" aria-labelledby="nav-table-tab">
                                <div class="card-body">

                                    <?php foreach($categories as $index =>  $cat): $document_no = 0;  ?>
                                        <div class="card bg-dark-transparent no-shadow mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#tnc_collapse_list_<?php echo $index; ?>">
                                                <h5 class="card-title text-white"><?php echo $cat['category']; ?> <span class="tnc_<?php echo $index; ?> badge badge-danger float-right"></span> </h5>
                                            </div>
                                            <div class="card-body collapse" id="tnc_collapse_list_<?php echo $index;?>">
                                                <div class="table-responsive bg-white p-3">
                                                    <table id="table_forms" class="table table-bordered table-hover">
                                                        <thead>
                                                            <th>Title</th>
                                                            <th>Description</th>
                                                            <th>Category</th>
                                                            <th width="10%"></th>
                                                        </thead>
                                                        <tbody>
                                                        <?php if($tncs): ?>
                                                            <?php foreach($tncs as $tnc):  ?>
                                                                <?php if($tnc['category'] == $cat['category']): $document_no++; ?>
                                                                <tr>
                                                                    <td><a target="_blank" href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>"><?php echo $tnc['title']; ?></a></td>
                                                                    <td><?php echo $tnc['description']; ?></td>
                                                                    <td><?php echo $tnc['category']; ?></td>
                                                                    <td class="text-center">
                                                                        <div class="btn-group btn-group-sm" role="group">
                                                                            <a download href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                            <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="openTncModal(<?php echo $tnc['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="deleteTnc(<?php echo $tnc['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                            <?php endif; ?>
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                                <?php endif; ?>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                        </tbody>
                                                    </table>

                                                    <input 
                                                            type="hidden" 
                                                            value="<?php echo $document_no; ?>" 
                                                            class="collapse_setter_doc_no"
                                                            data-collapsetarget=".tnc_<?php echo $index;?>"
                                                        >

                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>

                                    <div class="card bg-dark-transparent no-shadow mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#tnc_empty">
                                                <h5 class="card-title text-white"> No Category <span class="tnc_empty badge badge-danger float-right"></span></h5>
                                            </div>
                                            <div class="card-body collapse" id="tnc_empty">
                                                <div class="table-responsive bg-white p-3">
                                                <?php $document_no = 0;?>
                                                    <table id="table_forms" class="table table-bordered table-hover">
                                                        <thead>
                                                            <th>Title</th>
                                                            <th>Description</th>
                                                            <th width="10%"></th>
                                                        </thead>
                                                        <tbody>
                                                        <?php if($tncs): ?>
                                                            <?php foreach($tncs as $tnc):  ?>
                                                                <?php if(empty($tnc['category'])): $document_no++; ?>
                                                                <tr>
                                                                    <td><a target="_blank" href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>"><?php echo $tnc['title']; ?></a></td>
                                                                    <td><?php echo $tnc['description']; ?></td>
                                                                    <td class="text-center">
                                                                        <div class="btn-group btn-group-sm" role="group">
                                                                            <a download href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                            <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="openTncModal(<?php echo $tnc['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="deleteTnc(<?php echo $tnc['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                            <?php endif; ?>
                                                                        </div>
                                                                    </td>
                                                                </tr>
                                                                <?php endif; ?>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                        </tbody>
                                                    </table>

                                                    <input 
                                                            type="hidden" 
                                                            value="<?php echo $document_no; ?>" 
                                                            class="collapse_setter_doc_no"
                                                            data-collapsetarget=".tnc_empty"
                                                        >
                                                </div>
                                            </div>
                                        </div>





                                </div>
                            </div>
                            <div class="tab-pane fade" id="tncCardView" role="tabpanel" aria-labelledby="nav-card-tab">
                                <div class="card-body">
                                    
                                    <?php foreach($categories as $index => $cat): ?>
                                        <div class="card no-shadow bg-dark-transparent mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#tnc_collapse_card_<?php echo $index; ?>">
                                                <h5 class="card-title text-white"><?php echo $cat['category']; ?><span class="tnc_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                            </div>
                                            <div class="card-body collapse" id="tnc_collapse_card_<?php echo $index; ?>">
                                            
                                            <?php if($tncs): ?>
                                                <div class="row">
                                                    <?php $count = 0; ?>
                                                    <?php foreach($tncs as $tnc): ?>
                                                        <?php if($tnc['category'] == $cat['category']): ?>
                                                        <?php if($count==3): echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; endif; ?>
                                                        <?php $count++; ?>
                                                        <div class="col-4">
                                                            <div class="card no-shadow">
                                                                <div class="card-header">
                                                                    <div class="float-left">
                                                                        <h5 class="card-title"><a target="_blank" href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>"><?php echo $tnc['title']; ?></a></h5>
                                                                    </div>
                                                                    <div class="float-right">
                                                                        <div class="btn-group btn-group-sm" role="group">
                                                                            <a download href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                            <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="openTncModal(<?php echo $tnc['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="deleteTnc(<?php echo $tnc['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                            <?php endif; ?>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <p class="card-text"><?php echo $tnc['description']; ?></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </div>
                                            <?php endif; ?>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>




                                    <div class="card no-shadow bg-dark-transparent mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#tnc_empty_card">
                                                <h5 class="card-title text-white">No Category <span class="tnc_empty badge badge-danger float-right"></span></h5>
                                            </div>
                                            <div class="card-body collapse" id="tnc_empty_card">
                                            
                                            <?php if($tncs): ?>
                                                <div class="row">
                                                    <?php $count = 0; ?>
                                                    <?php foreach($tncs as $tnc): ?>
                                                        <?php if(empty($tnc['category'])): ?>
                                                        <?php if($count==3): echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; endif; ?>
                                                        <?php $count++; ?>
                                                        <div class="col-4">
                                                            <div class="card no-shadow">
                                                                <div class="card-header">
                                                                    <div class="float-left">
                                                                        <h5 class="card-title"><a target="_blank" href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>"><?php echo $tnc['title']; ?></a></h5>
                                                                    </div>
                                                                    <div class="float-right">
                                                                        <div class="btn-group btn-group-sm" role="group">
                                                                            <a download href="<?php echo base_url($tnc['file_location'].$tnc['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                            <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="openTncModal(<?php echo $tnc['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                <button type="button" class="btn btn-outline-dark" onclick="deleteTnc(<?php echo $tnc['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                            <?php endif; ?>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                                <div class="card-body">
                                                                    <p class="card-text"><?php echo $tnc['description']; ?></p>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </div>
                                            <?php endif; ?>
                                            </div>
                                        </div>

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

                <div class="tab-pane fade" id="manual" role="tabpanel" aria-labelledby="manual-tab">
                    <div class="card bg-light-transparent">
                        <div class="card-header bg-light" >
                            <div class="float-left">
                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                    <button onclick="openManualModal();" type="button" class="btn btn-outline-dark btn-sm"><i class="fa fa-plus"></i> Add Manual Guide</button>
                                <?php endif; ?>
                                <!-- <button id="btnShowManualFilters" type="button" class="btn btn-outline-dark btn-sm" data-toggle="collapse" data-target="#collapseManualFilter"><i class="fas fa-filter"></i> Show Filters</button> -->
                            </div>
                            <div class="float-right">
                                <nav>
                                    <div class="nav nav-tabs btn-group btn-group-sm" role="tablist">
                                        <a class="btn btn-outline-dark active" id="table-view-tab" data-toggle="tab" href="#manualTableView" role="tab" aria-controls="nav-table" aria-selected="true" data-tooltip="tooltip" title="Show List View"><i class="fas fa-list"></i></a>
                                        <a class="btn btn-outline-dark" id="card-view-tab" data-toggle="tab" href="#manualCardView" role="tab" aria-controls="nav-card" aria-selected="false" data-tooltip="tooltip" title="Show Card View"><i class="fas fa-th-large"></i></a>
                                    </div>
                                </nav>
                            </div>
                        </div>
                        
                        <div class="tab-content">
                            <div class="tab-pane fade show active" id="manualTableView" role="tabpanel" aria-labelledby="nav-table-tab">
                                <div class="card-body">
                                    <?php foreach($categories as $index =>  $cat): $document_no = 0;  ?>
                                        <div class="card bg-dark-transparent no-shadow mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#manual_collapse_list_<?php echo $index; ?>">
                                                <h5 class="card-title text-white"><?php echo $cat['category']; ?> <span class="manual_<?php echo $index; ?> badge badge-danger float-right"></span> </h5>
                                            </div>
                                            <div class="card-body collapse" id="manual_collapse_list_<?php echo $index;?>">
                                                <div class="table-responsive bg-white p-3">
                                                    <table id="table_manual" class="table table-bordered table-hover">
                                                        <thead>
                                                            <th width="40%">Title</th>
                                                            <th width="40%">Description</th>
                                                            <th width="10%">Category</th>
                                                            <th width="10%"></th>
                                                        </thead>
                                                        <tbody>
                                                            <?php if($manuals): ?>
                                                                <?php foreach($manuals as $manual):  ?>
                                                                    <?php if($manual['category'] == $cat['category']): $document_no++; ?>
                                                                        <tr>
                                                                            <td><a target="_blank" href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>"><?php echo $manual['title']; ?></a></td>
                                                                            <td><?php echo $manual['description']; ?></td>
                                                                            <td><?php echo $manual['category']; ?></td>
                                                                            <td class="text-center">
                                                                                <div class="btn-group btn-group-sm" role="group">
                                                                                    <a download href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                    <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="openManualModal(<?php echo $manual['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="deleteManual(<?php echo $manual['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                                    <?php endif; ?>
                                                                                </div>
                                                                            </td>
                                                                        </tr>
                                                                    <?php endif; ?>
                                                                <?php endforeach; ?>
                                                            <?php endif; ?>
                                                        </tbody>
                                                    </table>

                                                    <input 
                                                    type="hidden" 
                                                    value="<?php echo $document_no; ?>" 
                                                    class="collapse_setter_doc_no"
                                                    data-collapsetarget=".manual_<?php echo $index;?>"
                                                    >

                                                </div>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>

                                    <div class="card bg-dark-transparent no-shadow mb-3">
                                        <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#manual_empty">
                                            <h5 class="card-title text-white"> No Category <span class="manual_empty badge badge-danger float-right"></span></h5>
                                        </div>
                                        <div class="card-body collapse" id="manual_empty">
                                            <div class="table-responsive bg-white p-3">
                                                <?php $document_no = 0;?>
                                                <table id="table_manual" class="table table-bordered table-hover">
                                                    <thead>
                                                        <th width="45%">Title</th>
                                                        <th width="45%">Description</th>
                                                        <th width="10%"></th>
                                                    </thead>
                                                    <tbody>
                                                        <?php if($manuals): ?>
                                                            <?php foreach($manuals as $manual):  ?>
                                                                <?php if(empty($manual['category'])): $document_no++; ?>
                                                                    <tr>
                                                                        <td><a target="_blank" href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>"><?php echo $manual['title']; ?></a></td>
                                                                        <td><?php echo $manual['description']; ?></td>
                                                                        <td class="text-center">
                                                                            <div class="btn-group btn-group-sm" role="group">
                                                                                <a download href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="openManualModal(<?php echo $manual['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="deleteManual(<?php echo $manual['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                                <?php endif; ?>
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                <?php endif; ?>
                                                            <?php endforeach; ?>
                                                        <?php endif; ?>
                                                    </tbody>
                                                </table>

                                                <input 
                                                type="hidden" 
                                                value="<?php echo $document_no; ?>" 
                                                class="collapse_setter_doc_no"
                                                data-collapsetarget=".manual_empty"
                                                >
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="tab-pane fade" id="manualCardView" role="tabpanel" aria-labelledby="nav-card-tab">
                                <div class="card-body">

                                    <?php foreach($categories as $index => $cat): ?>
                                        <div class="card no-shadow bg-dark-transparent mb-3">
                                            <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#manual_collapse_card_<?php echo $index; ?>">
                                                <h5 class="card-title text-white"><?php echo $cat['category']; ?><span class="manual_<?php echo $index; ?> badge badge-danger float-right"></span></h5>
                                            </div>
                                            <div class="card-body collapse" id="manual_collapse_card_<?php echo $index; ?>">

                                                <?php if($manuals): ?>
                                                    <div class="row">
                                                        <?php $count = 0; ?>
                                                        <?php foreach($manuals as $manual): ?>
                                                            <?php if($manual['category'] == $cat['category']): ?>
                                                                <?php if($count==3): echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; endif; ?>
                                                                <?php $count++; ?>
                                                                <div class="col-4">
                                                                    <div class="card no-shadow">
                                                                        <div class="card-header">
                                                                            <div class="float-left">
                                                                                <h5 class="card-title"><a target="_blank" href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>"><?php echo $manual['title']; ?></a></h5>
                                                                            </div>
                                                                            <div class="float-right">
                                                                                <div class="btn-group btn-group-sm" role="group">
                                                                                    <a download href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                    <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="openManualModal(<?php echo $manual['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                        <button type="button" class="btn btn-outline-dark" onclick="deleteManual(<?php echo $manual['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                                    <?php endif; ?>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                        <div class="card-body">
                                                                            <p class="card-text"><?php echo $manual['description']; ?></p>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            <?php endif; ?>
                                                        <?php endforeach; ?>
                                                    </div>
                                                <?php endif; ?>
                                            </div>
                                        </div>
                                    <?php endforeach; ?>

                                    <div class="card no-shadow bg-dark-transparent mb-3">
                                        <div class="card-header bg-dark pointer" data-toggle="collapse" data-target="#manual_empty_card">
                                            <h5 class="card-title text-white">No Category <span class="manual_empty badge badge-danger float-right"></span></h5>
                                        </div>
                                        <div class="card-body collapse" id="manual_empty_card">

                                            <?php if($manuals): ?>
                                                <div class="row">
                                                    <?php $count = 0; ?>
                                                    <?php foreach($manuals as $manual): ?>
                                                        <?php if(empty($manual['category'])): ?>
                                                            <?php if($count==3): echo "<div class='w-100' style='padding-bottom: 2rem;'></div>"; $count = 0; endif; ?>
                                                            <?php $count++; ?>
                                                            <div class="col-4">
                                                                <div class="card no-shadow">
                                                                    <div class="card-header">
                                                                        <div class="float-left">
                                                                            <h5 class="card-title"><a target="_blank" href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>"><?php echo $manual['title']; ?></a></h5>
                                                                        </div>
                                                                        <div class="float-right">
                                                                            <div class="btn-group btn-group-sm" role="group">
                                                                                <a download href="<?php echo base_url($manual['file_location'].$manual['file_name']); ?>" class="btn btn-outline-dark" data-trigger="hover" data-tooltip="tooltip" title="Download Terms & Conditions"><i class="far fa-arrow-alt-circle-down"></i></a>
                                                                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="openManualModal(<?php echo $manual['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Terms & Conditions"><i class="far fa-edit"></i></button>
                                                                                    <button type="button" class="btn btn-outline-dark" onclick="deleteManual(<?php echo $manual['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Terms & Conditions"><i class="far fa-trash-alt"></i></button>
                                                                                <?php endif; ?>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="card-body">
                                                                        <p class="card-text"><?php echo $manual['description']; ?></p>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        <?php endif; ?>
                                                    <?php endforeach; ?>
                                                </div>
                                            <?php endif; ?>
                                        </div>
                                    </div>

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

                <div class="tab-pane fade" <?php if(strtolower($this->logged_module['role'])!='admin') echo 'hidden'; ?> id="settings" role="tabpanel" aria-labelledby="settings-tab">
                    <div class="card bg-light-transparent">
                        <div class="card-header bg-light" <?php if(strtolower($this->logged_module['role'])!='admin') echo 'hidden'; ?> >
                            <div class="float-left">
                                <?php if($this->logged_module['role'] == 'admin'): ?>
                                    <button onclick="openCategoryModal();" type="button" class="btn btn-outline-dark btn-sm"><i class="fa fa-plus"></i> Add Category</button>
                                <?php endif; ?>
                                <button id="btnShowSettingFilters" type="button" class="btn btn-outline-dark btn-sm" data-toggle="collapse" data-target="#collapseSettingFilter"><i class="fas fa-filter"></i> Show Filters</button> 
                            </div>
                        </div>
                        <!-- <div class="collapse" id="collapseSettingFilter">
                            <div class="card-header">
                                <div class="row">
                                    <div class="col-md-6">
                                        <div class="card no-shadow">
                                            <div class="card-body">
                                                Lorem ipsum dolor sit amet consectetur adipisicing elit. Ex, sed. Veritatis fugiat quasi expedita accusantium inventore quo dolor magnam. Ex soluta itaque quibusdam illum veritatis earum odio porro corrupti enim.
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <div class="card no-shadow">
                                            <div class="card-body">
                                                Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae a, quae fugiat tempora animi ipsam? Vero distinctio et tenetur earum quod, rem, adipisci hic explicabo ipsam dolore nulla cumque magnam.
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div> -->
                        <div class="card-body">
                            <div class="card no-shadow">
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table id="table_forms" class="table table-bordered table-hover">
                                            <thead>
                                                <th>Category</th>
                                                <th>Description</th>
                                                <th width="10%"></th>
                                            </thead>
                                            <tbody>
                                                <?php if($categories): ?>
                                                    <?php foreach($categories as $cat): ?>
                                                        <tr>
                                                            <td><?php echo $cat['category']; ?></td>
                                                            <td><?php echo $cat['description']; ?></td>
                                                            <td class="text-center">
                                                                <div class="btn-group btn-group-sm" role="group">
                                                                    <?php if($this->logged_module['role'] == 'admin'): ?>
                                                                        <button type="button" class="btn btn-outline-dark" onclick="openCategoryModal(<?php echo $cat['id']; ?>)" data-trigger="hover" data-tooltip="tooltip" title="Edit Category"><i class="far fa-edit"></i></button>
                                                                        <button type="button" class="btn btn-outline-dark" onclick="deleteCategory(<?php echo $cat['id']; ?>);" data-trigger="hover" data-tooltip="tooltip" title="Delete Category"><i class="far fa-trash-alt"></i></button>
                                                                    <?php endif; ?>
                                                                </div>
                                                            </td>
                                                        </tr>
                                                    <?php endforeach; ?>
                                                <?php endif; ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
</section>

<div class="modal fade" id="formModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="form-modal-title">New Form</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="formForm" class="form">
                <div class="modal-body">
					<div class="col" hidden>
						<div class="form-group">
							<label for="form_id">ID</label>
							<input type="text" class="form-control" name="form_id" id="form_id" value="">
						</div>
                    </div>
					<div class="form-row">
                        <div class="col">
                            <div class="form-group">
                                <label for="form_category">Category</label>
                                <select required data-parsley-error-message="Form category is required." class="select form-control" name="form_category" id="form_category">
                                    <option value="">Choose</option>
                                    <?php if (!empty($sub_categories)) foreach($categories as $cat): ?>
                                        <option value="<?php echo $cat['id']; ?>"><?php echo $cat['category']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <small class="form-text text-muted">Choose category for form.</small>
                            </div>
                        </div>
                    </div>
                    <div class="form-row">
                        <div class="col-3">
                            <div class="form-group">
                                <label for="form_code">Form Code</label>
                                <input type="text" required data-parsley-error-message="Form Code is required." class="form-control" name="form_code" id="form_code" placeholder="Code">
                            </div>
                        </div>
                        <div class="col">
                            <div class="form-group">
                                <label for="form_title">Title</label>
                                <input type="text" required data-parsley-error-message="Title is required." class="form-control" name="form_title" id="form_title" placeholder="Title">
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="form_description">Form Description</label>
                        <input type="text" class="form-control" name="form_description" id="form_description" placeholder="Form Description">
                    </div>
                    <div class="form-group">
                        <label for="form_file">File Upload</label>
                        <input type="file" required data-parsley-error-message="Form file is required." class="form-control" name="form_file" id="form_file" aria-describedby="formHelp">
                        <small id="formHelp" class="form-text text-muted">We only accept the following image formats: pdf, doc, docx, xls, xlsx</small>
                    </div>
                </div>
                <div class="modal-footer">
                   <div class="btn-group float-right">
						<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
						<button type="button" id="formModalSubmitBtn" onclick="uploadForm();" class="btn btn-light">Save</button>
					</div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="policyModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="policy-modal-title">New Policy</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="policyForm" class="form">
                <div class="modal-body">
					<div class="col" hidden>
						<div class="form-group">
							<label for="form_id">ID</label>
							<input type="text" class="form-control" name="policy_id" id="policy_id" value="">
						</div>
                    </div>
					<div class="form-row">
                        <div class="col">
                            <div class="form-group">
                                <label for="policy_category">Category</label>
                                <select required data-parsley-error-message="Policy category is required." class="select form-control" name="policy_category" id="policy_category">
                                    <option value="">Choose</option>
                                    <!-- <?php foreach($categories as $cat): ?>
                                        <optgroup label="<?php echo $cat['category']; ?>">
                                            <?php if (!empty($sub_categories)) foreach($sub_categories as $sub_cat): ?>
                                                <?php if($sub_cat['parent_id'] == $cat['id']): ?>
                                                    <option value="<?php echo $cat['id']; ?>"><?php echo $sub_cat['category']; ?></option>
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                        </optgroup>  
                                    <?php endforeach; ?> -->
                                    <?php if (!empty($categories)) foreach($categories as $cat): ?>
                                        <option value="<?php echo $cat['id']; ?>"><?php echo $cat['category']; ?></option>
                                    <?php endforeach; ?>
                                </select>
                                <small class="form-text text-muted">Choose category for policy.</small>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="policy_title">Title</label>
                        <input type="text" required data-parsley-error-message="Title is required." class="form-control" name="policy_title" id="policy_title" placeholder="Title">
                    </div>
                    <div class="form-group">
                        <label for="policy_description">Description</label>
                        <input type="text" class="form-control" name="policy_description" id="policy_description" placeholder="Policy Description">
                    </div>
                    <div class="form-group">
                        <label for="policy_file">File Upload</label>
                        <input type="file" required data-parsley-error-message="Policy file is required." class="form-control" name="policy_file" id="policy_file" aria-describedby="policyHelp">
                        <small id="policyHelp" class="form-text text-muted">The system only accept the following file formats: pdf, doc, docx, xls, xlsx</small>
                    </div>
                </div>
                <div class="modal-footer">
                   <div class="btn-group float-right">
						<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
						<button type="button" id="policyModalSubmitBtn" onclick="uploadPolicy();" class="btn btn-light">Save</button>
					</div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="tncModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="tnc-modal-title">New Terms & Conditions</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="tncForm" class="form">
                <div class="modal-body">
					<div class="col" hidden>
						<div class="form-group">
							<label for="tnc_id">ID</label>
							<input type="text" class="form-control" name="tnc_id" id="tnc_id" value="">
						</div>
                    </div>
                    <div class="form-group">
                        <label for="tnc_title">Title</label>
                        <input type="text" required data-parsley-error-message="Title is required." class="form-control" name="tnc_title" id="tnc_title" placeholder="Title">
                    </div>
                    <div class="form-group">
                        <label for="tnc_description">Description</label>
                        <input type="text" class="form-control" name="tnc_description" id="tnc_description" placeholder="Description">
                    </div>
                    <div class="form-group">
                        <label for="tnc_category">Category</label>
                        <select required data-parsley-error-message="Terms and conditions category is required." class="select form-control" name="tnc_category" id="tnc_category">
                            <option value="">Choose</option>
                            <?php foreach($categories as $cat): ?>
                                <option value="<?php echo $cat['id']; ?>"><?php echo $cat['category']; ?></option>
                            <?php endforeach; ?>
                        </select>
                        <small class="form-text text-muted">Choose category for Employee Handbooks.</small>
                    </div>
                    <div class="form-group">
                        <label for="tnc_file">File Upload</label>
                        <input type="file" required data-parsley-error-message="Form file is required." class="form-control" name="tnc_file" id="tnc_file" aria-describedby="uploadHelp">
                        <small id="uploadHelp" class="form-text text-muted">We only accept the following formats: pdf, doc, docx, xls, xlsx</small>
                    </div>
                </div>
                <div class="modal-footer">
                   <div class="btn-group float-right">
						<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
						<button type="button" id="tncModalSubmitBtn" onclick="uploadTnc();" class="btn btn-light">Save</button>
					</div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="manualModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="manual-modal-title">New Manual Guide</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="manualForm" class="form">
                <div class="modal-body">
                    <div class="col" hidden>
                        <div class="form-group">
                            <label for="manual_id">ID</label>
                            <input type="text" class="form-control" name="manual_id" id="manual_id" value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="manual_title">Title</label>
                        <input type="text" required data-parsley-error-message="Title is required." class="form-control" name="manual_title" id="manual_title" placeholder="Title">
                    </div>
                    <div class="form-group">
                        <label for="manual_description">Description</label>
                        <input type="text" class="form-control" name="manual_description" id="manual_description" placeholder="Description">
                    </div>
                    <div class="form-group">
                        <label for="manual_category">Category</label>
                        <select required data-parsley-error-message="Manual guide category is required." class="select form-control" name="manual_category" id="manual_category">
                            <option value="">Choose</option>
                            <?php foreach($categories as $cat): ?>
                                <option value="<?php echo $cat['id']; ?>"><?php echo $cat['category']; ?></option>
                            <?php endforeach; ?>
                        </select>
                        <small class="form-text text-muted">Choose category for Manual Guide.</small>
                    </div>
                    <div class="form-group">
                        <label for="manual_file">File Upload</label>
                        <input type="file" required data-parsley-error-message="Form file is required." class="form-control" name="manual_file" id="manual_file" aria-describedby="uploadHelp">
                        <small id="uploadHelp" class="form-text text-muted">We only accept the following formats: pdf, doc, docx, xls, xlsx</small>
                    </div>
                </div>
                <div class="modal-footer">
                   <div class="btn-group float-right">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
                        <button type="button" id="manualModalSubmitBtn" onclick="uploadTnc();" class="btn btn-light">Save</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="categoryModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="category-modal-title">New Category</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <form id="categoryForm" class="form">
                <div class="modal-body">
					<div class="col" hidden>
						<div class="form-group">
							<label for="category_id">ID</label>
							<input type="text" class="form-control" name="category_id" id="category_id" value="">
						</div>
                    </div>
                    <div class="form-group">
                        <label for="category">Category</label>
                        <input type="text" required data-parsley-error-message="Category is required." class="form-control" name="category" id="category" placeholder="Category Name">
                    </div>
                    <div class="form-group">
                        <label for="category_description">Description</label>
                        <input type="text" class="form-control" name="category_description" id="category_description" placeholder="Description">
                    </div>
                </div>
                <div class="modal-footer">
                   <div class="btn-group float-right">
						<button type="button" class="btn btn-primary" data-dismiss="modal">Cancel</button>
						<button type="button" id="categoryModalSubmitBtn" onclick="createCategory();" class="btn btn-light">Save</button>
					</div>
                </div>
            </form>
        </div>
    </div>
</div>

<script>
    $('#tab a').click(function(e) {
		e.preventDefault();
		$(this).tab('show');
	});

	var hash = window.location.hash;
	
	$(function() {
		$('#tab a[href="' + hash + '"]').tab('show');
        let a = $('.collapse_setter_doc_no');
        $.each(a,function(index,value){
            let document_no = $(value).val();
            let target = $(value).data('collapsetarget');


            $(target).html(document_no);
            console.log(target);
        });
	});
	
	$(".nav-pills > a").on("shown.bs.tab", function(e) {
		var id = $(e.target).attr("href").substr(1);
		window.location.hash = id;
	});

    $('#collapseFormFilter').on('show.bs.collapse', function () {
        $('#btnShowFormFilters').addClass('active');
    })
    $('#collapseFormFilter').on('hide.bs.collapse', function () {
        $('#btnShowFormFilters').removeClass('active');
    })
    $('#collapsePolicyFilter').on('show.bs.collapse', function () {
        $('#btnShowPolicyFilters').addClass('active');
    })
    $('#collapsePolicyFilter').on('hide.bs.collapse', function () {
        $('#btnShowPolicyFilters').removeClass('active');
    })
    $('#collapseTncFilter').on('show.bs.collapse', function () {
        $('#btnShowTncFilters').addClass('active');
    })
    $('#collapseTncFilter').on('hide.bs.collapse', function () {
        $('#btnShowTncFilters').removeClass('active');
    })
    $('#collapseSettingFilter').on('show.bs.collapse', function () {
        $('#btnShowSettingFilters').addClass('active');
    })
    $('#collapseSettingFilter').on('hide.bs.collapse', function () {
        $('#btnShowSettingFilters').removeClass('active');
    })

    function openFormModal(id)
    {
        if(id != null)
        {
            clearForm("#formForm");

            $.ajax({
                url: "<?php echo base_url('hr/form/getForms'); ?>",
				type: "POST",
				data: {id : id},
				dataType: "JSON",
				success: function(data) {
					if(data.status == 'Success')
					{
                        var form = data.form;
                        console.log(form.department_id);
                        $('#form-modal-title').html('Update Form');
                        $('#formModalSubmitBtn').attr('onclick', 'updateForm()');
                        $('#form_file').attr('required', false);

                        $('#form_id').val(id);
                        $('#form_department').val(form.department_id).trigger('change.select2');
                        $('#form_code').val(form.code);
                        $('#form_title').val(form.title);
                        $('#form_description').val(form.description);
					}
				}
            });
        }
        else
        {
            $('#form-modal-title').html('Add New Form');
            $('#form_file').attr('required', true);
            $('#formModalSubmitBtn').attr('onclick', 'uploadForm()');

            clearForm("#formForm");
        }

        $('#formModal').modal('show');
    }

    function uploadForm()
	{
		validateForm("#formForm", "Are you sure you want to add this form?", function(){
            $("#formModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");
			var form_data = new FormData();

			// form_data.append("category", $('#form_category').val());
			form_data.append("department_id",  $('#form_department').val());
			form_data.append("category_id",  $('#form_category').val());
			form_data.append("code",  $('#form_code').val());
			form_data.append("title",  $('#form_title').val());
			form_data.append("description",  $('#form_description').val());
            
			form_data.append("form", $('#form_file').prop('files')[0]);

			$.ajax({
				url: "<?php echo base_url('hr/form/uploadForm'); ?>",
				type: "POST",
				data: form_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#formModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function updateForm()
    {
        validateForm("#formForm", "Are you sure you want to update this form?", function(){
			var form_data = new FormData();

			form_data.append("id", $('#form_id').val());
			form_data.append("category_id",  $('#form_category').val());
			form_data.append("code",  $('#form_code').val());
			form_data.append("title",  $('#form_title').val());
			form_data.append("description",  $('#form_description').val());

            if($('#form_file').get(0).files.length > 0){
                form_data.append("form", $('#form_file').prop('files')[0]);
            }
             
			$.ajax({
				url: "<?php echo base_url('hr/form/updateForm'); ?>",
				type: "POST",
				data: form_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#formModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
    }

    function deleteForm(id)
	{
		toastConfirm("Are you sure you want to delete this form?", function(){
			$.ajax({
				type: 'POST',
				url: '<?php echo base_url('hr/form/deleteForm'); ?>',
				data: {
					'id' : id
				},
				dataType: 'JSON',
				success: function(data) {
					if(data.status == 'Success')
					{
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function openPolicyModal(id)
    {
        if(id != null)
        {
            clearForm("#policyForm");

            $.ajax({
                url: "<?php echo base_url('hr/policy/getPolicies'); ?>",
                type: "POST",
                data: {id : id},
                dataType: "JSON",
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        var policy = data.policy;
                        $('#policy-modal-title').html('Update Policy');
                        $('#policyModalSubmitBtn').attr('onclick', 'updatePolicy()');
                        $('#policy_file').attr('required', false);

                        $('#policy_id').val(id);
                        $('#policy_category').val(policy.category_id).trigger('change.select2');
                        $('#policy_title').val(policy.title);
                        $('#policy_description').val(policy.description);
                    }
                }
            });
        }
        else
        {
            $('#policy-modal-title').html('Add New Policy');
            $('#policy_file').attr('required', true);
            $('#policyModalSubmitBtn').attr('onclick', 'uploadPolicy()');

            clearForm("#policyForm");
        }

        $('#policyModal').modal('show');
    }

    function uploadPolicy()
	{
		validateForm("#policyForm", "Are you sure you want to add this policy?", function(){
            $("#policyModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");

			var form_data = new FormData();

			form_data.append("category_id", $('#policy_category').val());
			form_data.append("title",  $('#policy_title').val());
			form_data.append("description",  $('#policy_description').val());
            
			form_data.append("policy", $('#policy_file').prop('files')[0]);

			$.ajax({
				url: "<?php echo base_url('hr/policy/uploadPolicy'); ?>",
				type: "POST",
				data: form_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#policyModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function updatePolicy()
    {
        validateForm("#policyForm", "Are you sure you want to update this policy?", function(){
            $("#modalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");

			var form_data = new FormData();

			form_data.append("id", $('#policy_id').val());
			form_data.append("category_id",  $('#policy_category').val());
			form_data.append("title",  $('#policy_title').val());
			form_data.append("description",  $('#policy_description').val());

            if($('#policy_file').get(0).files.length > 0){
                form_data.append("policy", $('#policy_file').prop('files')[0]);
            }
             
			$.ajax({
				url: "<?php echo base_url('hr/policy/updatePolicy'); ?>",
				type: "POST",
				data: form_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#formModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
    }

    function deletePolicy(id)
	{
		toastConfirm("Are you sure you want to delete this policy?", function(){
			$.ajax({
				type: 'POST',
				url: '<?php echo base_url('hr/policy/deletePolicy'); ?>',
				data: {
					'id' : id
				},
				dataType: 'JSON',
				success: function(data) {
					if(data.status == 'Success')
					{
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function openTncModal(id)
    {
        if(id != null)
        {
            clearForm("#tncForm");

            $.ajax({
                url: "<?php echo base_url('hr/tnc/getTncs'); ?>",
                type: "POST",
                data: {id : id},
                dataType: "JSON",
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        var tnc = data.tnc;

                        $('#tnc_id').val(id);
                        $('#tnc_title').val(tnc.title);
                        $('#tnc_description').val(tnc.description);

                        $('#form-modal-title').html('Update Terms & Conditions');
                        $('#tncModalSubmitBtn').attr('onclick', 'updateTnc()');
                        $('#tnc_file').attr('required', false);
                    }
                }
            });
        }
        else
        {
            $('#form-modal-title').html('Add New Terms & Conditions');
            $('#tnc_file').attr('required', true);
            $('#tncModalSubmitBtn').attr('onclick', 'uploadTnc()');

            clearForm("#tncForm");
        }

        $('#tncModal').modal('show');
    }

    function uploadTnc()
	{
		validateForm("#tncForm", "Are you sure you want to add this Terms & Conditions?", function(){
            $("#tncModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");
			var tnc_data = new FormData();

			// tnc_data.append("category", $('#form_category').val());
			tnc_data.append("title",  $('#tnc_title').val());
			tnc_data.append("description",  $('#tnc_description').val());
            tnc_data.append("category", $('#tnc_category').val());    
			tnc_data.append("tnc", $('#tnc_file').prop('files')[0]);

			$.ajax({
				url: "<?php echo base_url('hr/tnc/uploadTnc'); ?>",
				type: "POST",
				data: tnc_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#tncModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function updateTnc()
    {
        validateForm("#tncForm", "Are you sure you want to update this Terms & Conditions?", function(){
			var tnc_data = new FormData();

			tnc_data.append("id", $('#form_id').val());
			tnc_data.append("title",  $('#form_title').val());
			tnc_data.append("description",  $('#form_description').val());

            if($('#tnc_file').get(0).files.length > 0){
                tnc_data.append("tnc", $('#tnc_file').prop('files')[0]);
            }
             
			$.ajax({
				url: "<?php echo base_url('hr/tnc/updateTnc'); ?>",
				type: "POST",
				data: tnc_data,
				dataType: "JSON",
				processData: false,
				contentType: false,
				success: function(data) {
					if(data.status == 'Success')
					{
						$('#formModal').modal('hide');
						
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
    }

    function deleteTnc(id)
	{
		toastConfirm("Are you sure you want to delete this Terms & Conditions?", function(){
			$.ajax({
				type: 'POST',
				url: '<?php echo base_url('hr/tnc/deleteTnc'); ?>',
				data: {
					'id' : id
				},
				dataType: 'JSON',
				success: function(data) {
					if(data.status == 'Success')
					{
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
	}

    function openCategoryModal(id)
    {
        if(id != null)
        {
            clearForm("#categoryForm");

            $.ajax({
                url: "<?php echo base_url('hr/policiesandprocedures/getCategories'); ?>",
                type: "POST",
                data: {id : id},
                dataType: "JSON",
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        var category = data.category;

                        $('#category_id').val(id);
                        $('#category').val(category.category);
                        $('#category_description').val(category.description);

                        $('#category-modal-title').html('Update Category');
                        $('#categoryModalSubmitBtn').attr('onclick', 'updateCategory()');
                    }
                }
            });
        }
        else
        {
            $('#category-modal-title').html('Add New Category');
            $('#categoryModalSubmitBtn').attr('onclick', 'createCategory()');

            clearForm("#categoryForm");
        }

        $('#categoryModal').modal('show');
    }

    function createCategory()
    {
        validateForm("#categoryForm", "Are you sure you want to create this category?", function(){
            $("#categoryModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");

            var create_data = {
					'category' 	  : $('#category').val(),
					'description' : $('#category_description').val()
				};

				$.ajax({
					url: "<?php echo base_url('hr/policiesandprocedures/createCategory'); ?>",
					type: "POST",
					data: create_data,
					dataType: "JSON",
					success: function(data) {
						if(data.status == 'Success')
						{
							$('#categoryModal').modal('hide');
							
							localStorage.setItem("status",data.status);
							localStorage.setItem("msg",data.msg);

							location.reload();
						}
					}
				})	
        });
    }

    function updateCategory()
    {
        validateForm("#categoryForm", "Are you sure you want to update this category?", function(){
            $("#categoryModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");

            var update_data = {
					'id' 	      : $('#category_id').val(),
					'category' 	  : $('#category').val(),
					'description' : $('#category_description').val()
				};

				$.ajax({
					url: "<?php echo base_url('hr/policiesandprocedures/updateCategory'); ?>",
					type: "POST",
					data: update_data,
					dataType: "JSON",
					success: function(data) {
						if(data.status == 'Success')
						{
							$('#categoryModal').modal('hide');
							
							localStorage.setItem("status",data.status);
							localStorage.setItem("msg",data.msg);

							location.reload();
						}
					}
				})	
        });
    }

    function deleteCategory(id)
    {
        toastConfirm("Are you sure you want to delete this Category?", function(){
			$.ajax({
				type: 'POST',
				url: '<?php echo base_url('hr/policiesandprocedures/deleteCategory'); ?>',
				data: {
					'id' : id
				},
				dataType: 'JSON',
				success: function(data) {
					if(data.status == 'Success')
					{
						localStorage.setItem("status",data.status);
						localStorage.setItem("msg",data.msg);

						location.reload();
					}
				}
			});
		});
    }

    function clearForm(e)
	{
		$(e).parsley().reset();

		$(e).find("input, textarea").val("");
		$(e).find("select").val("").trigger('change.select2');
	}

    function openManualModal(id)
    {
        if(id != null)
        {
            clearForm("#manualForm");

            $.ajax({
                url: "<?php echo base_url('hr/manual/getManuals'); ?>",
                type: "POST",
                data: {id : id},
                dataType: "JSON",
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        var manual = data.manual;

                        $('#manual_id').val(id);
                        $('#manual_title').val(manual.title);
                        $('#manual_description').val(manual.description);
                        $('#manual_category').val(manual.category_id).change();

                        $('#manual-modal-title').html('Update Manual Guide');
                        $('#manualModalSubmitBtn').attr('onclick', 'updateManual()');
                        $('#manual_file').attr('required', false);
                    }
                }
            });
        }
        else
        {
            $('#manual-modal-title').html('Add New Manual Guide');
            $('#manual_file').attr('required', true);
            $('#manualModalSubmitBtn').attr('onclick', 'uploadManual()');

            clearForm("#manualForm");
        }

        $('#manualModal').modal('show');
    }

    function uploadManual()
    {
        validateForm("#manualForm", "Are you sure you want to add this Manual Guide?", function(){
            $("#manualModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");
            var manual_data = new FormData();

            // manual_data.append("category", $('#form_category').val());
            manual_data.append("title",  $('#manual_title').val());
            manual_data.append("description",  $('#manual_description').val());
            manual_data.append("category_id", $('#manual_category').val());    
            manual_data.append("manual", $('#manual_file').prop('files')[0]);

            $.ajax({
                url: "<?php echo base_url('hr/manual/uploadManual'); ?>",
                type: "POST",
                data: manual_data,
                dataType: "JSON",
                processData: false,
                contentType: false,
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        $('#manualModal').modal('hide');
                        
                        localStorage.setItem("status",data.status);
                        localStorage.setItem("msg",data.msg);

                        location.reload();
                    }
                }
            });
        });
    }

    function updateManual()
    {
        validateForm("#manualForm", "Are you sure you want to update this Manual Guide?", function(){
            $("#manualModalSubmitBtn").attr('disabled', true).append("&nbsp;&nbsp;<i class='fas fa-spinner fa-spin'>");
            var manual_data = new FormData();

            manual_data.append("id", $('#manual_id').val());
            manual_data.append("title",  $('#manual_title').val());
            manual_data.append("description",  $('#manual_description').val());

            if($('#manual_file').get(0).files.length > 0){
                manual_data.append("manual", $('#manual_file').prop('files')[0]);
            }
             
            $.ajax({
                url: "<?php echo base_url('hr/manual/updateManual'); ?>",
                type: "POST",
                data: manual_data,
                dataType: "JSON",
                processData: false,
                contentType: false,
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        $('#manualModal').modal('hide');
                        
                        localStorage.setItem("status",data.status);
                        localStorage.setItem("msg",data.msg);

                        location.reload();
                    }
                }
            });
        });
    }

    function deleteManual(id)
    {
        toastConfirm("Are you sure you want to delete this Manual Guide?", function(){
            $.ajax({
                type: 'POST',
                url: "<?php echo base_url('hr/manual/deleteManual'); ?>",
                data: {
                    'id' : id
                },
                dataType: 'JSON',
                success: function(data) {
                    if(data.status == 'Success')
                    {
                        localStorage.setItem("status",data.status);
                        localStorage.setItem("msg",data.msg);

                        location.reload();
                    }
                }
            });
        });
    }
</script>