- azoblu3
- Nombre de messages : 3
Date d'inscription : 04/03/2010
AIDE - Le transport ne s'ajoute pas
Jeu 11 Mar 2010 - 13:40
Bonjour!
J'utilise PHP en localhost pour créer des factures dans Acomba.
Tout se passe bien, mais le transport n'apparait pas dans la facture dans Acomba.
Pourtant, elle passe bien dans la requête et il n'y a pas d'erreurs, mais le champ transport dans Acomba reste à zéro.
Voici le code PHP:
Et voici le traçage que ca donne dans mon navigateur:
Merci de votre aide!
J'utilise PHP en localhost pour créer des factures dans Acomba.
Tout se passe bien, mais le transport n'apparait pas dans la facture dans Acomba.
Pourtant, elle passe bien dans la requête et il n'y a pas d'erreurs, mais le champ transport dans Acomba reste à zéro.
Voici le code PHP:
- Code:
<?php
function AcombaAddFactureClient($conn, $cust_no, $inv_no, $trns_type, $ref_no, $desc, $num_lines, $sales_rep_number, $transport, $array_lines) {
$error = false;
/*ON VA CHERCHER LE UNIQUE ID DU CUSTOMER*/
$queryCustomer = "SELECT * from Customer WHERE CuNumber = '".$cust_no."'";
$rs_acomba_cust = $conn->Execute($queryCustomer);
$cusId = 1;
$cusName = "";
$cusCareOf = "";
$cusAddress = "";
$cusCity = "";
$cusPostalCode = "";
$cusISOCountryCode = "";
$CuTaxGroupCP = 1;
if(false != $rs_acomba_cust && $rs_acomba_cust->fields['RecCardPos'] != '') {
$cusId = $rs_acomba_cust->fields['RecCardPos'];
$cusName = $rs_acomba_cust->fields['CuName'];
$cusName = str_replace(',', ' ', $cusName);
$cusName = str_replace("'", ' ', $cusName);
$cusCareOf = $rs_acomba_cust->fields['CuCareOf'];
$cusCareOf = str_replace(',', ' ', $cusCareOf);
$cusCareOf = str_replace("'", ' ', $cusCareOf);
$cusAddress = $rs_acomba_cust->fields['CuAddress'];
$cusAddress = str_replace(',', ' ', $cusAddress);
$cusAddress = str_replace("'", ' ', $cusAddress);
$cusCity = $rs_acomba_cust->fields['CuCity'];
$cusCity = str_replace(',', ' ', $cusCity);
$cusCity = str_replace("'", ' ', $cusCity);
$CuTaxGroupCP = $rs_acomba_cust->fields['CuTaxGroupCP'];
$cusPostalCode = $rs_acomba_cust->fields['CuPostalCode'];
$cusISOCountryCode = $rs_acomba_cust->fields['CuISOCountryCode'];
}
/*ON VA VERIFIER LE NUMERO DU VENDEUR*/
$querySalesRep = "SELECT RecCardPos FROM SalesRep WHERE SRNumber = ".$sales_rep_number;
$rs_acomba_rep = $conn->Execute($querySalesRep);
$salesRep = 9999;
if(false != $rs_acomba_rep && $rs_acomba_rep->fields['RecCardPos'] != '') {
$salesRep = $rs_acomba_rep->fields['RecCardPos'];
}
/*ON FAIT L'INSERTION DU HEADER DE LA TRANSACTION*/
$conn->Execute("BEGIN_TRANSACTION_IN");
$query = "insert into TransactionHeader (InInvoiceNumber, InInvoiceType, InReference, InDescription, InCurrentDay, InTransactionActive, InCustomerSupplierCP, InTaxGroupCP, TANumLines, InSalesRepCP, InName, InCareOf, InAddress, InCity, InPostalCode, InISOCountryCode) values ('".$inv_no."', ".(int)$trns_type.", '".$ref_no."', '".$desc."', 1, 1, ".(int)$cusId.", ".$CuTaxGroupCP." , ".(int)$num_lines.", ".$salesRep.", '".$cusName."', '".$cusCareOf."', '".$cusAddress."', '".$cusCity."', '".$cusPostalCode."', '".$cusISOCountryCode."')";
$rs_acomba_new_invoice_header = $conn->Execute($query);
if(false == $rs_acomba_new_invoice_header) {
echo "Add invoice header failed! <br>query: $query<br><br><br>";
$conn->Execute("CANCEL_TRANSACTION_IN");
$error = true;
}else {
//echo "acomba::add_invoice_header, add successfull: <br>query: $query<br><br><br>";
}
foreach($array_lines as $ligne) {
/*ON VA CHERCHER LE ID DU GROUPE DU PRODUIT*/
$queryProduit = "SELECT RecCardPos, PrProductGroupCP, PrDescription1, PrDescription2, PrDescription3 FROM Product where PrNumber = '".$ligne['product_number']."'";
$rs_acomba_product = $conn->Execute($queryProduit);
$productCP = '';
$productDescription = $ligne['product_description'];
$productGroup = 1;
if(false != $rs_acomba_product) {
if($rs_acomba_product->fields['PrProductGroupCP'] != ''){
$productCP = ", ILProductCP = ".$rs_acomba_product->fields['RecCardPos'];
$productGroup = $rs_acomba_product->fields['PrProductGroupCP'];
$productDescription = $rs_acomba_product->fields['PrDescription1']." ".$rs_acomba_product->fields['PrDescription2']." ".$rs_acomba_product->fields['PrDescription3'];
}
}
/*ON INSERE NOS LIGNES DE TRANSACTION*/
$query_ligne = "update TransactionDetail set ILType = ".$trns_type.", ILLineNumber = ".$ligne['line_number'].", ILProductNumber = '".$ligne['product_number']."', ILDescription = '".$productDescription."', ILSellingPrice = ".$ligne['selling_price'].", ILProductGroupCP = ".$productGroup.", ILOrderedQty = ".$ligne['invoiced_qty'].", ILInvoicedQty = ".$ligne['invoiced_qty'].$productCP." where TaNum = ".$ligne['line_number'];
$rs_acomba_new_invoice_line = $conn->Execute($query_ligne);
if(false == $rs_acomba_new_invoice_line) {
echo "Add line failed! <br>query: $query_ligne<br><br><br>";
$conn->Execute("CANCEL_TRANSACTION_IN");
$error = true;
}else {
//echo "acomba::add_invoice_line, add successfull: <br>query: $query_ligne<br><br><br>";
}
}
if(!$error){
$conn->Execute("CALCULATE_TAXES");
}
if($transport != 0 && !$error){
$transport_line = $num_lines + 3;
$query_transport = "update TransactionDetail set ILType = 7, ILLineNumber = 991, ILTotalAmount = ".$transport." where TaNum = ".$transport_line;
$rs_acomba_transport_line = $conn->Execute($query_transport);
if(false == $rs_acomba_transport_line) {
echo "Add line failed! <br>query: $rs_acomba_transport_line<br><br><br>";
$conn->Execute("CANCEL_TRANSACTION_IN");
$error = true;
}else {
$conn->Execute("CALCULATE_TAXES");
//echo "acomba::add_invoice_line, add successfull: <br>query: $query_ligne<br><br><br>";
}
}
if(!$error){
$conn->Execute("END_TRANSACTION_IN");
}
}
?>
Et voici le traçage que ca donne dans mon navigateur:
- Code:
(odbc): SELECT * from Customer WHERE CuNumber = '0006865241'
(odbc): SELECT RecCardPos FROM SalesRep WHERE SRNumber = 82
(odbc): BEGIN_TRANSACTION_IN
(odbc): insert into TransactionHeader (InInvoiceNumber, InInvoiceType, InReference, InDescription, InCurrentDay, InTransactionActive, InCustomerSupplierCP, InTaxGroupCP, TANumLines, InSalesRepCP, InName, InCareOf, InAddress, InCity, InPostalCode, InISOCountryCode) values ('XXX4365435', 1, 'REFERENCENUMBER', 'Deux Items Attention', 1, 1, 15, 1 , 2, 2, 'JOHNNY S DREAM --', 'ACCOUNTING', '6901 OKEECHOBEE BLVD UNIT D1', 'WEST PALM BEACH FL 33411', '', 'US')
(odbc): SELECT RecCardPos, PrProductGroupCP, PrDescription1, PrDescription2, PrDescription3 FROM Product where PrNumber = 'XXX0001'
(odbc): update TransactionDetail set ILType = 1, ILLineNumber = 1, ILProductNumber = 'XXX0001', ILDescription = 'Produit 1', ILSellingPrice = 12.42, ILProductGroupCP = 1, ILOrderedQty = 124, ILInvoicedQty = 124 where TaNum = 1
(odbc): SELECT RecCardPos, PrProductGroupCP, PrDescription1, PrDescription2, PrDescription3 FROM Product where PrNumber = 'XXX002'
(odbc): update TransactionDetail set ILType = 1, ILLineNumber = 2, ILProductNumber = 'XXX002', ILDescription = 'Produit 2', ILSellingPrice = 0.54, ILProductGroupCP = 1, ILOrderedQty = 1020, ILInvoicedQty = 1020 where TaNum = 2
(odbc): CALCULATE_TAXES
(odbc): update TransactionDetail set ILType = 7, ILLineNumber = 991, ILTotalAmount = 10000 where TaNum = 5
(odbc): CALCULATE_TAXES
(odbc): END_TRANSACTION_IN
Merci de votre aide!
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum