コード例 #1
0
 public function actionReadTopic($id)
 {
     $thread = Thread::model()->getThreadInfoById($id);
     $this->forumBreadcrumb = array('Programs' => array('forum/index'), $thread['program_name'] => array('forum/programView', 'programId' => $thread['program_id']), $thread['semester_name'] => array('forum/viewTopics', 'programId' => $thread['program_id'], 'semesterId' => $thread['semester_id']), $thread['title'] < Yii::app()->params['forum_max_crumb_length'] ? $thread['title'] : substr($thread['title'], 0, Yii::app()->params['forum_max_crumb_length']) . '...');
     $this->areaLarge = $thread['program_name'];
     $this->areaSmall = $thread['semester_name'];
     $reply = new Reply();
     $complaint = new Complaint('postComplaint');
     if (isset($_POST['Reply'])) {
         $reply->attributes = $_POST['Reply'];
         $reply->post_item_id = $id;
         if ($reply->save()) {
             Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
             $reply->unsetAttributes();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
         }
     }
     if (isset($_POST['Complaint'])) {
         $complaint->attributes = $_POST['Complaint'];
         if ($complaint->save()) {
             if ($complaint->post_item_id == $id) {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             }
             $complaint->unsetAttributes();
         } else {
             Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
         }
     }
     $dataProvider = Thread::model()->getPostsDataInThread($id);
     Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
     $this->render('view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
 }
コード例 #2
0
 public function actionComplaintAdd()
 {
     if (Yii::app()->request->isPostRequest) {
         $model = Yii::app()->request->getPost('model');
         $external_id = Yii::app()->request->getPost('external_id');
         $store = $model::model()->findByPk($external_id);
         $profile = Yii::app()->user->getProfile();
         $Company = $profile->company;
         //            if ($Company->id == $store->user->company->id ) {
         //                throw new CHttpException(403);
         //            }
         $complaint = new Complaint();
         $complaint->from_company_id = $Company->id;
         $complaint->user_id = Yii::app()->user->id;
         $complaint->to_company_id = $store->user->company->id;
         $complaint->model = $model;
         $complaint->record_id = $external_id;
         if ($complaint->validate()) {
             $complaint->save();
             echo CJSON::encode(['status' => 'success', 'data' => '/cabinet/complaint/success']);
         } else {
             echo CJSON::encode(['status' => 'error', 'data' => print_r($complaint->getErrors(), true)]);
         }
     }
 }
コード例 #3
0
 public function actionReadTopic($id)
 {
     $thread = Thread::model()->getThreadInfoById($id);
     $this->areaLarge = $thread['program_name'];
     $this->areaSmall = $thread['semester_name'];
     $reply = new Reply();
     $complaint = new Complaint('postComplaint');
     if (isset($_POST['Reply'])) {
         $reply->attributes = $_POST['Reply'];
         $reply->post_item_id = $id;
         if ($reply->save()) {
             Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.reply.success'));
             $reply->unsetAttributes();
         } else {
             Yii::app()->user->setFlash('error', Yii::t('forum', 'forum.view.reply.error'));
         }
     }
     if (isset($_POST['Complaint'])) {
         $complaint->attributes = $_POST['Complaint'];
         if ($complaint->save()) {
             if ($complaint->post_item_id == $id) {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             } else {
                 Yii::app()->user->setFlash('success', Yii::t('forum', 'forum.view.complaint.success'));
             }
             $complaint->unsetAttributes();
         } else {
             Yii::app()->clientScript->registerScript('show_modal', "\$('#reportModal').modal('show');", CClientScript::POS_READY);
         }
     }
     $dataProvider = Thread::model()->getPostsDataInThread($id);
     Yii::log(CVarDumper::dumpAsString($dataProvider->getData()));
     $this->render('application.modules.community.views.front.post.view', array('thread' => $thread, 'threadId' => $id, 'dataProvider' => $dataProvider, 'reply' => $reply, 'complaint' => $complaint));
 }
コード例 #4
0
ファイル: Complaint.php プロジェクト: Headrun-php/TLG
 static function createComplaint($input)
 {
     $complaint = new Complaint();
     $complaint->customer_id = $input['customer_id'];
     $complaint->student_id = $input['student_id'];
     $complaint->franchisee_id = Session::get('franchiseId');
     $complaint->created_at = date("Y-m-d H:i:s");
     $complaint->created_by = Session::get('userId');
     $complaint->save();
     return $complaint;
 }
コード例 #5
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Complaint();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Complaint'])) {
         $model->attributes = $_POST['Complaint'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model));
 }
