Get all ads data with ads images in one query

1st table name my_ads and entries

+----+-------------+--------+----------+---------+
| id | title       | gender | country  | user_id |
+----+-------------+--------+----------+---------+
| 35 | NOman Javed | male   | Pakistan | 1       |
| 34 | Noman Javed | male   | Pakistan | 1       |
| 33 | Noman Javed | male   | Pakistan | 1       |
| 32 | Noman Javed | male   | Pakistan | 1       |
| 31 | Noman Javed | male   | Pakistan | 1       |
+----+-------------+--------+----------+---------+

2nd table ads_images

+----+-----------+---------------------------------+
| id | my_ads_id | image_path                      |
+----+-----------+---------------------------------+
| 28 | 35        | 1645180564-Screenshot-(529).png |
| 27 | 35        | 1645180562-Screenshot-(528).png |
| 26 | 35        | 1645180558-Screenshot-(527).png |
| 25 | 34        | 1645180318-Screenshot-(529).png |
| 24 | 34        | 1645180316-Screenshot-(528).png |
+----+-----------+---------------------------------+

I had written the query and combined it in one array value but I want it to be done with one query.

$all_ads = DB::table('my_ads')->get();

$my_ads_images = DB::table('ads_images')->select('id','my_ads_id', 'image_path')- 
>groupBy('my_ads_id')->get();

then compile with both tables values in one array on sub-index

foreach($all_ads as $ads_key => $ads) {

    $my_ads_array[$ads_key]['id'] = $ads->id;
    $my_ads_array[$ads_key]['title'] = $ads->title;

    foreach($my_ads_images as $my_ads_image) {
        if($ads->id == $my_ads_image->my_ads_id) {
            $my_ads_array[$ads_key]['image_path'] = $my_ads_image->image_path;
        }
    }
}

Can I write query to achieve $my_ads_array[$ads_key]['image_path'] = array of images here with one query. I am using Laravel 8 with MySQL.

I know it’s a basic query but I don’t know how it will work. I tried joins but that didn’t work for me don’t know why.

Looking for output like this:

[0] => Array
    (
        [id] => 35
        [title] => Noman Javed
        [gender] => male            
        [description] => Height: 5.6''
        [country] => Pakistan
        [image_path] => Array
            (
                [0] => 1645180558-Screenshot-(527).png
                [1] => 1645180562-Screenshot-(528).png
                [2] => 1645180564-Screenshot-(529).png
            )

        [created_at] => 2022-02-18 10:35:49

    )

Thanks in Advance in case sort this out.

How to set cookie value properly with $_SERVER[‘REQUEST_URI’]?

I have a Google AdWords campaign, so when users click on the ad it links them to a certain page. The page URL has a specific Google Ad string, so using it, I want to change some colors on all pages, not only one.

I’m trying to use $_SERVER['REQUEST_URI'] and setcookies() function. Let’s say that the Google Ad string is adword. So when the ad was clicked it linked to https://example.com/adword/ page and I get this slug string and set to cookies a value:

$cookie_val = '';
if (strpos($_SERVER['REQUEST_URI'], "adword") && !isset($_COOKIE['ad_cookies'])){
    setcookie('ad_cookies', 'myvalue', time()+(3600*6));  /* expire in 6 hours */
    $cookie_val = $_COOKIE['ad_cookies'];
}

I though then I can use this cookie value everywhere, for example by changing class name of a div:

<div class="page <?php echo $cookie_val ?>">

But it only works on one page https://example.com/adword/.

So my question is, how can I use this cookie value on every page when a user clicked the ad? Thanks in advance!

Betheme – On related posts, change read more button text for specific category

I am using Betheme on WordPress.

Under the related posts section, is it possible to change the ‘read more’ button for a specific post category?

I’ve created a podcast page, so would prefer the text to read ‘listen now’ just for that category.

You can translate the text in the theme options, but this applies to the whole site, and I would like it just for the specific category – podcasts (id-1396).

Send Email using GetResponse API keys

I have a WordPress site with getResponse plugin.

I have a registration form which should confirm the email of the user, then the user should be registered in the database.
I have an ajax call when the user submits the form, it gets the username and email to check if the email or username is already registered in the site.

The form html looks like this

