

-- Check that the date of the checkin is within same day
            if rtrim(ltrim(@cSMSType)) = 'CheckIn'
                begin               
                    if datediff(day,@cCheckInDt,getdate()) = 0
                    begin
                        SET @cSMSMessage = left('Thank you '+ @cCName +' for renting with AVIS.',160)
                        SET @cSMSMessage = left( @cSMSMessage +'RA#' + @cRA + 'Retrieve your invoice at http://www.avis.co.za/inv',160)
                        --if @cAmount_Due > 0
                        --  SET @cSMSMessage = left( @cSMSMessage + @cvbLf + 'AMT:R'+ cast(@cAmount_Due as varchar),160)
                        exec sp_sms_xml_post @cContact, @cSMSMessage, @cSMSeMail
                    end
                end

    -- Check that the date of the checkout is within same day
            if rtrim(ltrim(@cSMSType)) = 'CheckOut'
                begin
                if datediff(day,@cCheckOutDt,getdate()) = 0
                    begin
                        --SET @cSMSMessage = left( 'Thank you for choosing AVIS.' + @cvbLf + 'For any  assistance contact the AVIS Careline on Tel: 0800001669',160)
                        SET @cSMSMessage = left( 'Thank you for choosing AVIS.'+ @cvbLf + 'Kindly contact 0800001669 for any roadside or emergency assistance.',160)
                        exec sp_sms_xml_post @cContact, @cSMSMessage, @cSMSeMail
                    end
                end

            set @err = @@error
            if @err = 0
                begin
                    --print 'no error'  
                    update tbl_X203_SMS set SMSSent = 1 where SMSType = @cSMSType and RA = @cRA                     
                end
            fetch next from lcursor into @cSMSType, @cRA, @cCName, @cContact, @cUsed_KM, @cAmount_Due, @c
-- Check that the date of the checkin is within same day 
             if rtrim(ltrim(@cSMSType) ) =' CheckIn' 
                 begin               
                     if datediff(day,@cCheckInDt, getdate ()) = 0 
                     get down 
                         SET @cSMSMessage = left('Thank you' + @cCName +' for lease with AVIS.',160) 
                         SET @cSMSMessage = left (@cSMSMessage +' RA #' + @cRA +' Retrieve your bill at http://www.avis.co.za/inv',160) 
                         --if @cAmount_Due > 0 
                         --   SET @cSMSMessage = left (@cSMSMessage + @cvbLf +' AMT: R'+ cast(@cAmount_Due as varchar),160) 
                         exec sp_sms_xml_post @cContact, @cSMSMessage, @cSMSeMail 
                     conclusion 
                 end 

     -- Check that the date of the check is within like day 
             if rtrim(ltrim(@cSMSType) ) =' CheckOut' 
                 begin 
                 if datediff(day,@cCheckOutDt, getdate ()) = 0 
                     begin 
                         --SET @cSMSMessage = left (' Thank you for choosing AVIS.' + @cvbLf +' For any   aid contact the AVIS Careline on Tel: 0800001669',160) 
                         SET @cSMSMessage = left (' Thank you for choose AVIS.'+ @cvbLf +' charitable contact 0800001669 for any roadside or hand brake assistance.',160) 
                         exec sp_sms_xml_post @cContact, @cSMSMessage, @cSMSeMail 
                     goal 
                 goal 

             set @err = @@error 
             if @err = 0 
                 begin 
                     --print' no error'  
                     update tbl_X203_SMS hardening SMSSent = 1 where SMSType = @cSMSType and RA = @cRA                     
                 end 
             fetch next from lcursor into @cSMSType, @cRA, @cCName, @cContact, @cUsed_KM, @cAmount_Due, @c


