MONTHLY REPORT ON EXCEL FORMAT [closed]

A. Sales Volume:

Routine:

AA Branches:
Patients: 2969
Tests: 5497
Covid: 116
Grand total: 3085
Head Office:

Routine:
Cash: 3,342
Credit: 577
Covid: 233
Grand total: 4,152
Total number of tests: 8,920
B. Challenges:

Test delay and sudden discontinuation
Partial release
Information gap with customer support
Return sample
Toilet flush stolen twice in AA5
Barcode malfunction frequent in AA2
Contamination concern (Hepatitis B)
Incomplete and missing test information
Locker keys issue
Partial unreleased results
Result delay
Communication issues
Pity cash issue
Printer issue
C. Completed Challenges:

AA5 toilet fixed
Connection fixed
AA6 transportation problem resolved
Pity cash issue resolved
Partial unreleased results addressed (occasionally recurs)
D. Challenges in Progress:

Contamination concern (Hepatitis B): Request for vaccination in progress
Incomplete and missing test information: Deletion of incomplete tests and pricing resolution underway
Locker keys issue being addressed
Printer issue being resolved
Communication issues under investigation
E. Updates in Work:

New staff members welcomed
Tele Birr account set up for enhanced payment convenience
Cash machine introduced for streamlined cash handling
Promptly informing customers about delayed test results
F. Achievement for the Last Month Plan:

Increased number of customers
Increased number of tests conducted
Improved customer satisfaction
Enhanced operational efficiency
G. Plan for the Next Month:

Complete all ongoing work
Increase the number of customers
Develop and maintain relationships with staff members
Adhere to SOPs for smooth operations
Perform assigned duties
Conduct regular meetings
Implement result verification process
H. Achievement for the Last Month Plan:

Successfully attracted more customers
Conducted a higher number of tests
Customers expressed satisfaction with the prompt availability of test results
Improved operational efficiency PLEASE COMPILE THIS REPORT ON EXCELOR WORD FORMAT

A GOOD REPORT ON THIS LINK OR APP

Hiding the add to cart button for woocommerce regarding variable products

I’m developing a website in WordPress using Woocommerce and I’ve managed to hide the ‘add to cart button’ of the products for guest users and users according to a specific role. The php script I found (actually it was here in stackoverflow) works really well and hides the add to cart button in all simple products but not on the variable products according to the specific role.

This was the code I used for the role of Reseller

/* REMOVE ADD TO CART BUTTON FOR RESELLER USERS */
add_action('wp_loaded','get_user_role');
function get_user_role(){
$current_user = wp_get_current_user();
if(count($current_user->roles)!==0){
if($current_user->roles[0]=='Reseller'){
add_filter('woocommerce_is_purchasable', '__return_false');
}
}
}

It works fine with simple products but doesn’t work with variable products. Am I missing something?

Any help would be appreciated.

Thank you.

Laravel package development – How to install Illuminate Foundation without requiring laravel/framework?

I’m currently developing a Laravel package. The service provider of this package relies on magic methods config('my.config') and config_path('../my-config.php') defined in Illuminate/Foundation/helpers.php. PHPStorm notifies that it can’t find these magic methods. How to make sure that these dependencies resolve?

Things I tried:

  • The standalone package: https://packagist.org/packages/illuminate/foundation This package is apparently abandoned. No alternatives provided
  • Install the entire laravel/framework. This conflicts with the application with which I try to install the package. I also want to avoid installing unnecessary dependencies in the package.
  • I tried a bunch of packages from Illuminate: config, container and contracts. When I check the vendor folder, I don’t see any foundation directory in the Illuminate directory

Passing the value to other textbox in php [closed]

In my page there is an eye icon which opens a form, in which there is textbox 1 and textbox 2. The user inputs the value in both textboxs and save the form.

The second time the user clicks on the eye icon, can textbox 2 pass the value to textbox 1 in PHP?

Decorating JsonLd ItemNormalizer

In API Platform, I am trying to decorate the service api_platform.jsonld.normalizer.item (class ApiPlatformJsonLdSerializerItemNormalizer).

I notice this is causing some strange behavior in my application. For example, I get an error Specified class AppDtoFileFileMultipleResponseDto is not a resource class. which is not showing before setting up the decorator.

Here is my decorator :

<?php

declare(strict_types=1);

namespace AppSerializer;

