darabszám * @param boolean $invoice // Invoice / Receipt * * * @return array|mixed Data without useless information * * @url POST draft */ public function draft(array $cart, boolean $invoice = false, int $billing_id = null) { $array = []; $log_id = ApiNSULog::getLogId(); ApiNSULog::invoiceLog("{$log_id}: DBARRAPIInvoice->draft"); $dbTransactionID = $this->nsuControllerHelper->generateTransactionID($log_id); $lines = $this->nsuControllerHelper->getProductLines($product_id); $apiInvoiceHelper = new ApiInvoiceHelper; $invoiceObj = $apiInvoiceHelper->createInvoice($invoice, $log_id, $company_invoice); ApiNSULog::invoiceLog("{$log_id} Invoice created"); $products = []; foreach ($lines as $line) { $invoiceObj = $apiInvoiceHelper->addLineToInvoice($invoiceObj, $line, $log_id); $product = $apiInvoiceHelper->loadProductToResult($line); if (!empty($product)) { $products[] = $product; } } $invoiceObj->fetch_lines(); foreach ($products as &$row) { foreach ($invoiceObj->lines as $line) { if ($line->product_ref == $row['ref']) { $row['price'] = $line->multicurrency_total_ttc; $row['total_tva'] = $line->total_tva; } } } return $array; } /** * Invoice/createInvoice * * @param string $dolibar_transaction_id //Dolibarr transaction id * @param string $simple_transaction_id //Simple Pay transaction id * @param array $payment //Payment array * @param array $invoice //Invoice array * @param string $log_id //logId * * * * @return array|mixed Data without useless information * * @url POST createInvoice */ public function createInvoice(string $dolibar_transaction_id, string $simple_transaction_id, array $payment, array $invoice, string $log_id) { $array = []; $apiInvoiceHelper = new ApiInvoiceHelper; $invoiceObj = [] $invoiceObj = $apiInvoiceHelper->validateInvoice($invoiceObj, $log_id); /** * set payment */ $apiInvoiceHelper->setPayment($invoiceObj, $payment, $log_id); /** * save card payment data */ if (!empty($cardPaymentLog)) { $invoiceObj = $apiInvoiceHelper->saveCardPaymentLog($invoiceObj, $cardPaymentLog, $log_id); } ApiBbusLog::appLog("{$log_id} Invoice created. ID: {$invoiceObj->id} REF: {$invoiceObj->ref} REQ: {$log_id}"); dol_syslog("{$log_id} Invoice created. ID: {$invoiceObj->id} REF: {$invoiceObj->ref} REQ: {$log_id}", LOG_INFO, 0); //$bbApiLock->delete($user); ApiBbusLog::appLog("{$log_id}####################################################################"); dol_syslog("{$log_id}####################################################################", LOG_INFO, 0); $products = []; return [ 'log_id' => $log_id, 'invoice' => [ 'id' => $invoiceObj->id, 'ref' => $invoiceObj->ref, 'total' => $invoiceObj->multicurrency_total_ttc ], 'products' => $products, ]; return $array; } /** * Invoice/list * * @param int $backenduser_id //ID of the backenduser * @return array|mixed Data without useless information * * @url GET list */ public function list($backenduser_id) { $array = []; $sql = "SELECT * FROM llx_facture as f INNER JOIN llx_facture_extrafields as fe ON fe.fk_facture = f.rowid WHERE fe.backenduser_id = {$backenduser_id}"; $array = $this->nsuControllerHelper->getObject($sql); return $array; } /** * Invoice/details * * @param int $facture_id //Facture rowid * * * @return array|mixed Data without useless information * * @url GET details */ public function deatils(int $facture_id) { global $db; $factureObj = new Facture($db); $result = $factureObj->fetch($facture_id); if($db->num_rows($result) > 0){ return $factureObj; } return []; } /** * Invoice/resend * * @param int $facture_id //Facture rowid * * * @return array|mixed Data without useless information * * @url GET resend */ public function resend(int $facture_id) { $array = []; $note = ""; $this->nsuControllerHelper->emailSender($note, $array); } } class DBARRAPIBilling extends DolibarrApi { public $nsuControllerHelper = new NsuControllerHelper(); /** * billing/create * * @param string $name * @param string $city * @param int $zip * @param string $town * @param int $currency * @param string $currencyCode * * @return array|mixed Data without useless information * * @url POST create */ public function create(string $name, string $city, int $zip, string $town, int $currency, string $currencyCode) { $array = []; global $db, $user; $ThirdPartyObj = new Societe($db); $ThirdPartyObj->nom = $name; $ThirdPartyObj->entity = 1; $ThirdPartyObj->address = $city; $ThirdPartyObj->zip = $zip; $ThirdPartyObj->town = $town; $ThirdPartyObj->fk_multicurrency = $currency; $ThirdPartyObj->multicurrency_code = $currencyCode; $result = $ThirdPartyObj->create($user); if($result){ return $ThirdPartyObj; # Megnézni, hogy mivel tér vissza és mit kell visszaadni. } return $array; } /** * billing/modify * * @param int $thirdpartyID * @param string $name * @param string $city * @param int $zip * @param string $town * @param int $currency * @param string $currencyCode * * @return array|mixed Data without useless information * * @url POST modify */ public function modify(int $thirdpartyID, string $name, string $city, int $zip, string $town, int $currency, string $currencyCode) { $array = []; global $db, $user; $ThirdParty = new Societe($db); $result = $ThirdPartyObj->fetch($thirdpartyID); $ThirdPartyObj->nom = $name; $ThirdPartyObj->entity = 1; $ThirdPartyObj->address = $city; $ThirdPartyObj->zip = $zip; $ThirdPartyObj->town = $town; $ThirdPartyObj->fk_multicurrency = $currency; $ThirdPartyObj->multicurrency_code = $currencyCode; $result = $ThirdPartyObj->update($user); if($result){ return $ThirdPartyObj; # Megnézni, hogy mivel tér vissza és mit kell visszaadni. } return $array; } /** * billing/delete * * @param int $thirdpartyID * @param string $name * @param string $city * @param int $zip * @param string $town * @param int $currency * @param string $currencyCode * * @return array|mixed Data without useless information * * @url POST delete */ public function delete(int $thirdpartyID) { global $db, $user; $ThirdParty = new Societe($db); $result = $ThirdPartyObj->delete($thirdpartyID); if($result){ return true; # Megnézni, hogy mivel tér vissza és mit kell visszaadni. } return false; } } class DBARRAPIFacilities extends DolibarrApi { public $nsuControllerHelper = new NsuControllerHelper(); /** * ticket/list * * @return array|mixed Data without useless information * * @url GET list */ public function list() { $array = []; return $array; } /** * ticket/details * * @param int $facility_id //facility ID * * @return array|mixed Data without useless information * * @url GET details */ public function details(int $facility_id) { $array = []; return $array; } } class DBARRAPITicket extends DolibarrApi { public $nsuControllerHelper = new NsuControllerHelper(); /** * ticket/details * * @param int $ticket_id //ticket rowid * @param int $backend_user_id //backend_user_id * * * @return array|mixed Data without useless information * * @url GET details */ public function details(int $ticket_id, int $backend_user_id) { $array = []; global $db; $NSUTIcketObj = new NSUTicket($db); $result = $NSUTIcketObj->fetch($ticket_id); if($db->num_rows($result) > 0){ return $NSUTIcketObj; } return $array; } /** * ticket/tickets * * @param int $backenduser_id //backend_user_id * * * @return array|mixed Data without useless information * * @url GET tickets */ public function tickets(int $backenduser_id) { $array = []; $facturesArray = DBARRAPIInvoice::list($backenduser_id); if(!empty($facturesArray)){ $tmp_factures_array = []; foreach($facturesArray as $facture){ $tmp_factures_array[] = $facture['rowid']; } $factures = implode(',', $tmp_factures_array); $sql = "SELECT * FROM llx_nsu_ticket as t WHERE t.fk_facture IN ({$factures})"; $array = $this->nsuControllerHelper->getObject($sql); } return $array; } }