Lietotāja rīki

Vietnes rīki



lv:procedures

Atšķirības

Norādītais vecais variants no patreizējās lapas atšķiras ar.

Saite uz salīdzināšanas skatu.

Abās pusēs iepriekšējo versijuIepriekšējā versija
Nākamā versija
Iepriekšējā versija
lv:procedures [2020/09/15 17:32] marijalv:procedures [2020/10/27 19:06] (patlaban) – ALG_rek_0610 marija
Rinda 1: Rinda 1:
 <code> <code>
-ALTER      PROCEDURE [dbo].[xml_core_SISSE_webshop] AS +<?xml version="1.0" encoding="utf-8"?> 
-DECLARE @klient_kood bigint, @kood bigint, @nimitmp nvarchar(255),@addrtmp nvarchar(255),@konttmp nvarchar(255), @koodid varchar(1000+<xsl:stylesheet version="1.0" 
-declare @ladu nvarchar(32)@seeria nvarchar(32), @objekt nvarchar(32), @s1 int, @s2 int@webid nvarchar(32), @webtype nvarchar(32+xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
-declare @number int, @maa int, @kmk nvarchar(32), @x int@kinnitatud int +xmlns:fo="http://www.w3.org/1999/XSL/Format" 
-DECLARE @myyja nvarchar(32), @aeg datetime +xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
-declare @key nvarchar(32)@appkey nvarchar(64), @appkey_setting nvarchar(64+xmlns:js="urn:formulas" 
-declare @result1 xml, @result2 nvarchar(max) +exclude-result-prefixes="msxsl js fo"> 
-declare @artikkel nvarchar(32)@id_exist int +<xsl:output method="html"/> 
-declare @kl_kood nvarchar(32)@nimi nvarchar(255), @kustuta int +<xsl:decimal-format name="N" NaN="0" decimal-separator='.' grouping-separator=' ' /> 
-declare @ag datetime +  <xsl:template match="/"> 
-declare @err nvarchar(32+   <xsl:variable name="item_per_page">25</xsl:variable> 
-select @ag =getdate() + <xsl:variable name="eiro"> 
-set @key=CONVERT(nvarchar,getdate()) + <xsl:choose> 
-update in_webshop_tell_tellimused set x=@key where x is null + <xsl:when test="/documents/document/valuuta='LVL'"> 
-update xml_in_imago_tellimused set x=@key where x is null + 1.42287181 
-set @koodid='' + </xsl:when> 
- + <xsl:when test="/documents/document/valuuta=''"> 
-select @appkey_setting=setting from settings where ID='xmlcore_key' + 1.42287181 
- + </xsl:when> 
-create table #results + <xsl:when test="/documents/document/valuuta='EUR'"> 
-(number nvarchar(32)tyyp nvarchar(32)result intdescr nvarchar(255), submittype nvarchar(32)) + 0.702804 
- + </xsl:when> 
- + <xsl:when test="/documents/document/valuuta!='EUR' and  /documents/document/valuuta!='LVL'"> 
- + <xsl:value-of select="/documents/document/kurssbv1"/> 
---vastuvotmine, kogused + </xsl:when> 
---SELECT * FROM in_webshop_tell_tellimused WHERE number '2000117' + </xsl:choose> 
--- DELETE FROM in_webshop_tell_tellimused WHERE number = '2000117+ </xsl:variable> 
--- UPDATE in_webshop_tell_tellimused SET x null WHERE number = '2000117' +   <xsl:variable name="nauda"> 
--- EXEC [dbo].[xml_core_SISSE_webshop] + <xsl:choose> 
- + <xsl:when test="/documents/document/valuuta='LVL'">LVL</xsl:when> 
---sales order from E-agent [LV software] + <xsl:when test="/documents/document/valuuta=''">LVL</xsl:when> 
-declare tellimused cursor for select numberappkey from in_webshop_tell_tellimused with(nolockwhere x=@key + <xsl:when test="/documents/document/valuuta!='' and /documents/document!='LVL'"> 
-open tellimused + <xsl:value-of select="/documents/document/valuuta"/> 
-FETCH NEXT FROM tellimused INTO @webid, @appkey + </xsl:when> 
-WHILE @@FETCH_STATUS 0 + </xsl:choose> 
-BEGIN + </xsl:variable> 
- if ISNULL(@appkey,'')!=ISNULL(@appkey_setting,''+ <xsl:variable name="nauda2"> 
- begin + <xsl:choose> 
- insert into #results values (@appkey, 'ORDER', 1, 'Incorrect key','Orders') + <xsl:when test="/documents/document/valuuta='LVL'">EUR</xsl:when> 
- + <xsl:when test="/documents/document/valuuta=''">EUR</xsl:when> 
- end+ <xsl:when test="/documents/document/valuuta!='' and /documents/document!='LVL'">LVL</xsl:when> 
 + </xsl:choose> 
 + </xsl:variable> 
 +   <xsl:variable name="rekina_summa"> 
 +     <xsl:choose> 
 +   <xsl:when test="$nauda='LVL'"> 
 +  <xsl:value-of select="format-number((/documents/document/converted_tasuda div 100* $eiro'0.00')" /> 
 +   </xsl:when> 
 +     <xsl:when test="$nauda='EUR'"> 
 +  <xsl:value-of select="format-number(/documents/document/converted_tasuda div 100'0.00')" /> 
 +   </xsl:when> 
 +   <xsl:when test="$nauda!='LVL' or $nauda!='EUR'"> 
 +   <xsl:value-of select="format-number(/documents/kontakt/saldo div /documents/document/kurssbv1'0.00')"/> 
 +   </xsl:when> 
 +   </xsl:choose> 
 +   </xsl:variable> 
 +   <xsl:variable name="saldo"> 
 +   <xsl:choose> 
 +   <xsl:when test="$nauda='LVL' or $nauda='EUR'"> 
 +   <xsl:value-of select="format-number(/documents/kontakt/saldo'0.00')"/> 
 +   </xsl:when> 
 +   <xsl:when test="$nauda!='LVL' or $nauda!='EUR'"> 
 +   <xsl:value-of select="format-number(/documents/kontakt/saldo div /documents/document/kurssbv1'0.00')"/> 
 +   </xsl:when> 
 +   </xsl:choose> 
 +   
 +   </xsl:variable> 
 +    <xsl:variable name="parads"> 
 +   <xsl:value-of select="format-number($saldo - $rekina_summa ,'0.00')"/> 
 +   </xsl:variable> 
 +   <xsl:variable name="neapm_summa"> 
 +   <xsl:choose> 
 +   <xsl:when test="/documents/document/valuuta!=''"> 
 +   <xsl:value-of select="format-number($parads'0.00')"/> 
 +   </xsl:when> 
 +   <xsl:when test="/documents/document/valuuta=''"> 
 +   <xsl:value-of select="$parads"/> 
 +   </xsl:when> 
 +   </xsl:choose> 
 +   </xsl:variable> 
 +   <xsl:variable name="atlaide"> 
 +    <xsl:choose><xsl:when test="sum(documents/document/rows/row[pross &gt; 0]/pross&gt; 0">1</xsl:when> 
 +    <xsl:otherwise>0</xsl:otherwise> 
 +    </xsl:choose> 
 +   </xsl:variable> 
 +   <xsl:variable name="atlaides_summa"> 
 +    <xsl:for-each select="/documents/document/rows/row[pross &gt; 0]"> 
 + <a_summa> 
 + <xsl:value-of select="format-number(hind*kogus*pross div 100, '0.0000')"/> 
 + </a_summa> 
 +    </xsl:for-each> 
 +   </xsl:variable> 
 +    
 +   <script language="JavaScript" type="text/javascript"><![CDATA[ 
 +    if (document.getElementById('first')) { 
 +     document.write('<div class="pbreak"></div>'); 
 +    } else { 
 +     document.write('<div id="first"></div>'); 
 +    } 
 +   ]]></script> 
 +    
 +   <html> 
 +   <head> 
 +   <title><xsl:value-of select="/documents/language/arve_nr" /><!--Rēķins Nr.--> <xsl:value-of select="/documents/document/number" /></title> 
 +    
 +   <style type="text/css"> 
 +    body { 
 +    text-align:center; 
 +    font-family:Century Gothic; 
 +    font-size:10px; 
 +    } 
 +     
 +    .container { 
 +    display:table
 +    text-align:left; 
 +    width:660px; 
 +    margin:auto; 
 +    } 
 +     
 +    .main_table { 
 +    width:660px; 
 +    border-collapse:collapse; 
 +    } 
 +     
 +    .main_table th { 
 +    font-size:14px; 
 +    font-family:Century Gothic; 
 +    font-weight:normal; 
 +    text-align:right; 
 +    padding:1px; 
 +    border:1px solid #B4B4B4; 
 +    } 
 +     
 +    .main_table td { 
 +    font-size:10px; 
 +    font-family:Century Gothic; 
 +    padding:1px; 
 +    border:1px solid #B4B4B4; 
 +    } 
 +     
 +    .main_table td.nos.main_table td.kods.main_table th.nos.main_table th.kods { 
 +    text-align:left; 
 +    } 
 +     
 +    .main_table tr.cont { 
 +    height:16px; 
 +    } 
 +     
 +    .left { 
 +    float:left; 
 +    padding:30px 0px 0px 30px; 
 +    font-size:14px; 
 +    } 
 +     
 +    .right { 
 +    float:right; 
 +    text-align:right; 
 +    font-size:14px; 
 +    } 
 + .left2 { 
 +    float:left; 
 +    text-align:left; 
 +    font-size:14px; 
 +    } 
 +     
 +    .right_small { 
 +    float:right; 
 +    text-align:right; 
 +    } 
 +     
 +    .spacer { 
 +    height:20px; 
 +    clear:both; 
 +    } 
 +     
 +    .divider { 
 +    clear:both; 
 +    } 
 +     
 +    .pbreak { 
 +    page-break-after:always; 
 +    } 
 +     
 +    h4.pb { 
 +    display:none; 
 +    } 
 +   </style>   
 +   </head> 
 +   <body> 
 +   <div class="container"> 
 +    <div class="spacer" style="height:0px;"></div> 
 +    <div style="float:left;" class="left2" valign="bottom"> 
 + <IMG height="90" alt="Logo"><xsl:attribute name="SRC" ><xsl:value-of select="/documents/footer/firma_logo"/></xsl:attribute></IMG> 
 +    </div> 
 +    <div class="right"> 
 + <br /> 
 +    <xsl:choose><!--Rēķins Nr.--> 
 +     <xsl:when test="/documents/document/tingimus='Kand /documents/document/keel=''"><xsl:value-of select="/documents/document/maksetingimus_nimi" /> Nr.&#160;</xsl:when> 
 +     <xsl:when test="/documents/document/tingimus='K' and /documents/document/keel!=''">Credit note no.&#160;</xsl:when> 
 +     <xsl:when test="/documents/document/keel=''">Rēķins Nr.&#160;</xsl:when> 
 +     <xsl:otherwise><xsl:value-of select="/documents/language/arve_nr" />.</xsl:otherwise></xsl:choose><xsl:value-of select="/documents/document/number" /><br /> 
 +     <xsl:choose><!--Kreditē rēķinu Nr.--> 
 +     <xsl:when test="/documents/document/tingimus='Kand /documents/document/keel=''">Kreditē rēķinu Nr.&#160;<xsl:value-of select="/documents/document/kredarve" /><br /></xsl:when> 
 +     <xsl:when test="/documents/document/tingimus='K' and /documents/document/keel!=''">Credited invoice no.&#160;<xsl:value-of select="/documents/document/kredarve" /><br /></xsl:when> 
 +     </xsl:choose> 
 +     <xsl:choose><!--Datums--> 
 +     <xsl:when test="/documents/document/keel=''">Datums</xsl:when> 
 +     <xsl:otherwise><xsl:value-of select="/documents/language/aeg" /></xsl:otherwise></xsl:choose>:&#160; 
 +     <xsl:variable name="day" select="substring(/documents/document/aeg_date,1,2)" /> 
 +     <xsl:variable name="month" select="substring(/documents/document/aeg_date,4,2)" /> 
 +     <xsl:variable name="year" select="substring(/documents/document/aeg_date,7,4)" /> 
 +     <xsl:variable name="menesis"> 
 +      <xsl:choose> 
 +       <xsl:when test="/documents/document/keel=''"> 
 +        <xsl:if test="$month='01'">Janvāris</xsl:if> 
 +        <xsl:if test="$month='02'">Februāris</xsl:if> 
 +        <xsl:if test="$month='03'">Marts</xsl:if> 
 +        <xsl:if test="$month='04'">Aprīlis</xsl:if> 
 +        <xsl:if test="$month='05'">Maijs</xsl:if> 
 +        <xsl:if test="$month='06'">Jūnijs</xsl:if> 
 +        <xsl:if test="$month='07'">Jūlijs</xsl:if> 
 +        <xsl:if test="$month='08'">Augusts</xsl:if> 
 +        <xsl:if test="$month='09'">Septembris</xsl:if> 
 +        <xsl:if test="$month='10'">Oktobris</xsl:if> 
 +        <xsl:if test="$month='11'">Novembris</xsl:if> 
 +        <xsl:if test="$month='12'">Decembris</xsl:if> 
 +       </xsl:when> 
 +       <xsl:otherwise> 
 +        <xsl:if test="$month='01'">January</xsl:if> 
 +        <xsl:if test="$month='02'">February</xsl:if> 
 +        <xsl:if test="$month='03'">March</xsl:if> 
 +        <xsl:if test="$month='04'">April</xsl:if> 
 +        <xsl:if test="$month='05'">May</xsl:if> 
 +        <xsl:if test="$month='06'">June</xsl:if> 
 +        <xsl:if test="$month='07'">July</xsl:if> 
 +        <xsl:if test="$month='08'">August</xsl:if> 
 +        <xsl:if test="$month='09'">September</xsl:if> 
 +        <xsl:if test="$month='10'">October</xsl:if> 
 +        <xsl:if test="$month='11'">November</xsl:if> 
 +        <xsl:if test="$month='12'">December</xsl:if> 
 +       </xsl:otherwise> 
 +      </xsl:choose> 
 +     </xsl:variable> 
 +     <xsl:choose> 
 +      <xsl:when test="/documents/document/keel=''"><xsl:value-of select="concat($year,'. gada',' ',$day,'. ',$menesis)" /></xsl:when> 
 +      <xsl:otherwise><xsl:value-of select="concat($menesis,' ',$day,', ',$year)" /></xsl:otherwise> 
 +     </xsl:choose> 
 +   
 + <xsl:choose> 
 + <xsl:when test="/documents/document/tellimusenr!=''"> 
 + <br /> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Saskaņā ar priekšapmaksas rēķinu </xsl:when> 
 + <xsl:otherwise>According to proforma invoice </xsl:otherwise>  
 + </xsl:choose> 
 + <xsl:value-of select="/documents/document/tellimusenr" /> 
 + </xsl:when>  
 + </xsl:choose> 
 +  
 +    </div> 
 +     
 +    <div class="spacer"></div> 
 +     
 +    <div class="left2" valign="top"> 
 +     <xsl:if test="/documents/kontakt/kontakt!=''"><xsl:value-of select="/documents/kontakt/kontakt" /><br /></xsl:if> 
 +     <xsl:value-of select="/documents/document/klient_nimi" /><br /> 
 +     <xsl:if test="/documents/document/aadress1!=''"><xsl:value-of select="/documents/document/aadress1" /><br /></xsl:if> 
 +     <xsl:if test="/documents/document/aadress2!=''"><xsl:value-of select="/documents/document/aadress2" /></xsl:if> 
 +     <xsl:if test="/documents/document/aadress3!=''">&#160;<xsl:value-of select="/documents/document/aadress3" /><br /></xsl:if> 
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Reģ. Nr.: </xsl:when> 
 + <xsl:otherwise>Reg. No.: </xsl:otherwise> 
 + </xsl:choose> 
 + <xsl:value-of select="/documents/kontakt/regnr" /><br />  
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">PVN Reģ. Nr.: </xsl:when> 
 + <xsl:otherwise>VAT Reg. No.: </xsl:otherwise> 
 + </xsl:choose> 
 + <xsl:value-of select="/documents/kontakt/kmregnr" /><br />  
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Banka: </xsl:when> 
 + <xsl:otherwise>Bank: </xsl:otherwise> 
 + </xsl:choose> 
 + <xsl:value-of select="/documents/kontakt/pank" /><br /> 
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Konta Nr.: </xsl:when> 
 + <xsl:otherwise>Account No.: </xsl:otherwise> 
 + </xsl:choose> 
 + <xsl:value-of select="/documents/kontakt/arveldusarve" /><br /> 
 + <xsl:choose> 
 + <xsl:when test="/documents/kontakt/lahaadress2!=''"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Piegādes adrese: </xsl:when> 
 + <xsl:otherwise>Delivery address: </xsl:otherwise> 
 + </xsl:choose> 
 + <xsl:value-of select="/documents/kontakt/lahaadress2" /><br />  
 + </xsl:when>  
 + </xsl:choose>  
 +    </div>
   
- else +    <div class="right"> 
- begin+     <xsl:value-of select="/documents/footer/firma_nimi" /><br /> 
 +     <xsl:if test="/documents/footer/firma_aadress!=''"><xsl:value-of select="/documents/footer/firma_aadress" /><br /></xsl:if> 
 +     <xsl:if test="/documents/footer/firma_aadress2!=''"><xsl:value-of select="/documents/footer/firma_aadress2" /></xsl:if> 
 +     <xsl:if test="/documents/footer/firma_aadress3!=''">&#160;<xsl:value-of select="/documents/footer/firma_aadress3" /><br /></xsl:if>  
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Reģ. #: </xsl:when> 
 + <xsl:otherwise>Reg. #: </xsl:otherwise> 
 + </xsl:choose><!--Reģ. Nr--><xsl:value-of select="/documents/footer/firma_regnr" /><br /> 
 +    <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">PVN Reģ. #: </xsl:when> 
 + <xsl:otherwise>VAT Reg. #: </xsl:otherwise> 
 + </xsl:choose><!--PVN Reģ. Nr--><xsl:value-of select="/documents/footer/firma_kmnr" /><br /> 
 +    </div> 
 +     
 +    <div class="spacer" style="height:60px;"></div> 
 +     
 +    <table class="main_table" height="380" cellspacing="0" cellpadding="0"> 
 +     <tr class="cont"> 
 +      <th class="kods" width="100"> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Kods</xsl:when> 
 + <xsl:otherwise>Item</xsl:otherwise> 
 + </xsl:choose><!--Kods--></th> 
 +      <th class="nos" width="300"><!--Nosaukums--> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Nosaukums</xsl:when> 
 + <xsl:otherwise>Description</xsl:otherwise> 
 + </xsl:choose> 
 +   </th> 
 +      <th> <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Mērv.</xsl:when> 
 + <xsl:otherwise>Unit</xsl:otherwise> 
 + </xsl:choose><!--Mērvienība--></th> 
 +      <th> <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Daudz.</xsl:when> 
 + <xsl:otherwise>Qty total</xsl:otherwise> 
 + </xsl:choose><!--Daudz.--></th> 
 +      <xsl:if test="$atlaide!=0"> 
 +       <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Atlaide</xsl:when> 
 + <xsl:otherwise>Discount</xsl:otherwise> 
 + </xsl:choose><!--Atlaide--></th> 
 +      </xsl:if> 
 +    
 +      <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Cena <xsl:value-of select="$nauda"/></xsl:when> 
 + <xsl:otherwise>Price <xsl:value-of select="$nauda"/></xsl:otherwise> 
 + </xsl:choose></th> 
 +      <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Summa <xsl:value-of select="$nauda"/></xsl:when> 
 + <xsl:otherwise>Total <xsl:value-of select="$nauda"/></xsl:otherwise> 
 + </xsl:choose></th> 
 +     </tr> 
 +      
 +     <xsl:for-each select="/documents/document/rows/row"> 
 +      
 +     <tr class="cont"> 
 +     <xsl:choose> 
 +      <xsl:when test="artikkel!=''"> 
 +      <td class="kods" width="100"><xsl:value-of select="artikkel" /></td> 
 +      <td class="nos" width="250"><xsl:value-of disable-output-escaping="yes" select="keelne_seletus" /></td> 
 +      <td align="center"><xsl:value-of select="yhik" /></td> 
 +      <td align="center"><xsl:value-of select="kogus" /></td> 
 +      <xsl:if test="$atlaide!=0"> 
 +       <td class="atl"> 
 +        <xsl:choose> 
 +         <xsl:when test="pross!=''"><xsl:value-of select="pross" /> %</xsl:when> 
 +         <xsl:otherwise>&#160;</xsl:otherwise> 
 +        </xsl:choose> 
 +       </td> 
 +      </xsl:if> 
 +      <td align="right"><xsl:value-of select="format-number((converted_hind) div 100,'0.00')"/></td> 
 +      <td align="right"><xsl:value-of select="format-number((converted_summa) div 100,'0.00')" /></td> 
 +      </xsl:when> 
 +     <xsl:otherwise> 
 + <td>&#160;</td> 
 + <td class="nos" width="250"><xsl:value-of disable-output-escaping="yes" select="keelne_seletus" /></td> 
 + <td>&#160;</td> 
 +         <td>&#160;</td> 
 + <td>&#160;</td> 
 + <td>&#160;</td> 
 +         <xsl:if test="$atlaide!=0"> 
 + <td>&#160;</td> 
 + </xsl:if> 
 +     </xsl:otherwise> 
 +     </xsl:choose> 
 +     </tr> 
 +      
 +     <xsl:if test="((position() mod $item_per_page)=0) and (position()!=last())"> 
 +      <tr><td colspan="6" style="border-width:0px;">&#160;</td></tr> 
 +      <xsl:text disable-output-escaping="yes">&lt;/table&gt;</xsl:text> 
 +      <div style="text-align:right;"><!--Turpinājums-->...</div> 
 +      <div style="text-align:center; margin-left:10px; margin-top:215px; width:35px; height:29px; #height:37px; border:1px solid #000000; padding:8px 0px 0px 0px;"> 
 +       <xsl:value-of select="floor((position()+1) div $item_per_page)" />&#160; 
 +      </div> 
 +      <xsl:text disable-output-escaping="yes">&lt;/div&gt;</xsl:text> 
 +       
 +      <div class="pbreak"></div> 
 +       
 +      <xsl:text disable-output-escaping="yes">&lt;div class="container"&gt;</xsl:text> 
 +      <div style="text-align:right; padding-bottom:5px;"> 
 +       <xsl:value-of select="floor((position()+1) div $item_per_page)+1" /> 
 +       <xsl:text>/</xsl:text> 
 +       <xsl:value-of select="ceiling(/documents/document/ridu div $item_per_page)" /> 
 +      </div> 
 +      <xsl:text disable-output-escaping="yes">&lt;table class="main_table" height="740" cellspacing="0" cellpadding="0"&gt;</xsl:text> 
 +     <tr class="cont"> 
 +      <th class="kods" width="100"> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Kods</xsl:when> 
 + <xsl:otherwise>Item</xsl:otherwise> 
 + </xsl:choose><!--Kods--></th> 
 +      <th class="nos" width="300"><!--Nosaukums--> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Nosaukums</xsl:when> 
 + <xsl:otherwise>Description</xsl:otherwise> 
 + </xsl:choose> 
 +   </th> 
 +      <th> <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Mērv.</xsl:when> 
 + <xsl:otherwise>Unit</xsl:otherwise> 
 + </xsl:choose><!--Mērvienība--></th> 
 +      <th> <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Daudz.</xsl:when> 
 + <xsl:otherwise>Qty total</xsl:otherwise> 
 + </xsl:choose><!--Daudz.--></th> 
 +      <xsl:if test="$atlaide!=0"> 
 +       <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Atlaide</xsl:when> 
 + <xsl:otherwise>Discount</xsl:otherwise> 
 + </xsl:choose><!--Atlaide--></th> 
 +      </xsl:if> 
 +    
 +      <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Cena <xsl:value-of select="$nauda"/></xsl:when> 
 + <xsl:otherwise>Price <xsl:value-of select="$nauda"/></xsl:otherwise> 
 + </xsl:choose></th> 
 +      <th><xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Summa <xsl:value-of select="$nauda"/></xsl:when> 
 + <xsl:otherwise>Total <xsl:value-of select="$nauda"/></xsl:otherwise> 
 + </xsl:choose></th> 
 +     </tr> 
 +     </xsl:if> 
 +      
 +     <xsl:if test="position()=last()"> 
 +      <tr><td colspan="6" style="border-width:0px;">&#160;</td></tr> 
 +     </xsl:if> 
 +      
 +     </xsl:for-each> 
 +      
 +    </table>
  
- select @id_exist=count(*) from tell_tellimused with(nolock) where number=@webid +    <table class="main_table" cellspacing="0" cellpadding="0"> 
- if @id_exist=0 +    <tr><td style="text-align:left; border-width:0px;"><xsl:value-of select="documents/document/kommentaar"/></td></tr> 
- BEGIN +    </table>
- set @number=@webid +
-  +
- select @maa=maa from kliendid with(nolock) where kood=(select klient_kood from in_webshop_tell_tellimused with(nolock) where number=@number)+
  
- insert into tell_tellimused (number, myyjaaeg,  klient_kood, arvetasub tingimus, ladu, klient_nimi, lahetusviis +    <table class="main_table" height="260" cellspacing="0" cellpadding="0"> 
- ,  kommentaar, valuuta, kurssbv1  +    <tr style="height:220px;"> 
- ,esindaja, telefon, aadress1, aadress2, aadress3 +    <td style="text-align:left; border-width:0px;"> 
- ,lahetusaadress1, lahetusaadress2, lahetusaadress3 +     
- ,klient_nimi_lahetusel +    <div style="border:solid #B4B4B4; border-width:2px 0px 2px 0px; display:table; width:660px;"> 
- , ts, cu, Field57, objekt +      
-  ,hinnakirilahetusaeglisa_field1 +     <div style="float:left; width:350px;" valign="top" align="left"> 
-  )  + <table width="100%" border="0" cellapdding="0" cellspacing="0" align="left"> 
- SELECT @number +   <tr> 
-  +   <td align="left" style="border-width: 0px 0px 0px 0px;"> 
- ,ISNULL(myyja, 'XML') +   <xsl:choose> 
- , aeg +      <xsl:when test="/documents/document/keel=''"> 
- , klient_kood +      <xsl:choose> 
- ,  isnull((select top 1 arvetasub from kliendid where kood=klient_kood),arvetasub) +       <xsl:when test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
- isnull(tingimus,(select TOP 1 tingimus from kliendid with(nolock) where kood=klient_kood)) +    <xsl:choose> 
- , isnull(ladu,'GAL') +   <xsl:when test="$nauda='LVL' or $nauda='EUR'"> 
- , isnull(klient_nimi,(select TOP nimi from kliendid with(nolockwhere kood=klient_kood)) +        <xsl:value-of select="js:numText(string(format-number((/documents/document/converted_tasuda div 100)-(/documents/document/ettemaks)'0.00''N')),string($nauda))" /></xsl:when> 
- , isnull(tingimus,(select TOP 1 tingimus from kliendid with(nolockwhere kood=klient_kood)) +     </xsl:choose> 
- ,kommentaar +    </xsl:when> 
- 'EUR', 1 +       <xsl:otherwise> 
- , isnull(esindaja,(select TOP 1 kontakt from kliendid with(nolockwhere kood=klient_kood)) +    <xsl:choose> 
- , isnull(telefon,(select TOP 1 telefon from kliendid with(nolockwhere kood=klient_kood)) +   <xsl:when test="$nauda='LVL' or $nauda='EUR'"> 
- , isnull(aadress1,(select TOP 1 aadress1 from kliendid with(nolockwhere kood=klient_kood)) +        <xsl:value-of select="js:numText(string(format-number(/documents/document/converted_tasuda div 100'0.00''N')),string($nauda))" /></xsl:when> 
- , isnull(aadress2,(select TOP aadress2 from kliendid with(nolockwhere kood=klient_kood)) +     </xsl:choose> 
- , isnull(aadress3,(select TOP 1 aadress3 from kliendid with(nolockwhere kood=klient_kood)) +       </xsl:otherwise> 
- , isnull(lahaadress1,(select TOP 1 lahaadress1 from kliendid with(nolockwhere kood=klient_kood)) +      </xsl:choose> 
- , isnull(lahaadress2,(select TOP 1 lahaadress2 from kliendid with(nolockwhere kood=klient_kood)) +      </xsl:when> 
- , isnull(lahaadress3,(select TOP 1 lahaadress3 from kliendid with(nolockwhere kood=klient_kood)) +         <xsl:when test="/documents/document/keel!=''"> 
- , isnull(klientnimi_lahetusel,(select TOP 1 nimi_lahetusel from kliendid v where kood=klient_kood))+      <xsl:choose> 
 +       <xsl:when test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +    <xsl:choose> 
 +   <xsl:when test="$nauda='LVL' or $nauda='EUR'"> 
 +        <xsl:value-of select="js:numTextEng(string(format-number((/documents/document/converted_tasuda div 100)-(/documents/document/ettemaks), '0.00')),string($nauda))" /> 
 + </xsl:when> 
 +     </xsl:choose> 
 +    </xsl:when> 
 +       <xsl:otherwise> 
 +    <xsl:choose> 
 +   <xsl:when test="$nauda='LVL' or $nauda='EUR'"> 
 +        <xsl:value-of select="js:numTextEng(string(format-number((/documents/document/converted_tasuda div 100), '0.00')),string($nauda))" /></xsl:when> 
 +     </xsl:choose> 
 +       </xsl:otherwise> 
 +      </xsl:choose> 
 +      </xsl:when> 
 +      </xsl:choose> 
 +   </td> 
 +   </tr> 
 +   <xsl:for-each select="/documents/kmkoodid/kmkood"> 
 +   <tr> 
 +   <td align="left" style="border-width: 0px 0px 0px 0px;"> 
 +       <xsl:choose> 
 +   <xsl:when test="km='9'"> 
 +         <xsl:choose> 
 + <xsl:when test="/documents/document/keel!=''">Article 138 (1) of the EU VAT Directive (2006/112/EC)</xsl:when> 
 + <xsl:otherwise>Direktīvas 2006/112/EK 138. panta 1. punkts</xsl:otherwise> 
 + </xsl:choose><!--Summa--><br /> 
 +   </xsl:when> 
 +    <xsl:when test="km!='9'"> 
 +   &#160; 
 +   </xsl:when> 
 +   </xsl:choose> 
 +   </td> 
 +   </tr> 
 +      </xsl:for-each> 
 +   <tr> 
 +   <td  align="left" style="border-width: 0px 0px 0px 0px;"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Izrakstīja:</xsl:when> 
 + <xsl:otherwise>Salesman:</xsl:otherwise> 
 + </xsl:choose><!--Izrakstīja-->&#160;<xsl:value-of select="/documents/document/myyja_nimi" /> 
 +   </td> 
 +   </tr> 
 +   </table> 
 +     </div> 
 +      
 +     <div style="float:left; width:150px; text-align:right;"> 
 +   <table width="100%" border="0" cellapdding="0" cellspacing="0"> 
 +   <xsl:if test="$atlaide!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Atlaides summa:</xsl:when> 
 + <xsl:otherwise>Discount total:</xsl:otherwise> 
 + </xsl:choose><!--Kopējā summa--> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Summa bez PVN:</xsl:when> 
 + <xsl:otherwise>Total:</xsl:otherwise> 
 + </xsl:choose><!--Summa--> 
 +   </td> 
 +   </tr> 
 +   <xsl:for-each select="/documents/kmkoodid/kmkood"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +     <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">PVN:&#160;<xsl:value-of select="ilmakm" />%:</xsl:when> 
 + <xsl:otherwise>VAT&#160;<xsl:value-of select="ilmakm" />%:</xsl:otherwise> 
 + </xsl:choose> 
 +   </td> 
 +   </tr> 
 +      </xsl:for-each> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Kopā ar PVN:</xsl:when> 
 + <xsl:otherwise>Total with VAT:</xsl:otherwise> 
 + </xsl:choose> 
 +   </td> 
 +   </tr> 
 +   <xsl:if test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +<xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Priekšapmaksa:<xsl:value-of select="format-number(/documents/document/ettemaks div (/documents/document/converted_tasuda div 10000), '0.00')" /> %:</xsl:when> 
 + <xsl:otherwise>Prepayment:<xsl:value-of select="format-number(/documents/document/ettemaks div (/documents/document/converted_tasuda div 10000), '0.00')" /> %:</xsl:otherwise> 
 +  </xsl:choose> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   <xsl:if test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +<xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Summa apmaksai:</xsl:when> 
 + <xsl:otherwise>Sum To pay:</xsl:otherwise> 
 + </xsl:choose> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   </table> 
 +     </div> 
 +      
 +     <div class="right_small"> 
 +   <table width="100%" border="0" cellapdding="0" cellspacing="0"> 
 +   <xsl:if test="$atlaide!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +   <xsl:value-of select="format-number(sum(msxsl:node-set($atlaides_summa)/a_summa),'0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +   <xsl:value-of select="format-number(/documents/document/kokku,'0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   <xsl:for-each select="/documents/kmkoodid/kmkood"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +     <xsl:value-of select="format-number(summakm div 100,'0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +      </xsl:for-each> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +<xsl:value-of select="format-number(/documents/document/converted_tasuda div 100,'0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   <xsl:if test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +<xsl:value-of select="format-number(/documents/document/ettemaks, '0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   <xsl:if test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +   <tr> 
 +   <td width="50%" align="right" style="border-width: 0px 0px 0px 0px;"> 
 +<xsl:value-of select="format-number((/documents/document/converted_tasuda div 100) - /documents/document/ettemaks, '0.00')" />&#160;<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   </table> 
 +     </div> 
 +      
 +     <div class="spacer"></div> 
 +      
 +     <div style="float:left; width:350px;"
 +      <xsl:choose><xsl:when test="/documents/document/keel=''">Banka: </xsl:when><xsl:otherwise>Bank: </xsl:otherwise></xsl:choose><xsl:value-of select="/documents/footer/firma_pank" /><br /> 
 +      <xsl:choose><xsl:when test="/documents/document/keel=''">Bankas kods: </xsl:when><xsl:otherwise>Bank SWIFT: </xsl:otherwise></xsl:choose><xsl:value-of select="/documents/footer/firma_swift" /><br /> 
 +      <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Bankas konts:</xsl:when> 
 + <xsl:otherwise>Bank account:</xsl:otherwise> 
 + </xsl:choose><!--Konts-->&#160;<xsl:value-of select="/documents/footer/firma_aa" /> 
 +     </div> 
 +      
 +     <div style="float:left; width:150px;  text-align:right;"> 
 +      <!--<div style="padding-top:3px;"> 
 +   <div style="padding-top:3px;"></div> 
 +   <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Kopā apmaksai:</xsl:when> 
 + <xsl:otherwise>Total:</xsl:otherwise> 
 + </xsl:choose></div>--> 
 +      <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Apmaksas termiņš:</xsl:when> 
 + <xsl:otherwise>Due date:</xsl:otherwise> 
 + </xsl:choose><!--Apmaksas termiņš--> 
 +     </div> 
 +      
 +     <div class="right_small" width="130px"> 
 +   <table width="100%" cellpadding="1" cellspacing="1"> 
 + <!--   <xsl:if test="$saldo &gt; $rekina_summa"> 
 + <tr> 
 +   <td style="padding:2px; margin-bottom:5px; border:0px solid #000000;" width="50%"> 
 +   &#160; 
 +   </td> 
 +    <td style="padding:2px; margin-bottom:5px; border:2px solid #000000;"> 
 +<xsl:value-of select="$neapm_summa" />&#160; 
 +<xsl:value-of select="$nauda" /> 
 +   </td> 
 +   </tr> 
 +   </xsl:if> 
 +   <tr> 
 +   <td style="padding:2px; margin-bottom:5px; border:0px solid #000000;" width="50%"> 
 +   &#160; 
 +   </td> 
 +   <td style="padding:2px; margin-bottom:5px; border:2px solid #000000;"> 
 +   <xsl:choose> 
 +        <xsl:when test="/documents/document/ettemaks!='' and /documents/document/ettemaks!=0"> 
 +<xsl:value-of select="format-number((/documents/document/converted_tasuda div 100)-(/documents/document/ettemaks), '0.00')" /> 
 +   &#160; 
 +<xsl:value-of select="$nauda" /> 
 +        </xsl:when> 
 +        <xsl:otherwise> 
 + <xsl:value-of select="format-number((/documents/document/converted_tasuda div 100) + $parads, '0.00')" />&#160; 
 +<xsl:value-of select="$nauda" /> 
 +        </xsl:otherwise> 
 +       </xsl:choose> 
 +   </td> 
 +   </tr>--> 
 +   <tr> 
 +   <td style="padding:2px; margin-bottom:5px; border:0px solid #000000;" width="50%"> 
 +   &#160; 
 +   </td> 
 +   <td style="padding:2px; margin-bottom:5px; border:2px solid #000000;" align="right"> 
 + <xsl:value-of select="/documents/document/aeg2_date" /> 
 +   </td> 
 +   </tr> 
 +   </table> 
 +        
 +     </div> 
 +      
 +    </div> 
 + <!--<xsl:if test="$neapm_summa&gt;$rekina_summa"> 
 +    <div style="clear:both; padding:5px 0px 0px 0px; font-size:12px; font-weight:bold;"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/valuuta=''"> 
 +   Neapmaksāto rēķinu kopsumma: <xsl:value-of select="format-number(/documents/kontakt/saldo, '0.00')"/>&#160;<xsl:value-of select="$nauda"/><br /> 
 +   Neapmaksāto rēķinu kopsumma: <xsl:value-of select="format-number(/documents/kontakt/saldo div $eiro'0.00')"/>&#160;<xsl:value-of select="$nauda2"/><br /> 
 + </xsl:when> 
 + <xsl:when test="/documents/document/valuuta!=''"> 
 +   Neapmaksāto rēķinu kopsumma: <xsl:value-of select="format-number(/documents/kontakt/saldo, '0.00')"/>&#160;<xsl:value-of select="$nauda2"/><br /> 
 +   Neapmaksāto rēķinu kopsumma: <xsl:value-of select="format-number(/documents/kontakt/saldo div $eiro'0.00')"/>&#160;<xsl:value-of select="$nauda"/><br /> 
 + </xsl:when> 
 + </xsl:choose> 
 + Neapmaksāto rēķinu kopsumma: <xsl:value-of select="format-number(/documents/kontakt/saldo, '0.00')"/> 
 + </xsl:when> 
 + <xsl:otherwise> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/valuuta=''"> 
 +  Unpaid invoices total:<xsl:value-of select="format-number(/documents/kontakt/saldo'0.00')"/>&#160;<xsl:value-of select="$nauda"/><br /> 
 +   Unpaid invoices total:<xsl:value-of select="format-number(/documents/kontakt/saldo div $eiro, '0.00')"/>&#160;<xsl:value-of select="$nauda2"/><br /> 
 +  </xsl:when> 
 + <xsl:when test="/documents/document/valuuta!=''"> 
 +   Unpaid invoices total:<xsl:value-of select="format-number(/documents/kontakt/saldo '0.00')"/>&#160;<xsl:value-of select="$nauda2"/><br /> 
 +   Unpaid invoices total:<xsl:value-of select="format-number(/documents/kontakt/saldo div $eiro, '0.00')"/>&#160;<xsl:value-of select="$nauda"/><br /> 
 + </xsl:when> 
 + </xsl:choose> 
 + </xsl:otherwise> 
 + </xsl:choose> 
 +     <br /> 
 +      
 +    </div> 
 + </xsl:if>--> 
 +    <div style="clear:both; padding:5px 0px 0px 0px; font-size:14px;"> 
 + <xsl:choose> 
 + <xsl:when test="/documents/document/keel=''">Dokuments ir sagatavots elektroniski un derīgs bez paraksta.</xsl:when> 
 + <xsl:otherwise>The invoice is produced electronically and valid without signature.</xsl:otherwise> 
 + </xsl:choose>   
 +    </div>    
 +    </td> 
 +    </tr> 
 +    <!--<tr> 
 + <td style="height:0px; line-height:0px; border-width:0px; font-size:0px;"> 
 + <img SRC="http://login.directo.ee/logos/files/nordcity_lv_3.png" width="660"/>  
 + </td> 
 + </tr>--> 
 +    <tr> 
 +    <td style="text-align:left; border-width:0px;"> 
 +     
 +     
 +    </td> 
 +    </tr> 
 +    </table> 
 +     
 +   </div> <!-- Konteinera beigas --> 
 +   </body> 
 +    
 +   </html> 
 +  </xsl:template> 
 +<msxsl:script language="JScript" implements-prefix="js"><![CDATA[ 
 +var cipariEng=['','one ','two ','three ','four ','five ','six ','seven ','eight ','nine ']; 
 + var padsmitiEng=['ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen ']; 
 + var desmitiEng=['','','twenty ','thirty ','fourty ','fifty ','sixty ','seventy ','eighty ','ninety '];
  
- , GETDATE()'XML+ function simtiEng(str
- , isnull(email,(select TOP email from kliendid with(nolockwhere kood=klient_kood)+  res=''
- , isnull(objekt,(select TOP 1 objekt from kliendid with(nolockwhere kood=klient_kood)) +   
- ,(select TOP 1 hinnakiri from kliendid with(nolockwhere kood=klient_kood+  // pirmais cipars no labaas 
- , lahetusaeg +  if (str.charAt(1)=='1'// chekojam pirmspeedeejo ciparu - ja viens tad vai nu desmit vai padsmit 
- , isnull(lisa_field1,(select TOP sisu from yld_data with(nolockwhere kood='TRANSPORTERAND KLASS='KLIENTAND kaart=klient_kood)) +   res=padsmitiEng[parseInt(str.charAt(2))]; 
- FROM in_webshop_tell_tellimused with(nolockwhere number=@number+  else res=cipariEng[parseInt(str.charAt(2))]; 
 +   
 +  // otrais cipars no labaas 
 +  if (str.charAt(0)=='1'// ja treshais cipars no labaas ir 1 tad jaaraksta simts 
 +   res='hundred '+desmitiEng[parseInt(str.charAt(1))]+res; 
 +  else if (str.charAt(0)!='0') // ja treshais cipars no labaas nav 1 vai 0 tad jaaraksta simti 
 +   res='hundred '+desmitiEng[parseInt(str.charAt(1))]+res; 
 +  else // ja nav simtu 
 +   res=desmitiEng[parseInt(str.charAt(1))]+res; 
 +   
 +  // treshais cipars no labaas 
 +  res=cipariEng[parseInt(str.charAt(0))]+res; 
 +  return res; 
 + }
  
- -- UPDATE in_tell_tellimused_read SET artikkel = ISNULL((select artikkel from artiklid_hankija_artiklid with(nolock) where hankija_artikkel = in_tell_tellimused_read.artikkel),artikkelWHERE NOT EXISTS(SELECT top 1 kood FROM artiklid WITH(nolock) WHERE kood in_tell_tellimused_read.artikkel) + function numTextEng(skaitlis,nauda
- +  fullStr='0000000000'; 
- insert into tell_tellimused_read  +  tempStr=''; 
- (number,yhik, artikkel, variant, konto, kogus, field8, yhikuhind, summa, ostuhind, nimetus, kmkood, r_kommentaar, rn, rv) +  tempRes=''; 
- select @number +  resStr=''; 
-            ,isnull((select top 1 yhik from artiklid where kood=artikkel),'gb') +  minus=''; 
- , artikkel +   
- ,variant +  punkts=skaitlis.indexOf('.')
- , isnull((select konto_myyk from artiklid where kood=in_webshop_tell_tellimused_read.artikkel),(select TOP 1 myyk_eestis from artikliklassid with(nolock) where kood=(select TOP klass from artiklid where kood=artikkel))+  if (punkts==-1) { 
- , kogus +   pirmspStr=skaitlis; 
-            , case  +   aizpStr='0'
-             when EXISTS (select top 1 ale from mr_hinnavalemid_read with(nolock) where mida='8and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@numberand ((select aeg from tell_tellimused with(nolockwhere number=@number) between aeg1 and aeg2 ) and in_webshop_tell_tellimused_read.artikkel=artikkel or mida='8and kood=(select top hinnakiri from tell_tellimused with(nolockwhere number=@number) and(aeg1 is null and aeg2 is null) and in_webshop_tell_tellimused_read.artikkel=artikkel) +  } else { 
-                then +   pirmspStr=skaitlis.substring(0,punkts)
-                  ('0') +   aizpStr=skaitlis.substring(punkts+1)
- +  } 
-            when ((select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0' and kood=(select top hinnakiri from tell_tellimused with(nolock) where number=@number) and ((select aeg from tell_tellimused with(nolock) where number=@number) between aeg1 and aeg2 )) is NOT null)  +   
-  +  if (pirmspStr.charAt(0)=='-') { // ja ar miinus ziimi 
- then (select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0' and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and ((select aeg from tell_tellimused with(nolockwhere number=@number) between aeg1 and aeg2 ))  +   pirmspStr=pirmspStr.substring(1)
- +   minus='minus '; 
-when ((select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0' and kood=(select top hinnakiri from tell_tellimused with(nolock) where number=@number) and AEG1 IS NULL AND AEG2 IS NULL) is NOT null)  +  } 
-  +   
- then (select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0' and kood=(select top 1 hinnakiri from tell_tellimused with(nolock) where number=@number)  AND  aeg1 IS NULL and aeg2 IS NULL ) +  for (i=pirmspStr.length-1, j=9; i>=0; i--, j--{ // paarliekam uz fullstr, kas sastaav no desmit cipariem 
- +   fullStr=fullStr.substring(0,j+ pirmspStr.charAt(i+ fullStr.substring(j+1); 
- --when ((select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and ((select aeg from tell_tellimused with(nolockwhere number=@numberbetween aeg1 and aeg2 )) is null  +  } 
- --and (select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and (aeg1 is NOT null and aeg2 is NOT null ) AND  ((select top 1 AEG from tell_tellimused with(nolockwhere number=@number) between AEG1 AND AEG2)) is not null)  +   
-  +  if (fullStr.length>10) fullStr=fullStr.substring(fullStr.length-10); // ja vairaak par 10 cipariem, tad trim 
- --then (select top 1 ale from mr_hinnavalemid_read where mr_hinnavalemid_read.artikkel =in_webshop_tell_tellimused_read.artikkel and mida='0and kood=(select top 1 hinnakiri from tell_tellimused with(nolock) where number=@number) and (aeg1 is NOT null and aeg2 is NOT null ) AND  ((select top 1 AEG from tell_tellimused with(nolockwhere number=@number) between AEG1 AND AEG2)+   
-             +  if (nauda=='EUR'
- when  +   if (parseInt(fullStr,10)==1resStr+='euro'; // lats vai lati 
-               ((select top 1 ale from mr_hinnavalemid_read +    else if (parseInt(fullStr,10)!=0resStr+='euros'; 
-                 inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel  +    else resStr+='Null euros'
-                 inner join tell_tellimused ON tell_tellimused.number=@number +  } else if (parseInt(fullStr,10)!=0{ 
-                 where mr_hinnavalemid_read.klass=artiklid.klass and mida='0+   resStr+=nauda; 
-                 and mr_hinnavalemid_read.kood=(select top 1 hinnakiri from tell_tellimused with(nolock) where number=@number) +  } else resStr+='Null '+nauda; 
-                 and  +   
-                 ((tell_tellimused.aegbetween mr_hinnavalemid_read.aeg1 and mr_hinnavalemid_read.aeg2 )) is not null) +  if (parseInt(fullStr.substring(7),10)>0{ 
-                  +   tempStr=fullStr.substring(7); // simti 
- then (select top 1 ale from mr_hinnavalemid_read +   tempRes=simtiEng(tempStr)
-                 inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel  +   resStr=tempRes+resStr; 
-                 inner join tell_tellimused ON tell_tellimused.number=@number +  } 
-                 where mr_hinnavalemid_read.klass=artiklid.klass and mida='0' +   
-                and mr_hinnavalemid_read.kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) +  if (parseInt(fullStr.substring(4,7),10)>0{ 
-                 and  +   tempStr=fullStr.substring(4,7); // tūkstoši 
-                 ((tell_tellimused.aegbetween mr_hinnavalemid_read.aeg1 and mr_hinnavalemid_read.aeg2 )) +   tempRes=simtiEng(tempStr); 
-                 +   if ((tempStr.charAt(2)=='1') && (tempStr.charAt(1)!='1')) tempRes+='thousand '; 
- when ((select top 1 ale from mr_hinnavalemid_read +    else if (parseInt(tempStr,10)!=0tempRes+='thousand '; 
-                 inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel  +   resStr=tempRes+resStr; 
-                 inner join tell_tellimused ON tell_tellimused.number=@number +  } 
-                 where mr_hinnavalemid_read.klass=artiklid.klass and mida='0' +   
-                 and mr_hinnavalemid_read.kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) +  if (parseInt(fullStr.substring(1,4),10)>0
-                 and  +   tempStr=fullStr.substring(1,4); // miljoni 
-                 ((tell_tellimused.aegbetween mr_hinnavalemid_read.aeg1 and mr_hinnavalemid_read.aeg2 )) is  null and (select top 1 ale from mr_hinnavalemid_read +   tempRes=simtiEng(tempStr); 
-                 inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel  +   if ((tempStr.charAt(2)=='1'&& (tempStr.charAt(1)!='1')) tempRes+='million '
-                 inner join tell_tellimused ON tell_tellimused.number=@number +    else if (parseInt(tempStr,10)!=0tempRes+='million '; 
-                 where mr_hinnavalemid_read.klass=artiklid.klass and mida='0' +   resStr=tempRes+resStr; 
-                 and mr_hinnavalemid_read.kood=(select top hinnakiri from tell_tellimused with(nolockwhere number=@number) +  } 
-                 and  +   
-                 (mr_hinnavalemid_read.aeg1 is null and  mr_hinnavalemid_read.aeg2 is null )) is not null) +  if (fullStr.charAt(0)!='0'{ // miljardi 
-                 then (select top 1 ale from mr_hinnavalemid_read +   if (fullStr.charAt(0)=='1'resStr='one billion '+resStr; 
-                 inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel  +    else resStr=cipariEng[parseInt(fullStr.charAt(0),10)]+'billion '+resStr; 
-                 inner join tell_tellimused ON tell_tellimused.number=@number +  } 
-                 where mr_hinnavalemid_read.klass=artiklid.klass and mida='0+   
-                 and mr_hinnavalemid_read.kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number+  if (resStr!=''{ // pirmais burts lielais 
-                 and  +   resStr=resStr.charAt(0).toUpperCase()+resStr.substring(1)
-                 (mr_hinnavalemid_read.aeg1 is null and  mr_hinnavalemid_read.aeg2 is null )) END +  } 
-                 --  when  +   
-              --  ((select top 1 ale from mr_hinnavalemid_read  +  santimi=parseInt(aizpStr,10); //santimi 
-                --  inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel +  if (santimi>0) { 
-             --     where mr_hinnavalemid_read.klass=artiklid.klass +   resStr+=' '+santimi; 
-             --     and  +   if (santimi==1{ 
-             --     ((select aeg from tell_tellimused with(nolockwhere number=@numberbetween aeg1 and aeg2)) is null and (select top 1 ale from mr_hinnavalemid_read inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel where mr_hinnavalemid_read.klass=artiklid.klass and (aeg1 is null and aeg2 is null)) is not null+    resStr+=' cent'; 
-              --    then  (select top 1 ale from mr_hinnavalemid_read inner join artiklid ON artiklid.kood=in_webshop_tell_tellimused_read.artikkel where mr_hinnavalemid_read.klass=artiklid.klass and (aeg1 is null and aeg2 is null))END  +   } else { 
-            -- ,case when EXISTS (select top 1 ale from mr_hinnavalemid_read with(nolockwhere mida='8and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and ((select aeg from tell_tellimused with(nolockwhere number=@numberbetween aeg1 and aeg2 and in_webshop_tell_tellimused_read.artikkel=artikkel or mida='8and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@numberand(aeg1 is null and aeg2 is null) and in_webshop_tell_tellimused_read.artikkel=artikkel) +    resStr+=' cents'; 
-            -- then +   } 
-               -- '0+  } else { 
--- ELSE +    resStr+=' 00 cents'; 
- +  } 
--- isnull((select top 1 ale from mr_hinnavalemid_read with(nolockwhere mida='0' and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and ((select aeg from tell_tellimused with(nolockwhere number=@numberbetween aeg1 and aeg2 ) and in_webshop_tell_tellimused_read.artikkel=artikkel or mida='0and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@numberand(aeg1 is null and aeg2 is null) and in_webshop_tell_tellimused_read.artikkel=artikkel), +   
-      -- isnull((select top 1 ale from mr_hinnavalemid_read with(nolock) where mida='0and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and ((select aeg from tell_tellimused with(nolock) where number=@number) between aeg1 and aeg2 ) and klass=(select top 1 klass from artiklid where kood=in_webshop_tell_tellimused_read.artikkel)),(select top 1 ale from mr_hinnavalemid_read with(nolock) where mida='0' and kood=(select top 1 hinnakiri from tell_tellimused with(nolockwhere number=@number) and(aeg1 is null and aeg2 is nulland klass=(select top klass from artiklid where kood=in_webshop_tell_tellimused_read.artikkel)))+  return (minus+resStr);
-  -- END +
-               -- , isnull((select top 1  ale from mr_hinnavalemid_read where mida='8' and artikkel=(select top 1 artikkel from in_webshop_tell_tellimused_read where in_webshop_tell_tellimused_read.artikkel=artikkeland  (((select aeg from tell_tellimused where number=@number) between aeg1 and aeg2 ) or (aeg1 is null and aeg2 is null)) and kood=(select hinnakiri from tell_tellimused where number=@number)), 0) +
- -- , isnull(hind,(select dbo.get_hind6(artikkel,(SELECT top 1 hinnakiri from tell_tellimused INNER JOIN mr_hinnavalemid_read ON mr_hinnavalemid_read.artikkel=artikkel and mida='8and (((select aeg from tell_tellimused where number=@number) between aeg1 and aeg2 ) or (aeg1 is null and aeg2 is null)) where number=@number), null, null, null,null, null,null, null, null,null,0))+
-                ,case when EXISTS (select top 1 ale from mr_hinnavalemid_read with(nolock) where mida='8+
- and kood=(select top 1 hinnakiri from tell_tellimused with(nolock) where number=@number) +
-   and ((select aeg from tell_tellimused with(nolock) where number=@number) between aeg1 and aeg2 )  +
- and in_webshop_tell_tellimused_read.artikkel=artikkel  +
- or mida='8and kood=(select top 1 hinnakiri from tell_tellimused with(nolock) where number=@number) and(aeg1 is null and aeg2 is null) and in_webshop_tell_tellimused_read.artikkel=artikkel) +
-                then +
-                  (select dbo.get_hind6(artikkel,(SELECT top 1 hinnakiri from tell_tellimused where number=@number), null, null ,null,null, null,null, (select top 1 aeg from tell_tellimused where number=@number), null,null,0)) +
- +
    
-    +} 
-ELSE + var cipari=['','viens ','divi ','trīs ','četri ','pieci ','seši ','septiņi ','astoņi ','deviņi ']
- + var padsmiti=['desmit ','vienpadsmit ','divpadsmit ','trīspadsmit ','četrpadsmit ','piecpadsmit ','sešpadsmit ','septiņpadsmit ','astoņpadsmit ','deviņpadsmit ']; 
-(select top 1 baashind from artiklid where kood=in_webshop_tell_tellimused_read.artikkel) + var desmiti=['','','divdesmit ','trīsdesmit ','četrdesmit ','piecdesmit ','sešdesmit ','septiņdesmit ','astoņdesmit ','deviņdesmit '];
-   END +
-                , kogus*isnull(hind,(select top 1 baashind from artiklid with(nolock) where kood=artikkel))*(100-ISNULL(ale,0))/100 +
- , dbo.kesk_hind(artikkel,getdate()) +
- , isnull(nimetus,(select top 1 nimi from artiklid with(nolock) where kood=artikkel)) +
- , isnull((select top 1 kmkood from artiklid with(nolock) where kood=artikkel),(select top 1 kmk_eesti from artikliklassid with(nolock) where kood=(select TOP 1 klass from artiklid where kood=artikkel))) +
- ,kommentaar, ROW_NUMBER() OVER(ORDER BY rn) , ROW_NUMBER() OVER(ORDER BY rn ) +
- FROM in_webshop_tell_tellimused_read with(nolock) where number=@number +
- +
-  +
- update tell_tellimused_read +
- set kmkood=ISNULL((select top 1 KMkood from artiklid with(nolock) where kood=tell_tellimused_read.artikkel),(select kmk_eesti from artikliklassid with(nolock) where kood=(select top 1 klass from artiklid with(nolock) where kood=tell_tellimused_read.artikkel))) +
- where number=@number and kmkood is null +
- UPDATE tell_tellimused_read set tkkm = dbo.summaKM (yhikuhind,kmkood), rsum = dbo.summaKM(summa,kmkood) where number=@number +
- +
- update tell_tellimused_read +
- set konto=ISNULL((select top 1 konto_myyk from artiklid with(nolock) where kood=tell_tellimused_read.artikkel),(select myyk_eestis from artikliklassid with(nolock) where kood=(select top 1 klass from artiklid with(nolock) where kood=tell_tellimused_read.artikkel))) +
- where number=@number and konto is null +
- +
- --EXEC dbo.tell_tellimused_renum @number +
- EXEC dbo.arvuta_tellimus @number +
- update tell_tellimused_read set rv=rn where number=@number +
- exec hooldus_vaba 'tellimus',@number  +
-  +
- set @koodid=@koodid+convert(nvarchar,@number) +
-  +
- insert into kliendid (kood, nimi, aadress1, aadress2, aadress3, nimi_lahetusel, lahaadress1, lahaadress2, lahaadress3 +
- , kontakt, email, telefon +
- ,klient_tyyp, klass, regnr, kliendikaart +
- ,cu,ts) +
- select top 1  +
- klient_kood, klient_nimi, aadress1, aadress2, aadress3, klientnimi_lahetusel, lahaadress1, lahaadress2, lahaadress3 +
- , esindaja,email,telefon +
- ,klient_tyyp, klient_klass, klient_regnr, klient_kliendikaart +
- ,'XML',GETDATE() +
- FROM in_webshop_tell_tellimused with(nolock) where number=@number +
- and ISNULL(klient_kood,'')!='' +
- and klient_kood not in (select kood from kliendid with(nolock)) +
-  +
- insert into #results values (@webid, 'ORDER', 0, 'OK','Orders'+
- end +
- ELSE +
- BEGIN +
- insert into #results values (@webid, 'ORDER', 2, 'Duplicate','Orders'+
- END +
- +
- +
- set @x=@x+1 +
- end +
- FETCH NEXT FROM tellimused INTO @webid, @appkey +
- if @@FETCH_STATUS = 0 set @koodid=@koodid+';' +
-END +
-CLOSE tellimused +
-DEALLOCATE tellimused +
- +
- +
---cleanup +
---delete from in_webshop_tell_tellimused_klient where number in (select number from in_webshop_tell_tellimused where x=@key) +
- +
-delete from in_webshop_tell_tellimused_read where number in (select number from in_webshop_tell_tellimused where x=@key) +
-delete from in_webshop_tell_tellimused where x=@key +
- +
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +
---sales orders from imago [EE software] +
- +
---vastuvotmine, kogused +
-declare tellimused cursor for select number, appkey from xml_in_imago_tellimused where x=@key +
-open tellimused +
-FETCH NEXT FROM tellimused INTO @webid, @appkey +
-WHILE @@FETCH_STATUS = 0 +
-BEGIN +
- if ISNULL(@appkey,'')!=ISNULL(@appkey_setting,''+
- begin +
- insert into #results values (@appkey, 'ORDER', 1, 'Incorrect key','Orders'+
- +
- end +
-  +
- else +
- begin +
- +
- select @id_exist=count(*) from tell_tellimused where kliendi_tellimus=convert(nvarchar(max),@webid) +
- if @id_exist=0 +
- BEGIN +
- --set @number=@webid +
-  +
- EXEC dbo.get_dok_number @moodul='tellimus',@seeria='DOC',@NUMBER = NULL, @cu='xmlcore', @aeg=@ag, @keel = 'default', @num =@number OUTPUT, @err = @err OUTPUT +
- +
- update tell_tellimused set +
- myyja=iif(isnull(z.myyja,'')!='',z.myyja,iif(isnull((select myyja from kliendid where kood=z.arvetasub),'')!='',(select myyja from kliendid where kood=z.arvetasub),iif(isnull((select myyja from kliendid where kood=z.klient_kood),'')!='',(select myyja from kliendid where kood=z.klient_kood),'XML'))), +
- aeg=z.aeg, +
- klient_kood=z.klient_kood, +
- arvetasub=z.arvetasub, +
- tingimus=isnull(z.tingimus,(select tingimus from kliendid where kood=z.klient_kood)), +
- ladu=isnull(z.ladu,'GAL'), +
- klient_nimi=isnull(z.klient_nimi,(select nimi from kliendid where kood=z.klient_kood)), +
- lahetusviis=isnull(z.tingimus,(select tingimus from kliendid where kood=z.klient_kood)), +
- kommentaar=z.kommentaar, +
- valuuta='EUR', +
- kurssbv1=1, +
- esindaja=isnull(z.esindaja,(select kontakt from kliendid where kood=z.klient_kood)), +
- telefon=isnull(z.telefon,(select telefon from kliendid where kood=z.klient_kood)), +
- aadress1=isnull(z.aadress1,(select aadress1 from kliendid where kood=z.klient_kood)), +
- aadress2=isnull(z.aadress2,(select aadress2 from kliendid where kood=z.klient_kood)), +
- aadress3=isnull(z.aadress3,(select aadress3 from kliendid where kood=z.klient_kood)), +
- lahetusaadress1=isnull(z.lahaadress1,(select lahaadress1 from kliendid where kood=z.klient_kood)), +
- lahetusaadress2=isnull(z.lahaadress2,(select lahaadress2 from kliendid where kood=z.klient_kood)), +
- lahetusaadress3=isnull(z.lahaadress3,(select lahaadress3 from kliendid where kood=z.klient_kood)), +
- klient_nimi_lahetusel=isnull(z.klientnimi_lahetusel,(select nimi_lahetusel from kliendid where kood=z.klient_kood)), +
- ts=getdate(), +
- cu='XML', +
- Field57=isnull(z.email,(select email from kliendid where kood=z.klient_kood)), +
- objekt=isnull(z.objekt,(select objekt from kliendid where kood=z.klient_kood)), +
- hinnakiri=(select hinnakiri from kliendid where kood=z.klient_kood), +
- kliendi_tellimus=convert(nvarchar(max),@webid) +
- from (select * from xml_in_imago_tellimused where number=@webid)z +
- +
- where tell_tellimused.number=@number +
- +
- +
- select @maa=maa from kliendid where kood=(select klient_kood from xml_in_imago_tellimused where number=@number) +
-/* +
- insert into tell_tellimused (number, myyja, aeg,  klient_kood, arvetasub,  tingimus, ladu, klient_nimi, lahetusviis +
- ,  kommentaar, valuuta, kurssbv1  +
- ,esindaja, telefon, aadress1, aadress2, aadress3 +
- ,lahetusaadress1, lahetusaadress2, lahetusaadress3 +
- ,klient_nimi_lahetusel +
- , ts, cu, Field57, objekt +
- ,hinnakiri +
-+
- SELECT @number +
-  +
- ,iif(isnull('myyja','')!='',myyja,iif(isnull((select myyja from kliendid where kood=xml_in_imago_tellimused.arvetasub),'')!='',(select myyja from kliendid where kood=xml_in_imago_tellimused.arvetasub),iif(isnull((select myyja from kliendid where kood=xml_in_imago_tellimused.klient_kood),'')!='',(select myyja from kliendid where kood=xml_in_imago_tellimused.klient_kood),'XML'))) +
- , aeg +
- , klient_kood +
- ,  arvetasub +
- , isnull(tingimus,(select tingimus from kliendid where kood=klient_kood)) +
- , isnull(ladu,''+
- , isnull(klient_nimi,(select nimi from kliendid where kood=klient_kood)) +
- , isnull(tingimus,(select tingimus from kliendid where kood=klient_kood)) +
- ,kommentaar +
- , 'EUR', 1 +
- , isnull(esindaja,(select kontakt from kliendid where kood=klient_kood)) +
- , isnull(telefon,(select telefon from kliendid where kood=klient_kood)) +
- , isnull(aadress1,(select aadress1 from kliendid where kood=klient_kood)) +
- , isnull(aadress2,(select aadress2 from kliendid where kood=klient_kood)) +
- , isnull(aadress3,(select aadress3 from kliendid where kood=klient_kood)) +
- , isnull(lahaadress1,(select lahaadress1 from kliendid where kood=klient_kood)) +
- , isnull(lahaadress2,(select lahaadress2 from kliendid where kood=klient_kood)) +
- , isnull(lahaadress3,(select lahaadress3 from kliendid where kood=klient_kood)) +
- , isnull(klientnimi_lahetusel,(select nimi_lahetusel from kliendid where kood=klient_kood)) +
- +
- , GETDATE(), 'XML' +
- , isnull(email,(select email from kliendid where kood=klient_kood)) +
- , isnull(objekt,(select objekt from kliendid where kood=klient_kood)) +
- ,(select hinnakiri from kliendid where kood=klient_kood) +
- FROM xml_in_imago_tellimused where number=@number +
-  +
-*/ +
- select * from in_xml_log order by rn desc +
- insert into tell_tellimused_read  +
- (number, artikkel, variant, konto, kogus, field8, yhikuhind, summa, ostuhind, nimetus, kmkood, r_kommentaar, rn, rv) +
- select @number, artikkel,variant, (select myyk_eestis from artikliklassid where kood=(select klass from artiklid where kood=artikkel)), kogus +
- , ale +
- , isnull(hind,(select baashind from artiklid where kood=artikkel)) +
- , kogus*isnull(hind,(select baashind from artiklid where kood=artikkel))*(100-ISNULL(ale,0))/100 +
- , dbo.kesk_hind(artikkel,getdate()), nimetus +
- , (select kmk_eesti from artikliklassid where kood=(select klass from artiklid where kood=artikkel)) +
- ,kommentaar, rn, rn +
- FROM xml_in_imago_tellimused_read where number=@webid +
- +
-  +
- update tell_tellimused_read +
- set kmkood=ISNULL((select kmkood from artiklid where kood=tell_tellimused_read.artikkel),(select kmk_eesti from artikliklassid where kood=(select klass from artiklid where kood=tell_tellimused_read.artikkel))) +
- where number=@number and kmkood is null +
- UPDATE tell_tellimused_read set tkkm = dbo.summaKM (yhikuhind,kmkood), rsum = dbo.summaKM(summa,kmkood) where number=@number +
- +
- update tell_tellimused_read +
- set konto=ISNULL((select konto_myyk from artiklid where kood=tell_tellimused_read.artikkel),(select myyk_eestis from artikliklassid where kood=(select klass from artiklid where kood=tell_tellimused_read.artikkel))) +
- where number=@number and konto is null +
- +
- EXEC dbo.tell_tellimused_renum @number +
- EXEC dbo.arvuta_tellimus @number +
- update tell_tellimused_read set rv=rn where number=@number +
- exec hooldus_vaba 'tellimus',@number  +
-  +
- set @koodid=@koodid+convert(nvarchar,@number) +
-  +
- insert into kliendid (kood, nimi, aadress1, aadress2, aadress3, nimi_lahetusel, lahaadress1, lahaadress2, lahaadress3 +
- , kontakt, email, telefon +
- ,klient_tyyp, klass, regnr, kliendikaart +
- ,cu,ts) +
- select top 1  +
- klient_kood, klient_nimi, aadress1, aadress2, aadress3, klientnimi_lahetusel, lahaadress1, lahaadress2, lahaadress3 +
- , esindaja,email,telefon +
- ,klient_tyyp, klient_klass, klient_regnr, klient_kliendikaart +
- ,'XML',GETDATE() +
- FROM xml_in_imago_tellimused where number=@webid +
- and ISNULL(klient_kood,'')!='' +
- and klient_kood not in (select kood from kliendid) +
-  +
- insert into #results values (@webid, 'ORDER', 0, 'OK','Orders'+
- end +
- ELSE +
- BEGIN +
- insert into #results values (@webid, 'ORDER', 2, 'Duplicate','Orders'+
- END +
- +
- +
- set @x=@x+1 +
- end +
- FETCH NEXT FROM tellimused INTO @webid, @appkey +
- if @@FETCH_STATUS = 0 set @koodid=@koodid+';+
-END +
-CLOSE tellimused +
-DEALLOCATE tellimused +
- +
- +
---cleanup +
---delete from xml_in_imago_tellimused_klient where number in (select number from xml_in_imago_tellimused where x=@key) +
-delete from xml_in_imago_tellimused_read where number in (select number from xml_in_imago_tellimused where x=@key) +
-delete from xml_in_imago_tellimused where x=@key +
- +
---------------------------------------------------------------------------------------------------------------------------------------------------------- +
---tulemused valja +
- +
-if (select COUNT(*) from #results)=0 +
- insert into #results values (NULL, 'GENERAL ERROR', 99, 'No processable data found',NULL) +
- +
  
-select @result1+ function simti(str) { 
-(select result as "@Type", descr as "@Desc", number as "@docid", tyyp as "@doctype", submittype as "@submit" +  res=''; 
- from #results for xml path ('Result'))+   
 +  // pirmais cipars no labaas 
 +  if (str.charAt(1)=='1') // chekojam pirmspeedeejo ciparu - ja viens tad vai nu desmit vai padsmit 
 +   res=padsmiti[parseInt(str.charAt(2))]; 
 +  else res=cipari[parseInt(str.charAt(2))]; 
 +   
 +  // otrais cipars no labaas 
 +  if (str.charAt(0)=='1'// ja treshais cipars no labaas ir 1 tad jaaraksta simts 
 +   res='simts '+desmiti[parseInt(str.charAt(1))]+res; 
 +  else if (str.charAt(0)!='0') // ja treshais cipars no labaas nav 1 vai 0 tad jaaraksta simti 
 +   res='simti '+desmiti[parseInt(str.charAt(1))]+res; 
 +  else // ja nav simtu 
 +   res=desmiti[parseInt(str.charAt(1))]+res; 
 +   
 +  // treshais cipars no labaas 
 +  res=cipari[parseInt(str.charAt(0))]+res; 
 +  return res; 
 + }
  
-set @result2='<?xml version="1.0" encoding="UTF-8"?><results>'+CONVERT(nvarchar(max),@result1)+'</results>'+ function numText(skaitlis,nauda) { 
 +  fullStr='0000000000'; 
 +  tempStr=''; 
 +  tempRes=''; 
 +  resStr=''; 
 +  minus=''; 
 +   
 +  punkts=skaitlis.indexOf('.'); 
 +  if (punkts==-1) { 
 +   pirmspStr=skaitlis; 
 +   aizpStr='0'; 
 +  } else { 
 +   pirmspStr=skaitlis.substring(0,punkts); 
 +   aizpStr=skaitlis.substring(punkts+1); 
 +  } 
 +   
 +  if (pirmspStr.charAt(0)=='-') { // ja ar miinus ziimi 
 +   pirmspStr=pirmspStr.substring(1); 
 +   minus='mīnus '; 
 +  } 
 +   
 +  for (i=pirmspStr.length-1, j=9; i>=0; i--, j--) { // paarliekam uz fullstr, kas sastaav no desmit cipariem 
 +   fullStr=fullStr.substring(0,j) + pirmspStr.charAt(i) + fullStr.substring(j+1); 
 +  } 
 +   
 +  if (fullStr.length>10) fullStr=fullStr.substring(fullStr.length-10); // ja vairaak par 10 cipariem, tad trim 
 +   
 +  if (parseInt(fullStr,10)!=0) { 
 +    resStr+=nauda; 
 +  } else resStr+='Nulle '+nauda; 
 +   
 +  if (parseInt(fullStr.substring(7),10)>0) { 
 +   tempStr=fullStr.substring(7); // simti 
 +   tempRes=simti(tempStr); 
 +   resStr=tempRes+resStr; 
 +  } 
 +   
 +  if (parseInt(fullStr.substring(4,7),10)>0) { 
 +   tempStr=fullStr.substring(4,7); // t�ksto�i 
 +   tempRes=simti(tempStr); 
 +   if ((tempStr.charAt(2)=='1') && (tempStr.charAt(1)!='1')) tempRes+='tūkstotis '; 
 +    else if (parseInt(tempStr,10)!=0) tempRes+='tūkstoši '; 
 +   resStr=tempRes+resStr; 
 +  } 
 +   
 +  if (parseInt(fullStr.substring(1,4),10)>0) { 
 +   tempStr=fullStr.substring(1,4); // miljoni 
 +   tempRes=simti(tempStr); 
 +   if ((tempStr.charAt(2)=='1') && (tempStr.charAt(1)!='1')) tempRes+='miljons '; 
 +    else if (parseInt(tempStr,10)!=0) tempRes+='miljoni '; 
 +   resStr=tempRes+resStr; 
 +  } 
 +   
 +  if (fullStr.charAt(0)!='0') { // miljardi 
 +   if (fullStr.charAt(0)=='1') resStr='viens miljards '+resStr; 
 +    else resStr=cipari[parseInt(fullStr.charAt(0),10)]+'miljardi '+resStr; 
 +  } 
 +   
 +  if (resStr!='') { // pirmais burts lielais 
 +   resStr=resStr.charAt(0).toUpperCase()+resStr.substring(1); 
 +  } 
 +   
 +  santimi=parseInt(aizpStr,10); //santimi 
 +  if (santimi>0) { 
 +   resStr+='+santimi; 
 +   tmpSant=santimi.toString(); 
 +   if ((tmpSant.charAt(tmpSant.length-1)=='1') && (tmpSant.charAt(tmpSant.length-2)!='1')) { 
 +    resStr+=' cents'; 
 +   } else { 
 +    resStr+=' centi'; 
 +   } 
 +  } else { 
 +    resStr+=' 00 centi'; 
 +  } 
 +   
 +  return (minus+resStr); 
 +}
  
-select @result2 + ]]></msxsl:script>
-drop table #results+
  
-delete from in_xml_log where datediff(day,ts_inserted,getdate())>=5+ </xsl:stylesheet>
 </code> </code>
lv/procedures.1600180335.txt.gz · Labota: 2020/09/15 17:32 , labojis marija

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki