szollosil 1 yıl önce
ebeveyn
işleme
374779ba3c

+ 4 - 0
custom/bbus/class/api_bbus.class.php

@@ -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) {
@@ -1895,6 +1897,7 @@ class BBus extends DolibarrApi
 
 
 		$apiInvoiceHelper = new ApiInvoiceHelper;
+		$BookingApi = new BookingApi;
 		/**
 		 * handle invoice basic data
 		 */
@@ -1952,6 +1955,7 @@ class BBus extends DolibarrApi
 		ApiBbusLog::appLog("{$sendId}####################################################################");
 		dol_syslog("{$sendId}####################################################################", LOG_INFO, 0);
 
+		$BookingApi->updateBbticket(get_object_vars($invoiceObj), null);
 		#-------------- UPDATE BTICKET --------------
 		ApiBbusLog::appLog("{$sendId}: Update bbticket with curl");
 		$invoiceForCurl['id'] = $invoiceObj->id;

+ 5 - 3
custom/bbus/class/commissionhandler.class.php

@@ -216,8 +216,11 @@ class CommissionHandler
         $crossShoppingFactures = $this->curlRunner('bookingapi/getPrintedFacturesRefs', $postFields, 'POST', true);
         $sql = $this->createSQL($from, $to, $currency, $code, $entity, $user_id, $allComissionInvoicesOfUserInTheGroupFromUserInvoice, $crossShoppingFactures);
         $commissions = $this->getMulticurrencyTotalTTC($sql);
-        $sqlCroSho = $this->createSQL($from, $to, $currency, $code, $entity, $user_id, $allComissionInvoicesOfUserInTheGroupFromUserInvoice, $crossShoppingFactures, true);
-        $commissionsCroSho = $this->getMulticurrencyTotalTTC($sqlCroSho);
+        $commissionsCroSho = 0;
+        if($crossShoppingFactures !== ""){
+            $sqlCroSho = $this->createSQL($from, $to, $currency, $code, $entity, $user_id, $allComissionInvoicesOfUserInTheGroupFromUserInvoice, $crossShoppingFactures, true);
+            $commissionsCroSho = $this->getMulticurrencyTotalTTC($sqlCroSho);
+        }
         return $commissions + $commissionsCroSho;
     }
 
@@ -255,7 +258,6 @@ class CommissionHandler
         AND fk_mode_reglement = (SELECT id FROM public.llx_c_paiement WHERE entity = {$entity} AND code = '{$code}')
         AND multicurrency_code = '{$currency}' 
         AND date_closing BETWEEN '{$from}' AND '{$to}'";
-
         return $sql;
     }
 

+ 4 - 3
custom/bbus/class/roller_handling_helper.class.php

@@ -157,9 +157,10 @@ trait RollerHandligHelper
         $sql = "SELECT bbt.* FROM llx_bbus_bbticketinvoiceprinting as bbtip 
             INNER JOIN llx_product_extrafields as pre ON pre.fk_object = bbtip.product_id
             INNER JOIN llx_bbus_bbticket as bbt ON bbt.rowid = bbtip.ticket_id
+            INNER JOIN llx_bbus_basicservices as bbs ON bbs.rowid = CAST(pre.basic_service AS integer)
             WHERE bbtip.invoice_number = '{$invoice_number}'
             AND bbtip.printing_date_timestamp = '{$timestamp}'
