| @@ 939-956 (lines=18) @@ | ||
| 936 | * @return int |
|
| 937 | * @throws \EE_Error |
|
| 938 | */ |
|
| 939 | public function update_sold() { |
|
| 940 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
|
| 941 | array( array( |
|
| 942 | 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 943 | 'REG_deleted' => 0, |
|
| 944 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
|
| 945 | ) ) |
|
| 946 | ); |
|
| 947 | $sold = $this->sold(); |
|
| 948 | if ($count_regs_for_this_datetime > $sold) { |
|
| 949 | $this->increase_sold($count_regs_for_this_datetime - $sold); |
|
| 950 | $this->save(); |
|
| 951 | } else if ($count_regs_for_this_datetime < $sold) { |
|
| 952 | $this->decrease_sold($count_regs_for_this_datetime - $sold); |
|
| 953 | $this->save(); |
|
| 954 | } |
|
| 955 | return $count_regs_for_this_datetime; |
|
| 956 | } |
|
| 957 | } |
|
| 958 | ||
| 959 | /* End of file EE_Datetime.class.php */ |
|
| @@ 1392-1410 (lines=19) @@ | ||
| 1389 | * @return int |
|
| 1390 | * @throws \EE_Error |
|
| 1391 | */ |
|
| 1392 | public function update_tickets_sold() { |
|
| 1393 | $count_regs_for_this_ticket = $this->count_registrations( |
|
| 1394 | array( |
|
| 1395 | array( |
|
| 1396 | 'STS_ID' => EEM_Registration::status_id_approved, |
|
| 1397 | 'REG_deleted' => 0, |
|
| 1398 | ), |
|
| 1399 | ) |
|
| 1400 | ); |
|
| 1401 | $sold = $this->sold(); |
|
| 1402 | if ($count_regs_for_this_ticket > $sold) { |
|
| 1403 | $this->increase_sold($count_regs_for_this_ticket - $sold); |
|
| 1404 | $this->save(); |
|
| 1405 | } else if ($count_regs_for_this_ticket < $sold) { |
|
| 1406 | $this->decrease_sold($count_regs_for_this_ticket - $sold); |
|
| 1407 | $this->save(); |
|
| 1408 | } |
|
| 1409 | return $count_regs_for_this_ticket; |
|
| 1410 | } |
|
| 1411 | ||
| 1412 | ||
| 1413 | ||