示例#1
0
 public function postOrder($lang = 'id')
 {
     $url_source = Input::get('url_source');
     if ($url_source) {
         $url_source = URL::to('/');
     }
     $promo = Promo::Active()->first();
     if (!$promo) {
         return Redirect::to($url_source);
     }
     $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required'));
     if ($validator->fails()) {
         return Redirect::to($url_source);
     }
     $contact = new PromoOrder();
     $contact->name = Input::get('name');
     $contact->email = Input::get('email');
     $contact->promo_id = Input::get('promo_id');
     $contact->save();
     $email = Notification::sendEmailGetPromo($contact);
     if (!$email) {
         Log::error('Failed sending Promo Order email with reference ID : ' . $contact->id);
     }
     if (!$contact->id) {
         Log::error('Failed updating database promo order from : ' . $contact->name . ' - ' . $contact->email);
     }
     restrictPromoPopup();
     return Redirect::back();
 }
示例#2
0
 public function init()
 {
     try {
         \Yii::$app->db->createCommand('OPEN SYMMETRIC KEY [key_DataShare] DECRYPTION BY CERTIFICATE [cert_keyProtection]; SELECT 1 as a; ')->execute();
     } catch (Exception $e) {
         Log::trace("Error : " . $e);
         throw new Exception("Error : " . $e);
     }
     parent::init();
 }
示例#3
0
 public function loadModel($id)
 {
     $model = Log::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'The requested page does not exist.');
     }
     // if(!$model->hasAccess(Yii::$app->user->id))
     //    throw new \yii\web\HttpException(403,'Access Denaid');
     return $model;
 }
 public function postBuy($lang = 'id')
 {
     $product = Product::find(Input::get('product_id'));
     if (!$product) {
         return Redirect::route('site.product', array('lang' => $lang));
     }
     $validator = Validator::make(array('Captcha' => Input::get('g-recaptcha-response'), 'Name' => Input::get('name'), 'Email' => Input::get('email'), 'Phone' => Input::get('phone'), 'Address' => Input::get('address')), array('Captcha' => 'required|captcha', 'Name' => 'required', 'Email' => 'required', 'Phone' => 'required', 'Address' => 'required'));
     if ($validator->fails()) {
         return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->withErrors($validator->errors());
     }
     $contact = new ProductOrder();
     $contact->name = Input::get('name');
     $contact->email = Input::get('email');
     $contact->phone = Input::get('phone');
     $contact->address = Input::get('address');
     $contact->message = Input::get('message');
     $contact->product_id = $product->id;
     $contact->product_name = $product->name_id;
     if ($lang == 'en') {
         $contact->product_name = $product->name_en;
     }
     $contact->price = $product->price;
     $contact->save();
     $email = Notification::sendEmailBuyProduct($contact);
     if (!$email) {
         Log::error('Failed sending Product Purchase email with reference ID : ' . $contact->id);
     }
     if (!$contact->id) {
         $errorMessage = "Proses gagal, coba beberapa saat lagi";
         if ($lang == 'en') {
             $errorMessage = "Process failed, please try again later";
         }
         return Redirect::route('site.product.buy', array('lang' => $lang, 'slug' => $product->slug))->with('error_message', $errorMessage);
     }
     $successMessage = "Pesanan Anda telah kami terima, kami akan segera menghubungi anda untuk proses konfirmasi";
     if ($lang == 'en') {
         $successMessage = "We have received your order, we will contact you soon for confirmation";
     }
     return Redirect::route('site.product', array('lang' => $lang))->with('success', $successMessage);
 }
示例#5
0
 public function getNetPerfDatasetRep($cntr, $days = 2)
 {
     if (is_array($cntr)) {
         $counter = $cntr[0];
         $instance = $cntr[1];
     } else {
         $counter = $cntr;
     }
     if ($counter == 'disk') {
         try {
             $cmd = \Yii::$app->db->createCommand('exec dbo.usp_getNetRep :d;');
             $cmd->bindValue(':d', $days);
             $dataset = $cmd->queryAll();
         } catch (Exception $e) {
             Log::trace("Error : " . $e);
             throw new Exception("Error : " . $e);
         }
     }
     return !empty($dataset) ? $dataset : [[0, 0, 0, 0, 0]];
 }