use SymfonyComponentDependencyInjectionAttributeAsDecorator;
use SymfonyComponentSerializerExceptionLogicException;
use SymfonyComponentSerializerNormalizerCacheableSupportsMethodInterface;
use SymfonyComponentSerializerNormalizerDenormalizerInterface;
use SymfonyComponentSerializerNormalizerNormalizerInterface;
use SymfonyComponentSerializerSerializerAwareInterface;
use SymfonyComponentSerializerSerializerInterface;

#[AsDecorator('api_platform.jsonld.normalizer.item')]
class ItemJsonLdNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
{

    public function __construct(
        private readonly NormalizerInterface $normalizer,
    ) {}


    public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|ArrayObject|null
    {
        return $this->normalizer->normalize($object, $format, $context);
    }

    public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
    {
        return $this->normalizer->supportsDenormalization($data, $type, $format, $context);
    }

    public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
    {
        return $this->normalizer->denormalize($data, $type, $format, $context);
    }

    public function hasCacheableSupportsMethod(): bool
    {
        return $this->normalizer->hasCacheableSupportsMethod();
    }

    public function supportsNormalization(mixed $data, string $format = null)
    {
        return $this->normalizer->supportsNormalization($data, $format);
    }

    public function setSerializer(SerializerInterface $serializer)
    {
        return $this->normalizer->setSerializer($serializer);
    }

}

As you can see, it’s currently doing nothing appart from decorating the original service.
What am I doing wrong ?

ImageMagick PHP | Dynamic conversion from RGB to CMYK

I’m trying to make an algorithm that converts an image from RGB to CMYK and that modifies each CMYK channel with a given percentage. For example: I upload my RGB image and I say, convert it to CMYK and add 70% of magenta. The percentage can be negative too. Now, by using PHP ImageMagick I’ve done this so far:

     if ($imageMagick) {
        $pixelIter = $imageMagick->getPixelIterator();
        foreach($pixelIter as $row) {
          foreach($row as $pixel) {

            $cyanValue = $pixel->getColorValue(Imagick::COLOR_CYAN);
            $magentaValue = $pixel->getColorValue(Imagick::COLOR_MAGENTA);
            $yellowValue = $pixel->getColorValue(Imagick::COLOR_YELLOW);
            $blackValue = $pixel->getColorValue(Imagick::COLOR_BLACK);

            $cyanPercent = ($cyanValue / 100) * abs($cyan);
            $magentaPercent = ($magentaValue / 100) * abs($magenta);
            $yellowPercent = ($yellowValue / 100) * abs($yellow);
            $blackPercent = ($blackValue / 100) * abs($black);
            
            if ( $cyan < 0 ) {
                $finalCyan = $cyanValue - $cyanPercent;
            } else {
                $finalCyan = $cyanValue + $cyanPercent;
            }
            
            if ( $magenta < 0 ) {
                $finalMagenta = $magentaValue - $magentaPercent;
            } else {
                $finalMagenta = $magentaValue + $magentaPercent;
            }
            
            if ( $yellow < 0 ) {
                $finalYellow = $yellowValue - $yellowPercent;
            } else {
                $finalYellow = $yellowValue + $yellowPercent;
            }
            
            if ( $black < 0 ) {
                $finalBlack = $blackValue - $blackPercent;
            } else {
                $finalBlack = $blackValue + $blackPercent;
            }
            
            $pixel->setColorValue(Imagick::COLOR_CYAN, $finalCyan);
            $pixel->setColorValue(Imagick::COLOR_MAGENTA, $finalMagenta);
            $pixel->setColorValue(Imagick::COLOR_YELLOW, $finalYellow);
            $pixel->setColorValue(Imagick::COLOR_BLACK, $finalBlack);
          }
          $pixelIter->syncIterator();
        }
        
        $imageMagick->writeImage("cmykImage.jpg");
        
        echo "<img src='cmykImage.jpg'>";

    }

Values of channels like $cyan and $magenta are taken in input with $_POST and they are an integer between -100 and 100.

This code works pretty good. The conversion works, the first three channels are changed correctly. The only problem is that the black value doesn’t seem to have the same behaviour as the other three channels. If I try to change only the black, the image remain the same, even though the code is identical for all the channels. Any ideas?

Another thing I tried: every iteration, I tried to calculate the correct color of the pixel and set it with the setColor() function, but in the end I obtain a pixelated image, which is not what I want.

Thank you so much.

Counter Not Incrementing After Adding Items to Cart