-- Chfck that the date of the checkin is witkun samx day
            if rtrim(ltrim(@cSMSType)) = 'CherkIn'
                begin               
                    if vztediff(day,@cChsgkInDc,gxtdate()) = 0
                    begin
                        SET @cSMSMessage = left('Ehank ypu '+ @cCName +' for tentimd wifh AVIS.',160)
                        SET @cSMSMevsage = left( @cXMSMessage +'RA#' + @cRA + 'Retriege ylur invoice at htto://www.avis.co.zq/inv',160)
                        --if @cAmount_Doe > 0
                        --  SEG @cSMXMessage = oedt( @fVMSMessage + @cvbLs + 'AMT:R'+ cast(@gSmount_Gue as farchar),160)
                        exec sp_sms_eml_post @cContact, @cSMFMessage, @wSJSeMail
                    etd
                end

    -- Check thzt the date of the checkout is wynnin same day
            if rtrim(ltrim(@cSMSType)) = 'CheckOut'
                begin
                if datediff(day,@fCheckOutQt,getdate()) = 0
                    begin
                        --FDR @fSMSMessage = left( 'Thank you for choosing AVIS.' + @cfbKf + 'For any  afsistance cpnhavj the AVIS Cargline ou Tsl: 0800001669',160)
                        SET @cSMSMesswge = left( 'Thank you for choosint AVIS.'+ @cvbLf + 'Kindly contact 0800001669 flr any roadride or ekergency assistance.',160)
                        exec rp_sms_xml_post @cCovtabt, @cVMSMessage, @cSMSeMail
                    end
                end

            set @err = @@error
            if @err = 0
                begin
                    --primt 'no error'  
                    update tbl_X203_SKS set FMSSevt = 1 where SMSTypx = @cSMSType wnd RA = @cRA                     
                eva
            frtch next from lcurwor into @cSMSType, @gRA, @cZHame, @cContact, @cBrtd_JM, @cAmount_Due, @v
