how to count number of present(status 1 means present) for each student and input beside each student profile under present column

daily_attendances database

below is under crud_model

public function take_attendance()
    {
        $students = $this->input->post('student_id');
        $data['timestamp'] = strtotime($this->input->post('date'));
        $data['class_id'] = html_escape($this->input->post('class_id'));
        $data['section_id'] = html_escape($this->input->post('section_id'));
        $data['school_id'] = $this->school_id;
        $data['session_id'] = $this->active_session;
        $check_data = $this->db->get_where('daily_attendances', array('timestamp' => $data['timestamp'], 'class_id' => $data['class_id'], 'section_id' => $data['section_id'], 'session_id' => $data['session_id'], 'school_id' => $data['school_id']));
        if($check_data->num_rows() > 0){
            foreach($students as $key => $student):
                $data['status'] = $this->input->post('status-'.$student);
                $data['student_id'] = $student;
                $attendance_id = $this->input->post('attendance_id');
                $this->db->where('id', $attendance_id[$key]);
                $this->db->update('daily_attendances', $data);
            endforeach;
        }else{
            foreach($students as $student):
                $data['status'] = $this->input->post('status-'.$student);
                $data['student_id'] = $student;
                $this->db->insert('daily_attendances', $data);
            endforeach;
        }

        $this->settings_model->last_updated_attendance_data();

        $response = array(
            'status' => true,
            'notification' => get_phrase('attendance_updated_successfully')
        );

        return json_encode($response);
    }



public function get_presentcount_by_student_id($student_id="",$status ="") {
        
        $checker = array(
        
            'student_id' => $student_id,
            'status'    => 1
        );
        $presentcount_by_student_id = $this->db->get_where('daily_attendances', $checker);
        return $presentcount_by_student_id->num_rows();
    }

under the list.php where it shows the student name and the number of days present for each student.The code is below but it does not count number of presents for each student.It still remains 0

<td>
            
                
              <?php  echo $this->crud_model->get_presentcount_by_student_id($student['user_id'],'status');?>
              <br>
              
            </td>

Student detail list shown in table format
student_detail_list

Transparent dynamic circular progress bar in JavaScript/CSS like hollow from inside or background image visible?

I achieved the circular progress bar with background color like this:

enter image description here

But when i try to use this same code but without background color it becomes PI or rectangular. I want to achieve like this:

enter image description here

But what i have is:

enter image description here

If i try to remove bg color it becomes

enter image description here

I searched a lot but couldn’t found any solution.

Here is the code that i am using for this.

<!-- Progress bar -->
<div class="bar-container">
   <div class="circular-progress" style="background: conic-gradient(#FFCAF0 <?php echo $percentage * 3.6; ?>deg, #003866 5deg);">
      <div class="value-container"><?php echo $percentage; ?>%</div>
     </div>
</div>

Here is CSS code:

.bar-container {
        background-color: #003866;
        display: grid;
        place-items: center;
    }
    .circular-progress {
        position: relative;
        height: 200px;
        width: 200px;
        border-radius: 50%;
        display: grid;
        place-items: center;
    }
    .circular-progress::before {
        content: "";
        display: block !important;
        position: absolute;
        height: 84%;
        width: 84%;
        background-color: #003866;
        border-radius: 50%;
    }
    .value-container {
        position: relative;
        font-size: 20px;
        color: #FFCAF0;
    }

How to prevent users to access images, css and js files from url?

I would like to prevent users to access some files through the url. This does it.

RewriteEngine On
RewriteRule ^frontend/assets/(?:images|css|js) - [R=401,NC,L]

But, all those files are blocked and are not accessible during the normal operation of the application.
Is there a way to prevent users to access those files, and have the application worked properly ?

php array unique with a condition

i got arrays that needs to be unique and i need to have a condition to check if value dis is in ANSWERED status , if yes then keep it and remove the one that is in NO ANSWER status

this is my full array

Array
(
    [0] => Array
        (
            [dest] => 960
            [dis] => ANSWERED
        )

    [1] => Array
        (
            [dest] => 596
            [dis] => NO ANSWER
        )

    [2] => Array
        (
            [dest] => 596
            [dis] => ANSWERED
        )

    [3] => Array
        (
            [dest] => 595
            [dis] => NO ANSWER
        )

    [4] => Array
        (
            [dest] => 595
            [dis] => NO ANSWER
        )

)

after removing duplicates :

Array
(
    [dest] => 960
    [dis] => ANSWERED
)
Array
(
    [dest] => 596
    [dis] => NO ANSWER
)
Array
(
    [dest] => 596
    [dis] => ANSWERED
)
Array
(
    [dest] => 595
    [dis] => NO ANSWER
)