<div id="td-register-div">
  <div class="td_display_err"></div>
  <form id="register-form" action="#" method="post">
    <div class="td-login-input">
      <input class="td-login-input" type="text" name="register_email" id="register_email">
      <label for="register_email">Your Email</label>
    </div>
    <div class="td-login-input">
      <input class="td-login-input" type="text" name="register_user" id="register_user">
      <label for="register_user">Your Username</label>
    </div>
    <input type="button" name="register_button" id="register_buttonn" value="Register">
  </form>
</div>

jQuery looks like this

$("#registerForm #register_buttonn").click(function(e){
    e.preventDefault();
    var user_email = $("#registerForm #register_email").val();
    var user_name = $("#registerForm #register_user").val();
    if (user_email == "" || user_name == "") {
        $("#td-register-div > .td_display_err").html("Email and username required");
        $("#td-register-div > .td_display_err").css("display", "block");
    } else{
        jQuery.ajax({
            type: "post",
            url: my_ajax_object.ajax_url,
            data : {action: "user_register_ajax", user_email: user_email, user_name: user_name},
            success: function(response){
                $("#td-register-div > .td_display_err").css("display", "block");
                $("#td-register-div > .td_display_err").html(response);
            }
        });
    }
});

function.php looks like this

function user_register_ajax(){
global $wpdb;
//Get username and email
$user_email = $_REQUEST['user_email'];
$user_name = $_REQUEST['user_name'];
//Check if username or email already exists
$check_username = "SELECT * FROM wp_users WHERE user_login = '".$user_name."'";
$userNameResult = $wpdb->get_results($check_username, OBJECT);
$check_useremail = "SELECT * FROM wp_users WHERE user_email = '".$user_email."'";
$userEmailResult = $wpdb->get_results($check_useremail, OBJECT);
if (count($userNameResult) != 0) {
    echo "Username already taken";
    die();
} else if(count($userEmailResult) != 0){
    echo "Email already exists";
    die();
} else{
    $url = 'https://api.getresponse.com/v3/transactional-emails';

    $params = array(
        'fromFieldId' => '[email protected]',     
        'subject'     => 'subject',
        'content'     => 'Message',
        'to'          => '[email protected]',
    );

    $curl = curl_init($url);
    // Set the CURLOPT_RETURNTRANSFER option to true
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    // Set the CURLOPT_POST option to true for POST request
    curl_setopt($curl, CURLOPT_POST, true);
    // Set the request data as JSON using json_encode function
    curl_setopt($curl, CURLOPT_POSTFIELDS,  json_encode($params));
    // Set custom headers for X-Auth-Token, needed for Getresponse API
    curl_setopt($curl, CURLOPT_HTTPHEADER, [
      'X-Auth-Token: api-key XXXX',
      'Content-Type: application/json'
    ]);

    // Execute cURL request with all previous settings
    ob_start();
    curl_exec($curl);
    // close the connection, release resources used
    curl_close($curl);      
    ob_end_clean();
    echo "Check your mail and enter OTP";
    die();
  }
}
add_action('wp_ajax_nopriv_user_register_ajax', 'user_register_ajax');
add_action('wp_ajax_user_register_ajax', 'user_register_ajax');

If the user is not registered on the site he should get an email from getResponse mailing system with an OTP which the user will enter on the site and then he will get registered. Currently I’ve entered my email in the receiver’s email for testing purpose.

I’m stuck in the mailing part.

I had this code from Send mail using send grid api key and Pass Email and Name to GetResponse via API

I want to send an email from getResponse mailing system.

But so far this is all I got and can’t see the mistake in my code can anyone help me.

I am new to php can you help me solve this example [closed]

enter code here

can you help me

The electricity company wants to know to which group the citizens belong, based on their consumption and how much money they should pay at the end of the month.

Because of that the electricity company decided to reach out to you and asked you to write a program that finds which group a specific citizen belongs to.

Here are some information that will help you to decide which group a citizen belongs to:

Citizens groups
Group 1: 1 to 300 Kilowatt/hour, cost = 0.5$ for each Kilo.
Group 2: 300 to 600 Kilowatt/hour, cost = 1$ for each Kilo.``
Group 3: more than 600 Kilowatt/hour, cost = 2$ for each Kilo.
To calculate the cost in one month:
Use a variable called electricityConsumption.`enter code here`
In the variable add a value you want your program to check (this value in this variable is how much Kilowatts have been consumed in a single month).
At the end print to which group the citizen belongs to and how much his/her consumption cost.emphasized text

Session files are increasing fast in laravel

