/lms_debug/protected/controllers/LeadsController_24_feb_2014.php
PHP | 2890 lines | 2422 code | 215 blank | 253 comment | 403 complexity | 87137fca7de43a13e119048ab3b3ff12 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, LGPL-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- class LeadsController extends Controller
- {
- const SHARED_TITLE = "Admin Panel";
- /**
- * Declares class-based actions.
- */
- public function filters()
- {
- return array( 'accessControl',array(
- 'CHttpCacheFilter + view',
- 'cacheControl' => " max-age=604800, must-revalidate",
- ) ); // perform access control for CRUD operations
- }
- public function actions()
- {
- return array(
- // captcha action renders the CAPTCHA image displayed on the contact page
- 'captcha'=>
- array(
- 'class'=>'CCaptchaAction',
- 'backColor'=>0xFFFFFF,
- ),
- // page action renders "static" pages stored under 'protected/views/site/pages'
- // They can be accessed via: index.php?r=site/page&view=FileName
- 'page'=>array(
- 'class'=>'CViewAction',
- ),
- );
- }
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_welcome()
- {
- $model = new WelcomeMaster();
- $model = WelcomeMaster::model()->find("moduleId = '1' ");
- $this->render('lead_welcome',array('model'=>$model));
- }
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_list()
- {
- $relationManager = $_SESSION['relationalManager'];
- $managerMemberId = implode(",",array_unique(@$relationManager));
-
- if(@$_SESSION['isAllocator']=='yes' or Yii::app()->session->get('type')=='superadmin') {
- $querycondition = " leadStatusId = '35' AND currentAllocatedId > 0 AND isRead='no' ";
- } else {
- $querycondition = " leadStatusId = '35' AND currentAllocatedId > 0 AND isRead='no' AND currentAllocatedId IN (".@$managerMemberId.") ";
- }
- //$modelLead = Lead::model()->findAll(" $querycondition ");
- $this->render('lead_list');
- }
-
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_list_allocator()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $this->render('lead_list_allocator');
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionfollowup_lead_list()
- {
- $today12PM = mktime(0,0,0,date("m"),date("d"),date("Y"));
- $relationManager = $_SESSION['relationalManager'];
- $managerMemberId = implode(",",array_unique(@$relationManager));
- if(@$_SESSION['isAllocator']=='yes' or Yii::app()->session->get('type')=='superadmin') {
- $querycondition = ' startDate = "'.@$today12PM.'" and status="Pending" ';
- } else {
- $querycondition = " startDate = '".@$today12PM."' AND status = 'Pending' AND userId IN (".@$managerMemberId.") ";
- }
- //$modelLead = LeadFollowup::model()->findAll(" $querycondition ");
-
- $this->render('followup_lead_list');
- }
- public function actionfollowup_overall_lead_list()
- {
-
- $relationManager = $_SESSION['relationalManager'];
- $managerMemberId = implode(",",array_unique(@$relationManager));
- if(@$_SESSION['isAllocator']=='yes' or Yii::app()->session->get('type')=='superadmin') {
- $querycondition = ' status="Pending" ';
- } else {
- $querycondition = " status = 'Pending' AND userId IN (".@$managerMemberId.") ";
- }
- //$modelLead = LeadFollowup::model()->findAll(" $querycondition ");
-
- $this->render('followup_overall_lead_list');
- }
-
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_list_tc()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $this->render('lead_list_tc');
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionjunk_lead_list()
- {
- //$modelLead = Lead::model()->findAll(" leadStatusId = '36' ");
- $this->render('junk_lead_list');
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionduplicate_lead_list()
- {
- //$modelLead = Lead::model()->findAll(" leadStatusId = '10' ");
- $this->render('duplicate_lead_list');
- }
- public function actionclose_lead_list()
- {
- //$modelLead = Lead::model()->findAll(" leadStatusId = '7' ");
- $this->render('close_lead_list');
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionallocated_lead_list()
- {
- $relationManager = $_SESSION['relationalManager'];
- $managerMemberId = implode(",",array_unique(@$relationManager));
-
- if(@$_SESSION['isAllocator']=='yes' or Yii::app()->session->get('type')=='superadmin') {
- $querycondition = " currentAllocatedId>0 AND isRead = 'yes'";
- } else {
- $querycondition = " currentAllocatedId >0 AND isRead = 'yes' AND currentAllocatedId IN (".@$managerMemberId.") ";
- }
- //$modelLead = Lead::model()->findAll(" $querycondition ");
- $this->render('allocated_lead_list');
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionleads_details()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
-
- //for follow up
- if(isset($_POST['LeadFollowup'])){
- if(isset($_POST['LeadFollowup']['chkActionValid']) && @$_POST['LeadFollowup']['chkActionValid']==1){
- $res = $this->actionlead_followup(@$_POST['LeadFollowup'],@$_POST['Lead']['leadStatusId']);
- $decodeRes = json_decode($res);
- if(@$decodeRes->status == 'success'){
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- } else {
- echo $res;
-
- }
- }
- }
- // end of for follow ups
- $leadId = @$_GET['leadId'];
- $actionId = @$_REQUEST['actionId'];
- $actionmodel=LeadFollowup::model()->findByPk($actionId);
- $model = new Lead();
- $this->performAjaxValidation($model);
- $model->scenario = 'Lead';
-
- $managerMemberId = implode(",",$_SESSION['relationalManager']);
- $chkAllocatedLeads = $managerMemberId?Lead::model()->findAll(array("select"=>" leadId","condition"=>" leadStatusId != '26' AND leadStatusId != '25' AND currentAllocatedId IN (".@$managerMemberId.") ")):'0';
- $allocatedArr=array();
- foreach($chkAllocatedLeads as $key=>$value){
- $allocatedArr[]=$chkAllocatedLeads[$key]->leadId;
- }
- //print_r($allocatedArr);
- //die;
- /*if(Yii::app()->session->get('isAllocator')!='yes' and Yii::app()->session->get('type')!='superadmin'){
- if(!in_array($leadId,$allocatedArr)){
- $this->redirect(array('leads/lead_list'));
- }
- }*/
-
- if(!empty($leadId)){
- $model=Lead::model()->findByPk($leadId);
- $chkrecentlyViewed=recentlyViewed::model()->findByAttributes(array('leadId'=>$leadId,'userId'=>Yii::app()->session->get('id')));
- if(count($chkrecentlyViewed) == 0){
- $recentlyViewed = new recentlyViewed;
- $recentlyViewed->setAttributes(array(
- 'userId' => Yii::app()->session->get('id'),
- 'leadId' => $leadId,
- 'moduleId' => 0,
- 'updatedOn' => $_SESSION['id'],
- 'updatedBy' => $_SESSION['id'],
- ));
-
- $recentlyViewed->save(false);
- }
- }
- if(isset($_POST['Lead']))
- {
-
-
- $model->setAttributes(array(
- 'updatedOn' => time(), //additional
- 'updatedBy' => $_SESSION['id'], //additional
- 'status' => 'Active', //additional //additional
- ));
- $prevLeadStatusId=$model->leadStatusId;
-
- foreach($_POST['Lead'] as $name=>$value)
- {
- if($model->leadStatusId==''){
- $model->leadStatusId=$model->leadStatusParentId;
- }
- if($model->email=='Email'){
- $model->email='';
- }
- if($model->name=='Name'){
- $model->name='';
- }
- if($model->address=='Address'){
- $model->address='';
- }
- if($model->children=="Children (Less than 25 Yrs)"){
- $model->children='';
- }
- if($model->ageGroup=="Age of eldest member"){
- $model->ageGroup='';
- }
- if($model->leadStatusId==''){
- $model->leadStatusId=$prevLeadStatusId;
- }
-
-
- if(@$leadId!='' && $model->leadStatusId!='34' && @$model->leadStatusId!='35'){
- $model->isRead='yes';
- }
- $model->$name=$value;
- }
-
- if(@$leadId!='' && $model->leadStatusId!='34'){
-
- $update = Yii::app()->db->createCommand("update `lead` set `isRead`='yes' where `leadId`='$leadId' and currentAllocatedId > 0")->query();
- }
-
- $chkStatusMandatoryOrNot = leadStatus::model()->findByAttributes(array('leadStatusId'=>$model->leadStatusId));
-
- if(count($chkStatusMandatoryOrNot) > 0){
- $condMandatory = $chkStatusMandatoryOrNot['compulsary'];
-
- if($condMandatory == 'No'){
- if($model->validate(array('mobile'))){
-
- if(@$_POST['Lead']['emailOptOut']=='on') { $model->emailOptOut='Y'; } else { $model->emailOptOut='N'; }
- if(@$_POST['Lead']['mobileOptOut']=='on') { $model->mobileOptOut='Y'; } else { $model->mobileOptOut='N'; }
- if(@$_POST['Lead']['isJunk']=='on') { $model->isJunk='yes'; } else { $model->isJunk='no'; }
- if(@$_POST['Lead']['isDuplicate']=='on') { $model->isDuplicate='yes'; } else { $model->isDuplicate='no'; }
- if(@$_POST['Lead']['status']=='on') { $model->status='Close'; } else { $model->status='Active'; }
-
-
- $modelHistory = new LeadHistory();
- $modelHistory->scenario = 'LeadHistory';
- $modelHistory->setAttributes(array(
- 'leadId' => @$leadId, //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => $_SESSION['id'], //additional
- 'status' => 'Active', //additional
- ));
- foreach($_POST['Lead'] as $name1=>$value1)
- {
- if($modelHistory->leadStatusId==''){
- $modelHistory->leadStatusId=$modelHistory->leadStatusParentId;
- }
- if($model->leadStatusId==''){
- $model->leadStatusId=2;
- }
- $modelHistory->$name1=$value1;
- }
- $model->save(false);
- $modelHistory->save();
- CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
- }
- }
- }
-
- $model->save();
- if($model->validate()){
- if(@$_POST['Lead']['emailOptOut']=='on') { $model->emailOptOut='Y'; } else { $model->emailOptOut='N'; }
- if(@$_POST['Lead']['mobileOptOut']=='on') { $model->mobileOptOut='Y'; } else { $model->mobileOptOut='N'; }
- if(@$_POST['Lead']['isJunk']=='on') { $model->isJunk='yes'; } else { $model->isJunk='no'; }
- if(@$_POST['Lead']['isDuplicate']=='on') { $model->isDuplicate='yes'; } else { $model->isDuplicate='no'; }
- if(@$_POST['Lead']['status']=='on') { $model->status='Close'; } else { $model->status='Active'; }
-
-
- $modelHistory = new LeadHistory();
- $modelHistory->scenario = 'LeadHistory';
- $modelHistory->setAttributes(array(
- 'leadId' => @$leadId, //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => $_SESSION['id'], //additional
- 'status' => 'Active', //additional
- ));
- foreach($_POST['Lead'] as $name1=>$value1)
- {
- if($modelHistory->leadStatusId==''){
- $modelHistory->leadStatusId=$modelHistory->leadStatusParentId;
- }
- if($model->leadStatusId==''){
- $model->leadStatusId=2;
- }
- $modelHistory->$name1=$value1;
- }
-
- $modelHistory->save();
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
- //Yii::app()->end();
- //die;
- //$this->redirect(array('leads/leads_details'));
- } else {
- $error = CActiveForm::validate($model);
- if($error!='[]')
- echo $error;
- Yii::app()->end();
- //$this->render('leads_details',array('model'=>$model));
- }
- } else {
-
- $this->render('leads_details',array('model'=>@$model,'actionmodel'=>@$actionmodel,'quotesmobile'=>@$model->mobile));
- }
- }
- protected function performAjaxValidation($models)
- {
- if(isset($_POST['ajax']) && $_POST['ajax']==='user-form')
- {
- echo CActiveForm::validate($models);
- Yii::app()->end();
- }
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_followup()
- {
- $actionId = @$_REQUEST['actionId'];
- $model = new LeadFollowup();
- $model->scenario = 'LeadFollowup';
- if(isset($actionId) && !empty($actionId)){
- $model=LeadFollowup::model()->findByPk($actionId);
- } else {
-
- }
-
- if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Task'){
- $model->scenario = 'LeadFollowupTask';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Follow Up'){
- $model->scenario = 'LeadFollowup';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Meeting'){
- $model->scenario = 'LeadFollowup';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Notes'){
- $model->scenario = 'LeadFollowupNotes';
- }
- $this->performAjaxValidation($model);
- if(isset($_POST['LeadFollowup']))
- {
- $userId = $_POST['LeadFollowup']['userId'];
- $model->setAttributes(array(
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => @$userId, //additional
- 'createdBy' => @$userId, //additional
- 'status' => 'Pending', //additional
- ));
- foreach($_POST['LeadFollowup'] as $name=>$value)
- {
- $model->$name=$value;
- }
- $model->leadStatusId=@$_POST['Lead']['leadStatusId'];;
- if(@$_POST['LeadFollowup']['actionType']=='Notes') {
- $prefix=substr(time(),0,5);
- $folder = 'siteupload/';
- $model->notesFile=CUploadedFile::getInstance($model,'notesFile');
- if($model->notesFile !='')
- $model->notesFile->saveAs($folder.$prefix.$model->notesFile);
- $model->notesFile=$prefix.CUploadedFile::getInstance($model,'notesFile');
- }
- if(@$_POST['LeadFollowup']['startDate']!='') {
- $startDateVal = strtotime($_POST['LeadFollowup']['startDate']);
- $model->startDate=@$startDateVal;
- if(@$_POST['LeadFollowup']['hour']!='') {
- $model->startDateWithTime=(@$startDateVal-300)+(@$_POST['LeadFollowup']['hour']*3600)+(@$_POST['LeadFollowup']['minutes']*60);
- }
- }
- if(@$_POST['LeadFollowup']['taskDueDate']!='') {
- $taskDueDateVal = strtotime($_POST['LeadFollowup']['taskDueDate']);
- $model->taskDueDate=@$taskDueDateVal;
- }
- if(@$_POST['LeadFollowup']['taskCompleted']!='') {
- $model->taskCompleted='yes';
- }
- if($model->validate()){
- $model->save();
- $leadId = $_POST['LeadFollowup']['leadId'];
- return CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
- } else {
- $error = CActiveForm::validate($model);
- if($error!='[]')
- return $error;
- Yii::app()->end();
- }
- //$this->redirect(array('leads/leads_details', 'leadId'=>@$leadId));
- }
- $this->redirect(array('leads/lead_list'));
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_followupcalender()
- {
- $actionId = @$_REQUEST['actionId'];
- $model = new LeadFollowup();
- $model->scenario = 'LeadFollowup';
- if(isset($actionId) && !empty($actionId)){
- $model=LeadFollowup::model()->findByPk($actionId);
- } else {
-
- }
-
- if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Task'){
- $model->scenario = 'LeadFollowupTask';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Follow Up'){
- $model->scenario = 'LeadFollowup';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Meeting'){
- $model->scenario = 'LeadFollowup';
- }if(isset($_POST['LeadFollowup']['actionType']) && $_POST['LeadFollowup']['actionType']=='Notes'){
- $model->scenario = 'LeadFollowupNotes';
- }
- $this->performAjaxValidation($model);
- if(isset($_POST['LeadFollowup']))
- {
- $userId = $_POST['LeadFollowup']['userId'];
- $model->setAttributes(array(
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => @$userId, //additional
- 'createdBy' => @$userId, //additional
- 'status' => 'Pending', //additional
- ));
- foreach($_POST['LeadFollowup'] as $name=>$value)
- {
- $model->$name=$value;
- }
- $model->leadStatusId=@$_POST['Lead']['leadStatusId'];;
- if(@$_POST['LeadFollowup']['actionType']=='Notes') {
- $prefix=substr(time(),0,5);
- $folder = 'siteupload/';
- $model->notesFile=CUploadedFile::getInstance($model,'notesFile');
- if($model->notesFile !='')
- $model->notesFile->saveAs($folder.$prefix.$model->notesFile);
- $model->notesFile=$prefix.CUploadedFile::getInstance($model,'notesFile');
- }
- if(@$_POST['LeadFollowup']['startDate']!='') {
- $startDateVal = strtotime($_POST['LeadFollowup']['startDate']);
- $model->startDate=@$startDateVal;
- }
- if(@$_POST['LeadFollowup']['taskDueDate']!='') {
- $taskDueDateVal = strtotime($_POST['LeadFollowup']['taskDueDate']);
- $model->taskDueDate=@$taskDueDateVal;
- }
- if(@$_POST['LeadFollowup']['taskCompleted']!='') {
- $model->taskCompleted='yes';
- }
- if($model->validate()){
- $model->save();
- $leadId = $_POST['LeadFollowup']['leadId'];
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
- } else {
- $error = CActiveForm::validate($model);
- if($error!='[]')
- return $error;
- Yii::app()->end();
- }
- //$this->redirect(array('leads/leads_details', 'leadId'=>@$leadId));
- }
- $this->redirect(array('leads/lead_list'));
- }
-
-
- public function actionlead_contacts()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $model = new LeadContacts();
- $model->scenario = 'LeadContacts';
- $this->performAjaxValidation($model);
- if(!empty($_GET['contactId']))
- {
- $leadContactId=$_GET['leadContactId'];
- $model=LeadContacts::model()->findByPk($leadContactId);
- }
- if(!empty($_POST['LeadContacts']['leadContactId']))
- {
- $leadContactId=$_POST['LeadContacts']['leadContactId'];
- $model=LeadContacts::model()->findByPk($leadContactId);
- }
- if(isset($_POST['LeadContacts']))
- {
- $userId = $_POST['LeadContacts']['userId'];
- $leadId = $_POST['LeadContacts']['leadId'];
- $model->setAttributes(array(
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => @$userId, //additional
- 'createdBy' => @$userId, //additional
- 'status' => 'Active', //additional
- ));
- foreach($_POST['LeadContacts'] as $name=>$value)
- {
- $model->$name=$value;
- }
- if($model->validate()){
- $model->save();
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
- } else {
- $error = CActiveForm::validate($model);
- if($error!='[]')
- echo $error;
- Yii::app()->end();
-
- }
-
- //$this->redirect(array('leads/leads_details', 'leadId'=>@$leadId));
- }
- $this->redirect(array('leads/lead_list'));
- }
- public function actionChangeContactStatus()
- {
-
- $Id=$_REQUEST['contactId'];
- $leadId=$_REQUEST['leadId'];
- $status=$_REQUEST['status'];
- if(isset($status)&&($status=='Inactive')){
- $status="Active";
- } else {
- $status="Inactive";
- }
- if(!empty($Id))
- {
- $model=LeadContacts::model()->findByPk($Id);
- }
- else
- {
- $model = LeadContacts::model()->findAll();
- }
- $model->status=$status;
- $model->save();
- $this->redirect(array('leads/leads_details', 'leadId'=>@$leadId));
- }
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actioncreate_lead()
- {
- $model=new Lead();
- $model->scenario = 'Lead';
- if(!empty($_GET['leadId']))
- {
- $leadId=$_GET['leadId'];
- $model=Lead::model()->findByPk($leadId);
- $chkrecentlyViewed=recentlyViewed::model()->findByAttributes(array('leadId'=>$leadId,'userId'=>Yii::app()->session->get('id')));
- if(count($chkrecentlyViewed) == 0){
- $recentlyViewed = new recentlyViewed;
- $recentlyViewed->setAttributes(array(
- 'userId' => Yii::app()->session->get('id'),
- 'leadId' => $leadId,
- 'moduleId' => 0,
- 'createdOn' => time(),
- 'updatedOn' => time(),
- 'updatedBy' => time(),
- 'createdBy' => time(),
- ));
-
- $recentlyViewed->save(false);
- }
- }
- if(!empty($_POST['Lead']['leadId']))
- {
- $leadId=$_POST['Lead']['leadId'];
- $model=Lead::model()->findByPk($leadId);
- }
- if(isset($_POST['Lead']))
- {
-
- $model->setAttributes(array(
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => Yii::app()->session->get('id'), //additional
- 'createdBy' => Yii::app()->session->get('id'),
- ));
- foreach($_POST['Lead'] as $name=>$value)
- {
- $model->$name=$value;
- if($model->leadStatusId==''){
- $model->leadStatusId=$model->leadStatusParentId;
- }
- if($model->leadStatusId==''){
- $model->leadStatusId=34;
- }
- if($model->mobile=='Mobile*'){
- $model->mobile='';
- }
- if($model->email=='Email'){
- $model->email='';
- }
- if($model->name=='Name'){
- $model->name='';
- }
- if($model->address=='Address'){
- $model->address='';
- }
- if($model->children=="Children (Less than 25 Yrs)"){
- $model->children='';
- }
- if($model->ageGroup=="Age of eldest member"){
- $model->ageGroup='';
- }
- }
-
- if($model->leadSourceId=='' or empty($model->leadSourceId)){
- $model->leadSourceId = '2';
- }
- if(Yii::app()->session->get('isAllocator')!='yes' and Yii::app()->session->get('type')!='superadmin') {
- @$model->leadStatusId=35;
- @$model->currentAllocatedId=Yii::app()->session->get('id');
- }
-
- if(@$leadId!='' && $model->leadStatusId!='34'){
- $update = Yii::app()->db->createCommand("update `lead` set `isRead`='yes' where `leadId`='$leadId' and currentAllocatedId > 0")->query();
- }
-
- if(@$_POST['Lead']['emailOptOut']=='on') { $model->emailOptOut='Y'; } else { $model->emailOptOut='N'; }
- if(@$_POST['Lead']['mobileOptOut']=='on') { $model->mobileOptOut='Y'; } else { $model->mobileOptOut='N'; }
- if(@$_POST['Lead']['isJunk']=='on') { $model->isJunk='yes'; } else { $model->isJunk='no'; }
- if(@$_POST['Lead']['isDuplicate']=='on') { $model->isDuplicate='yes'; } else { $model->isDuplicate='no'; }
- if(@$_POST['Lead']['status']=='on') { $model->status='Close'; } else { $model->status='Active'; }
- $chkStatusMandatoryOrNot = leadStatus::model()->findByAttributes(array('leadStatusId'=>$model->leadStatusId));
-
- if(count($chkStatusMandatoryOrNot) > 0){
- $condMandatory = $chkStatusMandatoryOrNot['compulsary'];
- if($condMandatory == 'No'){
- if($model->validate(array('mobile'))){
-
-
-
-
-
- $mobileNumber = @$_POST['Lead']['mobile'];
- $checkJunkNumber = JunkNumbersMaster::model()->find('junkLeadNumber = "'.@$mobileNumber.'"');
- if(empty($checkJunkNumber)){
- $beforethreemonth = time()-7776000;
- $checkDuplicateNumber = Lead::model()->find('mobile = "'.@$mobileNumber.'" AND createdOn > "'.@$beforethreemonth.'" AND status = "Active" AND leadId != "'.@$leadId.'" ');
- if(empty($checkDuplicateNumber)){
-
- $model->save(false);
- Yii::app()->user->setFlash('lead_msg_success','Successfully Inserted');
- } else {
- $duplicateLeadId = $checkDuplicateNumber->leadId;
- $model->leadStatusId='10';
- $model->duplicateLeadId=@$duplicateLeadId;
- $model->currentAllocatedId=$checkDuplicateNumber->currentAllocatedId;
- $model->save(false);
- Yii::app()->user->setFlash('lead_msg_success','Successfully Inserted');
- }
- } else {
- $model->leadStatusId='36';
- $model->save(false);
- Yii::app()->user->setFlash('lead_msg_success','Junk Lead');
- }
- $this->redirect(array('leads/lead_list'));
-
- // $model->save(false);
- // $this->redirect(array('leads/lead_list'));
- }
- }
- }
- if($model->leadStatusId==36){
- $model->save(false);
- $this->redirect(array('leads/lead_list'));
- } else {
- if($model->validate()){
- $mobileNumber = $_POST['Lead']['mobile'];
- $checkJunkNumber = JunkNumbersMaster::model()->find('junkLeadNumber = "'.@$mobileNumber.'"');
- if(empty($checkJunkNumber)){
- $beforethreemonth = time()-7776000;
- $checkDuplicateNumber = Lead::model()->find('mobile = "'.@$mobileNumber.'" AND createdOn > "'.@$beforethreemonth.'" AND status = "Active" AND leadId != "'.@$leadId.'" ');
- if(empty($checkDuplicateNumber)){
-
- $model->save();
- Yii::app()->user->setFlash('lead_msg_success','Successfully Inserted');
- } else {
- $duplicateLeadId = $checkDuplicateNumber->leadId;
- $model->leadStatusId='10';
- $model->duplicateLeadId=@$duplicateLeadId;
- $model->save();
- Yii::app()->user->setFlash('lead_msg_success','Successfully Inserted');
- }
- } else {
- $model->leadStatusId='36';
- $model->save();
- Yii::app()->user->setFlash('lead_msg_success','Junk Lead');
- }
- $this->redirect(array('leads/lead_list'));
- } else {
- $this->render('create_lead',array('model'=>$model));
- }
- }
- } else {
- $this->render('create_lead',array('model'=>$model));
- }
- }
- public function actionAllocateLeads()
- {
- $Id = $_REQUEST['userids'];
- $teamleaderId = $_REQUEST['User']['id'];
- $userId = $_REQUEST['Team']['teamMemberId'];
- $updatedBy = @$_SESSION['id'];
- $temIds = Yii::app()->db->createCommand("select distinct teamId from teamUserMapping where userId='".@$teamleaderId."' and status='Active' order by id desc ")->queryAll();
-
- $teamId = $temIds[0]['teamId'];
-
-
- foreach($Id as $key=>$value){
- $model = new AllocatedLeads();
- $model->scenario = 'AllocatedLeads';
- $model->setAttributes(array(
- 'currentAllocatedDate' => time(), //additional data you want to insert
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => @$updatedBy, //additional
- 'createdBy' => @$updatedBy, //additional
- 'leadStatusId' => '35', //additional //additional
- ));
- $leadId = @$value;
- $model->leadId = @$value;
- $model->userId = @$userId;
- $model->teamId = @$teamId;
- $model->teamLeaderId = @$teamleaderId;
- //echo @$teamId.' - '.@$userId.' - '.@$leadId;
- $model->allocatedId = null;
- $model->isNewRecord = true;
- $model->save();
- $model=new Lead();
- $model->scenario = 'Lead';
- $updatedOn = time();
- Lead::model()->updateByPk(@$value, array('currentAllocatedId'=>@$userId,'leadStatusId'=>'35','updatedBy'=>@$updatedBy,'updatedOn'=>@$updatedOn,'currentAllocatedDate'=>@$updatedOn));
- }
- //
- //$this->redirect(array('leads/lead_list'));
- $this->redirect(array('leads/fresh_leads'));
- }
- /**
- * This is the 'lead_list_allocator' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionlead_assign()
- {
- $model = new Lead();
- $model->scenario = 'Lead';
- $leadId = $_REQUEST['AssignLead']['leadId'];
- $userId = $_REQUEST['AssignLead']['userId'];
- $assign = $_REQUEST['AssignLead']['assign'];
- if($leadId!='') {
- $updatedOn = time();
- $chkleadStatus = Lead::model()->findByPk($leadId);
- $existsOrNot = $chkleadStatus['leadStatusId'];
- $leadStatusIdUpdate = $existsOrNot?$existsOrNot:'34';
- if($leadStatusIdUpdate == 34){
- $leadStatusIdUpdate = 35;
- } else {
- $leadStatusIdUpdate = $leadStatusIdUpdate;
- }
-
- if($assign=='open') {
- Lead::model()->updateByPk(@$leadId, array('currentAllocatedId'=>'','status'=>'Active','leadStatusId'=>34,'updatedBy'=>@$userId,'updatedOn'=>@$updatedOn,'currentAllocatedDate'=>''));
- } elseif($assign=='self'){
- Lead::model()->updateByPk(@$leadId, array('currentAllocatedId'=>@$userId,'status'=>'Allocated','leadStatusId'=>@$leadStatusIdUpdate,'updatedBy'=>@$userId,'updatedOn'=>@$updatedOn,'currentAllocatedDate'=>@$updatedOn));
- } else {
- Lead::model()->updateByPk(@$leadId, array('currentAllocatedId'=>@$assign,'status'=>'Allocated','leadStatusId'=>@$leadStatusIdUpdate,'updatedBy'=>@$userId,'updatedOn'=>@$updatedOn,'currentAllocatedDate'=>@$updatedOn));
- }
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- Yii::app()->end();
-
- //$this->redirect(array('leads/leads_details', 'leadId'=>@$leadId));
- } else {
-
- $this->redirect(array('leads/lead_list'));
- }
- }
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionarchive_leads()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $model=new Lead();
- $model=Lead::model()->findAll();
- $this->render('archive_leads',array('model'=>$model));
- }
-
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionbulk_import_leads()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $model=new Lead();
- $this->render('bulk_import_lead',array('model'=>$model));
- }
-
- /**
- * This is the 'roles' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionjunk_leads()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
- $this->render('junk_leads');
- }
- /**
- * This is the 'module master' action that is invoked
- * when an action is not explicitly requested by users.
- */
- public function actionmodule_master()
- {
- // renders the view file 'protected/views/site/index.php'
- // using the default layout 'protected/views/layouts/main.php'
-
- $model=new ModuleMaster();
- $model->scenario = 'ModuleMaster';
-
- if(!empty($_GET['moduleId']))
- {
- $moduleId=$_GET['moduleId'];
- $model=ModuleMaster::model()->findByPk($moduleId);
-
- }
-
- if(!empty($_POST['ModuleMaster']['moduleId']))
- {
- $moduleId=$_POST['ModuleMaster']['moduleId'];
- $model=ModuleMaster::model()->findByPk($moduleId);
- }
-
- if(isset($_POST['ModuleMaster']))
- {
- $model->setAttributes(array(
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => time(), //additional
- 'createdBy' => time(),
- 'status' => 'Activated', //additional //additional
-
- ));
- foreach($_POST['ModuleMaster'] as $name=>$value)
- {
- $model->$name=$value;
- }
-
- if($model->validate()){
- $model->save();
- $model2=ModuleMaster::model()->findAll();
- $this->render('module_master',array('model'=>$model,'model2'=>$model2));
- Yii::app()->user->setFlash('module_master_msg_success','Successfully Inserted');
- } else {
- Yii::app()->user->setFlash('module_master_msg_error','Please check. error occured');
- $this->render('module_master',array('model'=>$model));
-
- }
- } else {
- $model2=ModuleMaster::model()->findAll();
- //Yii::app()->user->setFlash('lead_stage_msg_error','Please check. error occured');
- $this->render('module_master',array('model'=>$model,'model2'=>$model2));
- }
- }
- /**
- * This is the action to handle external exceptions.
- */
- public function actionError()
- {
- if($error=Yii::app()->errorHandler->error)
- {
- if(Yii::app()->request->isAjaxRequest)
- echo $error['message'];
- else
- $this->render('error', $error);
- }
- }
-
- /**
- * Displays the contact page
- */
- public function actionContact()
- {
- $model=new ContactForm;
- if(isset($_POST['ContactForm']))
- {
- $model->attributes=$_POST['ContactForm'];
- if($model->validate())
- {
- $name='=?UTF-8?B?'.base64_encode($model->name).'?=';
- $subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';
- $headers="From: $name <{$model->email}>\r\n".
- "Reply-To: {$model->email}\r\n".
- "MIME-Version: 1.0\r\n".
- "Content-type: text/plain; charset=UTF-8";
-
- mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers);
- Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');
- $this->refresh();
- }
- }
- $this->render('contact',array('model'=>$model));
- }
-
- /**
- * Displays the login page
- */
- public function actionLogin()
- {
- $model=new User;
-
- // if it is ajax validation request
- if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
- {
- echo CActiveForm::validate($model);
- Yii::app()->end();
- }
-
- // collect user input data
- if(isset($_POST['User']))
- {
-
- $model->attributes=$_POST['User'];
- // validate user input and redirect to the previous page if valid
- if($model->validate() && $model->login()){
- $this->redirect(array('masters/dashboard'));
- } else {
- $this->redirect(Yii::app()->user->returnUrl);
- }
- }
- // display the login form
- $this->render('login',array('model'=>$model));
- }
-
- /**
- * Logs out the current user and redirect to homepage.
- */
- public function actionLogout()
- {
- Yii::app()->user->logout();
- $this->redirect(Yii::app()->homeUrl);
- }
- public function getPageType()
- {
- return "Leads";
- }
- public function init(){
- $obj =new RecentlyViewedController(); // preparing object
- $data=$obj->actionUserRoleAccess();
- $moduleArray=array();
- if(Yii::app()->session->get('type')=='superadmin'){
- $moduleArray['read']='yes';
- $moduleArray['write']='yes';
- $moduleArray['delete']='yes';
- }else{
- foreach($data as $key=>$value){
- if($data[$key]->modules->moduleName=='Leads'){
- $moduleArray['moduleName']=$data[$key]->modules->moduleName;
- $moduleArray['read']=$data[$key]->read;
- $moduleArray['write']=$data[$key]->write;
- $moduleArray['delete']=$data[$key]->delete;
- }
- }
- }
-
- return $moduleArray;
-
- }
-
- public function getNameFromNumber($num) {
- $numeric = $num % 26;
- $letter = chr(65 + $numeric);
- $num2 = intval($num / 26);
- if ($num2 > 0) {
- return getNameFromNumber($num2 - 1) . $letter;
- } else {
- return $letter;
- }
- }
- /*function actionexportArchiveList()
- {
- // generate a resultset
- $model=new User;
- $model=User::model()->findAll();
- // render data to xlsx format and echo resultant file back to browser.
- ExcelExporter::sendAsXLS($model, true, 'closedLeads.xls');
- }*/
-
- public function actionDownloadLeadTemp(){
-
- Yii::import('ext.phpexcel.XPHPExcel');
- $objPHPExcel= XPHPExcel::createPHPExcel();
- $objPHPExcel->getProperties()->setCreator("LeadTemplate")
- ->setLastModifiedBy("LeadTemplate")
- ->setTitle("LeadTemplate")
- ->setSubject("LeadTemplate")
- ->setDescription("LeadTemplate.")
- ->setKeywords("LeadTemplate")
- ->setCategory("LeadTemplate");
-
- //echo $total_excelColumns=$this->getNameFromNumber(4);
- $total_excelColumns='I';
- // Rename worksheet
- $objPHPExcel->getActiveSheet()->setTitle('ClosedLeads');
- $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
- $objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('I')->setWidth(30);
- $objPHPExcel->getActiveSheet()->duplicateStyleArray(
- array(
- 'font' => array(
- 'name' => 'Times New Roman',
- 'bold' => true,
- 'italic' => false,
- 'size' => 12
- ),
- 'borders' => array(
- 'top' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'left' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'right' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)
- ),
- 'alignment' => array(
- 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
- 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
- 'wrap' => true
- )
- ),
- 'A1:'.$total_excelColumns.'1'
- );
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
-
- // Add some data
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', 'Name')
- ->setCellValue('B1', 'City')
- ->setCellValue('C1', 'Email')
- ->setCellValue('D1', 'Mobile')
- ->setCellValue('E1', 'Suminsured')
- ->setCellValue('F1', 'Age')
- ->setCellValue('G1', 'No. Of Members')
- ->setCellValue('H1', 'Date on submit')
- ->setCellValue('I1', 'Lead Source');
-
- // Miscellaneous glyphs, UTF-8
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A2', 'Lead Name')
- ->setCellValue('B2', 'city')
- ->setCellValue('C2', 'test@yesk.com')
- ->setCellValue('D2', '9999999999')
- ->setCellValue('E2', '56')
- ->setCellValue('F2', '23')
- ->setCellValue('G2', 'test')
- ->setCellValue('H2', '07-Sep-2013')
- ->setCellValue('I2', 'test');
-
- //To create new sheet in current file
- /*$objPHPExcel->createSheet(1);
- $objPHPExcel->setActiveSheetIndex(1);
- $objPHPExcel->getActiveSheet()->setTitle('Title');
- */
-
- // Redirect output to a clients web browser (Excel5)
- header('Content-Type: application/vnd.ms-excel');
- header('Content-Disposition: attachment;filename="LeadTemplates.xls"');
- header('Cache-Control: max-age=0');
- // If you're serving to IE 9, then the following may be needed
- header('Cache-Control: max-age=1');
- // If you're serving to IE over SSL, then the following may be needed
- header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
- header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
- header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
- header ('Pragma: public'); // HTTP/1.0
-
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
- $objWriter->save('php://output');
- Yii::app()->end();
- }
- public function actionImportLeadTemplate(){
- $model=new lead();
- $data='';
- $final_arr=@$_POST['final_arr']?@$_POST['final_arr']:'';
-
- if(isset($_POST['ImportLeads']) && empty($final_arr) && !empty($_FILES['Lead']['name']['import'])){
-
- Yii::import('ext.phpexcelreader.JPhpExcelReader');
- $model->attributes='import';
- $model->import=CUploadedFile::getInstance($model,'import');
- $prefix=substr(time(),0,5);
- $folder = '/tempdata';
- $model->import->saveAs($folder.$prefix.$model->import);
- $data=new JPhpExcelReader($folder.$prefix.$model->import);
-
- //$this->render('bulk_import_lead',array('data'=>$data,'model'=>$model));
-
- //$this->redirect(Yii::app()->createUrl('leads/bulk_import_leads'),array('data'=>$data,'model'=>$model));
- $this->render('bulk_import_lead',array('data'=>$data,'model'=>$model));
- }
-
- if(isset($_POST['ImportLeads']) && !empty($final_arr) && isset($final_arr) && empty($_FILES['Lead']['name']['import'])){
- $final_arr = unserialize(urldecode($_POST["final_arr"]));
- $dateTime=time();
- for($i=0;$i<sizeof($final_arr);$i++)
- {
- $junkNumberQuery = Yii::app()->db->createCommand("SELECT `junkLeadNumberId` FROM `junkLeadNumberMaster` WHERE `junkLeadNumber` = '".@$final_arr[$i]['mobile']."' ")->queryAll();
- $junkNumberResult = $junkNumberQuery;
-
- //$duplicateQuery = Yii::app()->db->createCommand("SELECT `leadId` FROM `lead` WHERE `mobile`= '".@$final_arr[$i]['mobile']."' ")->queryAll();(Original, changed below by Baljeet)
- $duplicateQuery = Yii::app()->db->createCommand("SELECT `leadId`,`currentAllocatedId` FROM `lead` WHERE `mobile`= '".@$final_arr[$i]['mobile']."' ")->queryAll();
- $duplicateResult = ($duplicateQuery);
- if(count($junkNumberResult) > 0){
- $leadStatusId = '36';
- $duplicateLeadId = '';
- } elseif(count($duplicateResult)>0){
- $leadStatusId = '10';
- $duplicateLeadId = @$duplicateResult[0]['leadId'];
- $currentAllocatedId = @$duplicateResult[0]['currentAllocatedId']; //added by baljeet
- } else {
- $leadStatusId = '34';
- $duplicateLeadId = '';
- }
-
-
-
- $model=new lead();
- $model->name=$final_arr[$i]['name'];
- $model->cityId=$final_arr[$i]['cityId'];
- $model->email=$final_arr[$i]['email'];
- $model->mobile=$final_arr[$i]['mobile'];
- $model->si=$final_arr[$i]['suminsured'];
- $model->age=$final_arr[$i]['age'];
- $model->members=$final_arr[$i]['noofmembers'];
- $model->dateonSubmit=$final_arr[$i]['dateonsubmit'];
- $model->leadSourceId=$final_arr[$i]['leadSourceId'];
- $model->leadStatusId=$leadStatusId;
- $model->duplicateLeadId=@$duplicateLeadId;
- $model->currentAllocatedId=@$currentAllocatedId;
- $model->productId='1';
- $model->status='Active';
- $model->createdOn=$dateTime;
- $model->createdBy=Yii::app()->session->get('id');
- $model->updatedOn=$dateTime;
- $model->updatedBy=Yii::app()->session->get('id');
- $model->isNewRecord = true;
- $model->save(false);
-
- }
- $this->redirect(array('leads/lead_list'));
- }
- if(isset($_POST['ImportLeads']) && empty($final_arr) && empty($_FILES['Lead']['name']['import'])){
- $model->validate();
- $this->render('bulk_import_lead',array('model'=>$model));
- }
- }
- public function actionleadSearch()
- {
- $searched = new Lead();
- $this->render('lead_search',array('searched'=>$searched));
- }
-
- public function actionExportExcel()
- {
- // It calls the actionCreateExcel to generates excel reports'
- $this->actionCreateExcel();
-
-
- }
-
- public function actionCreateExcel(){
-
- //Here is the code to set conditions for fetch records from database
- $criteria = new CDbCriteria;
- $criteria->select = 't.*,`city`.`city`, `state`.`state`, `leadSourceMaster`.`leadSourceTitle`,`leadSourceMaster`.`leadSourceCode`,`leadStageMaster`.`leadStage`,`leadStatus`.`leadStatus`, `customerTypeMaster`.`customerType`,`productMaster`.`productName`,`policyTypeMaster`.`policyType`,`planTypeMaster`.`planType`,`campaign`.`campaignName`';
- $criteria->join ='LEFT JOIN city ON (city.cityId = t.cityId) LEFT JOIN state ON (state.stateId = t.stateId) LEFT JOIN leadSourceMaster ON (leadSourceMaster.leadSourceId = t.leadSourceId) LEFT JOIN leadStageMaster ON (leadStageMaster.leadStageId = t.leadStageId)LEFT JOIN leadStatus ON (leadStatus.leadStatusId = t.leadStatusId)LEFT JOIN customerTypeMaster ON (customerTypeMaster.customerTypeId = t.customerTypeId)LEFT JOIN productMaster ON (productMaster.productId = t.productId)LEFT JOIN policyTypeMaster ON (policyTypeMaster.policyTypeId = t.policyTypeId)LEFT JOIN planTypeMaster ON (planTypeMaster.planTypeId = t.planTypeId)LEFT JOIN campaign ON (campaign.campaignId = t.campaignId)';
- $criteria->condition='t.status != "Allocated" AND t.leadStatusId != "25" AND t.leadStatusId != "26" ';
- $criteria->order='leadId DESC';
-
- $model=new LeadReport();
- $model->scenario = 'LeadReport';
- $reportmodel=LeadReport::model()->findAll($criteria);
- $data=array();
- $datas = $reportmodel;
- foreach($datas as $key=>$value){
- $data[$key]=$value;
- }
- if(count($data)>0){
- Yii::import('ext.phpexcel.XPHPExcel');
- $objPHPExcel= XPHPExcel::createPHPExcel();
- $objPHPExcel->getProperties()->setCreator("ReligareLMS")
- ->setLastModifiedBy("ReligareLMS")
- ->setTitle("Office 2007 XLSX Test Document")
- ->setSubject("Office 2007 XLSX Test Document")
- ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
- ->setKeywords("office 2007 openxml php")
- ->setCategory("Test result file");
- $total_excelColumns=$this->getNameFromNumber(8);
- // Rename worksheet
- $objPHPExcel->getActiveSheet()->setTitle('Sample Excel');
- $objPHPExcel->getActiveSheet()->getRowDimension(1)->setRowHeight(25);
- $objPHPExcel->getActiveSheet()->getRowDimension(2)->setRowHeight(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(6);
- $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('G')->setWidth(30);
- $objPHPExcel->getActiveSheet()->getColumnDimension('H')->setWidth(30);
-
- $objPHPExcel->getActiveSheet()->duplicateStyleArray(
- array(
- 'font' => array(
- 'name' => 'Times New Roman',
- 'bold' => true,
- 'italic' => false,
- 'size' => 12
- ),
- 'borders' => array(
- 'top' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'bottom' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'left' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE),
- 'right' => array('style' => PHPExcel_Style_Border::BORDER_DOUBLE)
- ),
- 'alignment' => array(
- 'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER,
- 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER,
- 'wrap' => true
- )
- ),
- 'A1:'.$total_excelColumns.'1'
- );
- // Set active sheet index to the first sheet, so Excel opens this as the first sheet
-
- // Add some data
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A1', 'SNO.')
- ->setCellValue('B1', 'Name')
- ->setCellValue('C1', 'Mobile')
- ->setCellValue('D1', 'Email')
- ->setCellValue('E1', 'Lead Stage')
- ->setCellValue('F1', 'Date and Time')
- ->setCellValue('G1', 'UTM Code')
- ->setCellValue('H1', 'status');
-
- // Miscellaneous glyphs, UTF-8
- $i=0;
- $k=2;
- $sn=1;
- while($i<count($data)){
- $objPHPExcel->setActiveSheetIndex(0)
- ->setCellValue('A'.$k,$sn)
- ->setCellValue('B'.$k,$data[$i]['name'])
- ->setCellValue('C'.$k,$data[$i]['mobile'])
- ->setCellValue('D'.$k,$data[$i]['email'])
- ->setCellValue('E'.$k,$data[$i]['leadStage'])
- ->setCellValue('F'.$k,date("d/m/y h:i A",$data[$i]['createdOn']))
- ->setCellValue('G'.$k,$data[$i]['leadSourceCode'])
- ->setCellValue('H'.$k,$data[$i]['status']);
-
- $i++;$k++;$sn++;}
- // Redirect output to a clients web browser (Excel5)
- header('Content-Type: application/vnd.ms-excel');
- header('Content-Disposition: attachment;filename="lead_report.xls"');
- header('Cache-Control: max-age=0');
- // If you're serving to IE 9, then the fo…
Large files files are truncated, but you can click here to view the full file