with this code :
foreach(array_unique($testArr, SORT_REGULAR) as $doc)
{
    print_r($doc);
}

what i need to do now is remove array[1] that is NO ANSWER because array[2] with key : dis is ANSWERED

thanks for any help

I would like to view the products by category on the home page

I would like to view the products by category on the home page.
I have two category and products tables.
I tried to create the select categories first and after that of the products in the while.
The problem is that for each category I always get all the products.
How can I make sure that only the corresponding product is displayed for each category?
Sorry but I’m just starting out.

Scheme:

1 Category

corresponding product, corresponding product

2 Category

corresponding product

3 Category

corresponding product, corresponding product, corresponding product

Here is my query:

<?php
$sql_cat = "SELECT  category_id,category_name FROM category WHERE status='A' order by category_id ASC"; 
$result_cat = mysqli_query($conn, $sql_cat);
if (mysqli_num_rows($result_cat) > 0) {
    // output data of each row
    while($row_cat = mysqli_fetch_assoc($result_cat)) {
        $categoryid=$row_cat["category_id"];
        $category_name=$row_cat["category_name"];
        echo''.$category_name.'<br>';
        $sql = "SELECT * FROM product WHERE status='A' and category='$categoryid' Order by category ASC"; 
        $resultSet = mysqli_query($conn, $sql);
        while($row = mysqli_fetch_assoc($resultSet)) {
            $nameproduct=ucfirst(html_entity_decode($row['product_name'], ENT_QUOTES));
            echo''.$nameproduct.'';
        }   
    }   
}  

Work log and generate a PDF everys X days

I have created my first php system, it basically is a list of customers which the user can select and log work for which generates a PDF work record.

I want to extend it to generate an invoice every Thursday midnight and send it to the business, eg:

User 1 has worked:
Customer a – 1 hour
Customer c – 2 hours
Customer D – 4 hours

Total 7 hours at (Chargeable rate).

Now in my head it seems pretty straight forward but I want to sense check it with people it possible:

When the PDF is generated I need to store the information in a new table, User ID, Customer name, Hours worked, Time & date. Then each Thursday I need a script to run which will transfer the entries from the database (over the past X days – could I say from ID X which was the last ID to be ran in the previous pdf?) to a PDF, save the pdf to the server and email it to me.

A few questions:
Would It be beneficial to clear this data after X day so the DB doesn’t get too big?

What is the best way to ensure that an entry doesn’t get missed? I will most likely run the script every thursday at midnight, but I’m guessing theres room for error there if somebody submits an entry at the same time? (slim chance but possible)

I’ll be using mPDF for the invoice generation which I already use.

Magento 2 – Type error: require is not a function for admin grid in custom page with custom tab

I am trying to load a grid to a tab on a custom page in Mangento 2 admin. The grid is rendered beautifully but js seems to be uninitialized after the ajax reload fetches it from controller. The grid is not responsive at all. Browser console displays “Type Error: require is not a function”, but I don’t understand how to initialize js for the grid after ajax.

My code (skipping boilerplate e.g. registration.php, composer.json, etc/module.xml, etc/adminhtml/routes.xml):

/Vendor/Module/Controller/Adminhtml/Offers/Edit.php

<?php
  namespace VendorModuleControllerAdminhtmlOffers;

  class Edit extends MagentoBackendAppAction{
    
    protected $resultPageFactory;

    public function __construct(
        MagentoBackendAppActionContext $context,
        MagentoFrameworkViewResultPageFactory $resultPageFactory
    ) {
         parent::__construct($context);
         $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
         return  $resultPage = $this->resultPageFactory->create();
    }
  }
?>

/Vendor/Module/view/adminhtml/layouts/module_offers_edit.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>
            Angebot
        </title>
    </head>
    <body>
        <referenceContainer name="left">
            <block class="VendorModuleBlockAdminhtmlOfferEditTabs"
                name="vendor_module_offer.edit.tabs"/>
        </referenceContainer>
        <referenceContainer name="content">
            <block class="VendorModuleBlockAdminhtmlOfferEdit"
                name="vendor_module_offer.edit"/>
        </referenceContainer>
    </body>
</page>

/Vendor/Module/Block/Adminhtml/Offer/Edit.php

<?php
namespace VendorModuleBlockAdminhtmlOffer;

use MagentoBackendBlockWidgetFormContainer;

class Edit extends Container{

    protected $_coreRegistry = null;

    public function __construct(
        MagentoBackendBlockWidgetContext $context,
        MagentoFrameworkRegistry $registry,
        array $data = []
    ) {
        $this->_coreRegistry = $registry;
        parent::__construct($context, $data);
    }
    protected function _construct()
    {
        $this->_objectId = 'module_offer_id';
        $this->_blockGroup = 'Vendor_Module';
        $this->_controller = 'adminhtml_offer';
        parent::_construct();
        $this->buttonList->remove('save');
    }

    public function getHeaderText()
    {
        return __('Offer');
    }

    protected function _isAllowedAction($resourceId)
    {
        return $this->_authorization->isAllowed($resourceId);
    }

}

/Vendor/Module/Block/Adminhtml/Offer/Edit/Tabs.php

<?php
   namespace VendorModuleBlockAdminhtmlOfferEdit;

   use MagentoBackendBlockWidgetTabs as WidgetTabs;

   class Tabs extends WidgetTabs{

    protected function _construct()
    {
        parent::_construct();
        $this->setId('offer_edit_tabs');
        $this->setDestElementId('edit_form');
        $this->setTitle(__('Angebot'));
    }

    protected function _beforeToHtml()
    {
        $this->addTab(
            'Produkte',
            [
                'label' => __('Products'),
                'url' => $this->getUrl('module/*/products', ['_current' => true]),
                'class' => 'ajax'
            ]
        );
        return parent::_beforeToHtml();
    }
}

This is all just setup for the tabs to display on the page with path .../admin/module/offers/edit/ID. Now, to fill the tab with products I load the grid with this:

/Vendor/Module/Controller/Adminhtml/Offers/Products.php

<?php
  namespace VendorModuleControllerAdminhtmlOffers;

  class Products extends MagentoBackendAppAction{
    protected $resultPageFactory;

    public function __construct(
        MagentoBackendAppActionContext $context,
        MagentoFrameworkViewResultPageFactory $resultPageFactory
    ) {
         parent::__construct($context);
         $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
         return  $resultPage = $this->resultPageFactory->create();
    }
  }
?>

/Vendor/Module/view/adminhtml/layout/module_offers_products.xml

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/layout_generic.xsd">
    <container name="root" label="Root">
        <block class="VendorModuleBlockAdminhtmlOfferEditTabViewProducts" name="offer.edit.tab.product"/>
    </container>
</layout>

/Vendor/Module/Block/Adminhtml/Offer/Edit/Tab/View/Products.php

<?php
namespace VendorModuleBlockAdminhtmlOfferEditTabView;

use MagentoCustomerControllerRegistryConstants;

class Products extends MagentoBackendBlockWidgetGridExtended
{

    protected $_coreRegistry = null;

    protected $_collectionFactory;

    public function __construct(
        MagentoBackendBlockTemplateContext $context,
        MagentoBackendHelperData $backendHelper,
        VendorModuleModelOfferItemFactory $collectionFactory,
        MagentoFrameworkRegistry $coreRegistry,
        PsrLogLoggerInterface $logger,
        array $data = []
    ) {
         $this->_logger = $logger;
        $this->_coreRegistry = $coreRegistry;
        $this->_collectionFactory = $collectionFactory;
        parent::__construct($context, $backendHelper, $data);
    }

    protected function _construct()
    {
        parent::_construct();
        $this->setId('offer_view_products_grid');
        $this->setDefaultSort('offer_item_stock_id', 'desc');
        $this->setSortable(true);
        $this->setPagerVisibility(true);
        $this->setFilterVisibility(true);
    }

    protected function _preparePage()
    {
        $this->getCollection()->setPageSize(5)->setCurPage(1);
    }

    protected function _prepareCollection()
    {
        $collection = $this->_collectionFactory->create()->getCollection();
        $this->setCollection($collection);
        return parent::_prepareCollection();
    }

    protected function _prepareMassaction()
    {
        $this->setMassactionIdField('offer_item_stock_id');
        $this->getMassactionBlock()->setFormFieldName('stock_ids');
        $this->getMassactionBlock()->addItem(
            'customize',
            [
                'label' => __('Anpassen (ToDo)'),
                'url' => $this->getUrl('test/test/test')
            ]
        );
        return $this;
    }
     protected function _prepareColumns()
    {
        $this->addColumn(
            'offer_item_stock_id',
            ['header' => __('Stock ID'), 'index' => 'offer_item_stock_id', 'type' => 'number', 'width' => '50px']
        );
        return parent::_prepareColumns();
    }

    public function getHeadersVisibility()
    {
        return $this->getCollection()->getSize() >= 0;
    }

    public function getRowUrl($row)
    {
        return $this->getUrl('test/test/test');
    }
}

So my question is how to initialize js for the grid after ajax load.

Showing 403 forbidden error on removing members of discord server in laravel php

 $discord = new DiscordClient(['token' => 'OTIzMDg2MTgzNDg2MDYyNjQz.YcK5AA.HfoDRu-6sKDUPnneA29m3eHQtT4']);
 $users = $discord->guild->listGuildMembers(['guild.id' =>923083706934120448, 'limit' => 25]);
 $discord->guild->removeGuildMember(['guild.id'=>923083706934120448,'user.id'=>894299782481334302]);

There was an error executing the removeGuildMember command: Client error: DELETE https://discord.com/api/v6/guilds/923083706934120448/members/894299782481334302 resulted in a 403 Forbidden response:

When I am kicking a member from server it is giving me forbidden error
I have use Restcord library in this I have fetched the members through
it ,And it is working prperly but when i am removing member it is
giing me forbidden error I have given permission to my bot through
oath url generator but still it is givig me this error if you any idea
about this i can explain more you can ask me?

How to get changed value using array_diff in laravel?

public function changeData(Request $request)
{
     $product = Product::where('_id', '=', $request->product['_id'])->first()->toArray();

        //result product : 
        // array(4) {
        //     ["_id"]=>
        //     string(24) "5fffc00df116005c724859f2"
        //     ["name"]=>
        //     string(6) "iphone"
        //     ["slug"]=>
        //     string(14) "product-iphone"
        //     ["status"]=>
        //     string(14) "1"
        // }


        // result $request->product :
        // array(4) {
        //     ["_id"]=>
        //     string(24) "5fffc00df116005c724859f2"
        //     ["name"]=>
        //     string(7) "samsung"
        //     ["slug"]=>
        //     string(15) "product-samsung"
        //     ["status"]=>
        //     string(14) "1"
        // }

        $diff = array_diff($request->product, $product);
        var_dump($diff);
}

ERROR: ‘Array to string conversion’

If I use the :

$diff = array_diff(array_map('serialize',$request->product), array_map('serialize',$product));

Then it will return the following result:

 array(2) {
        ["name"]=>
        string(15) "s:6:"samsung";"
        ["slug"]=>
        string(25) "s:15:"product-samsung";"
      }

The results above are correct for what I need. But it shows "s:6: and "s:15: inside the result. Is there a way for these two to not appear. I just want to get the correct result eg name is samsung. Thank you.

PHP mail stops after changing host [duplicate]

Years ago someone made this PHP script for me. I use it on dozens of web pages.
Recently my hoster was taken over by another company and my script stopped working after that.
The helpdesk of the new hoster gave me a tip to look at:

How to send an HTML email using SMTP in PHP

You can use the hostname below in the article above:
$host = “mail.argewebhosting.nl”;

However, I am not a php specialist and I would like to be able to modify it myself. Can someone tell me what I can do to get the script working again?

==========================================================

<?php
if (!isset($_POST['naam_inzender']) || !isset($_POST['emailadres_inzender']) || !isset($_POST['opmerkingen'])) {
echo 'U heeft niet alle velden ingevuld!';
exit;

}

$naam = htmlspecialchars($_POST['naam_inzender']);
$email = htmlspecialchars($_POST['emailadres_inzender']);
$bericht = htmlspecialchars($_POST['opmerkingen']);
$organisatie= htmlspecialchars($_POST['organisatie']);
$plaats_organisatie= htmlspecialchars($_POST['plaats_organisatie']);
$email_onderwerp= htmlspecialchars($_POST['email_onderwerp']);
$auteur= htmlspecialchars($_POST['auteuradres']);
$header = "From: ".$naam."<$email>rn";
$header .= "BCC: [email protected]";
$tijd = time();
$datum = strftime('%d/%m/%y %H:%M', $tijd);
$ip = getenv('REMOTE_ADDR');
$message = $naam.' -'.$organisatie.'-'.$plaats_organisatie.'- met het e-mailadres '.$email.' en het IP '.$ip.' stuurde op '.$datum.' het volgende bericht:

____________________________________

'.$bericht.'

------------------------------------';

if(mail($auteur, $email_onderwerp, $message, $header))
header("Location: https://www.webkwestie.nl/bedankt_voor_opmerkingen.htm");
else
echo 'Niet verstuurd';
?>

===========================================================================

Undefined index: REQUEST_URI and HTTP_HOST

How can I get rid of this errors.

Line 8 : define('CURRENT_PAGE', basename($_SERVER['REQUEST_URI']));
Line 15: define('READ_PATH', $_SERVER['HTTP_HOST'].'/read.php?id=');

errors:

Undefined index: REQUEST_URI in ......... on line 8
Undefined index: HTTP_HOST in ....... on line 15

anchor tag download is not working on live laravel project

I am using this code to download the pdf files which are placed in main directory “public/download/ca/”
CODE:

      <a download="" class="download" target="_blank" href="{{ asset('download/ca/'.$doc>
              file_name) }}">
      </a>

It is working perfectly on my local server project also downloads the files but it is not working on my live server project, its showing “failed – Server Problem”.