tally_integration.php(Main)
<?php
public function getListOfAccount(){
ini_set('display_errors', 1);
$requestXML13 = '<ENVELOPE>
<HEADER>
<TALLYREQUEST>Export Data</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<REPORTNAME>List of Accounts</REPORTNAME>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
</REQUESTDESC>
</EXPORTDATA>
</BODY>
</ENVELOPE>';
$requestXML = '<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST>
<TYPE>Data</TYPE>
<ID>Balance Sheet</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<EXPLODEFLAG>Yes</EXPLODEFLAG>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
</DESC>
</BODY>
</ENVELOPE>';
$requestXML1 = '<ENVELOPE>
<HEADER>
<VERSION>1</VERSION>
<TALLYREQUEST>EXPORT</TALLYREQUEST>
<TYPE>COLLECTION</TYPE>
<ID>Remote Ledger Coll</ID>
</HEADER>
<BODY>
<DESC>
<STATICVARIABLES>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
<TDL>
<TDLMESSAGE>
<COLLECTION NAME="Remote Ledger Coll"
ISINITIALIZE="Yes">
<TYPE>Ledger</TYPE>
<NATIVEMETHOD>Name</NATIVEMETHOD>
<NATIVEMETHOD>OpeningBalance
</NATIVEMETHOD>
</COLLECTION>
</TDLMESSAGE>
</TDL>
</DESC>
</BODY>
</ENVELOPE>';
$arr1 = array();
$DSPDISPNAME = '';
$BSSUBAMT = '';
$BSMAINAMT = '';
$server = 'http://192.168.192.203:9000';
//$server='http://192.168.1.220:9000';
$headers = array("Content-type: text/xml;charset=UTF-8", "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);
} else {
/* My Code */
$p = xml_parser_create();
xml_parse_into_struct($p, $data, $vals, $index);
xml_parser_free($p);
$val_length = count($vals);
$i = 0;
$f1 = 0;
$f2 = 0;
$f3 = 0;
while ($val_length > $i) {
if ($vals[$i]['tag'] == 'DSPDISPNAME') {
$f1 = 1;
foreach ($vals[$i] as $key => $value) {
if ($key == 'value') {
$DSPDISPNAME = '';
if($value != '')
{
$DSPDISPNAME = $value;
}
}
else {
$DSPDISPNAME = '';
}
}
}
else if ($vals[$i]['tag'] == 'BSSUBAMT') {
$f2 = 1;
foreach ($vals[$i] as $key => $value1) {
if ($key == 'value') {
$BSSUBAMT = '';
if($value1 != ''){
$BSSUBAMT = $value1;
}
}
else {
$BSSUBAMT = '';
}
//$BSSUBAMT = '';
}
}
else if ($vals[$i]['tag'] == 'BSMAINAMT') {
$f3 = 1;
foreach ($vals[$i] as $key => $value2) {
if ($key == 'value') {
$BSMAINAMT = '';
if($value2 != ''){
$BSMAINAMT = $value2;
}
}
else {
$BSMAINAMT = '';
}
}
}
if ($f1 == 1 && $f2 == 1 && $f3 == 1) {
array_push($arr1,array('DSPDISPNAME' =>$DSPDISPNAME ,'BSSUAMT' => $BSSUBAMT,'BSMAINAMT'=>$BSMAINAMT));
$f1=0;
$f2=0;
$f3=0;
}
$i++;
}
/* end My Code */
$data1['balace_sheet'] = $arr1;
$this->load->view('account/list_of_account', $data1);
curl_close($ch);
}
}
?>
great working for me
ReplyDeleteThank you dear
Deletebut same code i put at in mywebsite which is not working
Deleteerror like
Failed to connect to xxx.xxx.xxx.xxx port 9000: Connection timed out
Hi Leela Krishna,
DeletePlease check your tally ip and port, then put in code. See below :
$server = 'http://111.11.11.11:9000';
Is it possible then send me your tally after login screenshot
HI Sandeep, I think I am missing something. You code suggests that a class need to be used or extended as you are using public function. Please help, as it's not working for me.
ReplyDeleteHi,
DeleteThanks for comment.
Can you please send or post your code to me for debug?
Hi Sandeep, I have created a class Tallydata in a file tally_request2.php. I am getting the error - I am getting -
ReplyDeleteNotice: Undefined property: Tallydata::$load in E:\wamp\www\tally_request2.php
tally_request2.php is the file where I have copied your code.
Hello Sandip, how can send the details of the code to you, I don't have your mail ID.
ReplyDeleteThanks.
@Pawan you can send code to rsweb007@gmail.com id
DeleteHi , Do i need to do any special configuration for tally server to interact via http or directly i can access them
ReplyDeleteYes, You have to set IP address of that PC where tally is installed with port which define in tally.
DeleteThis comment has been removed by the author.
ReplyDeleteI am able to insert a voucher into tally. I saw that Tally creates the voucher Id and GUIID for the record created. How can I get these id's for the newly created voucher. Please advise
ReplyDeleteHi,
DeleteThanks for request.
Can you provide me your tally data and tally version?
And if is possible then send me your PC's IP in which tally installed.
We are using Tally ERP 9.0. I am trying to create the vouchers in tally which I am able to do so. But I would like to know some unique ID which represents the newly created voucher so that I dont create the same voucher again. please advise
DeleteThis comment has been removed by the author.
ReplyDeleteHi,
ReplyDeleteThanks for such a nice code.
I tried it worked for me .
Also modifying as per my requirements, will send output of PHP data to android on request from android
Hi Sandeep
ReplyDeleteI want to integrate Tally ERP to my Magento store. And I am new to Tally ERP.
Could you please guide me how can I achieve it? Does Tally provides API support to integrate it to some shopping carts like Magento?
Thanks for this article.
Hi
DeleteThanks for comment.
Actually I have developed only balance sheet.
But your requirement is totally different. So you have follow tally XML document which provide all kind of tally operation.
Hi Sandip
DeleteThanks for your reply.
Could you please tell me where can I get tally XML document.
Hi Vivek,
DeleteYou can download xml from below links based on requirement:
https://www.rtslink.com/TallyXMLTags.htm
https://docs.google.com/document/d/1vZh3fffXohtEq8H_hyl6ug4TVYKBNtUxhZx4S_VY8Fs/edit
I want to integrate Tally with PHP. Precisely, i want to be able to fetch the GRN details for each GRN- Goods Reecieved note from tally in PHP application. The above code is showing error:Parse error: syntax error, unexpected 'public' (T_PUBLIC) in.. Please, what am i doing wrong? Also,is there another : tally_integration.php(Main) page somewhere else? Pls I need assistance on this
ReplyDeleteHi, Thanks for your comments.
DeleteCan you please share your code?