<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$language.lblAdmin} : {if $offerID|default:"">0}  {$language.lblOfferEdit}  {else} {$language.lblOfferAddNew} {/if}</title>
{include file="CommonStyles.tpl"}
{include file="CommonCustomStyles.tpl"}
{include file="CommonJavaScript.tpl"}
<link rel="stylesheet" type="text/css" href="{$view_styles}/form_listing.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/inner-formlisting.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/right-menu.css" />	
<link href="{$view_styles}/jquery-ui-1.8.19.custom.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/ui.daterangepicker.css" />
</head><body>
<div class="outer_container"> {include file='CommonTop.tpl'} 
  <!--End:Header Container--> 
  <!--*************************************************START CONTAINER SECTION*************************************************-->
  <div class="content_container2 clearfix">

        <div class="right-sidebar">
          <div class="side_wrapper"> 
          {html->anchor priv_href="offer/new/" href="offer/new/" class="custom-btnt" content="<span class='plus-v'></span><span class='plus-h'></span><strong><span class='add'></span>{$language.lblOfferAddNew} </strong>" title="{$language.lblOfferList}"}
          <ul>
                <li>
                        {html->anchor priv_href="offer/index/" href="/offer/index/"  class="side_menu_a selected" content="{$language.lblManageOffers}<br /><span>{$language.lblManageOffers}</span>"} 

                </li>

        </ul>
          </div>
        </div>
        <!--End: Right Block-->
        <div class="left_wrapper">
        {form->start name="formOffer" action="" method="post"}
        {form->hidden name="offerID" value="{$offerID}"}
        
          <div class="content_wrapper">
              {if isset($offerID) && $offerID>0}
                <div class="fixing_right">
                     {if $offerID>0 && $availableLang|default:'' neq 0}
                 {include file='ContentLanguageOptions.tpl'}
                {/if} 
                </div>
                {/if}
                <h2>
                {if isset($offerID) && $offerID>0}
                        {$language.lblOfferEdit}
                {else}		
                        {$language.lblOfferAddNew} 
                {/if}
                </h2>
                <div class="inner_content_wrapper">
                <div id="common_message"></div>
                  <div class="form_listing form_listing03">
                        <ul>
                        <li class="clearfix">
							<div class="leftside01 mandatory">
								{$language.lblMenuBrands}
							</div>
							<!--End:Left-->
							<div class="rightside01"> 
								{form->select style="width:45%;" class="select" name="brandID" caption="->{$language.lblSelect}" options=$listBrand validate="required" error=$language.errFranchisee}
							</div>
							<!--End:right-->
						  </li>    
                        <li class="clearfix">
                                <div class="leftside01 mandatory">
                                        {$language.lblOfferofferTitle}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textbox
                                                name="offerTitle" 
                                                class="textbox" 
                                                tabindex="8"
                                                validate="required" 
                                                error="{$language.errOfferofferTitleRequired}"} 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01 mandatory">
                                        {$language.lblOfferofferUrlKey}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textbox
                                                name="offerUrlKey" 
                                                class="textbox" 
                                                tabindex="1"
                                                validate="required" 
