@@ 862-881 (lines=20) @@ | ||
859 | * @param int $paymentType The payment type to filter (default : Paypal) |
|
860 | * @return array The sale list. Otherwise return false |
|
861 | */ |
|
862 | public function getSaleListByPaymentType($paymentType = self::PAYMENT_TYPE_PAYPAL) |
|
863 | { |
|
864 | $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE); |
|
865 | $currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY); |
|
866 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
867 | ||
868 | $innerJoins = " |
|
869 | INNER JOIN $currencyTable c ON s.currency_id = c.id |
|
870 | INNER JOIN $userTable u ON s.user_id = u.id |
|
871 | "; |
|
872 | ||
873 | return Database::select( |
|
874 | ['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
|
875 | "$saleTable s $innerJoins", |
|
876 | [ |
|
877 | 'where' => ['s.payment_type = ? AND s.status = ?' => [intval($paymentType), self::SALE_STATUS_COMPLETED]], |
|
878 | 'order' => 'id DESC' |
|
879 | ] |
|
880 | ); |
|
881 | } |
|
882 | ||
883 | /** |
|
884 | * Get currency data by ID |
|
@@ 984-1003 (lines=20) @@ | ||
981 | * @param int $status The status to filter |
|
982 | * @return array The sale list. Otherwise return false |
|
983 | */ |
|
984 | public function getSaleListByStatus($status = self::SALE_STATUS_PENDING) |
|
985 | { |
|
986 | $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE); |
|
987 | $currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY); |
|
988 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
989 | ||
990 | $innerJoins = " |
|
991 | INNER JOIN $currencyTable c ON s.currency_id = c.id |
|
992 | INNER JOIN $userTable u ON s.user_id = u.id |
|
993 | "; |
|
994 | ||
995 | return Database::select( |
|
996 | ['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
|
997 | "$saleTable s $innerJoins", |
|
998 | [ |
|
999 | 'where' => ['s.status = ?' => intval($status)], |
|
1000 | 'order' => 'id DESC' |
|
1001 | ] |
|
1002 | ); |
|
1003 | } |
|
1004 | ||
1005 | /** |
|
1006 | * Get the statuses for sales |
|
@@ 1258-1284 (lines=27) @@ | ||
1255 | * @param int $id The user id |
|
1256 | * @return array The sale list. Otherwise return false |
|
1257 | */ |
|
1258 | public function getSaleListByUserId($id) |
|
1259 | { |
|
1260 | ||
1261 | if (empty($id)) { |
|
1262 | return []; |
|
1263 | } |
|
1264 | ||
1265 | $saleTable = Database::get_main_table(BuyCoursesPlugin::TABLE_SALE); |
|
1266 | $currencyTable = Database::get_main_table(BuyCoursesPlugin::TABLE_CURRENCY); |
|
1267 | $userTable = Database::get_main_table(TABLE_MAIN_USER); |
|
1268 | ||
1269 | $innerJoins = " |
|
1270 | INNER JOIN $currencyTable c ON s.currency_id = c.id |
|
1271 | INNER JOIN $userTable u ON s.user_id = u.id |
|
1272 | "; |
|
1273 | ||
1274 | return Database::select( |
|
1275 | ['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
|
1276 | "$saleTable s $innerJoins", |
|
1277 | [ |
|
1278 | 'where' => [ |
|
1279 | 'u.id = ? AND s.status = ?' => [intval($id), BuyCoursesPlugin::SALE_STATUS_COMPLETED] |
|
1280 | ], |
|
1281 | 'order' => 'id DESC' |
|
1282 | ] |
|
1283 | ); |
|
1284 | } |
|
1285 | ||
1286 | /** |
|
1287 | * Convert the course info to array with necessary course data for save item |