/lms_debug/protected/controllers/LeadsController_11dec2014.php
PHP | 3727 lines | 3051 code | 372 blank | 304 comment | 554 complexity | b2aaec71b70908335013c40e0a8879c4 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
- $parser = new CHtmlPurifier();
- if(isset($_POST['LeadFollowup'])){
- if(isset($_POST['LeadFollowup']['chkActionValid']) && @$_POST['LeadFollowup']['chkActionValid']==1){
- $res = $this->actionlead_followup(@$_POST['LeadFollowup'],$parser->purify(intval(@$_POST['Lead']['leadStatusId'])));
- $decodeRes = json_decode($res);
- if(@$decodeRes->status == 'success'){
- echo CJSON::encode(array(
- 'status'=>'success'
- ));
- } else {
- echo $res;
-
- }
- }
- }
-
- $leadFollDesc = @$_POST['LeadFollowup']['description'];
- // end of for follow ups
- $leadId = $parser->purify(intval(@$_GET['leadId']));
- $actionId = $parser->purify(intval(@$_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']))
- {
-
- if($_POST['LeadFollowup']['startDate']!='') {
- $finalLeadDesc = @$leadFollDesc;
- } else {
- $finalLeadDesc = @$_POST['Lead']['leadDescription'];
- }
- $model->setAttributes(array(
- 'updatedOn' => time(), //additional
- 'updatedBy' => $_SESSION['id'], //additional
- 'status' => 'Active', //additional //additional
- 'leadDescription' => @$finalLeadDesc, //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->ws_proposalid=='Proposal No.'){
- $model->ws_proposalid='';
- }
- if($model->children=="Children (Less than 25 Yrs)"){
- $model->children='';
- }
- if($model->ageGroup=="Age of eldest member"){
- $model->ageGroup='';
- }
- if($model->leadDescription=="Lead Description"){
- $model->leadDescription='';
- }
- if($model->leadStatusId==''){
- $model->leadStatusId=$prevLeadStatusId;
- }
-
-
- if(@$leadId!='' && $model->leadStatusId!='34' && @$model->leadStatusId!='35'){
- $model->isRead='yes';
- }
-
-
- if(is_array($value)){
- $value = '';
- } else {
- $value = $value;
- }
- $model->$name=$parser->purify($value);
- }
- if($model->leadStatusParentId=='1'){
- $model->salesClosedUpdatedOn=time();
- }
-
- $fetchAgentDetails=LeadSourceMaster::model()->findByPk($model->leadSourceId);
-
- $model->agentId = @$fetchAgentDetails->leadSourceCode;
- $model->ws_agentid = @$fetchAgentDetails->leadSourceCode;
-
-
- 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($model->leadStatusId=='1'){
- $model->scenario = 'salesclosed';
- }
-
- 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
- 'leadDescription' => @$finalLeadDesc,
-
- ));
- foreach($_POST['Lead'] as $name1=>$value1)
- {
- if($modelHistory->leadStatusId==''){
- $modelHistory->leadStatusId=$modelHistory->leadStatusParentId;
- }
- if(@$_POST['LeadFollowup']['description']=='Description'){
- $activitydesc = '';
- } else {
- $activitydesc = @$_POST['LeadFollowup']['description'];
- }
- $modelHistory->activityDescription=@$activitydesc;
- if($model->leadStatusId==''){
- $model->leadStatusId=2;
- }
- if($modelHistory->email=='Email'){
- $modelHistory->email='';
- }
- if($modelHistory->name=='Name'){
- $modelHistory->name='';
- }
- if($modelHistory->address=='Address'){
- $modelHistory->address='';
- }
- if($modelHistory->leadDescription=="Lead Description"){
- $modelHistory->leadDescription='';
- }
- if($modelHistory->children=="Children (Less than 25 Yrs)"){
- $modelHistory->children='';
- }
- if($modelHistory->ageGroup=="Age of eldest member"){
- $modelHistory->ageGroup='';
- }
- if(is_array($value1)){
- $value1 = '';
- } else {
- $value1 = $value1;
- }
-
- $modelHistory->$name1=$parser->purify($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
- 'leadDescription' => @$finalLeadDesc,
-
- ));
- foreach($_POST['Lead'] as $name1=>$value1)
- {
- if($modelHistory->leadStatusId==''){
- $modelHistory->leadStatusId=$modelHistory->leadStatusParentId;
- }
- $modelHistory->activityDescription=@$_POST['LeadFollowup']['description'];
- if($model->leadStatusId==''){
- $model->leadStatusId=2;
- }
- if(is_array($value1)){
- $value1 = '';
- } else {
- $value1 = $value1;
- }
- $modelHistory->$name1=$parser->purify($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';
- }
- $parser = new CHtmlPurifier();
- $this->performAjaxValidation($model);
- if(isset($_POST['LeadFollowup']))
- {
- $userId = $_POST['LeadFollowup']['userId'];
- $followupstartdatewithtime = strtotime(@$_POST['LeadFollowup']['startDate'])+(@$_POST['LeadFollowup']['hour']*60*60)+(@$_POST['LeadFollowup']['minutes']*60);
- $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)
- {
- if(is_array($value)){
- $value = '';
- } else {
- $value = $value;
- }
-
- $model->$name=$parser->purify($value);
- }
- $model->leadStatusId=@$_POST['Lead']['leadStatusId'];;
- $model->startDateWithTime=@$followupstartdatewithtime;
- 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()){
-
- $checkForSameDateExistsOrNot=LeadFollowup::model()->findAll(" leadId='".@$_POST['LeadFollowup']['leadId']."' and startDate <= '".$model->startDate."' and userId = '".@$userId."' and createdBy = '".@$userId."' ");
- if(count(@$checkForSameDateExistsOrNot) > 0){
- $update = Yii::app()->db->createCommand("UPDATE leadFollowup SET taskCompleted = 'yes',status = 'Completed' WHERE startDate <= '".$model->startDate."' and userId = '".@$userId."' and createdBy = '".@$userId."' and leadId='".@$_POST['LeadFollowup']['leadId']."' ")->execute();
- }
- $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->leadStatusParentId=='1'){
- $model->salesClosedUpdatedOn=time();
- }
-
- if($model->leadSourceId=='' or empty($model->leadSourceId)){
- $model->leadSourceId = '2';
- }
- $fetchAgentDetails=LeadSourceMaster::model()->findByPk($model->leadSourceId);
-
- $model->agentId = @$fetchAgentDetails->leadSourceCode;
- $model->ws_agentid = @$fetchAgentDetails->leadSourceCode;
- 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'];
-
- $teamId = @$_REQUEST['Team']['teamId'];
-
- $userId = $_REQUEST['Team']['teamMemberId'];
-
- $updatedBy = @$_SESSION['id'];
-
- $updatedOn = time();
-
-
-
- $teamIdString = '';
-
- if($teamId)
-
- {
-
- $teamIdString = ',teamId = ' . $teamId . ', ';
-
- }
-
- foreach($Id as $key => $value)
-
- {
-
- $commonQueryString = ", updatedBy = $updatedBy, updatedOn = $updatedOn where leadId = $value";
-
- $updateLead = "update lead set currentAllocatedId = $userId, leadStatusId = 35, currentAllocatedDate = $updatedOn $commonQueryString";
-
- Yii::app()->db->createCommand($updateLead)->execute();
-
- }
-
-
-
- $red = @$_REQUEST['red'];
-
- if($this->action->id=='AllocateLeads' && $red == 1)
-
- {
-
- $this->redirect(array('leads/lead_list'));
-
- }
-
- $this->redirect(array('leads/fresh_leads'));
-
-
- }
- public function actionAllocateLeads_17nov2014()
- {
- $Id = $_REQUEST['userids'];
- $teamId = @$_REQUEST['Team']['teamId'];
- $userId = $_REQUEST['Team']['teamMemberId'];
- $updatedBy = @$_SESSION['id'];
-
- 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;
- //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));
- }
- $red = @$_REQUEST['red'];
-
- if($this->action->id=='AllocateLeads' && $red == 1) {
- $this->redirect(array('leads/lead_list'));
- } else {
- $this->redirect(array('leads/fresh_leads'));
- }
- //$this->redirect(array('leads/lead_list'));
- }
-
- public function actionAllocateLeadswithcount()
- {
- $Id = $_REQUEST['userids'];
- $teamId = @$_REQUEST['Team']['teamId'];
- $userId = $_REQUEST['Team']['teamMemberId'];
- $updatedBy = @$_SESSION['id'];
-
- 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;
- //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));
- }
- $red = @$_REQUEST['red'];
-
- $chkleadAllocatedOrNot = Lead::model()->findByPk($leadId);
- $oldallocatedid = $chkleadAllocatedOrNot['currentAllocatedId'];
- if(isset($oldallocatedid) && !empty($oldallocatedid)){
-
- $checkLeadExistorNot=Leadallcount::model()->findByAttributes(array('userid'=>$oldallocatedid,'key'=>'2014'));
-
- if(count($checkLeadExistorNot) > 0){
-
- Leadallcount::model()->updateByPk(@$checkLeadExistorNot['id'], array('userid'=>@$oldallocatedid,'key'=>'2014','value'=>'35','updatedBy'=>@$updatedBy,'updatedOn'=>@$updatedOn,'currentAllocatedDate'=>@$updatedOn));
-
- } else {
- $leadcount = new Leadallcount();
- $leadcount->setAttributes(array(
- 'userid' => $oldallocatedid, //additional data you want to insert
- 'key' => 2014, //additional data you want to insert
- 'value' => 1, //additional data you want to insert
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => time(), //additional
- 'createdBy' => time(), //additional //additional
-
- ));
- $leadcount->save(false);
-
- }
-
-
- }
-
- /*$leadcount->setAttributes(array(
- 'userid' => time(), //additional data you want to insert
- 'key' => 2014, //additional data you want to insert
- 'value' => 1, //additional data you want to insert
- 'createdOn' => time(), //additional data you want to insert
- 'updatedOn' => time(), //additional
- 'updatedBy' => time(), //additional
- 'createdBy' => time(), //additional //additional
-
- ));
- $leadcount->save(false);*/
- die;
-
-
-
- if($this->action->id=='AllocateLeads' && $red == 1) {
- $this->redirect(array('leads/lead_list'));
- } else {
- $this->redirect(array('leads/fresh_leads'));
- }
- //$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_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()
- {
- setcookie ('PHPSESSID', '', time(), '/', '', 0, 0); // Destroy the cookie.
- 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'=>$mod…
Large files files are truncated, but you can click here to view the full file