<?php 
define('DOCUMENT_ROOT_CLASS','../');
define('DOCUMENT_ROOT_INC_FOLDER','');
$filepath = realpath(dirname(__FILE__));
require "../inc/header.php";
Session::CheckSession(); 
$msg = Session::get('msg');
Session::set("msg", NULL); 
$where = "";
if(!empty($_GET['state']) and $_GET['state'] == 4 OR $_GET['state'] == 5 OR $_GET['state'] == 6 OR $_GET['state'] == 7 OR $_GET['state'] == 8 OR $_GET['state'] == 9 OR $_GET['state'] == 10 OR $_GET['state'] == 11 OR $_GET['state'] == 12 OR $_GET['state'] == 13 OR $_GET['state'] == 14 OR $_GET['state'] == 15 OR $_GET['state'] == 16 OR $_GET['state'] == 17 OR $_GET['state'] == 18 OR $_GET['state'] == 19 OR $_GET['state'] == 20 OR $_GET['state'] == 21 OR $_GET['state'] == 22 OR $_GET['state'] == 23 OR $_GET['state'] == 24 OR $_GET['state'] == 25 OR $_GET['state'] == 26 OR $_GET['state'] == 27 OR $_GET['state'] == 28 ):
    if($_GET['state'] == 4){ $targetpage = "dictionaries.php?tbl=sys_erp_adm_countries_states&state=4"; }
    if($_GET['state'] == 5){ $targetpage = "dictionaries.php?tbl=tbl_staff&state=5"; }
    if($_GET['state'] == 6){ $targetpage = "dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6"; }
    if($_GET['state'] == 7){ $targetpage = "dictionaries.php?tbl=tbl_prospect_potential_level&state=7"; }
    if($_GET['state'] == 8){ $targetpage = "dictionaries.php?tbl=tbl_third_party_types&state=8"; }
    if($_GET['state'] == 9){ $targetpage = "dictionaries.php?tbl=tbl_prospection_status&state=9"; }
    if($_GET['state'] == 10){ $targetpage = "dictionaries.php?tbl=tbl_professional_titles&state=10"; }
    if($_GET['state'] == 11){ $targetpage = "dictionaries.php?tbl=tbl_contacts_types&state=11"; }
    if($_GET['state'] == 12){ $targetpage = "dictionaries.php?tbl=tbl_lead_status&state=12"; }
    if($_GET['state'] == 13){ $targetpage = "dictionaries.php?tbl=fin_accnt_taxes_types&state=13"; }
    if($_GET['state'] == 14){ $targetpage = "dictionaries.php?tbl=tbl_resources_types&state=14"; }
    if($_GET['state'] == 15){ $targetpage = "dictionaries.php?tbl=tbl_leave_types&state=15"; }
    if($_GET['state'] == 16){ $targetpage = "dictionaries.php?tbl=fin_accnt_expense_report_types&state=16"; }
    if($_GET['state'] == 17){ $targetpage = "dictionaries.php?tbl=tbl_transportation_category&state=17"; }
    if($_GET['state'] == 18){ $targetpage = "dictionaries.php?tbl=tbl_range_by_transportation_category&state=18"; }
    if($_GET['state'] == 19){ $targetpage = "dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19"; }
    if($_GET['state'] == 20){ $targetpage = "dictionaries.php?tbl=fin_accnt_payment_trems&state=20"; }
    if($_GET['state'] == 21){ $targetpage = "dictionaries.php?tbl=fin_accnt_payment_mode&state=21"; }
    if($_GET['state'] == 22){ $targetpage = "dictionaries.php?tbl=tbl_origin_of_proposals&state=22"; }
    if($_GET['state'] == 23){ $targetpage = "dictionaries.php?tbl=tbl_ordering_methods&state=23"; }
    if($_GET['state'] == 24){ $targetpage = "dictionaries.php?tbl=tbl_shipping_methods&state=24"; }
    if($_GET['state'] == 25){ $targetpage = "dictionaries.php?tbl=tbl_delivery_delay&state=25"; }
    if($_GET['state'] == 26){ $targetpage = "dictionaries.php?tbl=tbl_paper_formats&state=26"; }
    if($_GET['state'] == 27){ $targetpage = "dictionaries.php?tbl=tbl_units&state=27"; }
    if($_GET['state'] == 28){ $targetpage = "dictionaries.php?tbl=tbl_incoterms&state=28"; }
    $limit = 100;
    $total_pages = $commonFunctions->getData($_GET['tbl'],'');
    $total_pages = count($total_pages);
    $stages = 3;
    $page = @$_GET['page'];
    if($page){
        $start = ($page - 1) * $limit; 
    }else{
        $start = 0; 
    } 
    if($_GET['state'] == 4){
        $where = " WHERE rowid ORDER BY rowid DESC LIMIT $start, $limit ";
    }
    if($_GET['state'] == 5 OR $_GET['state'] == 6 OR $_GET['state'] == 7 OR $_GET['state'] == 8 OR $_GET['state'] == 9 OR $_GET['state'] == 10 OR $_GET['state'] == 11 OR $_GET['state'] == 12 OR $_GET['state'] == 13 OR $_GET['state'] == 14 OR $_GET['state'] == 15 OR $_GET['state'] == 16 OR $_GET['state'] == 17 OR $_GET['state'] == 18 OR $_GET['state'] == 19 OR $_GET['state'] == 20 OR $_GET['state'] == 21 OR $_GET['state'] == 22 OR $_GET['state'] == 23 OR $_GET['state'] == 24 OR $_GET['state'] == 25 OR $_GET['state'] == 26 OR $_GET['state'] == 27 OR $_GET['state'] == 28){
        $where = " WHERE id ORDER BY id DESC LIMIT $start, $limit ";
    }

    // Initial page num setup
    if ($page == 0){ $page = 1; }
    $prev = $page - 1;  
    $next = $page + 1;  
    $lastpage = ceil($total_pages/$limit);  
    $LastPagem1 = $lastpage - 1;    
    $paginate = '';
    if($lastpage > 1)
    {       
        $paginate .= "<div class='paginate'>";
        // Previous

        if ($page > 1){
            $paginate.= "<a href='$targetpage&page=$prev'>Previous</a>";
        }else{
            $paginate.= "<span class='disabled'>Previous</span>";   }
        // Pages    
        if ($lastpage < 7 + ($stages * 2))  // Not enough pages to breaking it up
        {   
            for ($counter = 1; $counter <= $lastpage; $counter++)
            {
                if ($counter == $page){
                    $paginate.= "<span class='current'>$counter</span>";
                }else{
                    $paginate.= "<a href='$targetpage&page=$counter'>$counter</a>";}    
            }
        }
        elseif($lastpage > 5 + ($stages * 2))   // Enough pages to hide a few?
        {
            // Beginning only hide later pages
            if($page < 1 + ($stages * 2))   
            {
                for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage&page=$counter'>$counter</a>";}    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage&page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage&page=$lastpage'>$lastpage</a>";
            }
            // Middle hide some front and some back
            elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
            {
                $paginate.= "<a href='$targetpage&page=1'>1</a>";
                $paginate.= "<a href='$targetpage&page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage&page=$counter'>$counter</a>";}    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage&page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage&page=$lastpage'>$lastpage</a>";
            }
            // End only hide early pages
            else
            {
                $paginate.= "<a href='$targetpage&page=1'>1</a>";
                $paginate.= "<a href='$targetpage&page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage&page=$counter'>$counter</a>";}
                }
            }       
        }       
                // Next
        if ($page < $counter - 1){ 
            $paginate.= "<a href='$targetpage&page=$next'>Next</a>";
        }else{
            $paginate.= "<span class='disabled'>Next</span>";
            }
        $paginate.= "</div>";   
    }
