|
@@ 903-922 (lines=20) @@
|
| 900 |
|
* @param int $paymentType The payment type to filter (default : Paypal) |
| 901 |
|
* @return array The sale list. Otherwise return false |
| 902 |
|
*/ |
| 903 |
|
public function getSaleListByPaymentType($paymentType = self::PAYMENT_TYPE_PAYPAL) |
| 904 |
|
{ |
| 905 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE); |
| 906 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY); |
| 907 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER); |
| 908 |
|
|
| 909 |
|
$innerJoins = " |
| 910 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id |
| 911 |
|
INNER JOIN $userTable u ON s.user_id = u.id |
| 912 |
|
"; |
| 913 |
|
|
| 914 |
|
return Database::select( |
| 915 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
| 916 |
|
"$saleTable s $innerJoins", |
| 917 |
|
[ |
| 918 |
|
'where' => ['s.payment_type = ? AND s.status = ?' => [intval($paymentType), self::SALE_STATUS_COMPLETED]], |
| 919 |
|
'order' => 'id DESC', |
| 920 |
|
] |
| 921 |
|
); |
| 922 |
|
} |
| 923 |
|
|
| 924 |
|
/** |
| 925 |
|
* Get currency data by ID |
|
@@ 1024-1043 (lines=20) @@
|
| 1021 |
|
* @param int $status The status to filter |
| 1022 |
|
* @return array The sale list. Otherwise return false |
| 1023 |
|
*/ |
| 1024 |
|
public function getSaleListByStatus($status = self::SALE_STATUS_PENDING) |
| 1025 |
|
{ |
| 1026 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE); |
| 1027 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY); |
| 1028 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER); |
| 1029 |
|
|
| 1030 |
|
$innerJoins = " |
| 1031 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id |
| 1032 |
|
INNER JOIN $userTable u ON s.user_id = u.id |
| 1033 |
|
"; |
| 1034 |
|
|
| 1035 |
|
return Database::select( |
| 1036 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
| 1037 |
|
"$saleTable s $innerJoins", |
| 1038 |
|
[ |
| 1039 |
|
'where' => ['s.status = ?' => intval($status)], |
| 1040 |
|
'order' => 'id DESC', |
| 1041 |
|
] |
| 1042 |
|
); |
| 1043 |
|
} |
| 1044 |
|
|
| 1045 |
|
/** |
| 1046 |
|
* Get the statuses for sales |
|
@@ 1306-1331 (lines=26) @@
|
| 1303 |
|
* @param int $id The user id |
| 1304 |
|
* @return array The sale list. Otherwise return false |
| 1305 |
|
*/ |
| 1306 |
|
public function getSaleListByUserId($id) |
| 1307 |
|
{ |
| 1308 |
|
if (empty($id)) { |
| 1309 |
|
return []; |
| 1310 |
|
} |
| 1311 |
|
|
| 1312 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE); |
| 1313 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY); |
| 1314 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER); |
| 1315 |
|
|
| 1316 |
|
$innerJoins = " |
| 1317 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id |
| 1318 |
|
INNER JOIN $userTable u ON s.user_id = u.id |
| 1319 |
|
"; |
| 1320 |
|
|
| 1321 |
|
return Database::select( |
| 1322 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'], |
| 1323 |
|
"$saleTable s $innerJoins", |
| 1324 |
|
[ |
| 1325 |
|
'where' => [ |
| 1326 |
|
'u.id = ? AND s.status = ?' => [intval($id), self::SALE_STATUS_COMPLETED], |
| 1327 |
|
], |
| 1328 |
|
'order' => 'id DESC', |
| 1329 |
|
] |
| 1330 |
|
); |
| 1331 |
|
} |
| 1332 |
|
|
| 1333 |
|
/** |
| 1334 |
|
* Convert the course info to array with necessary course data for save item |