/**
  * @param int[] $products
  *
  * @return string
  */
 public function actionBuy($products)
 {
     session_start();
     $check = \app\models\Check::createByProductIds(json_decode($products, true));
     $_SESSION['price'] = $check->price;
     $_SESSION['fullPrice'] = $check->fullPrice;
     $this->redirect(['site/delivery']);
 }
 public function actionDetail($id = null, $check_status = null, $dealername = null, $foreignid = null, $email_id)
 {
     $model = new VerifyMessage();
     $session = Yii::$app->session;
     //得到这份邮件
     if (isset($_POST['message'])) {
         $message = $_POST['message'];
         $check_status = $_POST['check_status'];
         //            $foreignid=$_POST['foreignid'];
         $check = new Check();
         $check = Check::find()->where(['id' => $foreignid])->one();
         $check->check_status = $check_status;
         $check->check_advise = $message;
         $check->save();
         $session['count'] = $session['count'] - 1;
         $email = SentEmail::find()->where(['id' => $id])->asArray()->one();
         if ($check_status == 1 && $email_id != NULL && $email_id != 0) {
             $email_d = SentEmail::find()->where(['id' => $email_id])->asArray()->one();
             $model = new Mail();
             $mailaccount = Setting::find()->one();
             $sendhost = $mailaccount->sendhost;
             $username = $mailaccount->username;
             $user = $mailaccount->user;
             $password = $mailaccount->password;
             error_reporting(E_ALL ^ E_WARNING);
             //$email=SentEmail::find()->where(['id'=>$id])->asArray()->one();
             $body = $email_d['text'];
             $to = $email_d['receiver'];
             $subject = $email_d['subject'];
             $mail = new sendmail();
             //新建发送
             if ($email['attachment'] != null) {
                 $filename = basename($email['attachment']);
                 $encode = mb_detect_encoding($filename, array("ASCII", "UTF-8", "GBK", "GB2312"));
                 if ($encode == "EUC-CN") {
                     $encode = "GB2312";
                 }
                 if ($encode != "GBK") {
                     $filename = iconv($encode, "GBK//IGNORE", $filename);
                 }
                 //echo $filename."before save"."</br>";
                 $mail->setServer($sendhost, $user, $password);
                 $mail->setFrom($username);
                 $mail->setReceiver("{$to}");
                 $mail->setMailInfo($subject, $body['body'], '../attachment/sendattachment/' . $filename);
                 //判断部分
             } else {
                 $mail->setServer($sendhost, $user, $password);
                 $mail->setFrom($username);
                 $mail->setReceiver("{$to}");
                 $mail->setMailInfo($subject, $body, "");
             }
             $mail->sendMail();
         }
         return $this->redirect('?r=site/login');
     } else {
         $email = SentEmail::find()->where(['id' => $id])->asArray()->one();
         $email['check_status'] = $check_status;
         //var_dump($email);
         //审核通过,邮件发送出去
         $email['dealername'] = $dealername;
         $email['foreignid'] = $foreignid;
         if ($check_status == 1 && $email_id != NULL && $email_id != 0) {
             $model = new Mail();
             $email_d = SentEmail::find()->where(['id' => $email_id])->asArray()->one();
             $mailaccount = Setting::find()->one();
             $sendhost = $mailaccount->sendhost;
             $username = $mailaccount->username;
             $user = $mailaccount->user;
             $password = $mailaccount->password;
             error_reporting(E_ALL ^ E_WARNING);
             //$email=SentEmail::find()->where(['id'=>$id])->asArray()->one();
             $body = $email_d['text'];
             $to = $email_d['receiver'];
             $subject = $email_d['subject'];
             $mail = new sendmail();
             //新建发送
             if ($email['attachment'] != null) {
                 $filename = basename($email['attachment']);
                 $encode = mb_detect_encoding($filename, array("ASCII", "UTF-8", "GBK", "GB2312"));
                 if ($encode == "EUC-CN") {
                     $encode = "GB2312";
                 }
                 if ($encode != "GBK") {
                     $filename = iconv($encode, "GBK//IGNORE", $filename);
                 }
                 //echo $filename."before save"."</br>";
                 $mail->setServer($sendhost, $user, $password);
                 $mail->setFrom($username);
                 $mail->setReceiver("{$to}");
                 $mail->setMailInfo($subject, $body, '../attachment/sendattachment/' . $filename);
                 //判断部分
             } else {
                 $mail->setServer($sendhost, $user, $password);
                 $mail->setFrom($username);
                 $mail->setReceiver("{$to}");
                 $mail->setMailInfo($subject, $body, "");
             }
             $mail->sendMail();
         }
         return $this->render('detail', ['model' => $model, 'email' => $email]);
     }
 }
