예제 #1
0
 public function actionCustomerDashboard()
 {
     $model = new CustomerUser();
     $msg = new ConversationMsg();
     $msgDetail = new MsgDetails();
     $email = $_SESSION['_registration__id'];
     $loggedId = Yii::app()->session['loggedId'];
     //echo $loggedId;die;
     //$rec=CustomerUser::model()->with('bookings')->findByAttributes(array('email'=>$email));
     $review = ServiceReview::model()->findAll(array('condition' => 'status=:status', 'params' => array(':status' => 1)));
     foreach ($review as $bookingIds) {
         $bookIds[] = $bookingIds['booking_id'];
         //$status[] =$bookingIds['status'];
     }
     //echo "<pre>";print_r($bookIds);die;
     $rec = CustomerUser::model()->with('bookings')->findByAttributes(array('id' => $loggedId));
     //echo "<pre>";print_r($rec);die;
     $bookings = Booking::model()->with('customer')->findAll(array('condition' => 'customer_id=:customer_id', 'params' => array(':customer_id' => $loggedId)));
     //echo "<pre>";print_r(count($rec));die;
     /*code to pagination*/
     /* $criteria=new CDbCriteria();
     
                $count=count($bookings);
                     
                $pages=new CPagination($count);
                     
                $pages->pageSize=4;
                $pages->applyLimit($criteria);
                $result = Booking::model()->findAll($criteria);
                echo "<pre>";print_r($result);die;
                $dataProvider = new CArrayDataProvider($result);
                */
     $criteria = new CDbCriteria();
     $criteria->condition = 'customer_id = :id';
     //$criteria->with      ='customer';
     $criteria->params = array(':id' => $loggedId);
     //$criteria->order = 'ac_name asc';
     //get count
     $count = Booking::model()->count($criteria);
     //pagination
     $pages = new CPagination($count);
     $pages->setPageSize(5);
     $pages->applyLimit($criteria);
     //result to show on page
     $dataProvider = Booking::model()->findAll($criteria);
     //echo "<pre>";print_r($result);die;
     //$dataProvider = new CArrayDataProvider($result);
     // echo "<pre>";print_r($dataProvider);die;
     // echo "<pre>";print_r($pages);die;
     foreach ($rec['bookings'] as $to) {
         $serviceId[] = $to['service_id'];
         $companyNam[] = $to->service['company_name'];
     }
     $finalTo = array_combine($serviceId, $companyNam);
     $convMsg = ConversationMsg::model()->findAll(array('condition' => ' reciver_id=:id', 'params' => array(':id' => $loggedId)));
     /*$inbox=MsgDetails::model()->findAll(array('condition'=>'to=:to','params'=>array(
                                     ':to'=>$loggedId
     
               	)));*/
     $inbox = MsgDetails::model()->findAll(array('condition' => 'tomsg=:tomsg  AND inbox_dlt_status=:status', 'group' => 'conversation_id', 'params' => array(':tomsg' => $loggedId, ':status' => 0)));
     //$convID =$inbox[0]['conversation_id'];
     //echo "<pre>";print_r($inbox);die;
     foreach ($inbox as $conId) {
         //echo $conId->conversation_id;
         $inboxDtal[] = MsgDetails::model()->findAll(array('condition' => 'conversation_id=:conversation_id AND inbox_dlt_status=:status', 'params' => array(':conversation_id' => $conId->conversation_id, ':status' => 0)));
         $companyName = ServiceUser::model()->findAll(array('condition' => 'id=:id', 'params' => array(':id' => $conId->user_id)));
         // echo "<pre>";print_r($companyName);
     }
     //die;
     /*code to get the sent messages list*/
     $sentMsg = ConversationMsg::model()->findAll(array('condition' => 'sender_id=:sender_id', 'params' => array(':sender_id' => $loggedId)));
     $sentBox = MsgDetails::model()->findAll(array('condition' => 'user_id=:user_id AND sent_dlt_status=:status', 'group' => 'conversation_id', 'params' => array(':user_id' => $loggedId, ':status' => 0)));
     //echo "<pre>";print_r($sentBox);die;
     foreach ($sentBox as $conId) {
         $sentBoxDtl[] = MsgDetails::model()->findAll(array('condition' => 'conversation_id=:conversation_id AND user_id=:user_id AND sent_dlt_status=:status', 'params' => array(':user_id' => $loggedId, ':conversation_id' => $conId->conversation_id, ':status' => 0)));
         $companyName = ServiceUser::model()->findAll(array('condition' => 'id=:id', 'params' => array(':id' => $conId->tomsg)));
         //echo "<pre>";print_r($companyName);
     }
     //die;
     //echo "<pre>";print_r($sentBox);die;
     foreach ($sentMsg as $sender_id) {
         $custName = $sender_id->sender_id;
         /* $sentTo=ServiceUser::model()->findAll(array('condition'=>'id=:id','params'=>array(
         
                                          ':id'=>$sender_id->reciver_id,
                       	 )));*/
         $sentFrm = CustomerUser::model()->findAll(array('condition' => 'id=:id', 'params' => array(':id' => $sender_id->sender_id)));
         //echo "<pre>";print_r($sentTo);
     }
     //die;
     //echo "<pre>";print_r($sentMsg);die;
     $Request = CompanyRequest::model()->findAll(array('condition' => 'job_status=:job_status', 'params' => array(':job_status' => 1)));
     foreach ($Request as $arrReq) {
         $request[] = $arrReq['booking_id'];
         //echo "<pre>";print_r($request);
     }
     /*code to edit the job quotes starts here*/
     $mod = new CleaningTime();
     $service = new ServiceTypes();
     $list = CleaningTime::model()->findAll();
     $zip = UkPostcodes::model()->findAll();
     //echo "<pre>";print_r($zip);die;
     foreach ($zip as $z) {
         $post[] = $z->postcode;
     }
     $uniquePost = array_unique($post);
     $record = CompanyRequest::model()->find(array('condition' => 'booking_id=:booking_id AND job_status=:job_status', 'params' => array(':booking_id' => $_REQUEST['id'], ':job_status' => 1)));
     //echo "<pre>";print_r($rec->booking);die;
     $ser = ServiceTypes::model()->findAll();
     foreach ($ser as $se) {
         $ids[] = $se['id'];
         $serNam[] = $se['service_name'];
         $serName = array_combine($ids, $serNam);
     }
     $additionalSer = AdditionalServices::model()->findAll();
     foreach ($additionalSer as $ser) {
         $addnlSer[] = $ser['service_name'];
     }
     //echo "<pre>";print_r($addnlSer);die;
     /*code to edit the job quotes ends here*/
     /*code to get the new pending requests for company*/
     $companyRequest = CompanyRequest::model()->findAll(array('order' => 'id desc', 'condition' => 'customer_id=:customer_id AND job_status=:job_status', 'params' => array(':customer_id' => $loggedId, ':job_status' => 0)));
     $Request = CompanyRequest::model()->findAll(array('condition' => 'customer_id=:customer_id AND job_status=:job_status', 'params' => array(':customer_id' => $loggedId, ':job_status' => 1)));
     foreach ($Request as $arrReq) {
         $req[] = $arrReq['booking_id'];
         //echo "<pre>";print_r($request);
     }
     $links = CmsPages::model()->findAll();
     Yii::app()->params['MyArray'] = $links;
     $this->render('customerdashboard', array('model' => $model, 'bookingDetails' => $rec, 'bookIds' => $bookIds, 'review' => $review, 'msg' => $msg, 'msgDetail' => $msgDetail, 'finalTo' => $finalTo, 'convMsg' => $convMsg, 'companyName' => $companyName, 'c' => $num, 'sent' => $sentMsg, 'Frm' => $sentFrm, 'inbox' => $inbox, 'inboxDtal' => $inboxDtal, 'sentBox' => $sentBox, 'sentBoxDtl' => $sentBoxDtl, 'pages' => $pages, 'dataProvider' => $dataProvider, 'request' => $request, 'list' => $list, 'mod' => $mod, 'Post' => $uniquePost, 'rec' => $record, 'serName' => $serName, 'service' => $service, 'addnlSer' => $addnlSer, 'companyRequest' => $companyRequest, 'req' => $req));
 }
예제 #2
0
 public function actionAllDltConversation()
 {
     $id = $_REQUEST['id'];
     $detail = ConversationMsg::model()->with('msgDetails')->findByPk(array('id' => $id));
     //echo "<pre>";print_r($detail);die;
     foreach ($detail->msgDetails as $d) {
         if (!empty($d)) {
             $d->delete();
         }
     }
     //die;
     $detail->delete();
     echo "success";
     die;
 }