Example #1
0
 public function actionIndex()
 {
     $id = Yii::app()->user->getId();
     if (empty($id)) {
         $this->redirect(Yii::app()->user->returnUrl . 'site/login');
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 'ID_USERS = ' . $id;
     $criteria->order = 'ID_GALLERY_PRIBADI DESC';
     $gallery = GalleryPribadi::model()->findAll($criteria);
     $gallery_barang = GalleryBarang::model()->get_data_barang($id);
     $user = Users::model()->findByPk($id);
     // $criteria2 = new CDbCriteria();
     // $criteria->condition = 'ID_USERS = '.$id;
     // $criteria->order = 'ID_GALLERY_BARANG DESC';
     // $gallery = GalleryBarang::model()->findAll($criteria);
     if (isset($_POST['Users'])) {
         $rnd = rand(0, 9999);
         // generate random number between 0-9999
         $user->attributes = $_POST['Users'];
         $uploadedFile = CUploadedFile::getInstance($user, 'FOTO');
         $fileName = "{$rnd}-{$uploadedFile}";
         // random number + file name
         $user->FOTO = $fileName;
         $user->save();
         $uploadedFile->saveAs(Yii::app()->basePath . '/../images/profile/' . $fileName);
         $this->redirect(Yii::app()->user->returnUrl . 'profile');
     }
     $profile = TransaksiRegistrasi::model()->get_data_profile($id);
     // print_r($profile); die();
     $this->render('profile', array('model' => $user, 'data' => $profile, 'gallery' => $gallery, 'koleksi' => $gallery_barang));
 }
Example #2
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $criteria = new CDbCriteria();
     $dataProvider = new CActiveDataProvider('GalleryBarang');
     $id = Yii::app()->user->getId();
     // $criteria->condition = 'ID_USERS = '.$id;
     $criteria->order = 'ID_GALLERY_BARANG DESC';
     $gallery = GalleryBarang::model()->findAll($criteria);
     $this->render('index', array('dataProvider' => $dataProvider, 'gallery' => $gallery));
     // $this->render('index');
 }
Example #3
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;
        }
    }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return GalleryBarang the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = GalleryBarang::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }