<?php
require_once('config.php');
$page_title = 'Writer Profile '; // Custom Page Title

if (isset($_GET['id']) && $_GET['id'] !=='') {
    $writer_id_get = $_GET['id'];
    $get_tt_acc_user = showAllttdata("tt_accounts", "WHERE UserID =  '$writer_id_get'");
    if (!empty($get_tt_acc_user)) {
      foreach ($get_tt_acc_user as $tt_acc_user);

      // Update Data
      if (isset($_POST['update_user'])) {

        // Update User Status
        $update_info = UpdateData('tt_accounts', 'UserID', $tt_acc_user['UserID'], array(
          "UserName" => htmlentities($_POST['UserName'], ENT_QUOTES, 'utf-8'),
          "UserDesignation" => htmlentities($_POST['UserDesignation'], ENT_QUOTES, 'utf-8'),
          "UserDesignationEn" => htmlentities($_POST['UserDesignationEn'], ENT_QUOTES, 'utf-8'),
          "PostAbility" => htmlentities($_POST['PostAbility'], ENT_QUOTES, 'utf-8'),
          "UserAdminNotice" => htmlentities($_POST['UserAdminNotice'], ENT_QUOTES, 'utf-8'),
          "FirstVerificationStatus" => htmlentities($_POST['FirstVerificationStatus'], ENT_QUOTES, 'utf-8'),
          "PostPublish" => htmlentities($_POST['PostPublish'], ENT_QUOTES, 'utf-8'),
          "FamilyPosition" => $_POST['FamilyPosition'],
          "UserProfile" => htmlentities($_POST['UserProfile'], ENT_QUOTES, 'utf-8'),
          "UserUrl" => htmlentities($_POST['UserUrl'], ENT_QUOTES, 'utf-8'),
          "AccountStatus" => htmlentities($_POST['AccountStatus'], ENT_QUOTES, 'utf-8'),
          "UpdateProfile" => htmlentities($_POST['UpdateProfile'], ENT_QUOTES, 'utf-8'),
          "UserLastUpdate" => $the_time,
        ));

        $updates_changes = ""; // Initialize variable to store changes

        // Check each field and store changes
        if ($_POST['UserName'] != $tt_acc_user['UserName']) {
            $updates_changes .= " <b>User Name: " . htmlentities($tt_acc_user['UserName'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserName'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UserDesignation'] != $tt_acc_user['UserDesignation']) {
            $updates_changes .= " <b>User Designation: " . htmlentities($tt_acc_user['UserDesignation'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserDesignation'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UserDesignationEn'] != $tt_acc_user['UserDesignationEn']) {
            $updates_changes .= " <b>User Designation EN: " . htmlentities($tt_acc_user['UserDesignationEn'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserDesignationEn'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['FamilyPosition'] != $tt_acc_user['FamilyPosition']) {
            $updates_changes .= " <b>User Family Position  " . htmlentities($tt_acc_user['FamilyPosition'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['FamilyPosition'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['PostAbility'] != $tt_acc_user['PostAbility']) {
            $updates_changes .= " <b>Post Ability: " . htmlentities($tt_acc_user['PostAbility'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['PostAbility'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UserAdminNotice'] != $tt_acc_user['UserAdminNotice']) {
            $updates_changes .= " <b>Admin Notice: " . htmlentities($tt_acc_user['UserAdminNotice'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserAdminNotice'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['FirstVerificationStatus'] != $tt_acc_user['FirstVerificationStatus']) {
            $updates_changes .= " <b>First Verification: " . htmlentities($tt_acc_user['FirstVerificationStatus'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['FirstVerificationStatus'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['PostPublish'] != $tt_acc_user['PostPublish']) {
            $updates_changes .= " <b>Post Publish: " . htmlentities($tt_acc_user['PostPublish'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['PostPublish'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UserProfile'] != $tt_acc_user['UserProfile']) {
            $updates_changes .= " <b>Show User Profile: " . htmlentities($tt_acc_user['UserProfile'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserProfile'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UserUrl'] != $tt_acc_user['UserUrl']) {
            $updates_changes .= " <b> Profile Username: " . htmlentities($tt_acc_user['UserUrl'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UserUrl'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['AccountStatus'] != $tt_acc_user['AccountStatus']) {
            $updates_changes .= " <b>Account Status: " . htmlentities($tt_acc_user['AccountStatus'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['AccountStatus'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($_POST['UpdateProfile'] != $tt_acc_user['UpdateProfile']) {
            $updates_changes .= " <b>User Can Change Profile: " . htmlentities($tt_acc_user['UpdateProfile'], ENT_QUOTES, 'utf-8') .
                                "</b> <i class='bi bi-arrow-right'></i> <b>" . htmlentities($_POST['UpdateProfile'], ENT_QUOTES, 'utf-8') . "</b><br>";
        }

        if ($update_info) {
            if ($updates_changes !='') {
              userActivity($tt_acc_user['UserID'], "Account", "Account settings changed by Admin", $updates_changes);
            }

            header('Location:writer-profile.php?id='.$tt_acc_user['UserID']);
            exit;
        }else {
          $tt_alert = ttAlert('danger', 'Something went wrong to Update !');
        }
      }

      // Send New Password
      if (isset($_POST['send_new_password'])) {
        $send_pwd_number = $tt_acc_user['UserMobile'];
        $send_pwd = generateTempPwd();
$send_new_password =  sendSMS($send_pwd_number,"(".$advancenews['COMPANY_NAME'].")
Your temporary password is $send_pwd . Please change this password after first login.");

        if ($send_new_password  == 'SENT') {
          userActivity($tt_acc_user['UserID'], "Security", "New Password send by SMS", "Password Changed By Admin ");
          UpdateData('tt_accounts', 'UserID', $tt_acc_user['UserID'], array(
            'UserPassword' => password_hash($send_pwd, PASSWORD_BCRYPT),
            'UserPwdTemp' => 'yes',
          ));
          header('Location:writer-profile.php?id='.$tt_acc_user['UserID']);
          exit;
        }else {
          $tt_alert = ttAlert('danger', 'Something went wrong to send password');
        }
      }

      // Send New Password
      if (isset($_POST['send_new_password_email'])) {
        $send_pwd_email = $tt_acc_user['UserEmail'];
        $send_pwd = generateTempPwd();
        $send_new_password =  sendEmailPwd($send_pwd_email, $send_pwd);

        if (1==1) {
          userActivity($tt_acc_user['UserID'], "Security", "New Password send by Email", "Password Changed By Admin : $send_pwd");
          UpdateData('tt_accounts', 'UserID', $tt_acc_user['UserID'], array(
            'UserPassword' => password_hash($send_pwd, PASSWORD_BCRYPT),
            'UserPwdTemp' => 'yes',
          ));
          header('Location:writer-profile.php?id='.$tt_acc_user['UserID']);
          exit;
        }else {
          $tt_alert = ttAlert('danger', 'Something went wrong to send password');
        }
      }


      if (isset($_POST['mahamudfutureit_login_writer'])) {
        if ($tt_acc_user['UserLoginKey'] !='') {
          $login_key = $tt_acc_user['UserLoginKey'];
        }else {
          $login_key = md5(randomString().time());
          UpdateData('tt_accounts', 'UserID', $tt_acc_user['UserID'], array("UserLoginKey" => $login_key));
        }
        //  Now Login
        setcookie("lsp_cpa", $login_key, time() + (86400 * 7), "/");
        header("Location:".$site_domain."account/");
      }

    }else {
      header('Location:404.php');
      exit;
    }

}else {
  header('Location:404.php');
  exit;
}
require_once('inc/header.php');
?>
<main id="main" class="main">
  <div class="row">
    <div class="col-6 align-items-center">
      <div class="pagetitle mb-2">
        <h1><?php echo $page_title ?></h1>
      </div>
    </div>
    <div class="col-6 text-end">
        <a href="writer.php" class="btn btn-primary btn-sm"><i class="bi bi-grid"></i> All Writer </a>
    </div>
  </div>
   <?php echo $tt_alert ?? '';  ?>
   <section class="section profile">
    <div class="row">
      <div class="col-xl-4">
        <div class="card">
          <div class="card-body text-center profile-card pt-4 d-flex flex-column align-items-center">
            <img src=" <?php echo  userAvaterDB($tt_acc_user['UserID']) ?>" alt="Profile" class="rounded-circle">
            <h2 class="fs-5 mb-2">
              <a target="_blank" class="text-dark" href="<?php echo userProfile($tt_acc_user['UserID']) ?>"><?php echo $tt_acc_user['UserName'] ?></a>
            <?php
            if ($tt_acc_user['UserpZilla'] !='') {
              ?>
              <h3> <i class="fs-6 bi bi-geo-alt-fill"></i> <?php echo getSingleValue('mahamudfutureit_loc_districts','id', $tt_acc_user['UserpZilla'], 'name' ) ?></h3>
              <?php
            }
            if ( $tt_acc_user['UserDesignation'] !='') {
              ?>
              <h6><?php echo $tt_acc_user['UserDesignation'] ?></h4>
              <?php
            }


            if ($tt_acc_user['AccountStatus'] == 'active') {
              ?>
              <form class="" action="" method="post">
                <button type="submit" name="mahamudfutureit_login_writer" class="btn btn-primary btn-sm">Login Writer Account </button>
              </form>
              <?php
            }
            ?>
          </div>


        </div>
        <?php
          if ( $tt_acc_user['UserAdminNotice'] !='') {
            ?>
            <div class="bg-warning mt-2 p-3 rounded-2 bg-opacity-25  text-center">
              <?php echo $tt_acc_user['UserAdminNotice'] ?>
            </div>
            <?php
          }
        ?>
      </div>

      <div class="col-xl-8">
        <div class="card">
          <div class="card-body pt-3">
            <!-- Bordered Tabs -->
            <ul class="nav nav-tabs nav-tabs-bordered">

              <li class="nav-item">
                <button class="nav-link active" data-bs-toggle="tab" data-bs-target="#profile-overview">Overview</button>
              </li>
              <?php
              if ($curent_user_page_role != "Editor") {
                ?>

                <li class="nav-item">
                  <button class="nav-link" data-bs-toggle="tab" data-bs-target="#profile-settings">Settings</button>
                </li>

                <li class="nav-item">
                  <button class="nav-link" data-bs-toggle="tab" data-bs-target="#profile-change-password">Activity</button>
                </li>
                <?php
              }
              ?>
            </ul>
            <div class="tab-content pt-2">

              <div class="tab-pane fade show active profile-overview" id="profile-overview">

                <h5 class="card-title">Profile Details</h5>
                <div class="row">
                  <div class="col-lg-4 label "> Name Bangla</div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserName'] ?></div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label "> Designation</div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserDesignation'] ?></div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label ">Designation En</div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserDesignationEn'] ?></div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label">Name English</div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserNameEN'] ?></div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label"> Gender </div>
                  <div class="col-lg-8">  <?php echo $tt_acc_user['UserGender'] ?>  </div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label"> Date of Birth </div>
                  <div class="col-lg-8">  <?php echo $tt_acc_user['UserDOB'] ?>  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label">Father`s Name  </div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserFather'] ?></div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label">Mother`s Name  </div>
                  <div class="col-lg-8"><?php echo $tt_acc_user['UserMother'] ?></div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label">Mobile Number</div>
                  <div class="col-lg-8"> <a href="tel:<?php echo $tt_acc_user['UserMobile'] ?>"><?php echo $tt_acc_user['UserMobile'] ?></a> </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label">NID Number</div>
                  <div class="col-lg-8"> <?php echo $tt_acc_user['UserNID'] ?>  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label">Email</div>
                  <div class="col-lg-8"> <a href="mailto:<?php echo $tt_acc_user['UserEmail'] ?>"><?php echo $tt_acc_user['UserEmail'] ?></a>  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label"> Profession</div>
                  <div class="col-lg-8">  <?php echo $tt_acc_user['UserProfession'] ?>  </div>
                </div>


                <div class="row">
                  <div class="col-lg-4 label"> T-Shirt Size</div>
                  <div class="col-lg-8">  <?php echo $tt_acc_user['UserTshirtSize'] ?>  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label"> Journalism Experience</div>
                  <div class="col-lg-8">  <?php echo $tt_acc_user['UserExperience'] ?>  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label">Present Address</div>
                  <div class="col-lg-8">
                    <strong>Zila : </strong> <?php echo getSingleValue('mahamudfutureit_loc_districts','id', $tt_acc_user['UserZilla'], 'name' ) ?>
                    <strong> Upazila :</strong>  <?php echo getSingleValue('mahamudfutureit_loc_upazilas','id', $tt_acc_user['UserUpazila'], 'name' ) ?> <br>
                    <strong>Address : </strong> <?php echo $tt_acc_user['UserAddress'] ?>
                  </div>
                </div>
                <div class="row">
                  <div class="col-lg-4 label">Parmanent Address</div>
                  <div class="col-lg-8">
                    <strong>Zila : </strong> <?php echo getSingleValue('mahamudfutureit_loc_districts','id', $tt_acc_user['UserpZilla'], 'name' ) ?>
                    <strong> Upazila :</strong>  <?php echo getSingleValue('mahamudfutureit_loc_upazilas','id', $tt_acc_user['UserpUpazila'], 'name' ) ?> <br>
                    <strong> Upazila :</strong>  <?php echo getSingleValue('mahamudfutureit_loc_unions','id', $tt_acc_user['UserpUnion'], 'name' ) ?> <br>
                    <strong>Address : </strong> <?php echo $tt_acc_user['UserPaddress'] ?>
                  </div>
                </div>

                <div class="row">
                  <div class="col-lg-4 label">Files</div>
                  <div class="col-lg-8">
                    <strong>Photo : </strong>
                    <?php if (!empty($tt_acc_user['PhotoFile'])): ?>
                        <a download href="<?php echo $site_domain . 'uploads/public_files/' . $tt_acc_user['PhotoFile']; ?>"> <small class="text-primary">Download</small> </a>
                    <?php endif; ?> <br>
                    <strong> CV :</strong>
                    <?php if (!empty($tt_acc_user['CvFile'])): ?>
                        <a download href="<?php echo $site_domain . 'uploads/public_files/' . $tt_acc_user['CvFile']; ?>"> <small class="text-primary">Download</small> </a>
                    <?php endif; ?> <br>
                    <strong>NID : </strong>
                    <?php if (!empty($tt_acc_user['NidFile'])): ?>
                        <a download href="<?php echo $site_domain . 'uploads/public_files/' . $tt_acc_user['NidFile']; ?>"> <small class="text-primary">Download</small> </a>
                    <?php endif; ?>
                  </div>
                </div>

                <hr>
                <div class="row">
                  <div class="col-lg-4 label">Registration Date</div>
                  <div class="col-lg-8">
                      <?php
                      echo date("j F Y, g:i A", strtotime($tt_acc_user['JoinDate'] ));
                      ?>
                      </div>
                </div>
              </div>
              <?php
              if ($curent_user_page_role != "Editor") {
                ?>

                <div class="tab-pane fade pt-3" id="profile-settings">
                  <form action="" method="post">
                    <div class="row  mb-3">
                      <div class="col-lg-4 label">
                        Change Name <span class="text-danger">*</span>
                        <i title="লেখকের নাম অনুমতি সাপেক্ষে লেখক পরিবর্তন করতে পাড়বেন" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i>
                      </div>
                      <div class="col-lg-8">
                        <input class="form-control" type="text" name="UserName" value="<?php echo $tt_acc_user['UserName'] ?>" required>
                      </div>
                    </div>
                    <div class="row  mb-3">
                      <div class="col-lg-4 label"> Designation
                        <i title="লেখকের পদবি সংবাদে লেখকের নামের পাশে দেখাবে  " data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i>
                      </div>
                      <div class="col-lg-8">
                        <input class="form-control" type="text" name="UserDesignation" value="<?php echo $tt_acc_user['UserDesignation'] ?>">
                      </div>
                    </div>
                    <div class="row  mb-3">
                      <div class="col-lg-4 label"> Designation En
                        <i title="লেখকের পদবি আইডিকার্ড এ দেখাবে  " data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i>
                      </div>
                      <div class="col-lg-8">
                        <input class="form-control" type="text" name="UserDesignationEn" value="<?php echo $tt_acc_user['UserDesignationEn'] ?>">
                      </div>
                    </div>
                    <div class="row  mb-3">
                      <div class="col-lg-4 label">Profile Username
                        <i title="লেখকের প্রোফাইল লিংক/ইউজারনেম । ডিফল্ট ভাবে ইউজারের আইডি দেখাবে।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i>
                      </div>
                      <div class="col-lg-8">
                        <input id="checkUrl" class="form-control" type="text" name="UserUrl" value="<?php echo $tt_acc_user['UserUrl'] ?>">
                        <span id="checkUrlfdback"></span>
                      </div>
                    </div>
                    <hr>
                    <div class="row mb-3">
                        <label for="AccountStatus" class="col-lg-4 col-form-label">  Family Position
                        <i title="কোন পোস্ট এ কমেন্ট করতে পাড়বে কি না ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      <div class="col-lg-8">
                        <select class="form-control" name="FamilyPosition">
                          <option value="" selected disabled>Select Team </option>
                          <?php
                          $tt_team = showAllttdata("mahamudfutureit_team", "ORDER BY  Position  ASC");
                          if (!empty($tt_team)) {
                            ?>
                              <?php
                              foreach ($tt_team as $the_team) {
                                ?>
                                <option <?php echo ($tt_acc_user['FamilyPosition'] == $the_team['ID']) ? 'selected' : '' ?> value="<?php echo $the_team['ID'] ?>"><?php echo $the_team['TeamName'] ?></option>
                                <?php
                              }
                              ?>
                            <?php
                          }
                          ?>
                        </select>
                      </div>
                    </div>
                    <hr>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">Post Ability
                        <i title="লেখক তার প্রোফাইল থেকে লেখা প্রকাশ/সাবমিট করতে পারবেন কি না।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      <div class="col-lg-8">
                        <select class="form-control" name="PostAbility">
                          <option <?php echo ($tt_acc_user['PostAbility'] == 'yes') ? 'selected' : '' ?> value="yes">Yes</option>
                          <option <?php echo ($tt_acc_user['PostAbility'] == 'none') ? 'selected' : '' ?> value="none">None</option>
                        </select>
                      </div>
                    </div>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">Post Publish
                        <i title=" প্রোফাইল থেকে লেখা সাবমিট করার পরে সরারি পোস্ট হবে কি না । যদি Manually থাকে তবে লেখা প্রকাশের পরে এডমিন কতৃক লেখা যাচাই করে প্রকাশ করতে হবে । আর যদি Automatic হয় তবে লেখা প্রকাশের সাথে তা ওয়েবসাইটে প্রকাশ পাবে ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </label>
                      <div class="col-lg-8">
                        <select class="form-control" name="PostPublish">
                          <option <?php echo ($tt_acc_user['PostPublish'] == 'Manually') ? 'selected' : '' ?> value="Manually">Manually</option>
                          <option <?php echo ($tt_acc_user['PostPublish'] == 'Automatic') ? 'selected' : '' ?> value="Automatic">Automatic</option>
                        </select>
                      </div>
                    </div>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">Show Writer Profile
                        <i title="ওয়েবসাইটে ইউজারের প্রোফাইল দৃশ্যমান হবে কি না ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </label>
                      <div class="col-lg-8">
                        <select class="form-control" name="UserProfile">
                          <option <?php echo ($tt_acc_user['UserProfile'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
                          <option <?php echo ($tt_acc_user['UserProfile'] == 'deactive') ? 'selected' : '' ?> value="deactive">Deactive</option>
                        </select>
                      </div>
                    </div>
                    <hr>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">OTP Varification Status
                        <i title="লেখকের প্রোফাইল ইমেইল/এসএমএস দ্বারা ভেরিফিকেশন সম্পন্ন হয়েছে কি না । যদি Unverified নির্বাচন করা হয় তবে লেখককে আবার ভেরিয়াই করে নিতে হবে ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </label>
                      <div class="col-lg-8">
                        <select class="form-control" name="FirstVerificationStatus">
                          <option <?php echo ($tt_acc_user['FirstVerificationStatus'] == 'Verified') ? 'selected' : '' ?>>Verified</option>
                          <option <?php echo ($tt_acc_user['FirstVerificationStatus'] == 'Unverified') ? 'selected' : '' ?>>Unverified</option>
                        </select>
                      </div>
                    </div>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">Account Status
                        <i title="Deactive হলে লেখক তার একাউন্ট এ লগইন করতে পাড়বেন না ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </label>
                      <div class="col-lg-8">
                        <select class="form-control" name="AccountStatus">
                          <option <?php echo ($tt_acc_user['AccountStatus'] == 'active') ? 'selected' : '' ?> value="active">Active</option>
                          <option <?php echo ($tt_acc_user['AccountStatus'] == 'deactive') ? 'selected' : '' ?> value="deactive">Deactive</option>
                        </select>
                      </div>
                    </div>
                    <div class="row mb-3">
                      <label for="AccountStatus" class="col-lg-4 col-form-label">Can Edit Profile
                        <i title="লেখক তার প্রোফাইল থেকে কোন তথ্য পরিবর্তন করতে পাড়বেন কি না ।" data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </label>
                      <div class="col-lg-8">
                        <select class="form-control" name="UpdateProfile">
                          <option <?php echo ($tt_acc_user['UpdateProfile'] == 'active') ? 'selected' : '' ?> value="active">Yes</option>
                          <option <?php echo ($tt_acc_user['UpdateProfile'] == 'deactive') ? 'selected' : '' ?> value="deactive">No</option>
                        </select>
                      </div>
                    </div>
                    <div class="row  mb-3">
                      <div class="col-lg-4 label">Remark
                        <i title="এডমিন প্যানেলের জন্য লেখকে নিয়ে কোন মন্তব্য লিখতে পাড়েব " data-bs-toggle="tooltip" data-bs-placement="top" class="bi bi-info-circle-fill text-muted"></i></label>
                      </div>
                      <div class="col-lg-8">
                        <textarea name="UserAdminNotice" class="form-control" rows="2" cols="80"><?php echo $tt_acc_user['UserAdminNotice'] ?></textarea>
                      </div>
                    </div>
                    <div class="text-center">
                      <button id="SubmitChange" name="update_user" type="submit" class="btn-sm btn btn-primary">Save Changes</button>
                      <!-- Button trigger modal -->
                      <button type="button" class="btn btn-outline-danger btn-sm" data-bs-toggle="modal" data-bs-target="#resendPassword">
                        Send New Passowrd
                      </button>
                    </div>
                  </form><!-- End Profile Edit Form -->

                  <!-- Send New Password -->
                  <form class="" action="" method="post">
                    <div class="modal fade" id="resendPassword" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="resendPasswordLabel" aria-hidden="true">
                      <div class="modal-dialog">
                        <div class="modal-content">
                          <div class="modal-header">
                            <h1 class="modal-title fs-5" id="resendPasswordLabel">Send New Passowrd</h1>
                            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                          </div>
                          <div class="modal-body text-center">
                            <p>Send New Password For Account</p>
                            <img src=" <?php echo  userAvaterDB($tt_acc_user['UserID']) ?>" alt="Profile" class="rounded-circle w-25">
                            <h2 class="h4 mt-2"><?php echo $tt_acc_user['UserName'] ?></h2>
                            <h2 class="h6 mt-2"> <a href="tel:<?php echo $tt_acc_user['UserMobile'] ?>"><?php echo $tt_acc_user['UserMobile'] ?></a> </h5>
                          </div>
                          <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                            <button type="submit" name="send_new_password_email" class="btn btn-primary">Send Email</button>
                            <button type="submit" name="send_new_password" class="btn btn-primary">Send SMS</button>
                          </div>
                        </div>
                      </div>
                    </div>
                  </form>
                </div>
                <style media="screen">
                .icon-activity {
                    font-size: 18px;
                    display: inline-block;
                    height: 35px;
                    text-align: center;
                    width: 35px;
                    line-height: 36px;
                    color: white;
                    border-radius: 33px;
                }
                </style>
                <div class="tab-pane fade pt-3" id="profile-change-password">
                  <div class="text-start">
                    <table  class="tt_datatable" style="width:100%">
                      <thead>
                          <tr>
                              <th>Title</th>
                          </tr>
                      </thead>
                      <tbody>
                        <?php

                        $get_user_acitvity = showAllttdata("tt_account_log", "WHERE user_id =  '$writer_id_get' ORDER BY tt_time DESC");
                        foreach ($get_user_acitvity as $user_the_activity) {
                          ?>
                          <tr>
                            <th class="fw-normal">
                              <?php
                              if ($user_the_activity['type'] == "Account") {
                                ?>
                                <span class="icon-activity" style="background: linear-gradient(45deg, #0067ff, #668eff);">
                                  <i class="bi bi-person-gear"></i>
                                </span>

                                <?php
                              }elseif ($user_the_activity['type'] == "Security") {
                                ?>
                                <span class="icon-activity" style="    background: linear-gradient(45deg, #ff0808, #f8afaf);    line-height: 39px;">
                                  <i class="bi bi-shield-fill-exclamation"></i>
                                </span>
                                <?php
                              }

                              ?>
                              <span class="cursor-pointer fw-bold" data-bs-toggle="modal" data-bs-target="#activityView<?php echo $user_the_activity['id'] ?>"><?php echo $user_the_activity['title'] ?></span> <small> - <?php echo date("j F Y g:i A", strtotime($user_the_activity['tt_time'])) ?></small>

                              <div class="modal fade" id="activityView<?php echo $user_the_activity['id'] ?>" tabindex="-1"   aria-hidden="true">
                                <div class="modal-dialog">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <h5 class="modal-title" ><?php echo $user_the_activity['title'] ?></h5>
                                      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                                    </div>
                                    <div class="modal-body">
                                      <?php echo $user_the_activity['description'] ?>
                                    </div>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                                      <button type="button" class="btn btn-primary">Save changes</button>
                                    </div>
                                  </div>
                                </div>
                              </div>


                            </th>
                          </tr>
                          <?php
                        }
                        ?>

                      </tbody>
                    </table>

                  </div>
                </div>

                <?php
              }
              ?>

            </div><!-- End Bordered Tabs -->

          </div>
        </div>

      </div>
    </div>
  </section>
</main>
<script>
$(document).ready(function(){
    $("#checkUrl").on("input", function(){
        let username = $(this).val();
        let cleanUsername = username.replace(/[^a-zA-Z0-9-]/g, '');
        if (username !== cleanUsername) {
            $(this).val(cleanUsername);
        }

        // Send AJAX request if input is valid and not empty
        if(cleanUsername.length > 0) {
            $.ajax({
                url: "<?php echo $site_domain ?>/ajax_master/usernamechk/", // Change this to your PHP file
                type: "POST",
                data: { UserUrl: cleanUsername , UserId:<?php echo $tt_acc_user['UserID'] ?>  },
                success: function(response) {
                    $("#checkUrlfdback").html(response); // Display response
                }
            });
        } else {
            $("#checkUrlfdback").html(""); // Clear feedback if empty
        }
    });
});
</script>
<?php require_once('inc/footer.php'); ?>
