|
@@ -102,20 +102,29 @@ class RollerstorageApi extends DolibarrApi
|
|
|
*/
|
|
*/
|
|
|
public function checkPermissionLT()
|
|
public function checkPermissionLT()
|
|
|
{
|
|
{
|
|
|
|
|
+ global $conf, $user;
|
|
|
ApiBbusLog::LunaToursLog("checkPermissionLT_START");
|
|
ApiBbusLog::LunaToursLog("checkPermissionLT_START");
|
|
|
- global $conf;
|
|
|
|
|
- $permissionArray = [];
|
|
|
|
|
- $sqlProductsBasicService = "SELECt p.rowid, p.label, p.description, p.price_ttc, p.price, p.tva_tx FROM llx_product as p
|
|
|
|
|
- INNER JOIN llx_product_extrafields as pe ON pe.fk_object = p.rowid
|
|
|
|
|
- INNER JOIN llx_bbus_basicservices as bs ON bs.basic_service_id = pe.basic_service::integer
|
|
|
|
|
- WHERE bs.server_host = '{$conf->global->LOCAL_SERVER_HOST}'";
|
|
|
|
|
- $productsBasicServices = $this->runQuery($sqlProductsBasicService);
|
|
|
|
|
- foreach ($productsBasicServices as $key => $item) {
|
|
|
|
|
- if ($this->lunatours->localCheckAvailablePlacesForCheckPermission($item->rowid)) {
|
|
|
|
|
- $permissionArray[$item->rowid] = $item;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $memcached = new Memcached();
|
|
|
|
|
+ $memcached->addServer("szollosil-excelia-urbanms-memcached", 11211);
|
|
|
|
|
+
|
|
|
|
|
+ $key = '"' . $user->api_key . '"';
|
|
|
|
|
+
|
|
|
|
|
+ $cacheValue = $memcached->get($key);
|
|
|
|
|
+ if ($cacheValue === false) {
|
|
|
|
|
+ $permissionArray = [];
|
|
|
|
|
+ $sqlProductsBasicService = "SELECt p.rowid, p.label, p.description, p.price_ttc, p.price, p.tva_tx FROM llx_product as p
|
|
|
|
|
+ INNER JOIN llx_product_extrafields as pe ON pe.fk_object = p.rowid
|
|
|
|
|
+ INNER JOIN llx_bbus_basicservices as bs ON bs.basic_service_id = pe.basic_service::integer
|
|
|
|
|
+ WHERE bs.server_host = '{$conf->global->LOCAL_SERVER_HOST}'";
|
|
|
|
|
+ $productsBasicServices = $this->runQuery($sqlProductsBasicService);
|
|
|
|
|
+ $permissionArray = $this->lunatours->createPermissionArray($productsBasicServices);
|
|
|
|
|
+ $cacheValue = json_encode($permissionArray);
|
|
|
|
|
+ $memcached->set($key, $cacheValue, 600); // 5 percig tároljuk
|
|
|
|
|
+ ApiBbusLog::LunaToursLog("Adat betöltve az adatbázisból: " . $cacheValue);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ApiBbusLog::LunaToursLog("Adat betöltve a cache-ből: " . $cacheValue);
|
|
|
}
|
|
}
|
|
|
- return $permissionArray;
|
|
|
|
|
|
|
+ return json_decode($cacheValue, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -164,7 +173,7 @@ class RollerstorageApi extends DolibarrApi
|
|
|
return $createdPreOrderOBJ;
|
|
return $createdPreOrderOBJ;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
|
|
+ /**
|
|
|
* Validate and save invoice
|
|
* Validate and save invoice
|
|
|
*
|
|
*
|
|
|
* Return an array with details
|
|
* Return an array with details
|
|
@@ -190,20 +199,21 @@ class RollerstorageApi extends DolibarrApi
|
|
|
{
|
|
{
|
|
|
ApiBbusLog::LunaToursLog("validateandsaveinvoice: START");
|
|
ApiBbusLog::LunaToursLog("validateandsaveinvoice: START");
|
|
|
$createdInvoiceArray = $this->lunatours->localValidateAndSaveInvoice($invoice, $preorder, $payment, $cardPaymentLog, $company_invoice);
|
|
$createdInvoiceArray = $this->lunatours->localValidateAndSaveInvoice($invoice, $preorder, $payment, $cardPaymentLog, $company_invoice);
|
|
|
- ApiBbusLog::LunaToursLog(json_encode($preorder));
|
|
|
|
|
- foreach ($preorder as $order) {
|
|
|
|
|
- $sql = "SELECT fk_product, fk_event FROM llx_booking_preorder WHERE rowid = {$order}";
|
|
|
|
|
- $data = $this->db->query($sql);
|
|
|
|
|
- if ($this->db->num_rows($data) > 0) {
|
|
|
|
|
- while ($row = $this->db->fetch_object($data)) {
|
|
|
|
|
- $bookingHistory = $this->lunatours->saveEventData((int)$row->fk_event, $createdInvoiceArray[0]['invoice']['id'], null, $createdInvoiceArray[0]['invoice']['ref'], $note);
|
|
|
|
|
- ApiBbusLog::LunaToursLog("______________________________________________________________________________");
|
|
|
|
|
- $this->lunatours->updateBbticket($createdInvoiceArray[0]['invoice'], $bookingHistory);
|
|
|
|
|
- $this->lunatours->deletePreorder($preorder);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ ApiBbusLog::LunaToursLog(json_encode($preorder));
|
|
|
|
|
+ foreach ($preorder as $order) {
|
|
|
|
|
+ $sql = "SELECT fk_product, fk_event FROM llx_booking_preorder WHERE rowid = {$order}";
|
|
|
|
|
+ $data = $this->db->query($sql);
|
|
|
|
|
+ if ($this->db->num_rows($data) > 0) {
|
|
|
|
|
+ while ($row = $this->db->fetch_object($data)) {
|
|
|
|
|
+ $bookingHistory = $this->lunatours->saveEventData((int)$row->fk_event, $createdInvoiceArray[0]['invoice']['id'], null, $createdInvoiceArray[0]['invoice']['ref'], $note);
|
|
|
|
|
+ ApiBbusLog::LunaToursLog("______________________________________________________________________________");
|
|
|
|
|
+ $this->lunatours->updateBbticket($createdInvoiceArray[0]['invoice'], $bookingHistory);
|
|
|
|
|
+ $this->lunatours->deletePreorder($preorder);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
ApiBbusLog::LunaToursLog("validateandsaveinvoice: END");
|
|
ApiBbusLog::LunaToursLog("validateandsaveinvoice: END");
|
|
|
|
|
+ $this->lunatours->emailSender($note, $createdInvoiceArray);
|
|
|
return $createdInvoiceArray;
|
|
return $createdInvoiceArray;
|
|
|
}
|
|
}
|
|
|
|
|
|