コード例 #6
0
 public function save()
 {
     $adminId = Session::get('admin_id');
     if (!isset($adminId)) {
         return json_encode(array('message' => 'not logged'));
     }
     $complaint = new Complaint();
     $complaint->name = Input::get('name');
     $complaint->email = Input::get('email');
     $complaint->address = Input::get('address');
     $complaint->contact_number_1 = Input::get('contact_number_1');
     $complaint->contact_number_2 = Input::get('contact_number_2');
     $complaint->software_user_id = $adminId;
     $complaint->status = Input::get('status');
     $complaint->save();
     $complaintUpdate = new ComplaintUpdate();
     $complaintUpdate->complaint_id = $complaint->id;
     $complaintUpdate->software_user_id = $adminId;
     $complaintUpdate->description = Input::get('description');
     $complaintUpdate->status = $complaint->status;
     $complaintUpdate->save();
     return json_encode(array('message' => 'done'));
 }
コード例 #7
0
 public function save()
 {
     $type = (string) Input::get('type');
     if (!in_array($type, array('mismatch', 'spam', 'flood', 'rude', 'obscene'))) {
         return $this->respondWithError('Set incorrect complaint type');
     }
     $complaint = new Complaint();
     $complaint->owner_id = Auth::user()->id;
     $complaint->type = $type;
     if (Input::has('post_id')) {
         $post = Post::find((int) Input::get('post_id'));
         if (!$post) {
             return $this->respondWithError('Post isn\'t found');
         } else {
             if ($post->user_id == Auth::user()->id) {
                 return $this->respondWithError('Can\'t complain to your post');
             }
         }
         if (Complaint::where('owner_id', Auth::user()->id)->where('post_id', $post->id)->first()) {
             return $this->respondNoContent();
         }
         $complaint->post_id = $post->id;
     } else {
         if (Input::has('user_id')) {
             $user = User::find((int) Input::get('user_id'));
             if (!$user) {
                 return $this->respondWithError('User isn\'t found');
             } else {
                 if ($user->id == Auth::user()->id) {
                     return $this->respondWithError('Can\'t complain to your profile');
                 }
             }
             if (Complaint::where('owner_id', Auth::user()->id)->where('user_id', $user->id)->first()) {
                 return $this->respondNoContent();
             }
             $complaint->user_id = $user->id;
         } else {
             if (Input::has('comment_id')) {
                 $comment = Comment::find((int) Input::get('comment_id'));
                 if (!$comment) {
                     return $this->respondWithError('Comment isn\'t found');
                 } else {
                     if ($comment->user_id == Auth::user()->id) {
                         return $this->respondWithError('Can\'t complain to your comment');
                     }
                 }
                 if (Complaint::where('owner_id', Auth::user()->id)->where('comment_id', $comment->id)->first()) {
                     return $this->respondNoContent();
                 }
                 $complaint->comment_id = $comment->id;
             } elseif (Input::has('emergency_id')) {
                 $emergency = Emergency::find(Input::get('emergency_id'));
                 if (!$emergency) {
                     return $this->respondNotFound('Emergency not found');
                 }
                 if ($emergency->receiver != Auth::id()) {
                     return $this->respondInsufficientPrivileges('This emergency is not for you to complain');
                 }
                 $emergency->complained_at = Carbon::now();
                 $emergency->save();
                 $emergency->getMembersTokens()->each(function ($token) use($emergency) {
                     $state = new StateSender($token->auth_token);
                     $state->setEmergencyAsComplained($emergency->id, $emergency->complained_at);
                 });
                 return $this->respondNoContent();
             }
         }
     }
     $complaint->save();
     return $this->respondNoContent();
 }
コード例 #8
0
ファイル: import.php プロジェクト: nantmpeter/s-complaints
         if ($_POST['cover'] == 'on') {
             Complaint::delDataByMonth($_POST['table'], $tmp[1]);
         } else {
             $check = false;
             $check = Complaint::checkFirstLine($excel_array, $_POST['table']);
         }
         if ($check) {
             $error[$_POST['table']][] = $check['error'];
         } else {
             // TODO check if imported
             if ($excel_array) {
                 array_shift($excel_array);
                 $error[$_POST['table']] = array();
                 $record_id = Complaint::recordTable($_FILES['excel']['name'], $table, $date, $province_id, $user_info['user_id']);
                 foreach ($excel_array as $key => $value) {
                     $r = Complaint::save($value, $table, $date, $province_id, $record_id);
                     if (!$r) {
                         file_put_contents('../error_' . date('Y-m-d') . '.log', date('Y-m-d H:i:s') . ' ' . $_FILES['excel']['name'] . ' \'' . implode("','", $value) . "'\n", FILE_APPEND);
                         $error[$_POST['table']][] = '\'' . implode("','", $value) . "'<br>";
                     }
                 }
                 if (empty($error[$_POST['table']])) {
                     $error[$_POST['table']][] = '导入成功!';
                 }
             } else {
                 $error[$_POST['table']][] = "导入文件有问题!";
             }
         }
     }
 } else {
     $error[$_POST['table']][] = "请选择全部选项!";