예제 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChecks()
 {
     return $this->hasMany(Check::className(), ['id' => 'checkId'])->viaTable('check_has_loyalty', ['loyaltyId' => 'id']);
 }
예제 #4
0
 protected function resolve(models\Check $check)
 {
     foreach ($this->getActiveLoyalties() as $loyalty) {
         $check->link('loyalties', $loyalty);
     }
 }
예제 #5
0
 public function actionRewrite($email_id, $subject, $receiver, $text, $check_user)
 {
     $model = new Mail();
     $message = true;
     $session = Yii::$app->session;
     //$check_users=Users::find()->where(['permission'=>2])->asArray()->all();
     // print_r($check_users);
     if ($model->load(Yii::$app->request->post())) {
         //粘贴部分
         $mailaccount = Setting::find()->one();
         $sendhost = $mailaccount->sendhost;
         $username = $mailaccount->username;
         $user = $mailaccount->user;
         $password = $mailaccount->password;
         error_reporting(E_ALL ^ E_WARNING);
         $request = Yii::$app->request;
         $body = $request->post();
         $to = $model->receiver;
         $subject = $model->subject;
         $model->file = UploadedFile::getInstance($model, 'file');
         //error_reporting(E_ALL^E_WARNING);
         // $request = Yii::$app->request;
         //$body = $request->post();
         //$to=$model->receiver;
         //            $text=$model->text;
         // $subject=$model->subject;
         //            $body = $model->body;
         //print_r($model);
         //粘贴部分
         if ($model->file != null) {
             $filename = $model->file->name;
             $encode = mb_detect_encoding($filename, array("ASCII", "UTF-8", "GBK", "GB2312"));
             if ($encode == "EUC-CN") {
                 $encode = "GB2312";
             }
             if ($encode != "GBK") {
                 $filename = iconv($encode, "GBK//IGNORE", $filename);
             }
             //echo $filename."before save"."</br>";
             if ($model->file->saveAs('../attachment/sendattachment/' . $filename)) {
                 $mail = new sendmail();
                 //新建发送
                 $mail->setServer($sendhost, $user, $password);
                 $mail->setFrom($username);
                 $mail->setReceiver("{$to}");
                 $mail->setMailInfo($subject, $body['body'], '../attachment/sendattachment/' . $filename);
                 $message = true;
                 //插入check表
                 //$check_user=$_POST['check_user'];
                 if ($check_user != NULL) {
                     //更新sent邮件列表
                     $sent_email = SentEmail::findOne($email_id);
                     $sent_email->subject = $subject;
                     $sent_email->receiver = $to;
                     $sent_email->text = $body['body'];
                     $sent_email->attachment = '../attachment/sendattachment/' . $filename . ';';
                     //$sent_email->sender=$username;
                     //$sent_email->user_id=$session['user_id'];
                     $sent_email->save();
                     $ck = Check::find()->where(['email_id' => $email_id])->one();
                     //$check->user_id=$session['user_id'];
                     $ck->check_status = 0;
                     $ck->save();
                     return $this->redirect('?r=site/checkself&user_id=' . $session['user_id'] . '&check_status=0');
                 } else {
                     if (!$mail->sendMail()) {
                         $message = false;
                         return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_users' => $check_users]);
                     }
                     //$time=date("Y-m-d H:i:s",time());
                     $session = Yii::$app->session;
                     $sent_email = new SentEmail();
                     $sent_email->subject = $subject;
                     $sent_email->receiver = $to;
                     $sent_email->text = $body['body'];
                     $sent_email->attachment = '../attachment/sendattachment/' . $filename . ';';
                     $sent_email->sender = $username;
                     $sent_email->user_id = $session['user_id'];
                     $sent_email->save();
                     return $this->redirect('?r=site/sent&user_id=' . $session['user_id']);
                 }
             }
         } else {
             $mail = new sendmail();
             //新建发送
             $mail->setServer($sendhost, $user, $password);
             $mail->setFrom($username);
             $mail->setReceiver("{$to}");
             $mail->setMailInfo($subject, $body['body'], "");
             //插入已发送列表
             //插入check表
             //$check_user=$_POST['check_user'];
             if ($check_user != NULL) {
                 //$time=date("Y-m-d H:i:s",time());
                 $sent_email = SentEmail::findOne($email_id);
                 $sent_email->subject = $subject;
                 $sent_email->receiver = $to;
                 $sent_email->text = $body['body'];
                 //$sent_email->attachment='../attachment/sendattachment/'.$filename.';';
                 //$sent_email->sender=$username;
                 //$sent_email->user_id=$session['user_id'];
                 $sent_email->save();
                 $ck = Check::find()->where(['email_id' => $email_id])->one();
                 //$check->user_id=$session['user_id'];
                 $ck->check_status = 0;
                 $ck->save();
                 //print_r($check['user_id']);
                 return $this->redirect('?r=site/checkself&user_id=' . $session['user_id'] . '&check_status=0');
             } else {
                 if (!$mail->sendMail()) {
                     $message = false;
                     return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_user' => $check_user]);
                 }
                 //$time=date("Y-m-d H:i:s",time());
                 $session = Yii::$app->session;
                 $sent_email = new SentEmail();
                 $sent_email->subject = $subject;
                 $sent_email->receiver = $to;
                 $sent_email->text = $body['body'];
                 //$sent_email->attachment='../attachment/sendattachment/'.$filename.';';
                 $sent_email->sender = $username;
                 $sent_email->user_id = $session['user_id'];
                 $sent_email->save();
                 return $this->redirect('?r=site/sent&user_id=' . $session['user_id']);
             }
         }
     } else {
         return $this->render('rewrite', ['model' => $model, 'subject' => $subject, 'receiver' => $receiver, 'text' => $text, 'check_user' => $check_user]);
     }
 }