I have around 1000 users(website+application), the session files in framework folder are increasing rapidly, after sometime they are so much that godaddy’s limit is exhausted, my session lifetime is 525600, Can anyone help that how i will manage this.

Call to undefined function imap_open()

I’m trying to IMAP working on my Mac running Big Sur.

I used HomeBrew to install PHP 8.1:

brew tap shivammathur/php
brew tap shivammathur/extensions
brew install [email protected]

PHP is working and according to the phpinfo() it’s using the correct path.
There’s also the additional path to the imap.ini
The path in the imap.ini exists and there is a imap.so

When i run “php -m” imap is mentioned in the list.

But when I run my code I get the error:

Call to undefined function imap_open()

I tried reinstalling the php with extensions and I tried https://stackoverflow.com/a/66047249/909723 but no success

Hope someone can help!

Thanks in advance

PHP Undefined array key warning

I am creating an associative array from XML feed using foreach as you see here:

function load_xml() {
        global $db;

        if(!$xml=simplexml_load_file($this->path)){
            trigger_error('Error reading XML file',E_USER_ERROR);
            }
        foreach ($xml as $item) {
            $xml_items[] = $item_url;
            $data[] = ['item_id' => null,
                       'title' => $item->PRODUCT->__toString(),
                       'title_draft' => null,
                       'description' => $item->DESCRIPTION_SHORT->__toString(),
                       'description_draft' => null,
                       'text' => $item->DESCRIPTION->__toString(),
                       'text_draft' => null,
                       'item_url' => $item->URL->__toString(),
                       'merchant' => $item->MANUFACTURER->__toString(),
                       'price' => $item->PRICE_VAT->__toString(),
                       'price_initial' => $item->PRICE_VAT_SALE->__toString(),
                       'language_id' => 1,
                       'subcategory_id' => 0,
                       'head' => null,
                       'ean' => null,
                       'code' => null,
                       'category_id' => 0,
                       'subcategory_id' => 0,
                       'action' => 0,
                       'rank' => 0,
                       'keywords' => "",
                       'published' => 0];

        }
        return $data;
    }

But when I try to use the values in this load_existing_items function I get warning undefined array key:

function load_existing_items(){
        global $db;

        $data = $this->load_xml();

        foreach($data as $key => $value){
            $item_url = $data['item_url'];
            $merchant = $data['merchant'];
            $result = $db->query("SELECT url FROM item WHERE  url = '$item_url' AND manufacturer = '$merchant'");

            while(($row = mysqli_fetch_assoc($result))) {
            $this->$db_items[] = $row['url'];
        }
        }
    }   

This is most likely some kind of a really primitive mistake that I made last night while I was desperately finish the code. Thank you for any advice/help.

PHP list() expects numerical indexes in v7.4.6 [duplicate]

In the PHP manual, I read:

Before PHP 7.1.0, list() only worked on numerical arrays and assumes the numerical indices start at 0.

My code:

echo 'Current PHP version: ' . phpversion() . "n" ;
print_r( $Item ) ;
list( $Cost, $Quantity, $TotalCost ) = $Item ;

Output:

Current PHP version: 7.4.6
Array
(
    [cost] => 45800
    [quantity] => 500
    [total_cost] => 22900000
)
PHP Notice:  Undefined offset: 0 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 0 in D:OneDriveworkTornpm.php on line 27
PHP Notice:  Undefined offset: 1 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 1 in D:OneDriveworkTornpm.php on line 27
PHP Notice:  Undefined offset: 2 in D:OneDriveworkTornpm.php on line 27

Notice: Undefined offset: 2 in D:OneDriveworkTornpm.php on line 27

It seems to me that this version of PHP expects that the indexes are numerical, even if v7.4.6 should be greater than v7.1.0.
Am I missing something?

Image Upload in Livewire

When i login bay Sentinel package Then Livewire File Upload Faild. But Without Sentinel Login Livewire File Upload Working. How To File File/image upload in Livewire when login with sentinel ?

Calculating Average (Mean) in PHP

I’m a bit of a beginner with PHP and am implementing a review aggregator system for a few products.

I have created the input fields and am outputting the results from these fields using this code:

{ echo '<div class="review1">Review 1: '; the_field('review1'); '</div>';}
{ echo '<div class="review2">Review 2: '; the_field('review2'); '</div>';}
{ echo '<div class="review3">Review 3: '; the_field('review3'); '</div>';}
{ echo '<div class="review4">Review 4: '; the_field('review4'); '</div>';}
{ echo '<div class="review5">Review 5: '; the_field('review5'); '</div>';}