validate="required~*isUrlKey~*offerUrlKey->database->offers,offerUrlKey,offerID!='{$offerID|default:""}' AND status!='D'" error=$language.errOfferofferUrlKeyRequired|cat:'~*~*'|cat:$language.errUrlKeyExists validate_inline="yes"
                                               } 
                                </div>
                                <!--End:right-->
                          </li>
                                  <!--Language specific start-->           
                        {if $view_common_languages|@count>1}
                        <li class="clearfix">
                            <div class="leftside01 mandatory">
                                {$language.lblLanguages}:
                            </div>						
                            <div class="rightside01 ">
                                {if $availableLang|default:''==0 || $availableLang|default:''==''}
                                {assign var="languageVar" value="Yes"} 
                                {else}
                                {assign var="languageVar" value="No"} 
                                {/if}
                                {form->radio name="langSelect" class="AllLangOptions" options="Yes->{$language.lblCommonLanguage}~*No->{$language.lblSpecificLanguage}" value=$languageVar}
                            </div>
                        </li>											 

                        <li class="selection clearfix langSpecific">
                            <div class="leftside01 mandatory">{$language.lblLanguages}:</div>
                            <div class="rightside01">
                                <div class="div-languageSpecific" id="specificLangDiv">
                                    <ul class="levl-03 blogLanguage">{form->hidden name="currentContentLanguageID" value=$currentContentLanguageID|default:''}												
                                      {foreach item="specificLanguage" from=$view_common_languages}
                                      <li class="clearfix"> {form->checkbox tabindex="3"  name="selectedLang" class="cntntlanguage" options=$specificLanguage.0|cat:"->"|cat:"&nbsp;"|cat:$specificLanguage.1 value=$resLanguageSelects|default:''}</li>
                                          {/foreach}
                                         {if $testimonialsID}<span class="sub-text">{$language.msgSelectContentLanguage}</span>                    
                                    {*{form->hidden name="hiddenParentLangCheck" value="0"}                          
                                    {form->validate name="checkParentLang" validate="hiddenParentLangCheck->isequal->1~*required" error=$language.errParentMenuItemLanguageChange} 
                                    {form->hidden name="hiddenLangCheck" value="0"}*}
                                    {form->validate name="checkContentLang" validate="hiddenLangCheck->isequal->1~*required" error=$language.errMenuWithLanguageNotExists}             
                    {/if} 
                                    {form->validate name="checkLangSelect" validate="langSelect->isequal->No~*required" error=$language.errLanguage}                                     
                                    </ul>
                               </div>  													
                            </div>
                      </li>
                        {/if}
                        <li class="clearfix">
                                <div class="leftside01 ">
                                        {$language.lblFeatured}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->checkbox name="featured" value="Yes" checked="{if $featured=='Yes'}True{/if}" tabindex="4"}
                                </div>
                                <!--End:right-->
                          </li>
                          <li class="clearfix">
                                <div class="leftside01 mandatory">
                                        {$language.lblStartDate}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                    {if $offerStartTime|default:''!="" && $offerStartTime|default:''!="0000-00-00 00:00"} 
                                     {assign var="offerStartTime" value=$offerStartTime|customDate}
                                    {else}
                                     {assign var="offerStartTime" value=""}
                                    {/if} 
                                   {form->textbox name="offerStartTime"  tabindex="5" validate="required" autocomplete="OFF" error=$language.errStartDate  class="text-box date-field"}
                                </div>
                                <!--End:right-->
                          </li>
                                 <li class="clearfix">
                                <div class="leftside01 mandatory">
                                        {$language.lblEndDate}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                    {if $offerEndTime|default:''!="" && $offerEndTime|default:''!="0000-00-00 00:00"} 
                                     {assign var="offerEndTime" value=$offerEndTime|customDate}
                                    {else}
                                     {assign var="offerEndTime" value=""}
                                    {/if} 
                                   {form->textbox name="offerEndTime"  tabindex="5" validate="required~*hiddenStartEndDate->value->0->required" autocomplete="OFF" error=$language.errEndDate|cat:"~*"|cat:$language.errStartEndDate  class="text-box date-field"}
                                   {form->hidden name="hiddenStartEndDate" value="0"} 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01  mandatory">
                                        {$language.lblOfferofferDescription}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->editor
                                                name="offerDescription" 
                                                rows="5" cols="30" mode="advanced" skin=2
                                                tabindex="9"
                                                validate="required" 
                                                error="{$language.errOfferofferDescriptionRequired}"} 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01 ">
                                        {$language.lblOfferSubTitle}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textbox
                                                name="offerSubTitle" 
                                                class="textbox" 
                                                tabindex="9"} 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01 ">
                                        {$language.lblOfferSubDescription}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textarea
                                                name="offerSubDescription" 
                                                class="textarea" 
                                                tabindex="9"} 
                                </div>
                                <!--End:right-->
                          </li>        
                        <li class="clearfix">
                                <div class="leftside01 mandatory ">
                                        {$language.lblOfferofferImage}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->upload_image 
                                                name="offerImage"
                                                tabindex="2"	
                                                path 			= "uploads/offer/thumb/"
                                                file			= $offerImage|default:''                                                                                                 validate="required" 
                                                error="{$language.errOfferofferImageRequired}"
                                                }
                                </div>
                                <!--End:right-->
                          </li>        
                        <li class="clearfix">
                                <div class="leftside01 ">
                                        {$language.lblOfferofferMetaTitle}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textarea
                                                name="offerMetaTitle" 
                                                class="textarea" 
                                                tabindex="10"

                                                } 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01  "> 
                                        {$language.lblOfferofferMetaDescription}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textarea
                                                name="offerMetaDescription" 
                                                class="textbox" 
                                                tabindex="11"

                                                } 
                                </div>
                                <!--End:right-->
                          </li>
                        <li class="clearfix">
                                <div class="leftside01 ">
                                        {$language.lblOfferofferMetaKeywords}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        {form->textarea
                                                name="offerMetaKeywords" 
                                                class="textbox" 
                                                tabindex="12"

                                                } 
                                </div>
                                <!--End:right-->
                          </li>
                          <li class="clearfix">
                                <div class="leftside01 mandatory">
                                        {$language.lblOfferstatus}
                                </div>
                                <!--End:Left-->
                                <div class="rightside01"> 
                                        <div id="perioddiv">
                                        {form->radio 
                                                name="status" 
                                                class="customradio"
                                                tabindex="6"
                                                value="A"
                                                options="A->{$language.lblActive}~*I->{$language.lblInactive}" 

                                                } 
                                        </div>
                                </div>
                                <!--End:right-->
                          </li>
                          <li class="clearfix">
                                <div class="submit-block clearfix"> 
                                                <span>  </span>
                                                <div class="leftside01"> </div>
                                                <div class="rightside01">	
                                                {form->submit 
                                                        name="submitOffer" 
                                                        class="curve-3" 
                                                        value="{if isset($offerID) && $offerID>0}{$language.lblUpdate}{else}{$language.lblSave}{/if}"}
                                                        {$language.lblOr}
                                                        {html->anchor  href="offer/index/" content="{$language.lblCancel}"}

                                                 </div>
                                        </div>
                                <!--End:right-->
                          </li>
                        </ul>
                  </div>
                  <!--End:From Listing--> 
                </div>
                <!--End:Border 3--> 
          </div>
          <!--End:Border 2--> 
          {form->close} 
          </div>
        <!--End: left Block-->
        <div class="clear"></div>
  </div>
  <!--End: left Block-->
  <div class="clear"></div>