endif;

$resultData = $commonFunctions->getData($_GET['tbl'],$where);
?>    

    
    <!-- Page-Title -->
    <div class="row">
        <div class="col-sm-12">
            <div class="page-title-box">
                <div class="row">
                    <div class="col">
                        <h4 class="page-title">Admin Settings</h4>
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Admin Settings</a></li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Modules & Settings</a></li>
                            <li class="breadcrumb-item"><a href="javascript:void(0);">Setup</a></li>
                        </ol>
                    </div><!--end col-->
                    <div class="col-sm-3">
                        <a href="setup.php"><button type="button" class="btn btn-sm btn-outline-secondary clear_form">Back to Dictionary Setup List</button></a>
                        <!-- <button type="button" class="btn btn-sm btn-outline-danger">Delete</button> -->
                    </div>
                </div><!--end row-->                                                              
            </div><!--end page-title-box-->
        </div><!--end col-->
    </div><!--end row-->
    <!-- end page title end breadcrumb -->
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4 class="card-title"> Dictionary Setup -  <?php if(!empty($_GET['state']) and $_GET['state'] == 1): ?>Currencies<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 2): ?>sys_erp_adm_countries<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 3): ?>Regions<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 4): ?>State / Province<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 5): ?>Staff<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 6): ?>Legal Forms of Third Parties<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 7): ?>Prospect Potential Level<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 8): ?>Third Party Types<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 9): ?>Prospection Status<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 10): ?>Personal & Professional Titles<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 11): ?>Contacts / Addresses Types  <?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 12): ?>Lead Status for Project/Lead<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 13): ?>Social or Fiscal TAXES Types<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 14): ?>Type of Resources<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 15): ?>Type of Leave<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 16): ?>Types of Expense Report lines<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 17): ?>Expense Report - Transportation Categories<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 18): ?>Expense Report - Range by transportation Category<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 19): ?>Amount of TAX Stamps<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 20): ?>Payment Terms<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 21): ?>Payment Modes<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 22): ?>Origin of Proposals/orders<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 23): ?>Ordering methods<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 24): ?>Shipping methods<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 25): ?>Delivery delay<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 26): ?>Paper formats<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 27): ?>Units<?php endif; ?><?php if(!empty($_GET['state']) and $_GET['state'] == 28): ?>Incoterms<?php endif; ?>
                        
                        <!-- <a class="btn btn-warning" href="setup.php" style="float: right;">Back to Dictionary Setup List</a> -->
                    </h4>
                </div><!--end card-header-->


                <div class="card-body">
                    <?php echo !empty($msg1)?$msg1:''; ?>        
                    <?php echo !empty($msg)?$msg:''; ?>        
                    <div class="row">
                        <?php 
                        $editData = array();
                        if(!empty($_GET['state']) and $_GET['state'] == 1): 
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('fin_accnt_currencies'," WHERE code_iso = '".$_GET['code']."' ", " active ='".$_GET['flag']."'",'dictionaries.php?tbl=fin_accnt_currencies&state=1');       
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('fin_accnt_currencies'," WHERE code_iso = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('fin_accnt_currencies'," (code_iso,label,unicode) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['unicode']."') ",'dictionaries.php?tbl=fin_accnt_currencies&state=1');
                                    }
                                    if($_GET['action'] == "edit"){
                                        $commonFunctions->updateData('fin_accnt_currencies'," WHERE code_iso = '".$_POST['update_code']."' ", " code_iso='".$_POST['code']."', label='".$_POST['label']."' , unicode='".$_POST['unicode']."' ",'dictionaries.php?tbl=fin_accnt_currencies&state=1');
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=fin_accnt_currencies&state=1';</script>";
                                }
                            }
                        ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php $action = !empty($editData['code_iso'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['code_iso'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=fin_accnt_currencies&state=1&action=<?php echo $action;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="update_code" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code_iso'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Unicode</label>
                                                    <input name="unicode" id="unicode" placeholder="Unicode" type="text" class="form-control" value="<?php echo @$editData['unicode'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t1 table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Unicode</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        $i++;
                                                        echo "<tr>";
                                                        echo "<td>".$row['code_iso']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['unicode']."</td>";
                                                        $flag = '';
                                                        $flag_state = 1;
                                                        if($row['active'] == 1){
                                                            $flag = 'checked';
                                                            $flag_state = 0;
                                                        }
                                                        //<a href="dictionaries.php?tbl=fin_accnt_currencies&state=1&code='.$row['code_iso'].'&flag=0">
                                                        $url = 'dictionaries.php?tbl=fin_accnt_currencies&state=1&code='.$row['code_iso'].'&flag='.$flag_state.'&action=active';

                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>
                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=fin_accnt_currencies&state=1&code=".$row['code_iso']."&action=get_edit'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 
                        if(!empty($_GET['state']) and $_GET['state'] == 2): 
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('sys_erp_adm_countries'," WHERE rowid = '".$_GET['code']."' ", " active ='".$_GET['flag']."'",'dictionaries.php?tbl=sys_erp_adm_countries&state=2');
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('sys_erp_adm_countries'," WHERE rowid = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('sys_erp_adm_countries'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."') ",'dictionaries.php?tbl=sys_erp_adm_countries&state=2');
                                    }
                                    if($_GET['action'] == "edit"){
                                        $commonFunctions->updateData('sys_erp_adm_countries'," WHERE rowid = '".$_POST['update_code']."' ", " code='".$_POST['code']."', label='".$_POST['label']."'",'dictionaries.php?tbl=sys_erp_adm_countries&state=2');
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=sys_erp_adm_countries&state=2';</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['rowid'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['rowid'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=sys_erp_adm_countries&state=2&action=<?php echo $action;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="update_code" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        $i++;
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 1;
                                                        if($row['active'] == 1){
                                                            $flag = 'checked';
                                                            $flag_state = 0;
                                                        }
                                                        //<a href="dictionaries.php?tbl=sys_erp_adm_countries&state=2&code='.$row['code'].'&flag=0">
                                                        $url = 'dictionaries.php?tbl=sys_erp_adm_countries&state=2&code='.$row['rowid'].'&flag='.$flag_state.'&action=active';

                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=sys_erp_adm_countries&state=2&code=".$row['rowid']."&action=get_edit'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 
                        //3 Regions
                        if(!empty($_GET['state']) and $_GET['state'] == 3): 

                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_regions'," WHERE rowid = '".$_GET['code']."' ", " active ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_regions&state=3');
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_regions'," WHERE rowid = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_regions'," (code_region,label,country_id) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['country']."') ",'dictionaries.php?tbl=tbl_regions&state=3');
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_regions'," WHERE rowid = '".$_POST['update_code']."' ", " code_region='".$_POST['code']."', label='".$_POST['label']."', country_id='".$_POST['country']."' ",'dictionaries.php?tbl=tbl_regions&state=3');
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_regions&state=3';</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['rowid'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['rowid'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_regions&state=3&action=<?php echo $action;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="update_code" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code_region'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code_region']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        $flag = '';
                                                        $flag_state = 1;
                                                        if($row['active'] == 1){
                                                            $flag = 'checked';
                                                            $flag_state = 0;
                                                        }
                                                        //<a href="dictionaries.php?tbl=tbl_regions&state=3&code='.$row['code'].'&flag=0">
                                                        $url = 'dictionaries.php?tbl=tbl_regions&state=3&code='.$row['rowid'].'&flag='.$flag_state.'&action=active';
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_regions&state=3&code=".$row['rowid']."&action=get_edit'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 
                        // 4 State
                        if(!empty($_GET['state']) and $_GET['state'] == 4): 

                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('sys_erp_adm_countries_states'," WHERE rowid = '".$_GET['code']."' ", " active ='".$_GET['flag']."'",'dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('sys_erp_adm_countries_states'," WHERE rowid = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('sys_erp_adm_countries_states'," (code_departement,label,region_code) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['country']."') ",'dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('sys_erp_adm_countries_states'," WHERE rowid = '".$_POST['update_code']."' ", " code_departement='".$_POST['code']."', label='".$_POST['label']."', region_code='".$_POST['country']."' ",'dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['rowid'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['rowid'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="update_code" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code_departement'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country / Region</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" disabled ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                            
                                                            <?php 
                                                            $regionData = $commonFunctions->getData('tbl_regions',' WHERE active = 1 and country_id ='.$rw['rowid']);
                                                            foreach ($regionData as $rw1) { ?>
                                                                <option value="<?php echo $rw1['code_region'];?>" <?php echo (!empty($editData) and $editData['region_code'] == $rw1['code_region'])?"selected":"";?> >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $rw1['label']; ?></option>
                                                            <?php } ?>        
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t1 table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <!-- <th  class="text-center">Region</th> -->
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code_departement']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        //echo "<td>".$commonFunctions->getName($row['region_code'],'tbl_regions','label','code_region')."</td>";

                                                        //$country_id = $commonFunctions->getName($row['region_code'],'tbl_regions','country_id','code_region');

                                                        $country_id = !empty($row['country_id'])?$row['country_id']:0;
                                                        echo "<td>".$commonFunctions->getName($country_id,'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($country_id,'sys_erp_adm_countries','label','rowid')."</td>";
                                                        $flag = '';
                                                        $flag_state = 1;
                                                        if($row['active'] == 1){
                                                            $flag = 'checked';
                                                            $flag_state = 0;
                                                        }
                                                        $url = 'dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&code='.$row['rowid'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=sys_erp_adm_countries_states&state=4&code=".$row['rowid']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 
                        //5 Staff
                        if(!empty($_GET['state']) and $_GET['state'] == 5):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_staff'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_staff&state=5&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_staff'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_staff'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."') ",'dictionaries.php?tbl=tbl_staff&state=5&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_staff'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_staff&state=5&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_staff&state=5&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_staff&state=5&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_staff&state=5&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_staff&state=5&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 

                        //6 Legal Forms of Third Parties
                        if(!empty($_GET['state']) and $_GET['state'] == 6):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_legal_forms_of_third_parties'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_legal_forms_of_third_parties'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_legal_forms_of_third_parties'," (code,label,country_id) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['country']."') ",'dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_legal_forms_of_third_parties'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ,country_id = '".$_POST['country']."' ",'dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_legal_forms_of_third_parties&state=6&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 

                        //7 Prospect Potential Level
                        if(!empty($_GET['state']) and $_GET['state'] == 7):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_prospect_potential_level'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_prospect_potential_level&state=7&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_prospect_potential_level'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['sort_order'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select sort_orde !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['sort_order'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_prospect_potential_level'," (code,label,sort_order) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['sort_order']."') ",'dictionaries.php?tbl=tbl_prospect_potential_level&state=7&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_prospect_potential_level'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ,sort_order = '".$_POST['sort_order']."' ",'dictionaries.php?tbl=tbl_prospect_potential_level&state=7&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_prospect_potential_level&state=7&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_prospect_potential_level&state=7&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Sort Order <span class="error">*</span></label>
                                                    
                                                    <input name="sort_order" id="sort_order" placeholder="Sort Order" type="text" class="form-control" value="<?php echo @$editData['sort_order'];?>">
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Sort Order</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['sort_order']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_prospect_potential_level&state=7&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_prospect_potential_level&state=7&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 

                        //8 Third Party Types
                        if(!empty($_GET['state']) and $_GET['state'] == 8):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_third_party_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_third_party_types&state=8&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_third_party_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_third_party_types'," (code,label,country_id) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['country']."') ",'dictionaries.php?tbl=tbl_third_party_types&state=8&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_third_party_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ,country_id = '".$_POST['country']."' ",'dictionaries.php?tbl=tbl_third_party_types&state=8&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_third_party_types&state=8&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_third_party_types&state=8&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_third_party_types&state=8&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_third_party_types&state=8&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //9 Prospection Status 
                        if(!empty($_GET['state']) and $_GET['state'] == 9):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_prospection_status'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_prospection_status&state=9&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_prospection_status'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_prospection_status'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_prospection_status&state=9&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_prospection_status'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_prospection_status&state=9&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_prospection_status&state=9&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_prospection_status&state=9&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_prospection_status&state=9&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_prospection_status&state=9&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //10 Personal & Professional Titles 
                        if(!empty($_GET['state']) and $_GET['state'] == 10):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_professional_titles'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_professional_titles&state=10&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_professional_titles'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_professional_titles'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_professional_titles&state=10&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_professional_titles'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_professional_titles&state=10&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_professional_titles&state=10&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_professional_titles&state=10&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_professional_titles&state=10&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_professional_titles&state=10&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //11 Contacts / Addresses Types
                        if(!empty($_GET['state']) and $_GET['state'] == 11):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_contacts_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_contacts_types&state=11&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_contacts_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['element'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter element !</div>');
                                }
                                else if(empty($_POST['position'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter position !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_contacts_types'," (code,label,element,position,contact_type) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['element']."','".$_POST['position']."','".$_POST['contact_type']."' ) ",'dictionaries.php?tbl=tbl_contacts_types&state=11&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_contacts_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', element='".$_POST['element']."', position='".$_POST['position']."', contact_type ='".$_POST['contact_type']."' ",'dictionaries.php?tbl=tbl_contacts_types&state=11&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_contacts_types&state=11&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_contacts_types&state=11&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Element <span class="error">*</span></label>
                                                    
                                                    <select id="element" class="form-control flat element" name="element">
                                                        <option value="">&nbsp;</option>
                                                        <option value="agenda" <?php echo (!empty($editData) and $editData->element == "agenda")?"selected":"";?>>Agenda</option>
                                                        <option value="propal" <?php echo (!empty($editData) and $editData->element == "propal")?"selected":"";?>>Commercial Proposal</option>
                                                        <option value="contrat" <?php echo (!empty($editData) and $editData->element == "contrat")?"selected":"";?>>Contract</option>
                                                        <option value="fichinter" <?php echo (!empty($editData) and $editData->element == "fichinter")?"selected":"";?>>Intervention Card</option>
                                                        <option value="facture" <?php echo (!empty($editData) and $editData->element == "facture")?"selected":"";?>>Invoice</option>
                                                        <option value="commande" <?php echo (!empty($editData) and $editData->element == "commande")?"selected":"";?>>Order</option>
                                                        <option value="project" <?php echo (!empty($editData) and $editData->element == "project")?"selected":"";?>>Project</option>
                                                        <option value="order_supplier" <?php echo (!empty($editData) and $editData->element == "order_supplier")?"selected":"";?>>Purchase Order</option>
                                                        <option value="resource" <?php echo (!empty($editData) and $editData->element == "resource")?"selected":"";?>>Resource</option>
                                                        <option value="invoice_supplier" <?php echo (!empty($editData) and $editData->element == "invoice_supplier")?"selected":"";?>>Supplier Invoice</option>
                                                        <option value="project_task" <?php echo (!empty($editData) and $editData->element == "project_task")?"selected":"";?>>Task</option>
                                                        <option value="societe" <?php echo (!empty($editData) and $editData->element == "societe")?"selected":"";?>>Third-Party</option>
                                                        <option value="supplier_proposal" <?php echo (!empty($editData) and $editData->element == "supplier_proposal")?"selected":"";?>>Vendor Commercial Quotes
                                                        </option>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Contact Type <span class="error">*</span></label>
                                                    <select class="form-control" name="contact_type">
                                                        <option value="">Select Type</option>   
                                                        <option value="0" <?php echo (@$editData['contact_type'] == 0)?"selected":'';?> >Internal</option>   
                                                        <option value="1" <?php echo (@$editData['contact_type'] == 1)?"selected":'';?> >External</option>   
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Position <span class="error">*</span></label>
                                                    <input name="position" id="position" placeholder="Position" type="text" class="form-control" value="<?php echo @$editData['position'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Element</th>
                                                    <th  class="text-center">Contact Type</th>
                                                    <th  class="text-center">Position</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".ucfirst($row['element'])."</td>";
                                                        $type = "";
                                                        if($row['contact_type'] == 0){
                                                            $type = "Internal";
                                                        }else{
                                                            $type = "External";
                                                        }
                                                        echo "<td>".$type."</td>";
                                                        echo "<td>".$row['position']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_contacts_types&state=11&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_contacts_types&state=11&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //12 Lead Status for Project/Lead
                        if(!empty($_GET['state']) and $_GET['state'] == 12):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_lead_status'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_lead_status&state=12&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_lead_status'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['percentage'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter percentage !</div>');
                                }
                                else if(empty($_POST['position'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter position !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_lead_status'," (code,label,percentage,position) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['percentage']."','".$_POST['position']."' ) ",'dictionaries.php?tbl=tbl_lead_status&state=12&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_lead_status'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', percentage='".$_POST['percentage']."', position='".$_POST['position']."' ",'dictionaries.php?tbl=tbl_lead_status&state=12&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_lead_status&state=12&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_lead_status&state=12&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Percentage <span class="error">*</span></label>
                                                    <input name="percentage" id="percentage" placeholder="Percentage" type="text" class="form-control" value="<?php echo @$editData['percentage'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Position <span class="error">*</span></label>
                                                    <input name="position" id="position" placeholder="Position" type="text" class="form-control" value="<?php echo @$editData['position'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Percentage</th>
                                                    <th  class="text-center">Position</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['percentage']."</td>";
                                                        echo "<td>".$row['position']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_lead_status&state=12&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_lead_status&state=12&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //13 Social or Fiscal TAXES Types
                        if(!empty($_GET['state']) and $_GET['state'] == 13):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('fin_accnt_taxes_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=fin_accnt_taxes_types&state=13&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('fin_accnt_taxes_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('fin_accnt_taxes_types'," (code,label,country_id,accounting_code_id,deductible) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['country']."','".$_POST['accounting_code_id']."','".$_POST['deductible']."') ",'dictionaries.php?tbl=fin_accnt_taxes_types&state=13&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('fin_accnt_taxes_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ,country_id = '".$_POST['country']."', accounting_code_id='".$_POST['accounting_code_id']."' ,deductible = '".$_POST['deductible']."' ",'dictionaries.php?tbl=fin_accnt_taxes_types&state=13&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=fin_accnt_taxes_types&state=13&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=fin_accnt_taxes_types&state=13&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="accounting_code_id" class="">Accounting Code <span class="error">*</span></label>
                                                    <input name="accounting_code_id" id="accounting_code_id" placeholder="Accounting Code" type="text" class="form-control" value="<?php echo @$editData['accounting_code_id'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="deductible" class="">Deductible <span class="error">*</span></label>
                                                    <input name="deductible" id="deductible" placeholder="Deductible" type="text" class="form-control" value="<?php echo @$editData['deductible'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Accounting Code</th>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Deductible</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['accounting_code_id']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=fin_accnt_taxes_types&state=13&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo "<td>".$row['deductible']."</td>";
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=fin_accnt_taxes_types&state=13&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif; 

                        //14 Type of Resources
                        if(!empty($_GET['state']) and $_GET['state'] == 14):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_resources_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_resources_types&state=14&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_resources_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_resources_types'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_resources_types&state=14&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_resources_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_resources_types&state=14&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_resources_types&state=14&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_resources_types&state=14&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_resources_types&state=14&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_resources_types&state=14&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //15 Type of Leave  
                        if(!empty($_GET['state']) and $_GET['state'] == 15):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_leave_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_leave_types&state=15&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_leave_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_leave_types'," (code,label,manage_counter,notice_period,new_month,country_id) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['manage_counter']."','".$_POST['notice_period']."','".$_POST['new_month']."','".$_POST['country_id']."' ) ",'dictionaries.php?tbl=tbl_leave_types&state=15&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_leave_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."',manage_counter='".$_POST['manage_counter']."', notice_period='".$_POST['notice_period']."',new_month='".$_POST['new_month']."', country_id='".$_POST['country_id']."' ",'dictionaries.php?tbl=tbl_leave_types&state=15&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_leave_types&state=15&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_leave_types&state=15&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Manage a Counter <span class="error">*</span></label>
                                                    <input name="manage_counter" id="manage_counter" placeholder="Manage a Counter" type="text" class="form-control" value="<?php echo @$editData['manage_counter'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Notice Peried <span class="error">*</span></label>
                                                    <input name="notice_period" id="notice_period" placeholder="Notice Peried" type="text" class="form-control" value="<?php echo @$editData['notice_period'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">New by Month<span class="error">*</span></label>
                                                    <input name="new_month" id="new_month" placeholder="Notice Peried" type="text" class="form-control" value="<?php echo @$editData['new_month'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Manage a Counter</th>
                                                    <th  class="text-center">Notice Peried</th>
                                                    <th  class="text-center">New By Month</th>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['manage_counter']."</td>";
                                                        echo "<td>".$row['notice_period']."</td>";
                                                        echo "<td>".$row['new_month']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";

                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_leave_types&state=15&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;
                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_leave_types&state=15&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //16 Types of Expense Report lines
                        if(!empty($_GET['state']) and $_GET['state'] == 16):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('fin_accnt_expense_report_types'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('fin_accnt_expense_report_types'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('fin_accnt_expense_report_types'," (code,label,accounting_code) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['accounting_code']."' ) ",'dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('fin_accnt_expense_report_types'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', accounting_code='".$_POST['accounting_code']."' ",'dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Accounting Code<span class="error">*</span></label>
                                                    <input name="accounting_code" id="accounting_code" placeholder="Accounting Code" type="text" class="form-control" value="<?php echo @$editData['accounting_code'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Accounting Code</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['accounting_code']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=fin_accnt_expense_report_types&state=16&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //17 Expense Report - Transportation Categories
                        if(!empty($_GET['state']) and $_GET['state'] == 17):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_transportation_category'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_transportation_category&state=17&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_transportation_category'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_transportation_category'," (label) VALUES ('".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_transportation_category&state=17&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_transportation_category'," WHERE id = '".$_POST['id']."' ", " label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_transportation_category&state=17&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_transportation_category&state=17&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_transportation_category&state=17&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_transportation_category&state=17&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_transportation_category&state=17&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //18 Expense Report - Range by transportation Category
                        if(!empty($_GET['state']) and $_GET['state'] == 18):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_range_by_transportation_category'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_range_by_transportation_category&state=18&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_range_by_transportation_category'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['mileage_range']) OR $_POST['mileage_range'] != 0){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter mileage range !</div>');
                                }
                                if(empty($_POST['category_car_id'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter category of car !</div>');
                                }
                                 
                                if(!empty($_POST['mileage_range']) and !empty($_POST['category_car_id']) OR $_POST['mileage_range'] == 0){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_range_by_transportation_category'," (mileage_range,category_car_id) VALUES ('".$_POST['mileage_range']."','".$_POST['category_car_id']."' ) ",'dictionaries.php?tbl=tbl_range_by_transportation_category&state=18&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_range_by_transportation_category'," WHERE id = '".$_POST['id']."' ", " mileage_range='".$_POST['mileage_range']."',category_car_id='".$_POST['category_car_id']."' ",'dictionaries.php?tbl=tbl_range_by_transportation_category&state=18&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_range_by_transportation_category&state=17&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_range_by_transportation_category&state=18&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Mileage range <span class="error">*</span></label>
                                                    <input name="mileage_range" id="mileage_range" placeholder="Mileage range" type="text" class="form-control" value="<?php echo @$editData['mileage_range'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Category of car<span class="error">*</span></label>
                                                    <!-- <input name="category_car_id" id="category_car_id" placeholder="Category of car" type="text" class="form-control" value="<?php echo @$editData['category_car_id'];?>"> -->
                                                    <?php $CarCatData = $commonFunctions->getData('tbl_category_car',' WHERE active = 0 '); ?>
                                                    <select name="category_car_id" class="category_car_id form-control select2">
                                                        <option value="">Select</option>
                                                        <?php foreach ($CarCatData as $rw) { ?>
                                                            <option value="<?php echo $rw['id'];?>" <?php echo (!empty($editData['category_car_id']) and $editData['category_car_id'] == $rw['id'])?"selected":"";?> ><?php echo $rw['label']; ?></option>
                                                        <?php } ?>
                                                    </select>

                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Mileage range</th>
                                                    <th  class="text-center">Category of car</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['mileage_range']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['category_car_id'],'tbl_category_car','label','id')."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_range_by_transportation_category&state=17&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_range_by_transportation_category&state=18&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //19 Amount of TAX Stamps
                        if(!empty($_GET['state']) and $_GET['state'] == 19):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_amount_of_tax_stamps'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_amount_of_tax_stamps'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['amount'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter amount !</div>');
                                } else if(empty($_POST['type_of_tax_stamp'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter Type of TAX Stamp !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['amount']) and !empty($_POST['type_of_tax_stamp']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_amount_of_tax_stamps'," (amount,type_of_tax_stamp,country_id,sale_account_code_id,purchase_account_code_id,note) VALUES ('".$_POST['amount']."','".$_POST['type_of_tax_stamp']."','".$_POST['country']."','".$_POST['sale_account_code_id']."','".$_POST['purchase_account_code_id']."','".$_POST['note']."') ",'dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_amount_of_tax_stamps'," WHERE id = '".$_POST['id']."' ", " amount='".$_POST['amount']."', type_of_tax_stamp='".$_POST['type_of_tax_stamp']."' ,country_id = '".$_POST['country']."',sale_account_code_id='".$_POST['sale_account_code_id']."', purchase_account_code_id='".$_POST['purchase_account_code_id']."' ,note = '".$_POST['note']."' ",'dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="amount" class="">Amount <span class="error">*</span></label>
                                                    <input name="amount" id="amount" placeholder="Amount" type="text" class="form-control" value="<?php echo @$editData['amount'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="type_of_tax_stamp" class="">Type of TAX Stamp <span class="error">*</span></label>
                                                    <input name="type_of_tax_stamp" id="type_of_tax_stamp" placeholder="Type of TAX Stamp" type="text" class="form-control" value="<?php echo @$editData['type_of_tax_stamp'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="sale_account_code_id" class="">Sale Account. Code </label>
                                                    <!-- <input name="sale_account_code_id" id="sale_account_code_id" placeholder="Sale Account. Code" type="text" class="form-control" value="<?php echo @$editData['sale_account_code_id'];?>"> -->
                                                    <select name="sale_account_code_id" id="sale_account_code_id" class="form-control">
                                                        <option value="">Select</option>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="purchase_account_code_id" class="">Purchase Account. Code </label>
                                                    <!-- <input name="purchase_account_code_id" id="purchase_account_code_id" placeholder="Sale Account. Code" type="text" class="form-control" value="<?php echo @$editData['purchase_account_code_id'];?>"> -->
                                                    <select name="purchase_account_code_id" id="purchase_account_code_id" class="form-control">
                                                        <option value="">Select</option>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="note" class="">Note</label>
                                                    <textarea name="note" class="form-control" placeholder="Note"><?php echo @$editData['note'];?></textarea>
                                                </div>
                                                
                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Country</th>
                                                    <th  class="text-center">Amount</th>
                                                    <th  class="text-center">Type of TAX Stamp</th>
                                                    <th  class="text-center">Sale Account. Code</th>
                                                    <th  class="text-center">Purchase Account. Code</th>
                                                    <th  class="text-center">Note</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        echo "<td>".$row['amount']."</td>";
                                                        echo "<td>".$row['type_of_tax_stamp']."</td>";
                                                        echo "<td>".$row['sale_account_code_id']."</td>";
                                                        echo "<td>".$row['purchase_account_code_id']."</td>";
                                                        echo "<td>".$row['note']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_amount_of_tax_stamps&state=19&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //20 Payment Terms
                        if(!empty($_GET['state']) and $_GET['state'] == 20):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('fin_accnt_payment_trems'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=fin_accnt_payment_trems&state=20&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('fin_accnt_payment_trems'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                else if(empty($_POST['country'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please select country/region !</div>');
                                }
                                if(!empty($_POST['code']) and !empty($_POST['label']) and !empty($_POST['country'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('fin_accnt_payment_trems'," (country_id,label,code,label_on_document,no_of_days,at_end_of_month,offset,sort_order) VALUES ('".$_POST['country']."','".$_POST['label']."','".$_POST['code']."','".$_POST['label_on_document']."','".$_POST['no_of_days']."','".$_POST['at_end_of_month']."','".$_POST['offset']."','".$_POST['sort_order']."') ",'dictionaries.php?tbl=fin_accnt_payment_trems&state=20&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('fin_accnt_payment_trems'," WHERE id = '".$_POST['id']."'"," country_id = '".$_POST['country']."',code = '".$_POST['code']."',label = '".$_POST['label']."', label_on_document = '".$_POST['label_on_document']."',no_of_days = '".$_POST['no_of_days']."',at_end_of_month = '".$_POST['at_end_of_month']."',offset = '".$_POST['offset']."',sort_order = '".$_POST['sort_order']."' ",'dictionaries.php?tbl=fin_accnt_payment_trems&state=20&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=fin_accnt_payment_trems&state=20&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $countryData = $commonFunctions->getData('sys_erp_adm_countries',' WHERE active = 1 ');
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=fin_accnt_payment_trems&state=20&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Country <span class="error">*</span></label>
                                                    <select name="country" id="country" class="select2 form-control" >
                                                        <option value="">Select Country</option>
                                                        <?php foreach ($countryData as $rw) { ?>
                                                            <option value="<?php echo $rw['rowid'];?>" <?php echo (!empty($editData['country_id']) and $editData['country_id'] == $rw['rowid'])?"selected":"";?> ><?php echo $rw['label']."(".$rw['code'].")"; ?></option>
                                                        <?php } ?>
                                                    </select>
                                                </div>

                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label_on_document" class="">Label on Document <span class="error">*</span></label>
                                                    <textarea name="label_on_document" id="label_on_document" placeholder="Label on Document" type="text" class="form-control" ><?php echo @$editData['label_on_document'];?></textarea>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="no_of_days" class="">No of Days <span class="error">*</span></label>
                                                    <input name="no_of_days" id="no_of_days" placeholder="No of Days" type="text" class="form-control" value="<?php echo @$editData['no_of_days'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="no_of_days" class="">At end of Month <span class="error">*</span></label>
                                                    <select name="at_end_of_month" class="form-control">
                                                        <option value="" disabled=""></option>
                                                        <option value="0" <?php echo (@$editData['at_end_of_month'] == 0 )?"selected":"";?> >At end of month</option>
                                                        <option value="1" <?php echo (@$editData['at_end_of_month'] == 1 )?"selected":"";?> >Current/next</option>
                                                    </select>
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="offset" class="">Offset <span class="error">*</span></label>
                                                    <input name="offset" id="offset" placeholder="Offset" type="text" class="form-control" value="<?php echo @$editData['offset'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="sort_order" class="">Sort Order <span class="error">*</span></label>
                                                    <input name="sort_order" id="" placeholder="Sort Order" type="text" class="form-control" value="<?php echo @$editData['sort_order'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th class="text-center">Code</th>
                                                    <th class="text-center">Label</th>
                                                    <th class="text-center">Country</th>
                                                    <th class="text-center">Label On Description</th>
                                                    <th class="text-center">No of Days</th>
                                                    <th class="text-center">At end of Month</th>
                                                    <th class="text-center">Offset</th>
                                                    <th class="text-center">Sort Order</th>
                                                    <th class="text-center">Status</th>
                                                    <th class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','code','rowid')." - ".$commonFunctions->getName($row['country_id'],'sys_erp_adm_countries','label','rowid')."</td>";
                                                        echo "<td>".$row['label_on_document']."</td>";
                                                        echo "<td>".$row['no_of_days']."</td>";

                                                        $at_end_of_month = ($row['at_end_of_month'] == 0)?"At end of month":"Current/next";
                                                        echo "<td>".$at_end_of_month."</td>";
                                                        echo "<td>".$row['offset']."</td>";
                                                        echo "<td>".$row['sort_order']."</td>";

                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=fin_accnt_payment_trems&state=20&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=fin_accnt_payment_trems&state=20&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //21 Payment Modes
                        if(!empty($_GET['state']) and $_GET['state'] == 21):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('fin_accnt_payment_mode'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=fin_accnt_payment_mode&state=21&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('fin_accnt_payment_mode'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('fin_accnt_payment_mode'," (code,label,type) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['type']."' ) ",'dictionaries.php?tbl=fin_accnt_payment_mode&state=21&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('fin_accnt_payment_mode'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', type='".$_POST['type']."' ",'dictionaries.php?tbl=fin_accnt_payment_mode&state=21&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=fin_accnt_payment_mode&state=21&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=fin_accnt_payment_mode&state=21&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Type <span class="error">*</span></label>
                                                    <input name="type" id="type" placeholder="Type" type="text" class="form-control" value="<?php echo @$editData['type'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Type</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['type']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=fin_accnt_payment_mode&state=21&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=fin_accnt_payment_mode&state=21&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //22 Origin of Proposals/orders
                        if(!empty($_GET['state']) and $_GET['state'] == 22):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_origin_of_proposals'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_origin_of_proposals&state=22&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_origin_of_proposals'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_origin_of_proposals'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_origin_of_proposals&state=22&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_origin_of_proposals'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_origin_of_proposals&state=22&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_origin_of_proposals&state=22&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_origin_of_proposals&state=22&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_origin_of_proposals&state=22&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_origin_of_proposals&state=22&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //23 Ordering methods
                        if(!empty($_GET['state']) and $_GET['state'] == 23):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_ordering_methods'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_ordering_methods&state=23&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_ordering_methods'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_ordering_methods'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_ordering_methods&state=23&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_ordering_methods'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_ordering_methods&state=23&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_ordering_methods&state=23&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_ordering_methods&state=23&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_ordering_methods&state=23&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_ordering_methods&state=23&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //24 Shipping methods
                        if(!empty($_GET['state']) and $_GET['state'] == 24):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_shipping_methods'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_shipping_methods&state=24&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_shipping_methods'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_shipping_methods'," (code,label,tracking) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['tracking']."' ) ",'dictionaries.php?tbl=tbl_shipping_methods&state=24&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_shipping_methods'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', tracking='".$_POST['tracking']."' ",'dictionaries.php?tbl=tbl_shipping_methods&state=24&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_shipping_methods&state=24&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_shipping_methods&state=24&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Tracking <span class="error">*</span></label>
                                                    <input name="tracking" id="tracking" placeholder="Tracking" type="text" class="form-control" value="<?php echo @$editData['tracking'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Tracking</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['tracking']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_shipping_methods&state=24&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_shipping_methods&state=24&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //25 Delivery delay
                        if(!empty($_GET['state']) and $_GET['state'] == 25):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_delivery_delay'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_delivery_delay&state=25&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_delivery_delay'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_delivery_delay'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_delivery_delay&state=25&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_delivery_delay'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_delivery_delay&state=25&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_delivery_delay&state=25&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_delivery_delay&state=25&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_delivery_delay&state=25&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_delivery_delay&state=25&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //26 Paper formats

                        if(!empty($_GET['state']) and $_GET['state'] == 26):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_paper_formats'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_paper_formats&state=26&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_paper_formats'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_paper_formats'," (code,label,width,height,measuring_unit) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['width']."','".$_POST['height']."','".$_POST['measuring_unit']."' ) ",'dictionaries.php?tbl=tbl_paper_formats&state=26&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_paper_formats'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', width='".$_POST['width']."', height='".$_POST['height']."', measuring_unit='".$_POST['measuring_unit']."' ",'dictionaries.php?tbl=tbl_paper_formats&state=26&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_paper_formats&state=26&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_paper_formats&state=26&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="width" class="">Width <span class="error">*</span></label>
                                                    <input name="width" id="width" placeholder="Width" type="text" class="form-control" value="<?php echo @$editData['width'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="height" class="">Height <span class="error">*</span></label>
                                                    <input name="height" id="height" placeholder="Height" type="text" class="form-control" value="<?php echo @$editData['height'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="height" class="">Measuring Unit <span class="error">*</span></label>
                                                    <select name="measuring_unit" class="form-control">
                                                        <option value="">Select</option>
                                                        <option value="0" <?php echo (@$editData['height'] == "0" )?'selected':'';?> >MM</option>
                                                        <option value="1" <?php echo (!empty($editData) and @$editData['height'] == "1" )?'selected':'';?> >CM</option>
                                                        <option value="2" <?php echo (!empty($editData) and @$editData['height'] == "2" )?'selected':'';?> >Point</option>
                                                        <option value="3" <?php echo (!empty($editData) and @$editData['height'] == "3" )?'selected':'';?> >Inch</option>
                                                    </select>
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Width</th>
                                                    <th  class="text-center">Height</th>
                                                    <th  class="text-center">Measuring Unit</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['width']."</td>";
                                                        echo "<td>".$row['height']."</td>";
                                                        $measuring_unit = '';
                                                        if($row['measuring_unit'] == 0){ $measuring_unit = 'MM'; }
                                                        if($row['measuring_unit'] == 1){ $measuring_unit = 'CM'; }
                                                        if($row['measuring_unit'] == 2){ $measuring_unit = 'Point'; }
                                                        if($row['measuring_unit'] == 3){ $measuring_unit = 'Inch'; }
                                                        echo "<td>".$measuring_unit."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_paper_formats&state=26&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_paper_formats&state=26&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //27 Incoterms
                        if(!empty($_GET['state']) and $_GET['state'] == 27):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_units'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_units&state=27&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_units'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_units'," (code,label,short_label) VALUES ('".$_POST['code']."','".$_POST['label']."','".$_POST['short_label']."' ) ",'dictionaries.php?tbl=tbl_units&state=27&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_units'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."', short_label='".$_POST['short_label']."' ",'dictionaries.php?tbl=tbl_units&state=27&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_units&state=27&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_units&state=27&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="short_label" class="">Short Label <span class="error">*</span></label>
                                                    <input name="short_label" id="short_label" placeholder="Short Label" type="text" class="form-control" value="<?php echo @$editData['short_label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Short Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        echo "<td>".$row['short_label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_units&state=27&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_units&state=27&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        //28 Incoterms
                        if(!empty($_GET['state']) and $_GET['state'] == 28):
                            if(!empty($_GET['action']) and $_GET['action'] == 'active'){
                                $commonFunctions->updateData('tbl_incoterms'," WHERE id = '".$_GET['code']."' ", " status ='".$_GET['flag']."'",'dictionaries.php?tbl=tbl_incoterms&state=28&page='.$page);
                            }
                            if(!empty($_GET['action']) and $_GET['action'] == 'get_edit'){
                                $editData = $commonFunctions->getRowData('tbl_incoterms'," WHERE id = '".$_GET['code']."' ");
                            }
                            if(!empty($_POST)){
                                if(empty($_POST['code'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter code !</div>');
                                } else if(empty($_POST['label'])){
                                    Session::set('msg', '<div class="alert alert-danger alert-dismissible mt-3" id="flash-msg"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Error !</strong> Please enter label !</div>');
                                }
                                 
                                if(!empty($_POST['code']) and !empty($_POST['label'])){
                                    if($_GET['action'] == "add"){
                                        $commonFunctions->addData('tbl_incoterms'," (code,label) VALUES ('".$_POST['code']."','".$_POST['label']."' ) ",'dictionaries.php?tbl=tbl_incoterms&state=28&page='.$page);
                                    }
                                    if($_GET['action'] == "edit"){
                                        
                                        $commonFunctions->updateData('tbl_incoterms'," WHERE id = '".$_POST['id']."' ", " code='".$_POST['code']."', label='".$_POST['label']."' ",'dictionaries.php?tbl=tbl_incoterms&state=28&page='.$page);
                                    }
                                }else{
                                    echo "<script>location.href='dictionaries.php?tbl=tbl_incoterms&state=28&page=".$page."</script>";
                                }
                            }
                            ?>
                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <?php 
                                        $action = !empty($editData['id'])?'edit':'add';?>
                                        <?php $action_btn = !empty($editData['id'])?'Modify':'Add';?>
                                        <form action="dictionaries.php?tbl=tbl_incoterms&state=28&action=<?php echo $action;?>&page=<?php echo $page;?>" method="post">
                                            <div class="form-row">
                                                
                                                <input name="id" type="hidden" value="<?php echo @$_GET['code'];?>">
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="code" class="">Code <span class="error">*</span></label>
                                                    <input name="code" id="code" placeholder="Code" type="text" class="form-control" value="<?php echo @$editData['code'];?>">
                                                </div>
                                                <div class="position-relative form-group col-md-3">
                                                    <label for="label" class="">Label <span class="error">*</span></label>
                                                    <input name="label" id="label" placeholder="Label" type="text" class="form-control" value="<?php echo @$editData['label'];?>">
                                                </div>

                                                <div class="position-relative form-group col-md-2">
                                                    <button type="submit" class="btn btn-primary" style="margin-top: 2.3em;"><?php echo $action_btn;?></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>

                            <div class="col-md-12">
                                <div class="main-card mb-3 card">
                                    <div class="card-body">
                                        <table style="width: 100%;" class="table datatable_t table-hover table-striped table-bordered">
                                            <thead>
                                                <tr>
                                                    <th  class="text-center">Code</th>
                                                    <th  class="text-center">Label</th>
                                                    <th  class="text-center">Status</th>
                                                    <th  class="text-center"></th>
                                                </tr>
                                            </thead>
                                            <tbody>
                                                <?php 
                                                    $i=1;
                                                    foreach ($resultData as $row) {
                                                        echo "<tr>";
                                                        echo "<td>".$row['code']."</td>";
                                                        echo "<td>".$row['label']."</td>";
                                                        $flag = '';
                                                        $flag_state = 0;
                                                        if($row['status'] == 0){
                                                            $flag = 'checked';
                                                            $flag_state = 1;
                                                        }
                                                        $url = 'dictionaries.php?tbl=tbl_incoterms&state=28&code='.$row['id'].'&flag='.$flag_state.'&action=active&page='.$page;

                                                        $i++;
                                                        echo '<td>
                                                        <div class="custom-control custom-switch switch-primary">
                                                            <input type="checkbox" class="custom-control-input" id="customSwitchPrimary'.$i.'" '.$flag.' onchange=change_flag("'.$url.'")>
                                                            <label class="custom-control-label" for="customSwitchPrimary'.$i.'"></label>
                                                        </div>

                                                        </td>';
                                                        echo "<td><a class='btn btn-primary' href='dictionaries.php?tbl=tbl_incoterms&state=28&code=".$row['id']."&action=get_edit&page=".$page."'><i class='fa fa-pen'></i></a></td>";
                                                        echo "</tr>";
                                                    }
                                                ?>
                                            </tbody>
                                        </table>
                                        <?php echo "<center>".$paginate."</center>";?>
                                    </div>
                                </div>
                            </div>
                        <?php endif;

                        ?>
                    </div>
                </div>
            </div>
        </div> <!-- end col -->
    </div> <!-- end row -->


    <!-- end page-wrapper -->
<?php require "../inc/footer.php"; ?>
<script type="text/javascript">
    function change_flag(url){
        window.location.href = url;
    }
    $(".datatable_t").dataTable();
    $(".datatable_t1").dataTable({
        "paging":   false,
        "ordering": false,
        "info":     false
    });
</script>