public function actionTrainersRevenue()
 {
     $data = TransactionHistory::getTrainersRevenue();
     $dataProvider = new ActiveDataProvider(['query' => $data['users']]);
     unset($data['users']);
     return $this->render('trainers-revenue', ['dataProvider' => $dataProvider, 'data' => $data]);
 }
Exemple #2
0
 private function getBookingsCount()
 {
     if ($this->actives_group === NULL) {
         return false;
     }
     if (!$this->actives_group) {
         return TransactionHistory::find()->where("`class_id` IN (SELECT `class_id` FROM `classes` WHERE `class_activity` = {$this->actives_id}) ")->andWhere("`status` != 'REFUNDED'")->count();
     } else {
         return TransactionHistory::find()->where("`class_id` IN \r\n\t\t\t\t\t(SELECT `class_id` FROM `classes` WHERE `class_activity` IN \r\n\t\t\t\t\t(SELECT `actives_id` FROM `actives` WHERE `actives_group_parent` = {$this->actives_id})\r\n\t\t\t\t\t)\r\n\t\t\t\t")->andWhere("`status` != 'REFUNDED'")->count();
     }
 }
 public function actionUpdateList($id)
 {
     $this->checkAccess('admin_staff');
     $post = Yii::$app->request->post();
     $model = Classes::findOne((int) $id);
     $dataProvider = new ActiveDataProvider(['query' => TransactionHistory::find()->where(['class_id' => $id, 'transaction_dispute_status' => 'open'])]);
     if (!empty($post)) {
         switch ($post['Classes']['class_name']) {
             case 'approved':
                 TransactionHistory::setRefundDispute($model);
                 TransactionHistory::sendEmailStudentList($model);
                 break;
         }
         TransactionHistory::updateAll(['transaction_dispute_status' => $post['Classes']['class_name']], ['class_id' => $id, 'transaction_dispute_status' => 'open']);
         return $this->redirect('/dispute/list');
     } else {
         return $this->render('update-list', ['model' => $model, 'dataProvider' => $dataProvider]);
     }
 }
Exemple #4
0
 private function getBookingsCount()
 {
     return TransactionHistory::find()->where("`class_id` IN (SELECT `class_id` FROM `classes` WHERE `class_trainer_id` = {$this->user_id})")->andWhere("`status` != 'REFUNDED'")->count();
 }
 public static function setRefundDispute($class)
 {
     if (empty($class)) {
         throw new Exception("You already refunded for this class", 400);
     }
     $trans = self::find()->where(['class_id' => $class->class_id, 'transaction_dispute_status' => 'open'])->all();
     if ($trans) {
         foreach ($trans as $val) {
             $worldpay = new WorldpayHelper(self::$worldpayKey);
             // Sometimes your SSL doesnt validate locally
             // DONT USE IN PRODUCTION
             $worldpay->disableSSLCheck(true);
             try {
                 // Refund the order using the Worldpay order code
                 $worldpay->refundOrder($val->transation_id);
             } catch (Exception $e) {
                 throw new Exception($e->getMessage());
             }
             $transactionData = array("user_id" => $val->user_id, "description" => "Refunded class {$class->class_name}", "transation_id" => $val->transation_id, "status" => 'REFUNDED', "amount" => $val->amount * -1, "currency" => 'USD', "class_id" => $class->class_id, "transaction_refund" => 1);
             $transactionHistoty = new TransactionHistory();
             $transactionHistoty->load($transactionData, '');
             if (!$transactionHistoty->save()) {
                 throw new Exception($e->getMessage());
             }
         }
     }
 }
Exemple #6
0
 private function getDisputeCount()
 {
     return $this->hasOne(TransactionHistory::className(), ['class_id' => 'class_id'])->where(['transaction_dispute_status' => 'open'])->count();
 }