public function actionReplyFromAdminToCustomer() { //echo "<pre>";print_r($_REQUEST);die; $model = new ConversationMsg(); $msg = new MsgDetails(); //$senderId =$_REQUEST['loggedId']; $reciverId = $_REQUEST['receiverId']; $subject = $_REQUEST['subject']; $text = $_REQUEST['text']; $conversationID = $_REQUEST['conversionId']; //$bookingId =$_REQUEST['replysectionBookingId']; //echo "<pre>";print_r($_REQUEST);die; if (!empty($_REQUEST)) { $msg->conversation_id = $conversationID; $msg->user_type = 'admin'; $msg->msg = $text; $msg->user_id = 0; $msg->tomsg = $reciverId; $msg->logged_id = $loggedId; //$date =date('Y-m-d'); //$msg->date =$date; $msg->booking_id = 0; $msg->save(false); $msgConverLastId = Yii::app()->db->getLastInsertID(); $re = MsgDetails::model()->findByPk(array('id' => $msgConverLastId)); echo "<div class='name'>"; echo 'admin'; echo "</div>"; echo "<div class='leftMsg appendmsg" . $re['id'] . "'>"; echo "<div class='time'>"; echo date('jS \\of F Y H:i:s', strtotime($re['date'])); echo "</div>"; echo $re['msg']; echo "</div> "; //echo "success";die; } }
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; } }
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)); }