I want to use PHP to calculate the average (mean) however the number I am using to calculate this is set to 5 as that is the total number of number fields I have. Here is the code I am using

{ echo (get_field('review1')+get_field('review2')+get_field('review3')+get_field('review4')+get_field('review5'))/5;}

The problem with this method is that sometimes the fields will not contain a value so the number to divide by would need to be 1, 2, 3 or 4 instead of 5 depending on the total number of review fields that have a value.

Essentially I need to replace “/5” with “/n” where “n” is the total number of fields with values.

Can anyone please assist?

Regards,
Peter

Don’t output indent before PHP open tag

I am trying to style my PHP script like a templating language, but the problem is, that PHP outputs the indentation before <?php tags like this:

<ul>
    <? foreach ($arr as $val) { ?>
        <li><?= $val ?></li>
    <? } ?>
</ul>

This works, but outputs

<ul>
            <li>a</li>
            <li>b</li>
    </ul>

and that is terrible.

Is there a way to not output the indentation before PHP tags?


Secondly, the <li> tag is indented twice, but I want to remove one indentation level.

Is that possible?

Enter multiple rows in an MySQL table by pressing the Submit button in a PHP Form

So to preface – I’m trying to implement a “Mark Attendance” feature on my website where I’m printing all the registered students in a table (that is wrapped in ) – each student has a “Present / Absent” radio button and once the admin has selected his preferred option, he presses “Submit” and the form should mark all students Present OR Absent i.e insert multiple rows (equal to the number of total students in the table) with their Attendance Status i.e Absent or Present.

Following is the HTML part of the code (mixed with some PHP):

<form action="adminmarkattendance.php" method="post">
                                <div class="row">
                                    <div class="col">
                                        <div class="card bg-default shadow">
                                            <div class="card-header bg-transparent border-0">

                                                <div class="form-inline">
                                                    <div class="col-lg-6">
                                                        <h3 class="text-white mb-0">Registered Students</h3>
                                                    </div>
                                                    <div class="col-lg-6">
                                                        <div class="form-group">
                                                            <input style="width: 100%;" class="form-control" name="attendancedate" type="date" required>

                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="table-responsive" style="overflow-y: scroll; height: 600px;">
                                                <table class="table align-items-center table-dark table-flush">
                                                    <thead class="thead-dark">
                                                        <tr>

                                                            <th scope="col" class="sort" data-sort="name">Avatar</th>
                                                            <th scope="col" class="sort" data-sort="name">Student Name</th>
                                                            <th scope="col" class="sort" data-sort="status">Phone Number</th>
                                                            <th scope="col" class="sort" data-sort="status">Age</th>
                                                            <th scope="col" class="sort" data-sort="status">Gender</th>
                                                            <th scope="col" class="sort" data-sort="status">Address</th>
                                                            <th scope="col" class="sort" data-sort="status">Action</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody class="list">
                                                        <?php
                                                        foreach ($getRows as $row) {
                                                            $i = 0; ?>
                                                            <tr>
                                                                <td>
                                                                    <img src="<?php echo '../profileImages/' . $row['profile_image'] ?>" width="45" height="45" alt="">
                                                                    <input type="hidden" name="id" value="<?php echo $row['student_id']; ?>">
                                                                </td>
                                                                <th scope="row">
                                                                    <div class="media align-items-center">

                                                                        <div class="media-body">
                                                                            <span class="name mb-0 text-sm"><?php echo $row['fname'] . ' ' . $row['lname']; ?></span>
                                                                        </div>
                                                                    </div>
                                                                </th>

                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['phonenumber']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['age']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['gender']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <span class="badge badge-dot mr-4">
                                                                        <span class="status"><?php echo $row['address']; ?></span>
                                                                    </span>
                                                                </td>
                                                                <td>
                                                                    <div class="btn-group btn-group-toggle" data-toggle="buttons">
                                                                        <label class="btn btn-secondary active">
                                                                            <input type="radio" name="options" value="present" id="option1" autocomplete="off" checked> Present
                                                                        </label>
                                                                        <label class="btn btn-secondary">
                                                                            <input type="radio" name="options" value="absent" id="option2" autocomplete="off"> Absent
                                                                        </label>
                                                                    </div>
                                                                </td>

                                                            </tr>
                                                        <?php } ?>
                                                    </tbody>
                                                </table>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="text-center">
                                    <button type="submit" name="submit" style="width: 100%;" class="btn btn-warning">Mark Attendance</button>
                                </div>
                            </form>

