Exemplo n.º 1
0
/**
 * utils.php   file.
 *
 * Collection of utility functions
 * @author Miguel Sanchez <*****@*****.**>
 */
function sendHtmlEmail($toStr, $subject, $content, $ccStr = null)
{
    /* ini_set("SMTP", "mailserver.copservir.com");
        ini_set("smtp_port", "25");
        ini_set("sendmail_from", "mailserver.copservir.com");
        Yii::import('application.extensions.phpmailer.JPhpMailer');
        $mail = new JPhpMailer;
        $mail->isSMTP();
        $mail->Host = 'mailserver.copservir.com';
        $mail->Port = 25;
        $mail->SMTPAuth = false;
        $mail->isHTML(true);
        $mail->CharSet = "UTF-8";
       */
    Yii::import('application.extensions.phpmailer.JPhpMailer');
    $mail = new JPhpMailer();
    $mail->isSMTP();
    $mail->Host = 'smtp.gmail.com';
    $mail->SMTPAuth = true;
    $mail->Username = '******';
    $mail->Password = '******';
    $mail->SMTPSecure = 'tls';
    $mail->Port = 587;
    $mail->isHTML(true);
    $mail->CharSet = "UTF-8";
    $mail->From = Yii::app()->params->correoAdmin;
    $mail->FromName = Yii::app()->name;
    if ($toStr === null) {
        throw new Exception("email receiver is empty");
    }
    $toStr = trim($toStr);
    if (empty($toStr)) {
        throw new Exception("email receiver is empty");
    }
    $toArr = explode(",", $toStr);
    if (empty($toArr)) {
        throw new Exception("email receiver is empty");
    }
    foreach ($toArr as $to) {
        $mail->addAddress($to);
    }
    if ($ccStr !== null) {
        $ccArr = explode(",", $ccStr);
        foreach ($ccArr as $cc) {
            $mail->addCC($cc);
        }
    }
    $mail->Subject = $subject;
    $mail->Body = $content;
    if (!$mail->send()) {
        throw new Exception("Message could not be sent. " . $mail->ErrorInfo);
    }
}
Exemplo n.º 2
0
    function setDataBuy($vad, $id, $status, $type)
    {
        $model_produk = new TransaksiRequestPembelian();
        $idUsr = Yii::app()->user->getId();
        $profile = TransaksiRegistrasi::model()->get_data_profile($idUsr);
        $profile = (object) $profile;
        $user = Users::model()->findByPk($idUsr);
        $model = GalleryBarang::model()->findByPk($id);
        if ($type == 'POINT' && $user->POINT < $model->HARGA_POINT) {
            return false;
        } else {
            $model_produk->ID_USERS = $idUsr;
            $model_produk->ID_GALLERY_BARANG = $id;
            $model_produk->VAD = $vad;
            $model_produk->STATUS = $status;
            $model_produk->TYPE_PEMBELIAN = $type;
            $model_produk->save(false);
            if ($type == 'CASH') {
                Yii::import('application.extensions.phpmailer.JPhpMailer');
                $mail = new JPhpMailer();
                $mail->isSMTP();
                $mail->Debugoutput = 'html';
                $mail->Host = 'smtp.gmail.com';
                $mail->Port = 587;
                $mail->SMTPSecure = 'tls';
                $mail->SMTPAuth = true;
                $mail->Username = "******";
                $mail->Password = "******";
                $mail->setFrom('*****@*****.**', 'Admin Soniq');
                // $mail->addReplyTo('*****@*****.**', 'First Last');
                $mail->addAddress($profile->EMAIL, $profile->NAMA_LENGKAP);
                $mail->Subject = 'Konfirmasi Pembelian Produk Soniq';
                $mail->MsgHTML('<h1> Hello, ' . $profile->NAMA_LENGKAP . '</h1><br> 
					Anda Request Barang denganKODE BARANG : <b>' . $model->KODE_GALLERY . ' </b> dan 
					 NAMA BARANG : <b>' . $model->NAMA_GALLERY . '</b><br> Silahkan Transfer Biaya Pembelian Sebesar	: <b>' . $model->HARGA_CASH . '</b> Ke Rekening Berikut<br> 
					<br> Virtual ID anda : <b>' . $model_produk->VAD . '</b> <br> Terimakasih... ');
                $mail->send();
            } else {
                if ($type == 'POINT') {
                    $user->POINT = $user->POINT - $model->HARGA_POINT;
                    $user->save();
                }
            }
            return true;
        }
    }
Exemplo n.º 3
0
    public function actionConfirmTopUp()
    {
        $id = Yii::app()->user->getId();
        $model = new TransaksiRequestTopupPoint();
        $user = Users::model()->findByPk($id);
        $model->ID_USERS = $id;
        $model->TANGGAL = date('Y-m-d');
        $model->STATUS = 0;
        $model->save();
        $profile = TransaksiRegistrasi::model()->get_data_profile($id);
        $profile = (object) $profile;
        Yii::app()->user->setFlash('Virtual Account', $user->VAS);
        Yii::app()->user->setFlash('Email', $profile->EMAIL);
        if (Yii::app()->user->hasFlash('Virtual Account')) {
            Yii::import('application.extensions.phpmailer.JPhpMailer');
            $mail = new JPhpMailer();
            $mail->isSMTP();
            $mail->Debugoutput = 'html';
            $mail->Host = 'smtp.gmail.com';
            $mail->Port = 587;
            $mail->SMTPSecure = 'tls';
            $mail->SMTPAuth = true;
            $mail->Username = "******";
            $mail->Password = "******";
            $mail->setFrom('*****@*****.**', 'Admin Soniq');
            // $mail->addReplyTo('*****@*****.**', 'First Last');
            $mail->addAddress($profile->EMAIL, $profile->NAMA_LENGKAP);
            $mail->Subject = 'Konfirmasi TopUP Point Soniq';
            $mail->MsgHTML('<h1> Hello, ' . $profile->NAMA_LENGKAP . '</h1><br>
			Silahkan Transfer Biaya ke Virtual Account Anda <b>' . $user->VAS . '</b><br>
			Nilai Point adalah biaya / 5000 <br>
			<br> Terimakasih');
            // $mail->send();
            $this->render('confirm');
        } else {
            $this->redirect(array('point/topup'));
        }
    }
Exemplo n.º 4
0
 public function actionIndex()
 {
     $model = new TransaksiRegistrasi();
     $model_user = new Users();
     if (isset($_POST['TransaksiRegistrasi'])) {
         // 	if($model->validate() && $model_user->validate()){
         // 	echo "oke";
         // }else{
         // 	echo "ga oke";
         // }
         // die();
         $model->attributes = $_POST['TransaksiRegistrasi'];
         $cek = $model->validate();
         if ($cek) {
             // if($model->save()){
             $number = '';
             for ($i = 0; $i < 16; $i++) {
                 $number .= rand(0, 9);
             }
             $model->ID_FANBASE = 1;
             // $model->NO_SAKTI = $number;
             $model->VAD = $this->randomNumber(16);
             $model->STATUS_REKONSILIASI = 0;
             $model->STATUS_RELEASE = 0;
             $tgl = explode('/', $_POST['TransaksiRegistrasi']['TANGGAL']);
             $model->TANGGAL = $tgl[2] . '-' . $tgl[0] . '-' . $tgl[1];
             $model->VALIDASI_UPLOAD = 0;
             // print_r($model); die();
             $model->save(false);
             $model_user->ID_FANBASE = $model->ID_FANBASE;
             $model_user->ID_REGISTRASI = $model->ID_REGISTRASI;
             $model_user->ID_JENIS = 4;
             $model_user->VAS = '-';
             $model_user->STATUS = 0;
             $model_user->save(false);
             Yii::import('application.extensions.phpmailer.JPhpMailer');
             $mail = new JPhpMailer();
             $mail->isSMTP();
             $mail->Debugoutput = 'html';
             $mail->Host = 'smtp.gmail.com';
             $mail->Port = 587;
             $mail->SMTPSecure = 'tls';
             $mail->SMTPAuth = true;
             $mail->Username = "******";
             $mail->Password = "******";
             $mail->setFrom('*****@*****.**', 'Admin Soniq');
             // $mail->addReplyTo('*****@*****.**', 'First Last');
             $mail->addAddress($model->EMAIL, $model->NAMA_LENGKAP);
             $mail->Subject = 'Konfirmasi Registrasi Soniq';
             $mail->MsgHTML('<h1> Hello, ' . $model->NAMA_LENGKAP . '</h1><br> Virtual ID anda : <b>' . $model->VAD . '</b>');
             // $mail->Body    = '';
             // $mail->AltBody = 'This is a plain-text message body';
             //Attach an image file
             //$mail->addAttachment('images/phpmailer_mini.png');
             //send the message, check for errors
             // if (!$mail->send()) {
             // 	$res = "Email Gagal Dikirim";
             // }else {
             // 	$res = "Email Sudah Dikirm";
             // }
             $res = 'kirim email di matikan';
             Yii::app()->user->setFlash('Virtual ID', $model->VAD);
             Yii::app()->user->setFlash('Email', $model->EMAIL);
             Yii::app()->user->setFlash('Status', $res);
             // $data = array('vad'=>$model->VAD,'pwd'=>$model_user->PASSWORD,'email'=>$model->EMAIL);
             $this->redirect(array('confirm'));
         }
     }
     $this->render('create', array('model' => $model, 'model_user' => $model_user));
 }