-            AND pre.basic_service IN ('2','3')
+			AND bbs.server_host = 'excelia'
             ORDER BY bbtip.rowid DESC limit 1";
         $result = $this->db->query($sql);
         if ($this->db->num_rows($result) > 0) {
@@ -191,8 +192,8 @@ trait RollerHandligHelper
         if ($ticket_id !== '') {
             $sql = "SELECT expire_at FROM llx_bbus_bbticket WHERE rowid = {$ticket_id}";
             $result = $this->db->query($sql);
-            if($this->db->num_rows($result) > 0){
-                while($row = $this->db->fetch_object($result)){
+            if ($this->db->num_rows($result) > 0) {
+                while ($row = $this->db->fetch_object($result)) {
                     if (strtotime($row->expire_at) < strtotime($now)) {
                         return true;
                     } else {

+ 1 - 1
custom/bbus/core/triggers/interface_99_modBBus_BBusTriggers.class.php

@@ -133,7 +133,7 @@ class InterfaceBBusTriggers extends DolibarrTriggers
 			case 'LINEBILL_INSERT':
 				$productObj = new Product($this->db);
 				$productObj->fetch($object->fk_product);
-				if ($productObj->array_options['options_basic_service'] == '3') {
+				if ($productObj->array_options['options_basic_service'] == '3'   || $productObj->array_options['options_basic_service'] == '4') {
 					ApiBbusLog::appLog("LINEBILL_INSERT->basic_service = " . $productObj->array_options['options_basic_service']);
 					$bbTicketHandler = new BbTicketHandler();
 					$bbTicketHandler->addTicket($object, $action);

+ 12 - 10
custom/booking/class/api_booking.class.php

@@ -882,10 +882,11 @@ class BookingApi extends DolibarrApi
 			ApiBbusLog::appLog("{$this->db->error()}");
 			throw new RestException(401, "{$this->db->error()}");
 		}
+		$addedsql = $fk_booking_history == null ? "" : " booking_history_id = {$fk_booking_history},";
 		if ($this->db->num_rows($data) > 0) {
 			while ($row = $this->db->fetch_object($data)) {
 				$sql = "UPDATE llx_bbus_bbticket
-					SET booking_history_id = {$fk_booking_history}, invoice_number = '{$invoice['ref']}'
+					SET {$addedsql} invoice_number = '{$invoice['ref']}'
 					WHERE rowid = {$row->rowid}";
 				ApiBbusLog::appLog("{$sql}");
 				$this->db->query($sql);
@@ -1513,7 +1514,6 @@ class BookingApi extends DolibarrApi
 	 *
 	 * @param 	string		$from
 	 * @param 	string		$to
-	 * @param 	string		$factures
 	 * 
 	 * @url	POST getPrintedFacturesRefsArray
 	 
@@ -1523,19 +1523,21 @@ class BookingApi extends DolibarrApi
 	 * @throws RestException 506 No available spaces
 	 * 
 	 */
-	public function getPrintedFacturesRefsArray(string $from, string $to, string $factures)
+	public function getPrintedFacturesRefsArray(string $from, string $to, string $factures = '')
 	{
 		$refs = [];
-		global $db, $conf;
-		$curluser_id = $conf->global->CURL_USER_ID;
-		$sql = "SELECT bbt.invoice_number 
+		if ($factures !== '') {
+			global $db, $conf;
+			$curluser_id = $conf->global->CURL_USER_ID;
+			$sql = "SELECT bbt.invoice_number 
 				FROM llx_bbus_bbticket as bbt 
 				INNER JOIN llx_bbus_bbticketinvoiceprinting as bbtip ON bbtip.ticket_id = bbt.rowid 
 				WHERE bbt.fk_user_creat = {$curluser_id} AND bbt.invoice_number IN ({$factures}) AND bbt.date_creation BETWEEN '{$from}' AND '{$to}' ORDER BY bbt.rowid DESC";
-		$result = $db->query($sql);
-		if ($db->num_rows($result) > 0) {
-			while ($row = $db->fetch_object($result)) {
-				$refs[] = $row->invoice_number;
+			$result = $db->query($sql);
+			if ($db->num_rows($result) > 0) {
+				while ($row = $db->fetch_object($result)) {
+					$refs[] = $row->invoice_number;
+				}
 			}
 		}
 		return $refs;

+ 0 - 1
custom/settlements/class/daily_closing.class.php

@@ -324,7 +324,6 @@ class DailyClosing
         $params = ["from" => $startdate, "to" => $now, "factures" => $crossShoppingFacturesString];
         $postFields = json_encode($params);
         $crossShoppingFactures = $this->curlRunner('bookingapi/getPrintedFacturesRefsArray', $postFields, 'POST', true);
-
         $data = $db->query($sql);
         while ($row2 = pg_fetch_assoc($data)) {
             if (in_array($row2['ref'], $crossShoppingFactures)) {