|
|
@@ -326,7 +326,7 @@ class BBus extends DolibarrApi
|
|
|
$selectedTicket = $ticketChecker->getDataOfTheSelectedTicket();
|
|
|
|
|
|
$ticketChecker->setBbTicketRowId($selectedTicket->id);
|
|
|
-//----
|
|
|
+
|
|
|
$ticketChecker->checkExceptionHandlers($selectedTicket, 'ticketvalidationByPhone', $logId);
|
|
|
|
|
|
$ticketChecker->setMergedTickets($selectedTicket, 'ticketvalidationByPhone', $logId);
|
|
|
@@ -520,8 +520,10 @@ class BBus extends DolibarrApi
|
|
|
if ($printedCopies == 0) {
|
|
|
ApiBbusLog::appLog("printedCopies: no copies");
|
|
|
if (empty($facture_id)) {
|
|
|
+ ApiBbusLog::appLog("No facture_id");
|
|
|
$bbTicketsByFacture = $this->getTicketsByInvoiceNumber($ref);
|
|
|
} else {
|
|
|
+ ApiBbusLog::appLog("Facture_id: " . $facture_id);
|
|
|
$bbTicketsByFacture = $this->getTicketsByFactureId($facture_id);
|
|
|
}
|
|
|
foreach ($bbTicketsByFacture as $ticket) {
|
|
|
@@ -1864,7 +1866,7 @@ class BBus extends DolibarrApi
|
|
|
*/
|
|
|
public function invoice(array $invoice, array $lines, array $payment, string $cardPaymentLog = '', string $sendId = '', $server_host_curl = false, $company_invoice = '')
|
|
|
{
|
|
|
- global $user;
|
|
|
+ global $user, $conf;
|
|
|
$lockLabel = 'CREATE_INVOICE';
|
|
|
if (empty($sendId)) {
|
|
|
$sendId = substr(md5(rand()), 0, 8);
|
|
|
@@ -1895,6 +1897,7 @@ class BBus extends DolibarrApi
|
|
|
|
|
|
|
|
|
$apiInvoiceHelper = new ApiInvoiceHelper;
|
|
|
+ $BookingApi = new BookingApi;
|
|
|
/**
|
|
|
* handle invoice basic data
|
|
|
*/
|
|
|
@@ -1953,14 +1956,30 @@ class BBus extends DolibarrApi
|
|
|
dol_syslog("{$sendId}####################################################################", LOG_INFO, 0);
|
|
|
|
|
|
#-------------- UPDATE BTICKET --------------
|
|
|
- ApiBbusLog::appLog("{$sendId}: Update bbticket with curl");
|
|
|
- $invoiceForCurl['id'] = $invoiceObj->id;
|
|
|
- $invoiceForCurl['ref'] = $invoiceObj->ref;
|
|
|
- //$array['fk_booking_history'] = null;
|
|
|
- $array['invoice'] = $invoiceForCurl;
|
|
|
- $updateBBticketPostFields = json_encode($array);
|
|
|
- ApiBbusLog::appLog("{$updateBBticketPostFields}");
|
|
|
- $this->curlRunner('bookingapi/curlUpdateBbticket', $updateBBticketPostFields, 'POST', true);
|
|
|
+ foreach ($products as $product) {
|
|
|
+ $server_host = '';
|
|
|
+ $proSQL = "SELECT bbs.server_host FROM llx_product as pr
|
|
|
+ INNER JOIN llx_product_extrafields as pre ON pre.fk_object = pr.rowid
|
|
|
+ INNER JOIN llx_bbus_basicservices as bbs ON bbs.rowid = CAST(pre.basic_service AS integer)
|
|
|
+ WHERE pr.rowid = {$product['id']}";
|
|
|
+ $proResult = $this->db->query($proSQL);
|
|
|
+ if ($this->db->num_rows($proResult) > 0) {
|
|
|
+ while ($proRow = $this->db->fetch_object($proResult)) {
|
|
|
+ $server_host = $proRow->server_host;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($server_host == $conf->global->LOCAL_SERVER_HOST) {
|
|
|
+ $BookingApi->updateBbticket(get_object_vars($invoiceObj), null);
|
|
|
+ } else {
|
|
|
+ ApiBbusLog::appLog("{$sendId}: Update bbticket with curl");
|
|
|
+ $invoiceForCurl['id'] = $invoiceObj->id;
|
|
|
+ $invoiceForCurl['ref'] = $invoiceObj->ref;
|
|
|
+ $array['invoice'] = $invoiceForCurl;
|
|
|
+ $updateBBticketPostFields = json_encode($array);
|
|
|
+ ApiBbusLog::appLog("{$updateBBticketPostFields}");
|
|
|
+ $this->curlRunner('bookingapi/curlUpdateBbticket', $updateBBticketPostFields, 'POST', true);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return [
|
|
|
'sendId' => $sendId,
|
|
|
@@ -2333,4 +2352,148 @@ class BBus extends DolibarrApi
|
|
|
}
|
|
|
return $array;
|
|
|
}
|
|
|
+
|
|
|
+ public function giveMeAllProducts()
|
|
|
+ {
|
|
|
+ $productsArray = [];
|
|
|
+ $sql = "SELECT * FROM llx_product";
|
|
|
+ $result = $this->db->query($sql);
|
|
|
+ while ($row = $this->db->fetch_object($result)) {
|
|
|
+ $productsArray[$row->rowid]['product'] = $row;
|
|
|
+ $sqlef = "SELECT * FROM llx_product_extrafields WHERE fk_object = {$row->rowid}";
|
|
|
+ $resultef = $this->db->query($sqlef);
|
|
|
+ while ($rowef = $this->db->fetch_object($resultef)) {
|
|
|
+ $contentef = "-- new Extrafields row {$rowef->rowid}
|
|
|
+ DELETE FROM llx_product_extrafields WHERE fk_object = {$rowef->rowid};
|
|
|
+ INSERT INTO llx_product_extrafields (";
|
|
|
+ $valueContentef = "";
|
|
|
+ $keyNumberef = count((array)$rowef);
|
|
|
+ $keyNumberef - 2;
|
|
|
+ $counteref = 1;
|
|
|
+ foreach ($rowef as $efkey => $efvalue) {
|
|
|
+ if ($efkey == 'oneoccasion' || $efkey == 'online') {
|
|
|
+ $counteref++;
|
|
|
+ } else {
|
|
|
+ $contentef .= "{$efkey}";
|
|
|
+ if ($efkey == 'fk_user_author') {
|
|
|
+ $valueContentef .= intval(1);
|
|
|
+ } elseif ($efkey == 'fk_user_modif') {
|
|
|
+ $valueContentef .= intval(1);
|
|
|
+ } else {
|
|
|
+ $valueContentef .= "{$this->getvvalue($efvalue)}";
|
|
|
+ }
|
|
|
+ if ($counteref <= $keyNumberef - 1) {
|
|
|
+ $contentef .= ", ";
|
|
|
+ $valueContentef .= ", ";
|
|
|
+ } else {
|
|
|
+ $contentef .= ") VALUES (";
|
|
|
+ $valueContentef .= ") ON CONFLICT (rowid) DO NOTHING;";
|
|
|
+ }
|
|
|
+ $counteref++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $asdef = $contentef . $valueContentef;
|
|
|
+ $productsArray[$row->rowid]['extrafields'] = $asdef;
|
|
|
+ }
|
|
|
+ $sqlprice = "SELECT * FROM llx_product_price WHERE fk_product = {$row->rowid}";
|
|
|
+ $resultprice = $this->db->query($sqlprice);
|
|
|
+ while ($rowprice = $this->db->fetch_object($resultprice)) {
|
|
|
+
|
|
|
+ $contentprice = "-- product price rowid: {$rowprice->rowid}
|
|
|
+ DELETE FROM llx_product_price WHERE rowid = {$rowprice->rowid};
|
|
|
+ INSERT INTO llx_product_price (";
|
|
|
+ $valueContentprice = "";
|
|
|
+ $keyNumber = count((array)$rowprice);
|
|
|
+ $counter = 1;
|
|
|
+ foreach ($rowprice as $pricekey => $pricevalue) {
|
|
|
+ //print $pricekey . "\r\n";
|
|
|
+ $contentprice .= "{$pricekey}";
|
|
|
+ if ($pricekey == 'fk_user_author') {
|
|
|
+ $valueContentprice .= intval(1);
|
|
|
+ } elseif ($pricekey == 'fk_user_modif') {
|
|
|
+ $valueContentprice .= intval(1);
|
|
|
+ } else {
|
|
|
+ $valueContentprice .= "{$this->getvvalue($pricevalue)}";
|
|
|
+ }
|
|
|
+ if ($counter <= $keyNumber - 1) {
|
|
|
+ $contentprice .= ", ";
|
|
|
+ $valueContentprice .= ", ";
|
|
|
+ } else {
|
|
|
+ $contentprice .= ") VALUES (";
|
|
|
+ $valueContentprice .= ") ON CONFLICT (rowid) DO NOTHING;";
|
|
|
+ }
|
|
|
+ $counter++;
|
|
|
+ }
|
|
|
+ $asdprice = $contentprice . $valueContentprice;
|
|
|
+ $productsArray[$row->rowid]['prices'] = $asdprice;
|
|
|
+ }
|
|
|
+ //exit;
|
|
|
+ }
|
|
|
+ foreach ($productsArray as $key => $value) {
|
|
|
+ $content = "-- product rowid: {$key}
|
|
|
+ INSERT INTO llx_product (";
|
|
|
+ $valueContent = "";
|
|
|
+ $keyNumber = count((array)$value['product']);
|
|
|
+ $counter = 1;
|
|
|
+ foreach ($value['product'] as $vkey => $vvalue) {
|
|
|
+ $content .= "{$vkey}";
|
|
|
+ if ($vkey == 'fk_user_author') {
|
|
|
+ $valueContent .= intval(1);
|
|
|
+ } elseif ($vkey == 'fk_user_modif') {
|
|
|
+ $valueContent .= intval(1);
|
|
|
+ } else {
|
|
|
+ $valueContent .= "{$this->getvvalue($vvalue)}";
|
|
|
+ }
|
|
|
+ if ($counter <= $keyNumber - 1) {
|
|
|
+ $content .= ", ";
|
|
|
+ $valueContent .= ", ";
|
|
|
+ } else {
|
|
|
+ $content .= ") VALUES (";
|
|
|
+ $valueContent .= ") ON CONFLICT (rowid) DO NOTHING;";
|
|
|
+ }
|
|
|
+ $counter++;
|
|
|
+ }
|
|
|
+ $asd = $content . $valueContent;
|
|
|
+ print $asd . "\r\n";
|
|
|
+ print $value['extrafields'] . "\r\n";
|
|
|
+ print $value['prices'] . "\r\n";
|
|
|
+ }
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ function getvvalue($value)
|
|
|
+ {
|
|
|
+ //$value = str_replace("'", '"', $value);
|
|
|
+ if (is_numeric($value)) {
|
|
|
+ $value = intval($value);
|
|
|
+ } else {
|
|
|
+ if (is_null($value)) {
|
|
|
+ $value = 'NULL';
|
|
|
+ } else {
|
|
|
+ $value = "'" . $value . "'";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $value;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get events ids
|
|
|
+ *
|
|
|
+ * @return array|mixed Data without useless information
|
|
|
+ *
|
|
|
+ * @url POST /getAllEventids
|
|
|
+ */
|
|
|
+ public function getAllEventids()
|
|
|
+ {
|
|
|
+ global $db;
|
|
|
+ $array = [];
|
|
|
+ $sql = "SELECT rowid FROM llx_bbus_basicservices WHERE is_event = '1'";
|
|
|
+ $result = $db->query($sql);
|
|
|
+ if($db->num_rows($result) > 0){
|
|
|
+ while($row = $db->fetch_object($result)){
|
|
|
+ $array[] = $row->rowid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $array;
|
|
|
+ }
|
|
|
}
|