MMCT TEAM
Server IP : 103.191.208.50  /  Your IP : 216.73.216.53
Web Server : LiteSpeed
System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64
User : celkcksm ( 1031)
PHP Version : 7.4.33
Disable Function : show_source, system, shell_exec, passthru, popen, exec
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/Crons.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Crons  extends BaseAdminController
{

    public function onCheckInstitutePlatformRenewal(){

        $package_details=$this->pacm->get_system_package_payments(array('package_renewed'=>'no','package_inst_type'=>'institute'),false);

        $today=date('Y-m-d');

        if(!empty($package_details)){

            $today_strtotime=strtotime($today);

            foreach ($package_details as $key => $value) {
                $inst_type=$value->package_inst_type;

                $renewal_date=date(strtotime($value->package_renewal_date));

                $institute_data=$this->um->get_user(array('user_pk_id'=>$value->package_institute_id),'institute');

                if(!empty($institute_data)){

                    if($today_strtotime>$renewal_date){ 

                        

                    }


                }

            }

        }

    }


    public function onCheckInstituteBranchPlatformRenewal(){

        $package_details=$this->pacm->get_system_package_payments(array('package_renewed'=>'no','package_inst_type'=>'institute_branch'),false);


        if(!empty($package_details)){

            foreach ($package_details as $key => $value) {
                $inst_type=$value->package_inst_type;

                $institute_data=$this->um->get_user(array('branch_user_id'=>$value->package_institute_id),'institute_branch');             

            }

        }

    }


    public function onGenerateIntituteInvoice(){

        

        $invoice_date=date('Y-m').'-29';
        $current_date=date('Y-m-d');

        if($invoice_date===$current_date){

            $institutes=$this->um->get_users(array('user_status'=>'active'),'institute');

            //print_obj($institutes);die;

            if(!empty($institutes)){
                $i=1;
                foreach ($institutes as $key => $value) {
                    $invoices_data=$this->pacm->__get_system_package_payments(array('DATE(package_created_date)'=>$invoice_date,'package_institute_id'=>$value->user_pk_id),TRUE,'institute');

                    //print_obj($invoices_data);die;

                    if(empty($invoices_data)){

                        $package_data=$this->sm->get_packages(array('package_id'=>$value->user_package_id));

                        $cgst=($package_data->package_cost*CGST)/100;
                        $sgst=($package_data->package_cost*SGST)/100;

                        $total_tax=$cgst+$sgst;

                        $total_cost=$package_data->package_cost+$total_tax;

                        $invoice_no=INVOICEINITIAL.date('Ymd').$i;
                       
                        $invoice_data_to_insert=array(
                            'pacakge_pk_id'=>$package_data->package_id,
                            'package_inst_type'=>'institute',
                            'package_institute_id'=>$value->user_pk_id,
                            'pacakge_invoice_no'=>$invoice_no,
                            'package_txn_id'=>null,
                            'pacakge_subtotal'=>$package_data->package_cost,
                            'package_discount'=>'0',
                            'package_cgst_tax_rate'=>CGST,
                            'package_sgst_tax_rate'=>SGST,
                            'package_cgst_tax_amount'=>$cgst,
                            'package_sgst_tax_amount'=>$sgst,
                            'pacakge_tax_amount'=>$total_tax,
                            'package_total_payment'=>$total_cost,
                            'package_renewed'=>'no',
                            'package_payment_status'=>'not paid',
                            'package_payment_date'=>null,
                            'package_renewal_date'=>$value->user_expire_at,
                            'package_created_date'=>$current_date
                        );

                        //print_obj($invoice_data_to_insert);


                        $this->pacm->store_system_package_payments($invoice_data_to_insert);

                        $i++;
                    }
                }
            }            
        }
    }
}

MMCT - 2023