|
|
@@ -1442,7 +1442,7 @@ class BookingApi extends DolibarrApi
|
|
|
}
|
|
|
$ticket = new BbTicket($db);
|
|
|
$ticket->fk_facture = null;
|
|
|
- $ticket->bundle_id = $product_id;
|
|
|
+ $ticket->bundle_id = $this->getProductAssociationPere($product_id);
|
|
|
$ticket->usable_occasions = $occasions;
|
|
|
$ticket->usage = '0';
|
|
|
$ticket->available_at = $this->getAvailableAtDate($datec, $validperiod);
|
|
|
@@ -1455,6 +1455,18 @@ class BookingApi extends DolibarrApi
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ private function getProductAssociationPere($product_id)
|
|
|
+ {
|
|
|
+ $pere = $product_id;
|
|
|
+ $sql = "SELECT fk_product_pere FROM " . $this->db->prefix() . "product_association WHERE fk_product_fils = " . $product_id;
|
|
|
+ $result = $this->db->query($sql);
|
|
|
+ if ($this->db->num_rows($result) > 0) {
|
|
|
+ while ($sqlDataResult = $this->db->fetch_object($result)) {
|
|
|
+ return $sqlDataResult->fk_product_pere;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $pere;
|
|
|
+ }
|
|
|
private function getAvailableAtDate($date, $validperiod)
|
|
|
{
|
|
|
$available_at = date('Y-m-d H:i:s', strtotime($date . ' +' . $validperiod . ' days'));
|