</div>
<!--*********************************************END CONTAINER SECTION******************************************************--> 
<!--End:Content Container--> 
{include file='CommonBottom.tpl'}
</div>
<!--End:Outer Container--> 
{include file='CommonJavaScriptBottom.tpl'} 
<script type="text/javascript" src="{$common_js}/validate.plugin.js"></script> 
{form->basepath_script}
{form->validate_script form='formOffer'}
{html->messages_script id="common_message"}
{form->editor_script names="offerDescription"}
<script type="text/javascript" src="{$view_javascript}/jquery-ui-timepicker-addon.js"></script> 
<script type="text/javascript" src="{$view_javascript}/custom-radiobutton.js"></script>
<script type="text/javascript" src="{$view_javascript}/offerAdd.page.js"></script>
<script type="text/javascript">
    var settingsRedirectUrl = '{$settingsRedirectforurl}';
var sysKeys = '{$sysKeys}';
    var lblAny              =   '{$language.lblSelect}';
        {literal}
        $(function(){
                 $('#perioddiv input').customInput('');
        });	
        {/literal}
</script>

<script type="text/javascript" src="{$common_js}/uploadImage.plugin.js"></script> 
<script>
$(document).ready(function(){	
    checkParentlanguageIDs();
   // $('input[type="submit"]').prop("disabled", true);
var a=0;

if($('.AllLangOptions').is(':checked')){           
            if($('input[type="radio"]:checked').val() == 'No'){
            $('.langSpecific').show();
            }else{
            $('.langSpecific').hide();
            }
        }
    $('.AllLangOptions').click(function(){       
        if($('input[type="radio"]:checked').val() == 'No'){
        $('.langSpecific').show();
        }else{
        $('.langSpecific').hide();
        }
    });
});



//To validate parent menu item language change.
function checkParentlanguageIDs() {
    //Module check section 
    var itemType = $('#menuItemType option:selected').attr('modKey');
        if(itemType=='text'){
            $('.AjaxLinkDiv').attr('style','display:none');
        } 
        //module ends
	$("#hiddenParentLangCheck").val(0);
         $("#hiddenLangCheck").val(0);      
        var allLang=$('input:radio[name="langSelect"]:checked').val();
        var selLanguages = [];    
    if(allLang=='Yes'){ 
        var selected = '0'; 
        $("#hiddenLangCheck").val(0);                              
        $("#checkContentLang").trigger('blur');  
    }else {   
        var selected = '';
        $('#specificLangDiv input[type="checkbox"]:checked').each(function () {
                selLanguages .push($(this).val());
        });        
    }   
     if(selLanguages.length>0){
             $("#checkLangSelect").val(1);
         }else {
              $("#checkLangSelect").val('');
         }
         $("#checkLangSelect").trigger('blur');         
    if((selected!='0') )  {
               var content = $('#currentContentLanguageID').val();
               //check content languaage & selected language
                if((selLanguages.indexOf(content))== -1){
                    $("#hiddenLangCheck").val(1);                              
                    $("#checkContentLang").trigger('blur');                    
                }               
                        
	} 
        return false;
 } 
 
 $(".cntntlanguage").change(function () {
        checkParentlanguageIDs();
    })
     var currDate = new Date;
        currDate.setDate(currDate.getDate() - 1);
        currDate.setHours(00);
        currDate.setMinutes(00);
     $('#offerStartTime').datetimepicker({
            minDate: currDate,
             onSelect: function (dateText, inst) {
                $("#div_err_formOffer_offerStartTime").addClass("hide");
            }
        });
        $('#offerEndTime').datetimepicker({
            minDate: currDate,
             onSelect: function (dateText, inst) {
                $("#div_err_formOffer_offerEndTime").addClass("hide");
            }
        });
           $("#offerStartTime,#offerEndTime").change(function () {
            var setStartEndDateValidation = setCouponStartEndDateValidation();
        })
	function setCouponStartEndDateValidation() {
            var startDate = convertDate($("#offerStartTime").val(), datePickerDateFormat);
            var endDate = convertDate($("#offerEndTime").val(), datePickerDateFormat);
            if ((startDate < endDate) && (startDate != "") && (endDate != "")) {
                $("#hiddenStartEndDate").val(0);
            } else {
                $("#hiddenStartEndDate").val(1);
            }
        }
</script>

</body>
</html>