|
@@ 881-900 (lines=20) @@
|
| 878 |
|
* @param int $paymentType The payment type to filter (default : Paypal)
|
| 879 |
|
* @return array The sale list. Otherwise return false
|
| 880 |
|
*/
|
| 881 |
|
public function getSaleListByPaymentType($paymentType = self::PAYMENT_TYPE_PAYPAL)
|
| 882 |
|
{
|
| 883 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE);
|
| 884 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY);
|
| 885 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER);
|
| 886 |
|
|
| 887 |
|
$innerJoins = "
|
| 888 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id
|
| 889 |
|
INNER JOIN $userTable u ON s.user_id = u.id
|
| 890 |
|
";
|
| 891 |
|
|
| 892 |
|
return Database::select(
|
| 893 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'],
|
| 894 |
|
"$saleTable s $innerJoins",
|
| 895 |
|
[
|
| 896 |
|
'where' => ['s.payment_type = ? AND s.status = ?' => [intval($paymentType), self::SALE_STATUS_COMPLETED]],
|
| 897 |
|
'order' => 'id DESC'
|
| 898 |
|
]
|
| 899 |
|
);
|
| 900 |
|
}
|
| 901 |
|
|
| 902 |
|
/**
|
| 903 |
|
* Get currency data by ID
|
|
@@ 1002-1021 (lines=20) @@
|
| 999 |
|
* @param int $status The status to filter
|
| 1000 |
|
* @return array The sale list. Otherwise return false
|
| 1001 |
|
*/
|
| 1002 |
|
public function getSaleListByStatus($status = self::SALE_STATUS_PENDING)
|
| 1003 |
|
{
|
| 1004 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE);
|
| 1005 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY);
|
| 1006 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER);
|
| 1007 |
|
|
| 1008 |
|
$innerJoins = "
|
| 1009 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id
|
| 1010 |
|
INNER JOIN $userTable u ON s.user_id = u.id
|
| 1011 |
|
";
|
| 1012 |
|
|
| 1013 |
|
return Database::select(
|
| 1014 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'],
|
| 1015 |
|
"$saleTable s $innerJoins",
|
| 1016 |
|
[
|
| 1017 |
|
'where' => ['s.status = ?' => intval($status)],
|
| 1018 |
|
'order' => 'id DESC'
|
| 1019 |
|
]
|
| 1020 |
|
);
|
| 1021 |
|
}
|
| 1022 |
|
|
| 1023 |
|
/**
|
| 1024 |
|
* Get the statuses for sales
|
|
@@ 1284-1309 (lines=26) @@
|
| 1281 |
|
* @param int $id The user id
|
| 1282 |
|
* @return array The sale list. Otherwise return false
|
| 1283 |
|
*/
|
| 1284 |
|
public function getSaleListByUserId($id)
|
| 1285 |
|
{
|
| 1286 |
|
if (empty($id)) {
|
| 1287 |
|
return [];
|
| 1288 |
|
}
|
| 1289 |
|
|
| 1290 |
|
$saleTable = Database::get_main_table(self::TABLE_SALE);
|
| 1291 |
|
$currencyTable = Database::get_main_table(self::TABLE_CURRENCY);
|
| 1292 |
|
$userTable = Database::get_main_table(TABLE_MAIN_USER);
|
| 1293 |
|
|
| 1294 |
|
$innerJoins = "
|
| 1295 |
|
INNER JOIN $currencyTable c ON s.currency_id = c.id
|
| 1296 |
|
INNER JOIN $userTable u ON s.user_id = u.id
|
| 1297 |
|
";
|
| 1298 |
|
|
| 1299 |
|
return Database::select(
|
| 1300 |
|
['c.iso_code', 'u.firstname', 'u.lastname', 's.*'],
|
| 1301 |
|
"$saleTable s $innerJoins",
|
| 1302 |
|
[
|
| 1303 |
|
'where' => [
|
| 1304 |
|
'u.id = ? AND s.status = ?' => [intval($id), self::SALE_STATUS_COMPLETED]
|
| 1305 |
|
],
|
| 1306 |
|
'order' => 'id DESC'
|
| 1307 |
|
]
|
| 1308 |
|
);
|
| 1309 |
|
}
|
| 1310 |
|
|
| 1311 |
|
/**
|
| 1312 |
|
* Convert the course info to array with necessary course data for save item
|