PHP:

   if (isset($_POST["submit"])) {

    $student_id = $_POST["id"];
    $date = $_POST['attendancedate'];
    $date = date('Y-m-d', strtotime($date));
    $status = $_POST['options'];

    $queryInsert = $conn->prepare("INSERT
       into attendance
       (
       student_id,
       date,
       status
       )
       values 
       (
       $student_id,
       '$date',
       '$status'
       )
  ");
  $queryInsert->execute();
  

    echo "<script> location.replace('adminmarkattendance.php'); </script>";
}

As you can probably see in the code – I’m only trying to insert the student’s ID, date & his present/absent status.

Now, when I press submit, the information of only 1 student is inserted into the Attendance table. Usually, the last student. Which is not what I want – I want X number of rows inserted when I press submit, where X is equal to the number of students in the table.

How do I achieve this? Thank you for reading.

Laravel 8 Localisation Using mcamara package

I am trying to use multi language in my laravel 8 application frontend. I have used mcamara package, and set it up as per the guide on github.

I Have a form which accepts a input, which fetches the user. Based on the condition (if the user has taken survey, downloads a file. else shows the survey form and then redirects to download).

This is working absolutelyn fine in both languages. I am able to view the form in both languages, but once i enter the view page after id submission and i click on the language change button, i get this

SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.

The issue is only in the POST method. Rest works fine.
Can someone help me on how to fix this?

Thanks in advance.

My route file

Route::redirect('/', 'en');

Route::group(['prefix' => LaravelLocalization::setLocale()], function()
{

    Route::get('/', function () {
        return redirect()->route('certificate.download');
        // return view('welcome');
    });



    // Frontend
    Route::prefix('/registration')->group(function(){
        Route::get('/add', [RegController::class, 'RegEnqAppAdd'])-> name('reg.add');
        Route::get('signature_pad', [RegController::class, 'index']);
        Route::post('signature_pad', [RegController::class, 'store'])->name('signature_pad.store');
        Route::post('/store', [RegController::class, 'RegEnqAppAddStore'])-> name('reg.store');
        });

    // Frontend Downloads
    Route::prefix('/downloads')->group(function(){
        Route::get('/certificate', [DownloadController::class, 'DownloadCertificate'])-> name('certificate.download');
        Route::get('/addcertificate/{id}', [DownloadController::class, 'AddCertificate'])-> name('certificate.add');
        Route::get('/addcertificate/group/{id}', [DownloadController::class, 'AddCertificateGroup'])-> name('groupcertificate.add');
        Route::post('/storecertificate', [DownloadController::class, 'StoreCertificate'])-> name('certificate.store');
        Route::post('/viewcertificate', [DownloadController::class, 'ViewCertificate'])-> name('certificate.view');
        Route::get('/viewcertificates/{id}', [DownloadController::class, 'ViewCertificateRedirect'])-> name('certificateredirect.view');
        Route::get('/deletecertificate/{id}/{bid}', [DownloadController::class, 'DeleteCertificateBatch'])-> name('certificate.delete');
        Route::get('/deletegroupcertificate/{id}/{gid}', [DownloadController::class, 'DeleteCertificateGroup'])-> name('groupcertificate.delete');
        });

    // Frontend Surveys
    Route::prefix('/surveys')->group(function(){
        Route::get('/post-training-questionaire/{id}',   [SurveyController::class, 'PostTrainingQuestionaire'])-> name('surveys.posttraining');
        Route::post('/post-training-questionaire/store', [SurveyController::class, 'PostTrainingQuestionaireStore'])-> name('surveys.posttrainingstore');
        });
});
// Frontend Group
// Frontend Group

My Initial View File (id input)

@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')

<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="  crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

{{-- <link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> --}}


    <div class="content-wrapper">
        <div class="container-full">

            <div class="row">
                <div class="col-md-12">

                    <div class="content-header">
                        <div class="d-flex align-items-center">
                            <div class="mr-auto">
                                <div>
                                    <img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
                                </div>

                                <h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
                                    <div class="align-items-center">
                                        <nav>
                                            <ol class="breadcrumb">
                                                <li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
                                                <li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
                                            </ol>
                                        </nav>
                                    </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

            <section class="content">
                <div class="box">
                    <div class="box-header with-border">
                        <h4 class="box-title">{{ __('Enter Your CPR Number to Download Your Certificates') }}</h4>
                    </div>
                    <form class="form" method="post" action="{{ route('certificate.view') }}" enctype="multipart/form-data" id="posttrainingquestionaire">
                        @csrf
                        <div class="box-body">

                            <div class="row">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label>{{ __('CPR Number') }}</label>
                                        <input type="text" name="cprnumber" id="cprnumber" class="form-control" maxlength="9" placeholder="CPR Number" required data-validation-required-message="This field is required">
                                    </div>
                                        @error('cprnumber')
                                        <span class="text-info">{{ $message }}</span>
                                        @enderror
                                </div>
                            </div>

                        </div>
                        <div class="box-footer">
                            <button onclick="$('#posttrainingquestionaire').submit()" class="btn btn-rounded btn-primary btn-outline">
                                <i class="ti-save-alt"></i> {{ __('Submit & Download') }}
                            </button>
                        </div>
                    </form>
                </div>
            </section>

        </div>
    </div>

@endsection

My view_certificate view

@extends ('frontendlayouts.frontend_master')
@section ('frontendbody')

<script src="https://code.jquery.com/jquery-3.6.0.min.js"integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="  crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>


    <div class="content-wrapper">
        <div class="container-full">

            <div class="content-header">
                <div class="d-flex align-items-center">
                    <div class="mr-auto">
                        <div>
                            <img src="{{ asset('backend/images/amilogo.png') }}" width="150px" alt="">
                        </div>

                        <h3 class="page-title" style="border-right: none;">Downloads - Certificate Download</h3>
                            <div class="align-items-center">
                                <nav>
                                    <ol class="breadcrumb">
                                        <li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
                                        <li class="breadcrumb-item active" aria-current="page">{{ __('Course Certificate') }}</li>
                                    </ol>
                                </nav>
                            </div>
                    </div>
                </div>
            </div>

            <section class="content">
                <div class="box">
                    <div class="box-header with-border">
                        {{-- <h4 class="box-title">Enter Your CPR Number to Download Your Certificates</h4> --}}
                        <h1>{{ __('Welcome to Almoalem Institute') }}</h1>

                    </div>
                    <form class="form" method="post" action="{{ route('certificate.view' ) }}" enctype="multipart/form-data" id="posttrainingquestionaire">
                        @csrf
                        <div class="box-body">

                            <div class="row">
                                <div class="col-md-12">

                                    <div class="timeline-event">
                                        <div class="timeline-body">

                                            <div class="media-body">
                                                <div class="timeline-title"><strong>{{ __('CPR Number') }}:</strong></span> <span class="timeline-body">{{ $learnerData->cprnumber }}</span>
                                                    <br>
                                                <span class="timeline-title"><strong>{{ __('Full Name') }}:</strong></span> <span class="timeline-body">{{ $learnerData->fullname }}</span></div>
                                                <br>
                                                <br>

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

                                    <div class="col-12">
                                        <div class="box">
                                            <div class="box-body no-padding">
                                                <div class="table-responsive">
                                                    <table class="table table-hover">
                                                        <tr>
                                                            <th>Sl. No</th>
                                                            <th>Course</th>
                                                            <th>Download Certificate</th>
                                                        </tr>
                                                        <?php $app =array(); ?>
                                                        @foreach($downloadData as $key => $dd)
                                                        <tr>
                                                            <td>{{ $key+1 }}</td>
                                                            <td>{{ $dd->applicationmanagement->courseapplied }}</td>
                                                            <td>
                                                                @if($dd->surveytaken!=NULL || in_array($dd->courseapplication_id, $app))
                                                                <?php $app[$key]=$dd->courseapplication_id;?>
                                                                <p class="text-black">
                                                                    <a  href="{{asset('certificate/'.$dd->certificate) }}" class="btn btn-primary md-5" target="_blank">{{ __('Download Certificate') }}</a>
                                                                </p>
                                                                @else
                                                                <a href="{{route('surveys.posttraining',$dd->id)}}" class="btn btn-dark md-5"> {{ __('Complete Training Feedback to Download Certificate') }}</a>

                                                                @endif
                                                            </td>
                                                        </tr>
                                                        @endforeach
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                            </div>

                        </div>
                    </form>
                </div>
            </section>

        </div>
    </div>

@endsection