Jump to content

irandoct

Members
  • Posts

    10
  • Joined

  • Last visited

irandoct's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I'm trying to output a text file using php. how may i set this file as ascii? this is my code: function export_listnm(){ global $conn, $Language, $Security; $sdate = preg_replace('/-|:/', null, $_GET['sdate']); $edate = preg_replace('/-|:/', null, $_GET['edate']); $MedicalCouncilNumber = strip_tags(ew_ExecuteScalar("SELECT ConfigValue FROM configs WHERE ConfigKey = 'MedicalCouncilNumber'")); $NIDCode = strip_tags(ew_ExecuteScalar("SELECT ConfigValue FROM configs WHERE ConfigKey = 'NIDCode'")); $MainStaffName = strip_tags(ew_ExecuteScalar("SELECT ConfigValue FROM configs WHERE ConfigKey = 'MainStaffName'")); $MainStaffLastName = strip_tags(ew_ExecuteScalar("SELECT ConfigValue FROM configs WHERE ConfigKey = 'MainStaffLastName'")); $tedadnoskheh = ew_ExecuteScalar("SELECT COUNT(TreatmentID) FROM treatmenthistory WHERE ReportDate >= '".$_GET['sdate']."' AND ReportDate <= '".$_GET['edate']."' AND InsuranceID = '".$_GET['insurance']."'"); $sitename = ew_ExecuteScalar("SELECT ConfigValue FROM configs WHERE ConfigKey = 'SiteName'"); $insurance = ew_ExecuteScalar("SELECT InsuranceName FROM insurances WHERE InsuranceID = '".$_GET['insurance']."'"); $inscode = ew_ExecuteScalar("SELECT InsCode FROM insurances WHERE InsuranceID = '".$_GET['insurance']."'"); $cliniccode = ew_ExecuteScalar("SELECT ClinicCode FROM insurances WHERE InsuranceID = '".$_GET['insurance']."'"); $Percentage = ew_ExecuteScalar("SELECT Percentage FROM insurances WHERE InsuranceID = '".$_GET['insurance']."'"); $conn->Execute("SET @row_num = 0;"); $sSqlWrk = "SELECT @row_num := @row_num + 1 as row_number, treatmenthistory.*, referrers.RefName, referrers.MedicalCouncil, patients.FullName, patients.gender FROM treatmenthistory join referrers on treatmenthistory.RefID = referrers.RefID join patients on treatmenthistory.PatientID = patients.PatientID WHERE treatmenthistory.ReportDate >= '".$_GET['sdate']."' AND treatmenthistory.ReportDate <= '".$_GET['edate']."' AND InsuranceID = '".$_GET['insurance']."' ORDER BY treatmenthistory.ReceptionDate ASC"; $theres = $conn->Execute($sSqlWrk); if (!file_exists('insurancereports')) { mkdir('insurancereports', 0777, true); } $f = fopen("insurancereports/insurance.txt", "a"); fwrite($f, "<Y>\n"); fwrite($f, "<HR>\n"); fwrite($f, "<DC>".$cliniccode."</DC>\n"); fwrite($f, "<DN>".$sitename."</DN>\n"); fwrite($f, "<CR>kimia System 09133999236</CR>\n"); fwrite($f, "<RC>".$tedadnoskheh."</RC>\n"); fwrite($f, "<FD>".$sdate."</FD>\n"); fwrite($f, "<TD>".$edate."</TD>\n"); fwrite($f, "<MC>".$MedicalCouncilNumber."</MC>\n"); fwrite($f, "<NM>".$NIDCode."</NM>\n"); fwrite($f, "<AN>".$MainStaffName."</AN>\n"); fwrite($f, "<AF>".$MainStaffLastName."</AF>\n"); fwrite($f, "</HR>\n"); while (!$theres->EOF) { $row = ew_ExecuteRow("SELECT SUM(ExPriceIns) AS ExPriceIns FROM treatmentdetails WHERE TreatmentID = '".$theres->fields('TreatmentID')."'"); $fullprice = $row["ExPriceIns"]; $patientprice = $fullprice * $Percentage /100; $insprice = $fullprice - $patientprice; if ($theres->fields('gender') == "F"){ $gender = "0"; }else if ($theres->fields('gender') == "M"){ $gender = "1"; } $orderdate = preg_replace('/-|:/', null, $theres->fields('InsOrderDate')); $insuranceenddate = preg_replace('/-|:/', null, $theres->fields('InsEndDate')); $firstsession = ew_ExecuteScalar("SELECT VisitDay FROM appointments WHERE TreatmentID = '".$theres->fields('TreatmentID')."' AND IsCanceled = 'N' ORDER BY VisitDay ASC LIMIT 1"); $firstsession = preg_replace('/-|:/', null, $firstsession); $lastsession = ew_ExecuteScalar("SELECT VisitDay FROM appointments WHERE TreatmentID = '".$theres->fields('TreatmentID')."' AND IsCanceled = 'N' ORDER BY VisitDay DESC LIMIT 1"); $lastsession = preg_replace('/-|:/', null, $lastsession); fwrite($f, "<X>\n"); fwrite($f, "<PH>\n"); fwrite($f, "<SQ>".$theres->fields('row_number')."</SQ><ND>".$orderdate."</ND><RD>".$firstsession."</RD><LD>".$lastsession."</LD><VD>".$insuranceenddate."</VD><PT>".$inscode."</PT><SN>".$theres->fields('InsuranceNumber')."</SN><GR>".$gender."</GR><RN>".$theres->fields('InsPageNumber')."</RN><PG>1</PG><PC>".$theres->fields('MedicalCouncil')."</PC><DD>18</DD><PP>".$fullprice."</PP><IS>".$insprice."</IS><PS>".$patientprice."</PS>\n"); fwrite($f, "</PH>\n"); $sSqlWrk2 = "SELECT treatmentdetails.*, products.ProductCode FROM treatmentdetails join products on treatmentdetails.ProductID = products.ProductID WHERE treatmentdetails.TreatmentID = '".$theres->fields('TreatmentID')."' AND treatmentdetails.ShowInList = 'Y'"; $theres2 = $conn->Execute($sSqlWrk2); while (!$theres2->EOF) { $sahmbimeh = $theres2->fields('ExPriceIns') * $Percentage / 100; $sahmbimar = $theres2->fields('ExPriceIns') - $sahmbimeh; fwrite($f, "<MH><MG>".$theres2->fields('ProductCode')."</MG><OZ></OZ><NG>".$theres2->fields('Quantity')."</NG><NA>".$theres2->fields('BodyAreaIns')."</NA><FC>".$MedicalCouncilNumber."</FC><TK>1</TK><MD>".$theres2->fields('Quantity')."</MD><MR>".$theres2->fields('Quantity')."</MR><MP>".$theres2->fields('ExPriceIns')."</MP><MI>".$sahmbimeh."</MI><MS>".$sahmbimar."</MS></MH>\n"); $theres2->MoveNext(); } $theres2->Close(); fwrite($f, "<BY>\n"); fwrite($f, "</BY>\n"); fwrite($f, "</X>\n"); $theres->MoveNext(); } $theres->Close(); fwrite($f, "</Y>\n"); fclose($f); echo "<br><br>"; echo "<a href=insurancereports/insurance.txt>Download</a>"; echo "<br><br><br><br>"; } please help me save the text file as ascii! Thank you Mansour
  2. Hi, I changed my code to: $client = new SoapClient("http://sms-webservice.ir/v1/v1.asmx?wsdl"); $params = array( 'Username'=>$username, 'PassWord'=>$password, 'numberOfMessages'=>$numberOfMessages, 'destNumber'=>$destNumber, 'ErrNum'=>$ErrNum, ); $result = $client->GetAllMessages( $params ); if (is_soap_fault($result)) { echo '<h2>Fault:</h2><pre>'; print_r($result); echo '</pre>'; } else { $res = $result->GetAllMessagesResult->ArrayOfString; foreach($res as $key => $value){ $string = $value->string; $MyResult = ew_Execute("INSERT INTO receivedsms (MessageID, ReceiverNumber, SenderNumber, MessageTxt, ReceiveDate) VALUES ('".$string['0']."', '".$string['1']."', '".$string['2']."', '".$string['3']."', '".$string['4']."')"); } my script return the following error: Notice: Trying to get property of non-object in C:\xampp\htdocs\ourclinic\sendmessage.php on line 290 Please advise! Mansour
  3. thank you for your reply. i'm not familiar with php (biginner)! please post complete code! Regards Mansour
  4. Hi, i'm using SoapClient. i want to save result of SoapClient to a mysql database. my php code for webservice: $client = new SoapClient("http://sms-webservice.ir/v1/v1.asmx?wsdl"); $params = array( 'Username'=>$username, 'PassWord'=>$password, 'numberOfMessages'=>$numberOfMessages, 'destNumber'=>$destNumber, 'ErrNum'=>$ErrNum, ); $result = $client->GetAllMessages( $params ); if (is_soap_fault($result)) { echo '<h2>Fault:</h2><pre>'; print_r($result); echo '</pre>'; } else { $res = $result->GetAllMessagesResult->ArrayOfString; echo "<div dir=ltr>"; foreach($res as $key => $value){ print_r ($value); //$MyResult = ew_Execute("INSERT INTO receivedsms (MessageID, ReceiverNumber, SenderNumber, MessageTxt, ReceiveDate) VALUES ('', '', '', '', '')"); } echo "</div>"; //end get messages } my SoapClient results return the following data: stdClass Object ( [string] => Array ( [0] => 32979916 [1] => 5000206060500 [2] => 9140544602 [3] => A [4] => 10/16/2013 11:13:03 PM ) ) stdClass Object ( [string] => Array ( [0] => 32979917 [1] => 5000206060500 [2] => 9140544602 [3] => B [4] => 10/16/2013 11:13:13 PM ) ) stdClass Object ( [string] => Array ( [0] => 32979923 [1] => 5000206060500 [2] => 9140544602 [3] => C [4] => 10/16/2013 11:13:23 PM ) ) Please help me complete my code to save the soapclient results to mysql table! Regards Mansour
  5. Hi guys, webservice address: http://sms-webservice.ir/v1/v1.asmx?wsdl I'm looking forward... mansour
  6. Hi, i'm writing a webservice for my application. i can't print and save result of webservice. my php code: <?php .... $client = new SoapClient("http://addresst/code.asmx?wsdl"); $params = array( 'Username'=>$username, 'PassWord'=>$password, 'numberOfMessages'=>$numberOfMessages, 'destNumber'=>$destNumber, 'ErrNum'=>$ErrNum, ); $result = $client->GetAllMessages( $params ); if (is_soap_fault($result)) { echo '<h2>Fault:</h2><pre>'; print_r($result); echo '</pre>'; } else { print_r($result); //testing output echo "<hr/>"; $res = $result->GetAllMessagesResult;//testing output print_r($res); //end get messages } ?> xml schema: <s:element name="GetAllMessages"><s:complexType><s:sequence><s:element minOccurs="0" maxOccurs="1" name="Username" type="s:string"/><s:element minOccurs="0" maxOccurs="1" name="PassWord" type="s:string"/><s:element minOccurs="1" maxOccurs="1" name="numberOfMessages" type="s:int"/><s:element minOccurs="0" maxOccurs="1" name="destNumber" type="s:string"/><s:element minOccurs="1" maxOccurs="1" name="ErrNum" type="s:int"/></s:sequence></s:complexType></s:element><s:element name="GetAllMessagesResponse"><s:complexType><s:sequence><s:element minOccurs="0" maxOccurs="1" name="GetAllMessagesResult" type="tns:ArrayOfArrayOfString"/><s:element minOccurs="1" maxOccurs="1" name="ErrNum" type="s:int"/></s:sequence></s:complexType></s:element><s:complexType name="ArrayOfArrayOfString"><s:sequence><s:element minOccurs="0" maxOccurs="unbounded" name="ArrayOfString" nillable="true" type="tns:ArrayOfString"/></s:sequence></s:complexType> what's wrong? please post your code based on XML schema i posted here! Regards Mansour
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.