Here is some of the code , the function is "postsalesjournal" Salesjournal)){ // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); try{ $service = new NTLMSoapClient($this->Salesjournal); } catch (NTLMSoapClient $e) { prnMsg($e->getMessage()); } $mydate = $this->uptodate($this->Postingdate); // Create object $create = new stdClass(); $sq = new stdClass(); $update = new stdClass(); // Add Sales Quote to Create $create->Salesjournal = $sq; $create->CurrentJnlBatchName="DEFAULT"; $result = $service->create($create); // Retrieve record key to use in update request $key = $result->Salesjournal->Key; $sq->Key = $key; $sq->Document_Date = $mydate; $sq->Document_Type = 'Invoice'; $sq->Account_Type = 'Customer'; $sq->Account_No = $this->No; $sq->Amount = $this->BillAmount; $sq->Bal_Account_Type = 'G_L_Account'; $sq->Bal_Account_No = $this->Glaccountno; $sq->Description = $this->Comment; $update->Salesjournal = $sq ; $update->CurrentJnlBatchName="DEFAULT"; $record=$service->Update($update); return $record; } } function chartofaccounts (){ //Income_Balance//Income_Statement if(isset($this->chartofaccounts)){ $params = array('filter' => array( array('Field' => 'Gen_Posting_Type','Criteria' => 'Sale'), array('Field' => 'Account_Type','Criteria' => 'Posting'), array('Field' => 'Income_Balance','Criteria' => 'Income_Statement'), array('Field' => 'Direct_Posting','Criteria' => 'Yes')), 'setSize' => 0); // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); try{ $Page = new NTLMSoapClient($this->chartofaccounts); } catch (NTLMSoapClient $e) { prnMsg($e->getMessage()); } $result = $Page->ReadMultiple($params); $this->Accounts= $result->ReadMultiple_Result->chartofaccounts; } } function showcustomerdetails(){ if(isset($this->CustomerPage)){ // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); try{ $page = new NTLMSoapClient($this->CustomerPage); } catch (SoapFault $e) { prnMsg($e->getMessage()); } $params = array('No' =>$this->No); $result = $page->Read($params); $customer = $result->Customer; $this->Name = $customer->Name; $this->Balance_LCY = $customer->Balance_LCY; } } function getcustomerstatemnt(){ $this->Balance_LCY=0; // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); $f = $this->uptodate($this->Postingdate); $this->CustomerStatement = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/CustomerLedger'; if(isset($this->CustomerStatement)){ $params = array('filter' => array( array('Field' =>'Customer_No','Criteria'=>$this->No) ), 'setSize' => 0); try{ $Page = new NTLMSoapClient($this->CustomerStatement); } catch (SoapFault $e) { prnMsg($e->getMessage()); } $result = $Page->ReadMultiple($params); $entries = $result->ReadMultiple_Result->CustomerLedger; if(is_array($entries)){ foreach ($entries as $amount) { // $this->Balance_LCY += $amount->Amount_LCY; $this->datediff($amount->Posting_Date, $f, $amount->Amount_LCY); } } else { // $this->Balance_LCY += $entries->Amount_LCY; $this->datediff($entries->Posting_Date, $f, $entries->Amount_LCY); } } return $this->Balance_LCY; } function getlastpayment(){ $this->LastPayment_LCY=0; // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); $t = $this->fromdate($this->Postingdate); $this->CustomerStatement = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/CustomerLedger'; if(isset($this->CustomerStatement)){ // '2016-01-10' works $params = array('filter' => array( Array('Field' =>'Document_Type','Criteria'=>'Payment'), array('Field' =>'Customer_No','Criteria'=>$this->No)), 'setSize' =>0); try{ $Page = new NTLMSoapClient($this->CustomerStatement); } catch (SoapFault $e) { prnMsg($e->getMessage()); } $result = $Page->ReadMultiple($params); $entries = $result->ReadMultiple_Result->CustomerLedger; if(is_array($entries)){ foreach ($entries as $amount) { // $this->LastPayment_LCY += $amount->Amount_LCY; $this->date2diff($f,$amount->Posting_Date,$amount->Amount_LCY); } } else { // $this->LastPayment_LCY += $entries->Amount_LCY; $this->date2diff($f,$entries->Posting_Date,$entries->Amount_LCY); } } return $this->LastPayment_LCY; } function __construct($show=null){ // we unregister the current HTTP wrapper stream_wrapper_unregister('http'); // we register the new HTTP wrapper stream_wrapper_register('http','NTLMStream') or die("Failed to register protocol"); try { $this->Navservice = new NTLMSoapClient(baseURL.'SystemService'); } catch (NTLMSoapClient $e) { prnMsg($e->getMessage()); } if(Isset($_POST['company'])){ $_SESSION['SelectednavCompany']=$_POST['company']; } if($_SESSION['SelectednavCompany']) { //SalesPost $this->SalesPostCodeUnit = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Codeunit/SalesPost'; $this->CustomerPage = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/Customer'; $this->CustomerStatement = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/CustomerLedger'; $this->Salesjournal = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/Salesjournal'; $this->chartofaccounts = baseURL.rawurlencode($_SESSION['SelectednavCompany']).'/Page/chartofaccounts'; } if(!isset($show)){ echo ' '; echo ' '; echo ' '; if(isset($_SESSION['SelectednavCompany'])){ echo ' (Selected) Company Active:'.$_SESSION['SelectednavCompany'].' '; } echo ' '; // Find the first Company in the Companies $result = $this->Navservice->Companies(); $companies = $result->return_value; if (is_array($companies)) { foreach($companies as $company) { echo " ". $company ." "; } } else { echo " ". $companies ." "; } echo ' '; echo ' '; } stream_wrapper_restore('http'); } function uptodate($dateinput){ $Date_Array = explode('/',$dateinput); if ($_SESSION['DefaultDateFormat']=='d/m/Y' or $_SESSION['DefaultDateFormat']=='d.m.Y'){ $value =$Date_Array[2] . '-' . $Date_Array[1] . '-' . $Date_Array[0]; } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y'){ $value = $Date_Array[1] . '-' . $Date_Array[2] . '-' . $Date_Array[0]; } elseif ($_SESSION['DefaultDateFormat']=='Y-m-d' or $_SESSION['DefaultDateFormat']=='Y/m/d'){ $value = $Date_Array[0] . '-' . $Date_Array[1] . '-' . $Date_Array[2]; } return trim($value); } function fromdate($dateinput){ $Date_Array = explode('/',$dateinput); if ($_SESSION['DefaultDateFormat']=='d/m/Y' or $_SESSION['DefaultDateFormat']=='d.m.Y'){ $value = $Date_Array[2] . '-' . $Date_Array[1] . '-' . $Date_Array[0]; } elseif ($_SESSION['DefaultDateFormat']=='m/d/Y'){ $value =$Date_Array[1] . '-' . $Date_Array[2] . '-' . $Date_Array[0]; } elseif ($_SESSION['DefaultDateFormat']=='Y-m-d' or $_SESSION['DefaultDateFormat']=='Y/m/d'){ $value = $Date_Array[0] . '-' . $Date_Array[1] . '-' . $Date_Array[2]; } return trim($value); } function datediff($date1,$date2,$Balance_LCY){ $x = strtotime($date1); $y = strtotime($date2); $str = ($x - $y) ; $days = floor($str/3600/24); if($days Balance_LCY += $Balance_LCY; } // echo ' '.$days.'DateDiff='.$this->Balance_LCY; return $this->Balance_LCY ; } function date2diff($date1,$date2,$Balance_LCY){ $x = strtotime($date1); $y = strtotime($date2); $str = ($x - $y) ; $days = floor($str/3600/24); if($days>0){ $this->LastPayment_LCY += $Balance_LCY; } // echo ' '.$days.'Date2Diff='.$this->LastPayment_LCY; return $this->LastPayment_LCY ; } } ?>
↧