<?php


include '../assets/constant/config.php';
include '../assets/constant/checklogin.php';
try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}


?>

<?php

$stmt1 = $conn->prepare("SELECT * FROM `manage_web` ");
$stmt1->execute();
$record1 = $stmt1->fetchAll();
foreach ($record1 as $key1) { ?>

    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
        <title><?php echo $key1['title']; ?></title>
        <meta content="" name="description" />
        <meta content="" name="Mayuri K. Freelancer" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />

        <link rel="shortcut icon" href="../assets/images/<?php echo $key1['photos']; ?>">

       
        
        <link rel="stylesheet" href="../assets/css/feathericon.min.css">
        <link href="../assets/plugins/morris/morris.css" rel="stylesheet">

        <link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
        <link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
        <link href="../assets/css/style.css" rel="stylesheet" type="text/css">
        <link href="../assets/plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link href="../assets/plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <!-- Responsive datatable examples -->
        <link href="../assets/plugins/datatables/responsive.bootstrap4.min.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!---Barcode------------->
 <link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128+Text" rel="stylesheet">
 
        <!-----------Select2---------->
        <link href="../assets/css/select2.css" rel="stylesheet" type="text/css">
        <!-------------Sweetalert----------->
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
     
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    </head>


    <body class="fixed-left">

        <!-- Loader -->
       <div id="preloader">
  <img src="../assets/images/loader.gif" alt="Loading...">
</div>

        <!-- Begin page -->
        <div id="wrapper">

            <!-- ========== Left Sidebar Start ========== -->
            <div class="left side-menu">
                <button type="button" class="button-menu-mobile button-menu-mobile-topbar open-left waves-effect">
                    <i class="ion-close"></i>
                </button>

                <!-- LOGO -->
                <div class="topbar-left">
                    <div class="text-center">
                        <!--<a href="index.html" class="logo"><i class="mdi mdi-assistant"></i>Zoter</a>-->
                        <a class="logo">
                        <?php
// Read the image file and encode it to Base64
$imagePath = "../assets/images/" . $key1['photo1']; // Path to your image file
$imageData = file_get_contents($imagePath);
$base64Image = base64_encode($imageData);
?>
                            <img src="data:image/jpeg;base64,<?php echo $base64Image; ?>" alt="" class="logo-large"><?php } ?>
                        </a>
                    </div>
                </div>



                <?php $stmt = $conn->prepare("SELECT * FROM `login` WHERE id='".$_SESSION['id']."'");
   $stmt->execute();
   $admin = $stmt->fetch(PDO::FETCH_ASSOC);
  // print_r($admin); exit;
   $stmt = $conn->prepare("SELECT * FROM `permission_role` WHERE group_id='".$admin['role']."'");
   $stmt->execute();
   $roles = $stmt->fetchAll(); 
    // print_r($roles); exit;
   $setroles=array();
   foreach ($roles as $role) {
       $stmt = $conn->prepare("SELECT * FROM `permission` WHERE id='".$role['permission_id']."'");
     // print_r($stmt); exit;
   $stmt->execute();
   $per = $stmt->fetchAll();
   array_push($setroles, $per[0]['name']);
   }
  // print_r($setroles); exit;
   $_SESSION['userroles']=$setroles;
   $userroles=$_SESSION['userroles']; 
   ?>




                <div class="sidebar-inner niceScrollleft">

                    <div id="sidebar-menu">
                        <ul>
                            <li>
                                <a href="https://mayurik.com/" class="waves-effect" target="_blank">
                                <i data-feather="user-check"></i>
                                    <span> <b>Author</b> </span>
                                </a>
                            </li>

                          
                           <?php if (in_array('branch_management',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect"><i class="fa fa-building"></i> <span>Branches</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                          <?php if (in_array('add_branch',$userroles) || ($admin['role']==0) || ($admin['role']==2))
                  { ?>
                     <li><a href="add_branch.php">Add Branch</a></li>
                  <?php } ?>
                          <?php if (in_array('view_branch',$userroles) || ($admin['role']==0) || ($admin['role']==2) )
                  { ?>
                     <li><a href="manage_branch.php">Manage Branch</a></li>
                  <?php } ?>
                     </ul>
                  </li>  <?php } ?>

   

                 <?php if (in_array('member_management',$userroles) || ($admin['role']==0) || ($admin['role']==3)|| ($admin['role']==2))
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect"><i class="fa fa-users"></i> <span>Member</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                          <?php if (in_array('add_member',$userroles) || ($admin['role']==0) || ($admin['role']==3))
                  { ?>
                     <li><a href="add_member.php">Add Member</a></li>
                  <?php } ?>
                          <?php if (in_array('view_member',$userroles) || ($admin['role']==0) || ($admin['role']==3))
                  { ?>
                     <li><a href="manage_member.php">Manage Member</a></li>
                  <?php } ?>
                     </ul>
                  </li>  <?php } ?>






             <?php if (in_array('soul_winning_mgnt',$userroles) || ($admin['role']==0) || ($admin['role']==3)|| ($admin['role']==2))
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect"><i class="fa fa-handshake"></i> <span>Soul winning</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                          <?php if (in_array('add_soul_winning',$userroles) || ($admin['role']==0) || ($admin['role']==3))
                  { ?>
                     <li><a href="add_soulwinning.php">Add Soul winning</a></li>
                  <?php } ?>
                          <?php if (in_array('view_soul_winning',$userroles) || ($admin['role']==0) || ($admin['role']==3))
                  { ?>
                     <li><a href="manage_soulwinning.php">Manage Soul winning</a></li>
                  <?php } ?>
                     </ul>
                  </li>  <?php } ?>




    <?php if (in_array('event_mangement',$userroles) || ($admin['role']==0) || ($admin['role']==3)|| ($admin['role']==2))
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect"><i class="fa fa-calendar"></i> <span>Event</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                          <!-- <?php if (in_array('add_event',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="add_event.php">Add</a></li>
                  <?php } ?> -->
                          <?php if (in_array('view_event',$userroles) || ($admin['role']==0) ||($admin['role']==3))
                  { ?>
                     <li><a href="manage_event.php">View Event</a></li>
                  <?php } ?>
                  <?php if (in_array('view_location',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_location.php"> Manage Location</a></li>
                  <?php } ?>
                  <?php if (in_array('view_calender',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_calender.php"> Manage Calender</a></li>
                  <?php } ?>
                  <?php if (in_array('view_volunteerrole',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_volunteerrole.php">Manage Volunteerrole</a></li>
                  <?php } ?>
                   <?php if (in_array('view_payment',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_payment.php">Manage Payment</a></li>
                  <?php } ?>
                     </ul>
                  </li>  <?php } ?>



<?php if (in_array('pledge_management',$userroles) || ($admin['role']==0) || ($admin['role']==3)|| ($admin['role']==2) )
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect"><i class="fa fa-gift"></i> <span>Pledges</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                           <?php if (in_array('add_pledge',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="add_pledges.php">Add pledge</a></li>
                  <?php } ?> 
                          <?php if (in_array('view_pledge',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_pledges.php">View pledge</a></li>
                  <?php } ?>
                  <?php if (in_array('view_ampaign',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_campaign.php"> Manage campaign</a></li>
                  <?php } ?>
                  
                  
                     </ul>
                  </li>  <?php } ?>


                             

<?php if (in_array('contribution_mgnt',$userroles) || ($admin['role']==0) || ($admin['role']==3)|| ($admin['role']==2) )
                  { ?>
                     <li class="has_sub">
                     <a href="javascript:void(0);" class="waves-effect">  <i class="fas fa-money-bill-alt"></i> <span>Contribution</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                     <ul class="list-unstyled">
                           <?php if (in_array('add_contribution',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="Add_contribution.php">Add contribution</a></li>
                  <?php } ?> 
                          <?php if (in_array('view_contribution',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_contribution.php">View contribution</a></li>
                  <?php } ?>
                  <?php if (in_array('view_batch',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_batch.php"> Manage batch</a></li>
                  <?php } ?>
                  <?php if (in_array('view_fund',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_funds.php"> Manage Funds</a></li>
                  <?php } ?>
                  <?php if (in_array('view_paymentmethod',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_payementmethod.php">Manage Payment Method </a></li>
                  <?php } ?>
                  <?php if (in_array('view_contitype',$userroles) || ($admin['role']==0))
                  { ?>
                     <li><a href="manage_contritype.php">Manage contribution type  </a></li>
                  <?php } ?>
                     </ul>
                  </li>  <?php } ?>


                              


<?php if (in_array('followups_management', $userroles) || ($admin['role'] == 0) || ($admin['role']==3)|| ($admin['role']==2)) { ?>          
    <li class="has_sub">
        <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-comments"></i> <span>Follow Ups</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
        <ul class="list-unstyled">
            <?php if (in_array('add_followup', $userroles) || ($admin['role'] == 0)) { ?>             
                <li><a href="add_followup.php">Add Follow Ups</a></li>
            <?php } ?>
            <?php if (in_array('view_followup', $userroles) || ($admin['role'] == 0)) { ?>            
                <li><a href="manage_followup.php">View Follow Ups</a></li>
            <?php } ?>
            <?php if (in_array('view_followupcategory', $userroles) || ($admin['role'] == 0)) { ?>            
                <li><a href="manage_followupcategory.php">Manage Follow Ups Category</a></li>
            <?php } ?>
        </ul>
    </li>
<?php } ?>


                            




<?php if (in_array('payroll_management', $userroles) || ($admin['role'] == 0)|| ($admin['role']==2)) { ?>          
    <li class="has_sub">
        <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-paypal"></i> <span>PayRoll</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
        <ul class="list-unstyled">
            <?php if (in_array('add_payroll', $userroles) || ($admin['role'] == 0)) { ?>             
                <li><a href="add_payroll1.php">Add PayRoll</a></li>
            <?php } ?>
            <?php if (in_array('view_payroll', $userroles) || ($admin['role'] == 0)) { ?>            
                <li><a href="manage_payroll.php">Manage PayRoll</a></li>
            <?php } ?>
        </ul>
    </li>
<?php } ?>
    

<?php if (in_array('expense_management',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-share"></i> <span>Expense</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('add_expense',$userroles) || ($admin['role']==0))
                  { ?>             
                                    <li><a href="add_expense.php">Add Expense </a></li>
                                       <?php } ?>
                         <?php if (in_array('view_expense',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="manage_expense.php">Manage Expense </a></li>
                                       <?php } ?>
                                   
                                </ul>
                            </li>
                              
<?php } ?>
                         
<?php if (in_array('income_management',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-plus"></i> <span>Income</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('add_income',$userroles) || ($admin['role']==0))
                  { ?>             
                                    <li><a href="add_income.php">Add Income</a></li>
                                       <?php } ?>
                         <?php if (in_array('view_income',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="manage_income.php">Manage Income</a></li>
                                       <?php } ?>
                                   
                                    <li><a href="manage_incometype.php">Manage IncomeType</a></li>
                                      
                                   <li><a href="instapaymemt.php">insta Paymemt</a></li>
                                </ul>
                            </li>
                               <?php } ?>




                          
                           <?php if (in_array('report',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class=" fa fa-bar-chart"></i> <span>Report</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('view_report',$userroles) || ($admin['role']==0))
                  { ?>             
                                    <li><a href="cashflow_report.php">Cashflow Report</a></li>
                                       <?php } ?>
                         <?php if (in_array('view_report',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="profitloss_report.php">Profitloss Report </a></li>
                                       <?php } ?>
                                   
                                </ul>
                            </li>
                               <?php }?>
                                
                            

                            <?php if (in_array('asset_management',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-briefcase"></i> <span>Asset</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('add_asset',$userroles) || ($admin['role']==0))
                  { ?>             
                                    <li><a href="add_asset.php">Add Assets </a></li>
                                       <?php } ?>
                         <?php if (in_array('view_asset',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="manage_asset.php">Manage Asset </a></li>
                                       <?php } ?>
                                    <?php if (in_array('view_assettype',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="manage_assettype.php">Manage Assets Type  </a></li>
                                       <?php } ?>



                                </ul>
                            </li>
                               <?php }?>


  <?php if (in_array('communication',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class=" fa fa-envelope"></i> <span>Communication</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('email',$userroles) || ($admin['role']==0))
                  { ?>             
                            <li><a href="manage_mail.php"> Email</a></li>
                                       <?php } ?>
                        <li><a href=".php"> SMS Gateway</a></li>
                                   
                                </ul>
                            </li>
                               <?php }?>



<?php if (in_array('custom_field_management',$userroles) || ($admin['role']==0)|| ($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class=" fa fa-users"></i> <span>Custom Fields</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('add_custom_field',$userroles) || ($admin['role']==0))
                  { ?>             
                                    <li><a href="add_custom_field.php">Add Custom Fields </a></li>
                                       <?php } ?>
                         <?php if (in_array('view_custom_field',$userroles) || ($admin['role']==0))
                  { ?>            
                                    <li><a href="manage_custome_field.php">View Custom Fields </a></li>
                                       <?php } ?>
                                    


                                </ul>
                            </li>
                               <?php }?>

                <?php if (in_array('user_management',$userroles) || ($admin['role']==0) ||($admin['role']==2))
                  { ?>          
                 <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class=" fa fa-users"></i> <span>User</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                         <?php if (in_array('add_user',$userroles) || ($admin['role']==0) || ($admin['role']==2))
                  { ?>             
                                    <li><a href="add_user.php">Add User </a></li>
                                       <?php } ?>
                         <?php if (in_array('view_user',$userroles) || ($admin['role']==0)|| ($admin['role']==2) )
                  { ?>            
                                    <li><a href="manage_user.php">Manage User </a></li>
                                       <?php } ?>
                                   
 <li><a href="import_csv.php">Import file </a></li>


                                </ul>
                            </li>
                               <?php } ?>



  <?php if (in_array('role_management',$userroles) || ($admin['role']==0) ||($admin['role']==2))
                  { ?>         
                            <li class="has_sub">
                                <a href="javascript:void(0);" class="waves-effect"> <i class=" fa fa-user-circle"></i> <span>Role</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
                                <ul class="list-unstyled">
                                    
                                <?php if (in_array('Role_management',$userroles) || ($admin['role']==0) ||($admin['role']==2))
                  { ?> 
                                    <li><a href="add_role.php">Add </a></li>
                           <?php }
                           if (in_array('Add_role',$userroles) || ($admin['role']==0)|| ($admin['role']==2) )
                  { ?>         
                                    <li><a href="manage_role.php">Manage </a></li>
                                 <?php } ?>
                                   
                                </ul>
                            </li>
                         <?php } ?>



 <?php if (in_array('audit_trail', $userroles) || ($admin['role'] == 0)|| ($admin['role']==2)) { ?>         
    <li class="has_sub">
        <a href="javascript:void(0);" class="waves-effect"> <i class="fa fa-area-chart"></i> <span>Audit Trail</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
        <ul class="list-unstyled">
            <?php if (in_array('view_audit_trail', $userroles) || ($admin['role'] == 0)) { ?> 
                <li><a href="manage_activity.php">Audit Trail</a></li>
            <?php } ?>
        </ul>
    </li>
<?php } ?>

                             

                            <?php if($admin['role']==0)
                  { ?>
                  <li class="has_sub">
        <a href="javascript:void(0);" class="waves-effect"> <i class="fa-brands fa-youtube"></i> <span>Portfolio</span> <span class="float-right"><i class="mdi mdi-chevron-right"></i></span></a>
        <ul class="list-unstyled">
            <?php if (in_array('view_audit_trail', $userroles) || ($admin['role'] == 0)) { ?> 
                <li><a href="https://www.youtube.com/@MayuriK/videos" target="_blank">Video Demos</a></li>
            <?php } ?>
        </ul>
    </li>
               <?php } ?>



                        </ul>
                    </div>
                    <div class="clearfix"></div>
                </div> <!-- end sidebarinner -->
            </div>
            <!-- Left Sidebar End -->

            <!-- Start right Content here -->

            <div class="content-page">
                <!-- Start content -->
                <div class="content">