コード例 #1
0
 public function actionRelistJobCompany()
 {
     //echo "<pre>";print_r($_REQUEST);die;
     $conver = new ConversationMsg();
     $conversation = new MsgDetails();
     $loggedId = Yii::app()->session['loggedId'];
     if (!empty($_REQUEST)) {
         $senderId = $_REQUEST['loggedId'];
         $reciverId = $_REQUEST['customer_id'];
         $booID = $_REQUEST['booking_id'];
         $conver->sender_id = $senderId;
         $conver->sender_type = 'company';
         $conver->reciver_id = $reciverId;
         $conver->booking_id = $booID;
         $conver->reciver_type = 'customer';
         $conver->sender_status = 1;
         $conver->subject = 'Please Review';
         $conver->save(false);
         $insert_idConver = Yii::app()->db->getLastInsertID();
         $conversation->conversation_id = $insert_idConver;
         $conversation->user_type = 'company';
         $conversation->user_id = $loggedId;
         $conversation->booking_id = $booID;
         $conversation->tomsg = $reciverId;
         $conversation->msg = $_REQUEST['MsgDetails']['msg'];
         $conversation->save(false);
         // chnage the job status in company request table
         $rec = ServiceReview::model()->find(array('condition' => 'booking_id=:booking_id', 'params' => array(':booking_id' => $booID)));
         if (!empty($rec)) {
             $rec->status = 0;
             $rec->save(false);
         }
         echo "success";
         die;
     }
 }
コード例 #2
0
ファイル: MessageController.php プロジェクト: KaranSofat/yii
 public function actionCreateMessage()
 {
     $msg = new MsgDetails();
     $model = new ConversationMsg();
     if (isset($_POST['ConversationMsg']) && isset($_POST['MsgDetails'])) {
         $model->attributes = $_POST['ConversationMsg'];
         $msg->attributes = $_POST['MsgDetails'];
         if ($model->validate() || $msg->validate()) {
             $btn = $_REQUEST['btn'];
             if ($btn == 'company') {
                 //echo "<pre>";print_r($_REQUEST); die;
                 $email = $_REQUEST['ConversationMsg']['reciver_id'];
                 //echo $email;
                 $email = ltrim($email);
                 $email = rtrim($email);
                 $rec = ServiceUser::model()->findByAttributes(array('email' => $email));
                 //echo "fsfsf"."<pre>";print_r($rec);die;
                 $companyRecvierId = $rec->id;
                 //echo $companyRecvierId;die;
                 $sender_id = Yii::app()->session['username'];
                 $date = date('Y-m-d');
                 $model->date = $date;
                 $model->sender_id = $sender_id;
                 $model->sender_type = 'admin';
                 $model->reciver_id = $companyRecvierId;
                 $model->reciver_type = 'company';
                 $model->save(false);
                 $conversationId = Yii::app()->db->getLastInsertID();
                 $convMsg = ConversationMsg::model()->findByPk(array('id' => $conversationId));
                 //echo "<pre>";print_r($rec);die;
                 $text = $_REQUEST['MsgDetails']['msg'];
                 $msg->conversation_id = $conversationId;
                 $msg->user_type = 'admin';
                 $msg->msg = $text;
                 $msg->tomsg = $convMsg['reciver_id'];
                 $date = date('Y-m-d');
                 $msg->date = $date;
                 if ($msg->save(false)) {
                     $this->redirect(array('messagelisting'));
                 }
             } else {
                 $email = $_REQUEST['ConversationMsg']['reciver_id'];
                 //echo $email;die;
                 $email = ltrim($email);
                 $email = rtrim($email);
                 $rec = CustomerUser::model()->findByAttributes(array('email' => $email));
                 //echo "fsfsf"."<pre>";print_r($rec);die;
                 $companyRecvierId = $rec->id;
                 //echo $companyRecvierId;die;
                 $sender_id = Yii::app()->session['username'];
                 // echo $sender_id;die;
                 $date = date('Y-m-d');
                 $model->date = $date;
                 $model->sender_id = $sender_id;
                 $model->sender_type = 'admin';
                 $model->reciver_id = $companyRecvierId;
                 $model->reciver_type = 'company';
                 $model->save(false);
                 $conversationId = Yii::app()->db->getLastInsertID();
                 $convMsg = ConversationMsg::model()->findByPk(array('id' => $conversationId));
                 $text = $_REQUEST['MsgDetails']['msg'];
                 $msg->conversation_id = $conversationId;
                 $msg->user_type = 'admin';
                 $msg->msg = $text;
                 $msg->tomsg = $convMsg['reciver_id'];
                 $date = date('Y-m-d');
                 $msg->date = $date;
                 if ($msg->save(false)) {
                     $this->redirect(array('messagelisting'));
                 }
             }
         } else {
             $errors = $model->getErrors();
             //var_dump($errors);
             $err = $msg->getErrors();
             //var_dump($err);
         }
     }
     $this->render('createmessage', array('model' => $model, 'msg' => $msg));
 }