예제 #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getChecks()
 {
     return $this->hasMany(Check::className(), ['id' => 'checkId'])->viaTable('check_has_product', ['productId' => 'id']);
 }
예제 #7
0
 public function actionCheckself($user_id, $check_status)
 {
     $count = Check::find()->where(['user_id' => $user_id, 'check_status' => $check_status])->count();
     $user = Users::find()->where(['id' => $user_id])->asArray()->one();
     $pagination = new Pagination(['defaultPageSize' => 8, 'totalCount' => $count]);
     $check = Check::find()->where(['user_id' => $user_id, 'check_status' => $check_status])->offset($pagination->offset)->limit($pagination->limit)->asArray()->all();
     $emails = array();
     foreach ($check as $checkmail) {
         $sentmail = SentEmail::find()->orderBy(['send_time' => SORT_DESC])->where(['id' => $checkmail['email_id']])->asArray()->one();
         $sentmail['check_status'] = $checkmail['check_status'];
         $sentmail['check_advise'] = $checkmail['check_advise'];
         $checker = Users::find()->where(['id' => $checkmail['check_user_id']])->asArray()->one();
         $sentmail['checker'] = $checker['username'];
         $emails[] = $sentmail;
     }
     $check['count'] = $count;
     $check['username'] = $user['username'];
     return $this->render('/Users\\dealer\\check', ['emails' => $emails, 'pagination' => $pagination, 'check' => $check]);
 }
예제 #8
0
    echo '<i class="glyphicon glyphicon-send" style="margin-left:20px;color:red"></i>';
}
?>
                    </a>
                </li>

                <li>
                    <a href="#" id="pull">
                        <i class="glyphicon glyphicon-eye-open"></i>
                        <span class="title">&nbsp;&nbsp;审核邮件</span>
                        <span class="sr-only">(current)</span>
                         <i  id="pullico" class="glyphicon glyphicon-chevron-down pull-right" style="margin-left:20px"></i>
                        <?php 
use app\models\Check;
$wait_count = Check::find()->where(['check_status' => 0, 'user_id' => $session['user_id']])->count();
$fail_count = Check::find()->where(['check_status' => 2, 'user_id' => $session['user_id']])->count();
if ($wait_count + $fail_count > 0) {
    echo '<i class="pull-right glyphicon glyphicon-flash" style="color:red"></i>';
    //echo '<span class="badge pull-right">'.$count.'</span>';
}
?>
                        

                    </a>
                     <ul class="submenu">

                        <li>
                            <a href="<?php 
echo \yii\helpers\Url::toRoute(['site/checkself', 'user_id' => $session['user']['id'], 'check_status' => 0]);
?>
">