I hope you are doing well. Recently, I encountered an issue with my code after making modifications to remove the popup of the side bar cart. The problem now is that the counter no longer increments when items are added to the cart using the quick add button. Strangely, the counter only reflects the correct number of items added when I refresh the page, which was not the case before I made the code changes.
I would be extremely grateful if anyone could kindly assist me with this issue. Below is the modified code I used to remove the popup:

function onQuickBuyButtonClicked(id, pro_id) {
    const CartCount = document.getElementsByClassName('Header__CartCount')[0];

    $(".loader_" + id).addClass("add-success--adding");
    const product = {
        id: id,
        quantity: 1
    };

    $.ajax({
        type: 'POST',
        url: '/cart/add.js',
        data: JSON.stringify(product),
        dataType: 'json',
        headers: {
            'Content-Type': 'application/json'
        },
        success: function(cart) {
            setTimeout(function() {
               $(".loader_" + id).removeClass("add-success--adding");
                $(".loader_" + id).addClass("add-success--added");
//              cartRecommended(pro_id);
            }, 500);

/*
setTimeout(function() {
    document.dispatchEvent(new CustomEvent('product:added', {
        bubbles: true,
        detail: {
            variant: cart,
            quantity: 1
        }
    }));
}, 1200);
*/

            setTimeout(function() {
                $(".loader_" + id).removeClass("add-success--adding").removeClass("add-success--added");
              
            }, 1600);
          setTimeout(function() {
  //        $('#backdrop').addClass('backdrop_active');
          }, 2000);
        },
        error: function(errorThrown) {
            $(".loader_" + id).removeClass("add-success--adding");

            var r = jQuery.parseJSON(errorThrown.responseText);
            $(".error_" + pro_id).html("Error: " + r.description).show();
            setTimeout(function() {
                $(".error_" + pro_id).html("").hide(100);
            }, 3000);
        }
    });
return false;
}

Thank you so much for your help!

nginx config with docker bad getway

the error in terminal:
2023/07/31 09:30:16 [error] 23#23: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.21.1, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://192.168.21.3:9002/”, host: “192.168.21.4:84”
2023/07/31 09:30:16 [error] 23#23: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.21.1, server: localhost, request: “GET / HTTP/1.1”, upstream: “http://192.168.21.2:9003/”, host: “192.168.21.4:84”
192.168.21.1 – – [31/Jul/2023:09:30:16 +0000] “GET / HTTP/1.1” 502 559 “-” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36”
2023/07/31 09:30:16 [error] 23#23: *3 no live upstreams while connecting to upstream, client: 192.168.21.1, server: localhost, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://php-apps/favicon.ico”, host: “192.168.21.4:84”, referrer: “http://192.168.21.4:84/”
192.168.21.1 – – [31/Jul/2023:09:30:16 +0000] “GET /favicon.ico HTTP/1.1” 502 559 “http://192.168.21.4:84/” “Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36”

my nginx config :


worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    access_log /var/log/nginx/access.log;

    # Load balancer configuration
    upstream php-apps {
        server php-app1:9002;
        server php-app2:9003;
    }

    server {
        listen 84;
        server_name localhost;

        location / {
            proxy_pass http://php-apps;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}

app1.conf :

http {

    server {
        listen 9002;
        server_name php-app1;
        root /var/www/app1/html;

        index index.php;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ .php$ {
            fastcgi_pass php-app1:9000;
            fastcgi_index index.php;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }

}

--------

app2.conf/

http {

    server {
        listen 9003;
        server_name php-app2;
        root /var/www/app2/html;

        index index.php;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ .php$ {
            fastcgi_pass php-app2:9000;
            fastcgi_index index.php;
            fastcgi_param REQUEST_METHOD $request_method;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
}

my docker-compose :


version: '3'

services:
  nginx-lb:
    build: 
      context: ./nginx
    ports:
      - "84:84"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./nginx/app1-config/app1.conf:/etc/nginx/conf.d/app1.conf
      - ./nginx/app2-config/app2.conf:/etc/nginx/conf.d/app2.conf
    depends_on:
      - php-app1
      - php-app2
    networks:
      my-test-network:
#        ipv4_address: 192.168.21.2
  php-app1:
    image: php:fpm
    volumes:
      - ./app1/html:/var/www/html
    ports:
      - "9002:9000"
    networks:
      my-test-network:
#       ipv4_address: 192.168.21.3
  php-app2:
    image: php:fpm
    volumes:
      - ./app2/html:/var/www/html
    ports:
      - "9003:9000"
    networks:
      my-test-network:
#        ipv4_address: 192.168.21.4
networks:
  my-test-network:
    driver: bridge
#    ipam:
#      config:
#       - subnet: 192.168.21.0/24


enter image description here


Browser tells me that I have syntax error in json which doesnt exist [closed]

Im trying to fetch simple json text but my browser tells me that theres a syntax error which I cant find.

Heres my JS fetch function:

componentDidMount(){
        fetch("http://localhost/ajax/getProfile.php")
            .then((response) => {
                if (!response.ok) {
                    // Before parsing (i.e. decoding) the JSON data,
                    // check for any errors.
                    // In case of an error, throw.
                    throw new Error("Something went wrong!");
                }
                return response.json(); // Parse the JSON data.
            })
            .then((data) => {
                console.log(data);     
            })
            .catch((error) => {
                    console.log(error);
            });
}

And there is my php ajax php-code and output:

<?php
    header("Access-Control-Allow-Origin: http://localhost:3000");

    require_once "../php/dbh.php";
    require_once "../php/functions.php";

    session_start();

    if(!(userExists($conn,$_SESSION['email'],$_SESSION['email']) === false)){
        echo json_encode(userExists($conn,$_SESSION['email'],$_SESSION['email']));
    } else if(!(userExists($conn,$_SESSION['username'],$_SESSION['username']) === false)){
        echo json_encode(userExists($conn,$_SESSION['username'],$_SESSION['username']));
    }   
    
?>

Output:

{"userId":4,"username":"tt","userEmail":"[email protected]","userPwd":"$2y$10$Oo.HtuwOtauNoQ2Z3qETCObyn0HuNA71CgHdYXod8PEaG8RrASb4G"}

How to solve the error for Install the PHP on WSL2 Ubuntu?

I use WSL2 Ubuntu 22.04 LTS and tried to install the PHP 8.2.

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt upgrade
sudo apt install php8.2

then the error is follow.

libapache2-mod-php8.2 depends on php8.2-common (= 8.2.8-1+ubuntu22.04.1+deb.sury.org+1); however:
  Package php8.2-common is not configured yet.
 libapache2-mod-php8.2 depends on php8.2-opcache; however:
  Package php8.2-opcache is not configured yet.

dpkg: error processing package libapache2-mod-php8.2 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of php8.2-cli:
 php8.2-cli depends on php8.2-common (= 8.2.8-1+ubuntu22.04.1+deb.sury.org+1); however:
  Package php8.2-common is not configured yet.
 php8.2-cli depends on php8.2-opcache; however:
  Package php8.2-opcache is not configured yet.
 php8.2-cli depends on php8.2-readline; however:
  Package php8.2-readline is not configured yet.

dpkg: error processing package php8.2-cli (--configure):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.10.2-1) ...
Errors were encountered while processing:
 php8.2-common
 php8.2-opcache
 php8.2-readline
 php8.2
 libapache2-mod-php8.2
 php8.2-cli
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried the commands for reinstall the PHP:

sudo apt remove --purge
sudo apt autoremove
sudo apt autoclean
sudo apt update
sudo apt install php8.2

then error is same.

The follow is my package list for PHP. (dpkg -l | grep php)

iU  libapache2-mod-php8.2          8.2.8-1+ubuntu22.04.1+deb.sury.org+1         amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-common                     2:93+ubuntu22.04.1+deb.sury.org+2            all          Common files for PHP packages
iU  php8.2                         8.2.8-1+ubuntu22.04.1+deb.sury.org+1         all          server-side, HTML-embedded scripting language (metapackage)
iU  php8.2-cli                     8.2.8-1+ubuntu22.04.1+deb.sury.org+1         amd64        command-line interpreter for the PHP scripting language
iF  php8.2-common                  8.2.8-1+ubuntu22.04.1+deb.sury.org+1         amd64        documentation, examples and common module for PHP
iU  php8.2-opcache                 8.2.8-1+ubuntu22.04.1+deb.sury.org+1         amd64        Zend OpCache module for PHP
iU  php8.2-readline                8.2.8-1+ubuntu22.04.1+deb.sury.org+1         amd64        readline module for PHP

Thanks for your help!

I tried the various commands:

sudo apt remove --purge [packagename]
sudo apt autoremove
sudo apt autoclean
sudo dpkg --purge [packagename]
sudo dpkg --configure -a

error: 2: require_once(/home/chatcuck/public_html/Sources/Multimedia): Failed to open stream: No such file or directory [duplicate]

I get these errors in my log daily.The links are malformed. When clicked they generate these error and white screen. None of the other similar questions and answers address this problem. The directory exists and permissions to access it are fine.

Fatal error: Uncaught Error: Failed opening required ‘/home/chatcuck/public_html/Sources/Multimedia/’ (include_path=’.:/opt/cpanel/ea-php80/root/usr/share/pear’) in /home/chatcuck/public_html/Sources/Multimedia/Multimedia.php:173 Stack trace: #0 /home/chatcuck/public_html/index.php(172): multimedia_main() #1 {main} thrown in /home/chatcuck/public_html/Sources/Multimedia/Multimedia.php on line 173

https://chatcuck.com/index.php?seomod=multimedia%2Fsa%3Ddetailslid%3D355;action=multimedia;multimedia=1;sa=detailslid
/home/chatcuck/public_html/Sources/Multimedia/Multimedia.php (Line 173)
Backtrace information

Type of error: General
Error message Select
2: require_once(/home/chatcuck/public_html/Sources/Multimedia): Failed to open stream: No such file or directory

The code from multimedia.php lines 165-182

// Now what we should do if we don't have a SubAction
    if (empty($_REQUEST['sa']))
    {
        multimedia_index();
        loadtemplate('Multimedia');
    }   
    else
    {
        require_once(MM_SRC_FOLDER . '/' . @$subActions[$_REQUEST['sa']][0]);
        $subActions[$_REQUEST['sa']][1]();
        $sa = $_REQUEST['sa'];
    }

    // This is a vital function so we need it to load everything!
    if (!function_exists('multimedia_vital'))
        fatal_lang_error('You must 
        left the copyright in the template!',false);
}

The code from index.php (lines 171-175):

// What function shall we execute? (done like this for memory's sake.)
call_user_func(Shoutbox_Load(smf_main()));

// Call obExit specially; we're coming from the main area ;).
obExit(null, null, true);

Insert text after image inside Elementor posts loop via hook

I’m trying to insert text after image inside an Elementor posts loop (basically regular posts loop).

I can’t find the right hook for that, I found so far after long research only the_title hook, that in charge on the the title of each post. But I need it after the image and not inside the title.

add_filter( 'the_title', 'wpb_new_title', 10, 2 );
function wpb_new_title( $title, $id ) {
    global $post;
    if(!is_page( 'Wishlist' )){
       if('post' == get_post_type($id)){
            $exclusive = get_field('exclusive', $id);   // pass the id into get_field
            $title = $title .' Custom Text Here '. $exclusive;
        }
    }
    return $title;
}

Here is my current code, that works, though not after the image.

What is the correct way to insert custom text after post image?

Slim Framework mvc design [closed]

I created a small project named chat-app with slim framework but how should the MVC architecture be?

project/
│
├─ app/
│  ├─ Controllers/
│  │  ├─ GroupController.php
│  │  ├─ MessageController.php
│  │
│  ├─ Models/
│  │  ├─ GroupModel.php
│  │  ├─ MessageModel.php
│  │
│  ├─ Services/
│  │  ├─ GroupService.php
│  │  ├─ MessageService.php
│  │
│  ├─ Routes/
│  │  ├─ routes.php
│  │
│  └─ chatapp.sqlite
│
├─ public/
│  ├─ index.php
│  ├─ .htaccess
│
├─ vendor/
│
└─ composer.json

It’s my architecture. Should I add something else or should i change something?

sasasadsadasdsafasfasfa

Laravel join 3 tables and get the SUM

I have 3 tables which are orders, commissions and order_items. Below is the table structures

Orders

enter image description here

Commissions

enter image description here

Order Items

enter image description here

I want to get Totla commissions, and Total amount using joins.

  • Total amount is giving correct figure
  • Total commssions is not

How I know this is by getting the data separately by using one join (which works correctly), but using 2 joins does not.

Getting total commissions only (Gives correct values)

$getstats = Order::select(
                DB::raw('SUM(sc.amount) as totalcommissions')
            )
            ->leftJoin('commissions as sc', 'sc.order_id', '=', 'orders.id')
            ->first();

Getting both total commissions and total amount (wrong values)

$getstats = Order::select(
                DB::raw('SUM(sc.amount) as totalcommissions'),
                DB::raw('SUM(oi.qty * oi.each) as totalamount')
            )
            ->leftJoin('order_items as oi', 'oi.order_id', '=', 'orders.id')
            ->leftJoin('commissions as sc', 'sc.order_id', '=', 'orders.id')
            ->first();

Does not give correct values.

Where am I going wrong.