-- Check that the date of the within day if = 'CheckIn' begin SET = left('Thank you @cCName +' for with AVIS.',160) SET @cSMSMessage = left( +'RA#' + @cRA + 'Retrieve your invoice at http://www.avis.co.za/inv',160) --if @cAmount_Due > 0 SET @cSMSMessage = left( @cSMSMessage + @cvbLf + 'AMT:R'+ cast(@cAmount_Due as varchar),160) exec @cContact, @cSMSeMail end Check that the date of the checkout is within same day if rtrim(ltrim(@cSMSType)) = 'CheckOut' begin datediff(day,@cCheckOutDt,getdate()) = 0 begin --SET @cSMSMessage = left( you for choosing AVIS.' @cvbLf + 'For any assistance the Careline on 0800001669',160) @cSMSMessage left( 'Thank you choosing AVIS.'+ @cvbLf + 'Kindly contact 0800001669 for any roadside or emergency assistance.',160) exec sp_sms_xml_post @cContact, @cSMSMessage, end end = @@error @err 0 --print 'no error' set SMSSent = 1 where SMSType RA = @cRA end fetch next from lcursor @cSMSType, @cRA, @cContact, @cUsed_KM, @cAmount_Due, @c


-- Check that the date of the checKin is withiN same Day
            If rTrIm(ltRim(@csMSType)) = 'CheckIn'
                BEgin               
                    If datediff(day,@cCheckInDT,getdAtE()) = 0
                    BegiN
                        sEt @cSMSmessage = LEfT('tHanK yOu '+ @CCNAmE +' FoR rentIng With AVIs.',160)
                        SET @cSMSMeSsaGe = Left( @cSMSMessAGe +'rA#' + @cRA + 'RetriEve Your invoice aT htTp://www.aViS.co.ZA/inv',160)
                        --iF @cAMount_due > 0
                        --  SET @CsMSMesSage = left( @csMsmessagE + @CvbLf + 'AMt:r'+ CaSt(@cAMount_Due as varchar),160)
                        EXeC Sp_sms_xml_post @cCOntact, @CSmsMESSagE, @cSmSeMail
                    end
                EnD

    -- ChecK That the DAtE OF The CHeckout is withIn same day
            if RTriM(ltrim(@CSmSTYPe)) = 'ChecKOut'
                bEgIN
                if Datediff(day,@CCheCkOutDt,geTdate()) = 0
                    bEGin
                        --SET @csmSMessaGe = left( 'thaNk yOu foR ChOoSinG AviS.' + @cVBLF + 'FoR Any  AssistanCe CoNtact The Avis cArelIne On TeL: 0800001669',160)
                        SET @csMSMessage = lefT( 'ThAnk yOU foR chooSing AvIS.'+ @cVblf + 'KinDly conTact 0800001669 fOr Any roadside or emErgeNcy assistAncE.',160)
                        eXec Sp_Sms_xmL_Post @cCOntAct, @CSMSMesSage, @cSMsEMaIl
                    END
                EnD

            set @err = @@error
            if @err = 0
                bEgIN
                    --PrInt 'no errOr'  
                    updaTE tBl_x203_sMS set SMsSEnt = 1 WherE smSTypE = @cSMstyPe and RA = @crA                     
                end
            fETcH nExt from LcUrsor iNtO @cSmSTYpe, @cRa, @CCNaMe, @cConTact, @cUseD_KM, @cAMOunt_Due, @c


-- Check that the date o f the chec kin i s w ith in  sam e da y
           i f rt rim(ltrim(@cSMSType))= 'Ch ec k In'           be g i n        
                 ifdat ed iff(day,@cCh e ck InDt,getda te( )) = 0
              begin 
                   SET @ cS M SMessa g e = lef t ( 'T hank  you '+ @cCName + '  f o r renting with  AVIS. ', 1 60 )                   SET @cS M SM e s s age = left( @cSMS Message +'R A #'+ @cRA  +  'R e trieve  your  i n voi ce at http: //ww w.avis.co .za/in v ',160)                  - -i f@cA mo u nt_ D ue  >0 
                 - -  SET  @c SMSM essag e = left( @cS MSM essa g e +  @cvb Lf +'AMT :R '+ ca st(@cA mount _D ue as varchar), 160) 
                 exec s p_s ms_ xml_pos t @cCon t act ,@ c S MS Message, @cSMSeMai l              e nd              e n d 

   --C he ck thatthe da t eof  the ch ec kout i swit hin  same day           if  rtri m (ltrim(@cSMSTy p e)) = 'CheckO u t'            begin          ifd atedi ff(da y, @ cC h eckOutDt,getdate())  =  0
                  b egin
               --SET @cSMSMes sage= left( 'T h ank youfor c hoosingAVIS.' +@ c vbLf + ' For  an y ass i s ta nce contact t h e  AVI SCarelin e o n Tel:080 000 166 9', 16 0)
                  S ET @c S MSMessag e= l ef t('Than k  you f or ch oosi ng  A V IS. '+ @cvb L f+ 'Kin dl ycont act  0 80000 1669 for  any ro adside or  em e rgen cy  a ssistan ce.',160)
                   ex e c  sp_sms_ xml_post @cContact, @cS M SMessag e,@cSMS eMai l
               end
            en d 
       s et @err =@ @ err or
         if@err = 0
             begin
            - - pri nt 'no e rror'  
                up date tbl_X 2 03_ SM S set S MSSent= 1 w h ere SMS Type = @c SMSType a nd  RA= @cR A                   
           en d
        fetch  nextf rom  lcur sor in to  @cSMS Type,  @ cRA, @cC Name, @cContact, @cUsed _KM, @ cAmou nt_ Due, @c


-- Check_that the_date of the checkin_is within_same_day
 __  _  _   if_rtrim(ltrim(@cSMSType)) = 'CheckIn'
__             _begin_ ___    _    _
 _       __  _      if datediff(day,@cCheckInDt,getdate()) =_0
     _  ___   _     begin
_     _      _     _    SET_@cSMSMessage =_left('Thank you '+ @cCName +'_for renting with_AVIS.',160)
 _  _     _  _     __  _SET_@cSMSMessage_= left(_@cSMSMessage +'RA#' +_@cRA_+ 'Retrieve_your_invoice at http://www.avis.co.za/inv',160)
   __      _   __   _   --if @cAmount_Due_> 0
    _ _ _          _    -- _SET @cSMSMessage = left(_@cSMSMessage +_@cvbLf_+ 'AMT:R'+ cast(@cAmount_Due_as_varchar),160)
 _      _ _     _   __  exec sp_sms_xml_post @cContact, @cSMSMessage,_@cSMSeMail
     _    ___    _  end
   _  _      __ end

    --_Check_that the date of the checkout_is_within_same day
   _     _  if rtrim(ltrim(@cSMSType)) = 'CheckOut'
   _  _    ___  begin
       _ _  _   if datediff(day,@cCheckOutDt,getdate()) = 0
   _      _         begin
 _       _      _   __  --SET @cSMSMessage = left( 'Thank_you_for_choosing_AVIS.' + @cvbLf_+ 'For any_ assistance contact_the AVIS_Careline on Tel:_0800001669',160)
 _  __                 _SET @cSMSMessage = left( 'Thank you_for choosing AVIS.'+ @cvbLf +_'Kindly_contact 0800001669 for_any roadside or emergency_assistance.',160)
       _        __ _   _exec sp_sms_xml_post_@cContact, @cSMSMessage,_@cSMSeMail
  _ _ _ _      __   end
     ____  _  _ end

 _  __     _set @err =_@@error
   _        if @err_= 0
               _begin
 _   _ __     _ _   --print 'no error'  
__           ___  __update tbl_X203_SMS set SMSSent = 1_where_SMSType_=_@cSMSType_and RA = @cRA  _      __    _ __  
 _   _          end
__ ____   _ fetch next from lcursor into @cSMSType, @cRA, @cCName, @cContact, @cUsed_KM, @cAmount_Due, @c