有什么方法可以使用XML Integration从PHP创建公司?想法是,当我在用PHP开发的Web应用程序中添加客户时,应该同时在Tally中以相同的名称创建公司。
我已经尝试过使用此代码,但无法完成:-
$name = $_POST['nm'];
$requestXML = '<?xml version="1.0"?>
<ENVELOPE>
<HEADER>
<TALLYREQUEST>Import Data</TALLYREQUEST>
</HEADER>
<BODY>
<IMPORTDATA>
<REQUESTDESC>
<REPORTNAME>All Masters</REPORTNAME>
</REQUESTDESC>
<REQUESTDATA>
<TALLYMESSAGE xmlns:UDF="TallyUDF">
<COMPANY NAME="'.$name.'" ACTION="Create">
<!-- enable Maintain Multiple Godown -->
<ISMULTIGODOWNON>Yes</ISMULTIGODOWNON>
<!-- enable Use Debit/Credit Notes -->
<ISDCNOTEON>Yes</ISDCNOTEON>
<!-- enable Use Invoice mode for Credit Notes -->
<DNOTEASINVOICE>Yes</DNOTEASINVOICE>
<!-- enable Use Invoice mode for Debit notes -->
<CNOTEASINVOICE>Yes</CNOTEASINVOICE>
<!-- enable Use 0 valued entries in vouchers -->
<USEZEROENTRIES>Yes</USEZEROENTRIES>
</COMPANY>
</TALLYMESSAGE>
</REQUESTDATA>
</IMPORTDATA>
</BODY>
</ENVELOPE>';
/* Actual code for importing goes here */
$server = 'http://localhost:9000';
$headers = array( "Content-type: text/xml" ,"Content-length: ".strlen($requestXML) ,"Connection: close" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $server);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
if(curl_errno($ch))
{
print curl_error($ch);
echo " something went wrong..... try later";
}
else
{
echo " request accepted";
print $data;
curl_close($ch);
}
}