Posts

Showing posts from 2024
 // Replace 'YOUR_API_KEY' with your actual API key const apiKey = 'YOUR_API_KEY'; // Function to authenticate and log in an agent async function loginAgent(username, password) {     try {         const response = await fetch('https://api.ziwo.io/v1/auth/login', {             method: 'POST',             headers: {                 'Content-Type': 'application/json',                 'Authorization': `Bearer ${apiKey}`             },             body: JSON.stringify({                 username: username,                 password: password             })         });         if (!response.ok) {             throw new Error('Login failed');         }         const data = await response.json();         const authToken = data.token;         console.log('Agent logged in successfully:', authToken);         return authToken;     } catch (error) {         console.error('Error logging in agent:', error);         return nu
 // Replace 'YOUR_API_KEY' with your actual API key const apiKey = 'YOUR_API_KEY'; // Function to make a call using Ziwo API async function makeCall(toNumber, fromNumber) {     try {         const response = await fetch('https://api.ziwo.io/v1/calls', {             method: 'POST',             headers: {                 'Content-Type': 'application/json',                 'Authorization': `Bearer ${apiKey}`             },             body: JSON.stringify({                 to: toNumber,                 from: fromNumber,                 // Additional parameters can be added here, such as custom caller ID, etc.             })         });                  if (!response.ok) {             throw new Error('Failed to make call');         }                  const data = await response.json();         console.log('Call successfully initiated:', data);     } catch (error) {         console.error('Error making call:', er
 <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>Ziwo Integration</title> </head> <body>     <!-- Include Ziwo JavaScript SDK -->     <script src="https://cdn.ziwo.io/sdk/ziwo.min.js"></script>     <!-- Your other HTML content goes here -->     <script>         // Initialize Ziwo client with your API key         const ziwoClient = new Ziwo.Client('YOUR_API_KEY');         // Example: Make a call         ziwoClient.call.makeCall('TO_PHONE_NUMBER', 'FROM_PHONE_NUMBER');         // Example: Send an SMS         ziwoClient.sms.send('TO_PHONE_NUMBER', 'MESSAGE_CONTENT');         // Example: Listen for incoming calls         ziwoClient.on('callIncoming', (call) => {             // Handle incoming call        
 <?php // Sample data $bookings = array(     array("car_no" => 1234, "surved_car" => 1234, "allocation_from_date" => "20-02-2024 10:00", "allocation_to_date" => "20-03-2024 12:00", "lease_start_date" => "20-02-2024", "lease_end_date" => "20-02-2025", "type" => "allocated"),     array("car_no" => 1234, "surved_car" => 3856, "allocation_from_date" => "28-03-2024 10:00", "allocation_to_date" => "27-04-2024 12:00", "lease_start_date" => "28-03-2024", "lease_end_date" => "28-03-2025", "type" => "replaced"),     array("car_no" => 6989, "surved_car" => 3856, "allocation_from_date" => "21-01-2024 10:00", "allocation_to_date" => "21-02-2024 12:00&qu
 <?php // Sample data $bookings = array(     array("car_no" => 1234, "surved_car" => 1234, "allocation_from_date" => "20-02-2024 10:00", "allocation_to_date" => "20-03-2024 12:00", "lease_start_date" => "20-02-2024", "lease_end_date" => "20-02-2025", "type" => "allocated"),     array("car_no" => 1234, "surved_car" => 3856, "allocation_from_date" => "28-03-2024 10:00", "allocation_to_date" => "27-04-2024 12:00", "lease_start_date" => "28-03-2024", "lease_end_date" => "28-03-2025", "type" => "replaced"),     array("car_no" => 6989, "surved_car" => 6989, "allocation_from_date" => "21-01-2024 10:00", "allocation_to_date" => "21-02-2024 12:00&qu
 <?php // Database connection parameters $servername = "localhost"; $username = "username"; $password = "password"; $database = "your_database"; // Create connection $conn = new mysqli($servername, $username, $password, $database); // Check connection if ($conn->connect_error) {     die("Connection failed: " . $conn->connect_error); } // Select all records from tbl_booking_details $sql = "SELECT tbl_booking_details_primary_id, actual_end_date FROM tbl_booking_details"; $result = $conn->query($sql); if ($result->num_rows > 0) {     // Loop through each row in tbl_booking_details     while ($row = $result->fetch_assoc()) {         $booking_id = $row['tbl_booking_details_primary_id'];         $actual_end_date = $row['actual_end_date'];         // Check if actual_end_date is different in tbl_booked_car_details         $check_sql = "SELECT allocation_to_date FROM tbl_booked_car_details WHER
 <?php function getTotalDays($from_date, $to_date) {     // Define the current date     $current_date = time(); // Current Unix timestamp     // Convert provided dates to Unix timestamps     $from_date_timestamp = strtotime($from_date);     $to_date_timestamp = strtotime($to_date);     // If To date is greater than current date, set it to current date     if ($to_date_timestamp > $current_date) {         $to_date_timestamp = $current_date;     }     // Calculate the total days between From date and adjusted To date     $total_days = floor(($to_date_timestamp - $from_date_timestamp) / (60 * 60 * 24)) + 1; // Add 1 to include both From date and To date     return $total_days; } // Example usage $from_date = '20-03-2024'; $to_date = '30-05-2024'; $total_days = getTotalDays($from_date, $to_date); echo "Total days between From date and adjusted To date: " . $total_days . " days.\n"; ?>
 <?php // Define the current date $current_date = strtotime('02-04-2024'); // Current Unix timestamp for the example // Define the From date and To date from Table 1 $from_date_table1 = strtotime('20-03-2024'); $to_date_table1 = strtotime('30-05-2024'); // If To date is greater than current date, set it to current date if ($to_date_table1 > $current_date) {     $to_date_table1 = $current_date; } // Calculate the total days between From date and adjusted To date $total_days = floor(($to_date_table1 - $from_date_table1) / (60 * 60 * 24)) + 1; // Add 1 to include both From date and To date // Output the total days echo "Total days between From date and adjusted To date: " . $total_days . " days.\n"; ?>
 SELECT   CASE      WHEN type = 'allocated' THEN car_no     ELSE (SELECT car_no FROM tbl_booked_car_details b2            WHERE b2.tbl_booking_details_primary_id = bd.tbl_booking_details_primary_id              AND b2.type = 'allocated'              ORDER BY allocation_from_date DESC              LIMIT 1)   END AS car_no,    car_no as served_car,   allocation_from_date,   allocation_to_date FROM tbl_booked_car_details bd ORDER BY car_no, allocation_from_date;

ddd

 SELECT      t1.car_no,     SUM(DATEDIFF(FROM_UNIXTIME(t1.allocation_to_date), FROM_UNIXTIME(t1.allocation_from_date)) + 1) AS total_days_booked,     SUM(         CASE             WHEN t2.allocation_to_date IS NOT NULL THEN                  DATEDIFF(FROM_UNIXTIME(t1.allocation_from_date), FROM_UNIXTIME(t2.allocation_to_date)) - 1             ELSE                  0         END     ) AS missing_days FROM      tbl_booked_car_details t1 LEFT JOIN      tbl_booked_car_details t2 ON t1.car_no = t2.car_no AND FROM_UNIXTIME(t1.allocation_from_date) > FROM_UNIXTIME(t2.allocation_to_date) GROUP BY      t1.car_no;

query

  SELECT   d .aggregator_id ,   d .model_id ,   CASE   WHEN   COUNT ( r .tbl_demo_p_id )   =   d .quantity   THEN   'Full'   ELSE   'Empty'   END   AS   status   FROM   tbl_demo   d   LEFT   JOIN   tbl_demo_refer   r   ON   d .id   =   r .tbl_demo_p_id   WHERE   d .aggregator_id   =   1   AND   d .model_id   =   2   GROUP   BY   d .aggregator_id ,   d .model_id ,   d .quantity ; SELECT      d.aggregator_id,     d.model_id,     CASE          WHEN COUNT(r.tbl_demo_p_id) = d.quantity THEN 'Full'         ELSE 'Empty'     END AS status FROM      tbl_demo d LEFT JOIN      tbl_demo_refer r ON d.id = r.tbl_demo_p_id WHERE      d.aggregator_id = <aggregator_id_value>     AND d.model_id = <model_id_value>     AND r.car_no = '<car_no_value>' GROUP BY      d.aggregator_id, d.model_id, d.quantity;
 index.php <!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <meta name="viewport" content="width=device-width, initial-scale=1.0">   <title>Dynamic Page Loading with Login, Active Page, and Completed Pages</title>   <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">   <script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>   <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>   <style>     #content-container {       margin: 10px;       padding: 10px;       border: 1px solid #ddd;     }     #page-list {       list-style: none;       padding: 0;     }     #page-list li {       margin-bottom: 5px;       cursor: pointer;     }     #page-list li.active {       background-color: #007bff;       color: #fff;  

Select one checkbox at a time from group of checkbox

Select one checkbox at a time from group of checkbox <div class="btn-group" role="group" onclick="selectOne(event)">   <input type="checkbox" class="btn-check" id="btncheck1" value='1' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck1">Checkbox 1</label>   <input type="checkbox" class="btn-check" id="btncheck2" value='2' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck2">Checkbox 2</label>   <input type="checkbox" class="btn-check" id="btncheck3" value='2' autocomplete="off">   <label class="btn btn-outline-primary" for="btncheck3">Checkbox 3</label> </div> <script> function selectOne(event) {     const clickedElement = event.target;

Form Validation

Form Validation <!DOCTYPE html> <html> <head>     <title>Form Validation</title>      </head> <body>     <form id="loginForm">         <input type="text" name="username" required placeholder="Username" data-error-msg="Username is required"><br><br>         <input type="password" name="password" required placeholder="Password" data-error-msg="Password is required"><br><br>         <input type='text' class='form-control' data-error-msg="Data required" required>         <!-- Additional form fields -->         <button type="button" id="submitForm">Submit</button>     </form>     <div id="result"></div> </body> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>     <script>