<!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" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{$language.lblBusiness}: {$language.lblDeliveryZones} </title>
{include file='CommonStyles.tpl'}
{include file='CommonJavaScript.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/adding-page.css" />
<!--<link rel="stylesheet" type="text/css" href="{$view_styles}/right-menu.css" />-->
{include file='CommonCustomStyles.tpl'}

</head>
<body class="{$languageDirection}">
<div class="outer_container">{include file='CommonHeader.tpl'}
<!--***********************************************************************START CONTAINER SECTION******************************************************-->

  <div class="content-wrapper">  
<div class="container-fluid">
 <h2>{if $deliveryZoneID|default:''}{$language.lblEditDeliveryZone}{else}{$language.lblAddNewDeliveryZone}{/if}</h2>
 
       
        <div class="container-section col-md-12 col-xs-12">
         {form->start name="formDeliveryZone" method="post" enctype="multipart/form-data" class="form-horizontal"}
          <div class="form_listing clearfix">
            <ul>
              <li class="clearfix form-group">
                <label class="control-label col-md-3 col-sm-3 col-xs-12">{$language.lblDeliveryZoneName}</label>
                <!--End:Left-->
                <div class="col-sm-8 col-md-5 col-xs-12">
				{form->textbox auto_complete="off" name="deliveryZoneName" class="form-control" validate="required" error=$language.errDeliveryZoneName maxlength="100"  tabindex="1"} 
                {form->hidden name="countExists" value="0" id="countExists"}
                 {form->hidden name="existChecked" id="existChecked"}
                {form->validate  name="validateState" validate="countExists->isequal->1~*existChecked->required" error=$language.errDeliveryZoneAlreadyExist}
                             </div>
                    
                <!--End:right-->
              </li>
              <li class="clearfix form-group">
                <label class="control-label col-md-3 col-sm-3 col-xs-12">{$language.lblDescription} </label>
                <!--End:Left-->
                <div class="col-sm-8 col-md-5 col-xs-12"> {form->textarea name="deliveryZoneDescription" id="deliveryZoneDescription" class="form-control" maxlength="175" tabindex="2"} </div>
                <!--End:right-->
              </li>
              <li class="clearfix form-group">
                <label class="control-label col-md-3 col-sm-3 col-xs-12">{$language.lblZoneType}</label>
                <div class="col-sm-8 col-md-9 col-xs-12">
                 <div id="periodZoneTypediv"> {form->radio name="deliveryZoneType" class="customradio" options="National->{$language.lblNational}~*Region->{$language.lblRegion}~*Location->{$language.lblLocation}" value="National"} </div>
                </div>
                <div class="clear"></div>
              </li>              
              <li class="clearfix form-group" id="ajax_new_countryDiv" style="">
                 
                <div class="col-sm-8 col-md-offset-3 col-sm-offset-3 col-xs-12">
                  <div class="country-select" id="Zonehead" style="display:none;">                      
                      <table width="100%" align="center" cellpadding="0" cellspacing="0" > 
                           <tr> 
                               <th width="40%" id="country01">{$language.lblCountry}</th>
                                <th>
                                    <table width="100%">
                                        <tr>
                                            <th width="40%" id="state01">{$language.lblState}</th>
                                            <th width="100" id="zipcode01">{$language.lblZipCode}</th>
                                            <th></th>
                                        </tr>
                                    </table>
                                </th>
                            </tr>
                        {if $rsCountryState|default:''}
                            <tr>  <td colspan="3" id="ajax_new_country" width="100%">                                  
                             {assign var="count1" value=$rsCountryStateCount}
                             {if $count1>0}
                             {foreach item=rsCountryStat from=$rsCountryState key="k"}
                             <table width="100%" id="AjaxCountryExists_{$k}" border="0">
                             <tr class="zone-list" >                                 
                               <td  class="country_list" width="40%"  align="left" valign="top"> 
                                   {form->hidden class="selectdAjaxCntry" name="countryIDs[]" value=$k id="countryIDs"}                           
                                     {$rsCountryStat.countryName}&nbsp;                  
                                   {html->anchor href="" onclick="delCountry({$k});" title="{$language.lblRemoveCountry}"  alt='delete' class="icon-close2"}                         
                               </td>   
                              {if $zoneType neq 'National'} 
                                  <td>   
                                     
                                      <table class="states_list locationList"  id="states_list_{$k}" width="100%" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
                                                {if isset($rsCountryStat.rsStates) && $rsCountryStat.rsStates|@count >0}
                                                         {form->hidden name="hidCountryName" id="hidCountryName_$k" value=$rsCountryStat.countryName}
                                                         {assign var="totalstates" value=$rsCountryStat.rsStates|@count}  
                                                         {foreach from=$rsCountryStat.rsStates item="rsState" key=key1} 
                                                                {assign var="ID" value=$rsState.stateID}
                                                                {if $slctdStates.$k|@count gt 0 && $ID|in_array:$slctdStates.$k}
                                                                        {if $zoneType eq 'Location'}
                                                                                {assign var="countryZipArr" value=$rsCountryStat.$ID.zipCodes}
                                                                         {foreach from=$countryZipArr item="zips" key=zipkey}
                                                                                  <tr id="right_state{$k}_{$ID}">
                                                                                        <td {if $zoneType eq 'Location'}width="40%"{/if}>  
                                                                                                <span class="pp-rightpanel" >{$rsState.stateName} &nbsp; </span>
                                                                                                {form->checkbox class="statearray_{$k}" style="display:none" name="statearray[{$k}][]" id="check_{$ID}" checked="checked"  value="{$ID}"}
                                                                                        </td > 
                                                                                        <td align="left" valign="top"> 
                                                                                        {form->textbox value={$zips} name="zipCodes{$k}_{$ID}[]" class="form-control" style="width:100%;display:none"}{$zips}
                                                                                        {form->hidden name="isRange{$k}_{$ID}[]" value="{$rsCountryStat.$ID.isRange[$zipkey]}"}
                                                                                        </td>
                                                                                        <td align="left" valign="top">  
                                                                                                {if $zoneType eq 'Location'}
                                                                                                {html->anchor href="" style="float:right;" class="editlink icon-edit-fill" onClick="editStateAjax('{$k}','{$ID}','zip',this)" alt="{$language.lblEdit}"} 
                                                                                                {/if}
                                                                                         {html->anchor href="" style="float:right;margin-right:10px;" class="icon-close2" onClick="delStateAjax('{$k}','{$ID}','{$rsCountryStat.$ID.delZoneRegID[$zipkey]}',this)" alt="{$language.lblRemoveState}"} 
                                                                                        </td>
                                                                                   </tr>
                                                                        {/foreach}
                                                                        {else}
                                                                                <tr id="right_state{$k}_{$ID}">
                                                                                        <td {if $zoneType eq 'Location'}width="40%"{/if}> 
                                                                                                <span class="pp-rightpanel" >{$rsState.stateName} &nbsp; </span>
                                                                                                {form->checkbox class="statearray_{$k}" style="display:none" name="statearray[{$k}][]" id="check_{$ID}" checked="checked"  value="{$ID}"}
                                                                                          </td >   
                                                                                          <td align="left" valign="top">       
                                                                                                {html->anchor href="" style="float:right;margin-right:10px;" class="icon-close2" onClick="delStateAjax('{$k}','{$ID}','',this)" alt="{$language.lblRemoveState}"} 
                                                                                         </td>
                                                                                          </tr>
                                                                                {/if}
                                                                {/if}
                                                        {/foreach}
                                                {else}
                                                        {if $zoneType eq 'Location'}
                                                                  {foreach from=$rsCountryStat.0.zipCodes item="zips" key=zipkey}
                                                                          <tr id="right_state{$k}_0">
                                                                                <td  {if $zoneType eq 'Location'} width="40%"{/if}>{form->hidden name="hidCountryName" id="hidCountryName_$k" value=''}</td> 
                                                                                <td align="left" valign="top" colspan="2">
                                                                                        {form->textbox value={$zips} name="zipCodes{$k}_0[]" class="form-control" style="width:100%;display:none"}{$zips}{form->hidden name="isRange{$k}_0[]" value="{$rsCountryStat.0.isRange[$zipkey]}"}                                                                      
                                                                                </td>
                                                                                <td>{if $zoneType eq 'Location'}{html->anchor href="" style="float:right;" class="editlink icon-edit-fill" onClick="editStateAjax('{$k}','0','zip',this)" alt="{$language.lblEdit}"} {/if}
                                                                                {html->anchor href="" style="float:right;margin-right:10px;" class="icon-close2" onClick="delStateAjax('{$k}','0','{$rsCountryStat.0.delZoneRegID[$zipkey]}',this)"} 
                                                                                </td>
                                                                   </tr>
                                                                  {/foreach}
                                                        {else}
                                                                         <tr id="right_state{$k}_0">
                                                                           <td  {if $zoneType eq 'Location'} width="40%"{/if}>
                                                                                {form->hidden name="hidCountryName" id="hidCountryName_$k" value=''}
                                                                                {if $zoneType eq 'Region'}
                                                                                  {form->hidden name="AjaxAllStates_{$k}" value="1"}
                                                                                  <span >{$language.lblApplicabletoallstates}</span> 
                                                                                 {/if} 
                                                                           </td> 
                                                                         </tr>  
                                                   {/if}			
                                        {/if}
                                    </table>                      
                               </td>
                                {/if}
                               </tr>  </table>
                             {assign var="countryname" value=$rsCountryStat.countryName} 
                             {/foreach}              
                             {/if} 
                               </td></tr>
                             {/if}
                        <tr><td colspan="3" id="ajax_new_country" width="100%"> </td></tr>
                        </table>
                  </div>
                 </div> 
              </li>
              <li class="clearfix form-group" >
                
                <div class="col-sm-8 col-md-7 col-md-offset-3 col-sm-offset-3 col-xs-12"> 
                 <div class="country-outer clearfix">
                   
                   
                    {form->select name="AddCountry" class="form-control pull-left selectpicker margin-bottom" caption="->{$language.lblSelectaCountry}" id="AddCountry" options=$resCountry tabindex="5"}
                    
                    <div style="" id="stateInput" class="margin-bottom clearfix"></div>
                    
                   <div class="loc-save">{html->anchor id="addNewCountry" name="addNewCountry"  href="" class="btn btn-primary btn-xs" onclick="addCountryState();" content="{$language.lblAdd}"}
                   {html->anchor id="cancelEdit" class="btn btn-default btn-xs" name="cancelEdit" href="" onclick="cancelEdit();" content="{$language.lblCancel}"}
                  <span id="cityLoc_loader" class="hide">&nbsp;<img src="{$view_images}/loader.gif" /></span> </div>  </div>
                  {form->validate name="countryCount" id="countryCount" validate="countryCount->isequal->0~*AddCountry->required" error=$language.errSelectCountry}
                                  
                </div>                       
                {form->hidden name="selectedStates"  id="selectedStates" value=$slctdStates|default:''}                
                {form->hidden name="selectedCountries"  id="selectedCountries" value=$selcountries|default:''}                
                {form->hidden name="removeIcon"  id="removeIcon" value="$view_images/remove.gif"}                
                {form->hidden name="hidStateCount" id="hidStateCount" value=$hidStateCount|default:''} 
                {form->hidden name="deliveryZoneID" id="deliveryZoneID" value=$deliveryZoneID|default:''}
                {form->hidden name="slctdStatsLoctn" id="slctdStatsLoctn" value=$slctdStatsLoctn|default:''}
              </li>
              <li class="clearfix form-group">
              <label class="control-label col-sm-3 col-md-3 col-xs-12">{$language.lblStatus}</label>
                <div class="col-sm-8 col-md-5 col-xs-12">
                  <div id="perioddiv"> {form->radio name="deliveryZoneStatus" class="customradio" options="Active->{$language.lblActive}~*Inactive->{$language.lblInactive}" value="Active"}      
                    {form->hidden name="rsTaxRateCount" value=$resTaxRateCount|default:''} </div>
                </div>
              </li>
              <li class="clearfix form-group">
                <div class="col-sm-8 col-md-5 col-md-offset-3 col-sm-offset-3 col-xs-12">
                <div class="submit-block clearfix"> 
                   {form->submit name="submitDeliveryzone" id="submitDeliveryzone" class="btn btn-primary btn-sm"  value="{if $deliveryZoneID|default:''}{$language.lblUpdate}{else}{$language.lblSave}{/if}" tabindex="7"} 
                    {if !$previousURL|default:''} {assign var="previousURL" value="/deliveryzone/"}{/if} 
                       
                    {html->anchor name="cancel" id="cancel" class="btn btn-default btn-sm" content="{$language.lblCancel}" href="$previousURL" tabindex="8"}         </div>
                  </div>
              </li>
            </ul>
          </div>
          <!--End:From Listing-->
           {form->close}
        </div>
                
                 <!-- right side bar starts
    <div class="col-md-3">
    <div class="side_wrapper">
   
   <div>
    <ul>
    	<li>{html->anchor href="/deliveryzone/index/"  class="side_menu_a  selected"  content="{$language.lblListDeliveryZones} <span> <br/>{$language.lblListDeliveryZones} </span>" title="{$language.lblListDeliveryZones}"}</li>
       </ul>
    
    </div>
    </div>
    </div>
     right side bar ends-->

      </div>
   <div class="clear"></div>
              </div>
       
        <div class="clear"></div>
{include file='CommonFooter.tpl'}
</div>
<!--End:Outer Container--> 
<script type="text/javascript">
	
	var lblSelectOneCountry ="{$language.lblSelectOneCountry}";	
	var lblmsgConfirmsub	="{$language.lblmsgConfirmsub|default:''}";
	var lblMaxCharaLength	="{$language.lblMaxCharaLength}";
	var lblCountryAlongState="{$language.lblCountryAlongState}";
	var msgAddState			="{$language.msgAddState}";
	var lblPleaseAddCountry ="{$language.lblPleaseAddCountry}";
	var errSelectCountry    ="{$language.errSelectCountry}";
	var errDescription    ="{$language.errDescription}";
	var errDeliveryZoneName	=	"{$language.errDeliveryZoneName}";
        var errDeliveryZoneAlreadyExist="{$language.errDeliveryZoneAlreadyExist}";
		var deleteText = "{$language.lblDelete}";
        var errStateDeleteConfirm  = "{$language.errStateDeleteConfirm|default:''}";
        var errZIP  = "{$language.errZIP}";
        var errRange  = "{$language.errRange}";
        var errValidZIPRange  = "{$language.errValidZIPRange}";
        var lblSelectAll = "{$language.lblSelectAll}";
        var lblDeselectAll = "{$language.lblDeselectAll}";
        var lblEdit = "{$language.lblEdit}";
        var lblAdd = "{$language.lblAdd}";
    </script>
{include file='CommonJavaScriptBottom.tpl'}
<script type="text/javascript" src="{$view_javascript}/custom-radiobutton.js"></script>
<script type="text/javascript">
$(function(){
	 $('#periodZoneTypediv input').customInput('');
	 $('#perioddiv input').customInput('');
});	
    {*$('.selectpicker').selectpicker({
  style: 'btn-info',
  size: 4
});*}

</script>
{form->basepath_script}
<script type="text/javascript" src="{$common_js}/validate.plugin.js"></script>
{form->validate_script form="formDeliveryZone"}
{html->messages_script id="common_message"}
<script type="text/javascript" src="{$view_javascript}/deliveryzoneadd.page.js"></script>

</body>
</html>
