<!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} :{$language.lblModuleOffers}</title>
{include file='CommonStyles.tpl'}
{include file='CommonCustomStyles.tpl'}
{include file='CommonJavaScript.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/grid_listing.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/right-menu.css" />
<script type="text/javascript" src="{$view_javascript}/table.plugin.js"></script>

</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"> 
 {if $addPrivilege}	
 {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.lblOfferAddNew}"}
 {/if}
          </div>
        </div>
        <!--End: Right Block-->
        <div class="left_wrapper">
          <div class="content_wrapper">
                <div class="fixing_right">
                    {if $listOffer}
                        {include file='ContentLanguageOptions.tpl'}
                    {/if}
                </div>
                        
                <h2>{$language.lblModuleOffers}</h2>
                <div class="inner_content_wrapper"> 
                  <div id="common_message"></div>

                  {form->start name="formStatusOfferChange" action="" method="post" enctype="multipart/form-data"}
                        <div class="search_container">
                          <div class="inner single-box">
                                <ul class="clearfix">	
                                        <li class="column">
                                                <p class="label-field01">{$language.lblOfferofferTitle}</p>
                                                <span class="form-field01">
                                                    {form->textbox class="textbox " tabindex="8" name="offerTitle"}
                                                </span>
                                        </li>	
                                         <li class="column">
									<p class="label-field01">{$language.lblMenuBrands}</p>
									<span class="form-field01">
										{form->select class="select-box" name="brandID" caption="->{$language.lblSelect}" options=$listBrand}			                 
										</span>
								</li>       
                                        <li class="column">
                                            {form->submit name="search" tabindex="13" value="{$language.lblSearch}" class="button01 margin-r-10"} 
                                            {html->anchor href="/offer/" tabindex="14"  class="action-link" caption="{$language.lblListAll}" tabindex="8"}
                                        </li>
                                   </ul>
                          </div>
                        </div>
                        
                        {form->close}


                  {if $listOffer}
                  <div class="grid_table00"> 
                   {form->start name="formList" action=""  method="post" enctype="multipart/form-data"}
                   {form->hidden name="offerPriority"}
                   <table width="100%" border="0" cellspacing="0" cellpadding="0"   >
                          <tr>
                                {if $editPrivilege || $deletePrivilege}
                                <th align="left" valign="middle"  class="checkbox_column" style="width:5%;"> <div class="chekingdiv">
                                        <ul>
                                          <li> {form->checkbox name="ListStatusLinkCheckbox" id="ListStatusLinkCheckbox" class="fixing_left" value=""}
                                                {html->anchor href="" id="ListStatusLink" class="status-arw fixing_left" alt="down arrow"}
                                                <ul id="ListStatusSelection"  class="check_status">
                                                  <li> {html->anchor href="" rel="ListActive" content=$language.lblActive}</li>
                                                  <li> {html->anchor href="" rel="ListInactive" content=$language.lblInactive}</li>
                                                  <li> {html->anchor href="" rel="ListAll" content=$language.lblSelectAll}</li>
                                                </ul>
                                          </li>
                                        </ul>
                                  </div>
                                 </th>{/if}
                                <th  align="left" valign="middle" class="sort{if $sortby eq 'sort_offerTitle'}{$orderby}{/if}" style="width:35%;" >
                                {html->anchor href="{$link}sortby/sort_offerTitle/orderby/$orderby/" title="{$language.lblOfferofferTitle}" 	content="{$language.lblOfferofferTitle}"}
                                </th>
                                <th  align="left" valign="middle"  width="10%">{$language.lblMenuBrands}</th>
                                <th  align="left" valign="middle" style="width:50%;">
                                        {$language.lblOfferofferDescription}
                                </th>

                                {if $editPrivilege || $deletePrivilege}
                                <th  align="left" valign="middle" style="width:10%;" > </th>
                                {/if}
                          </tr>
                          </table>
                           </div>
<ul id="sort1" class="dragtree connectedSortable">
                          {foreach $listOffer as $key=>$offer}
                          {assign var="offerID" value=$offer.offerID}
<li data-id="{$offerID}" data-orderid="{$offer['priority']|default:0}">
     <table width="100%" cellspacing="0"  cellpadding="0" class="drag_table">
                          <tr class="shade01">
                                        {if $editPrivilege || $deletePrivilege}
                                                <td align="left" valign="middle" class="checkbox_column" style="width:5%;">
                                                          {form->checkbox 
                                                                name="offerID[]" 
                                                                class="adminUserBulkStatus checkbox01 ListAll 
                                                                {if $offer.status   eq 'A'}ListActive{else}ListInactive{/if}"  
                                                                options="" value=$offerID}                  
                                                </td>
                                        {/if}	
                                        <td align="left" valign="middle" style="width:35%;">
                                                {$offer['offerTitle']}
                                        </td>	
                                        <td align="left" valign="middle" style="width:10%;">
                                                {$offer['brandName']}
                                        </td>	
                                        <td align="left" valign="middle" style="width:50%;">
                                                {$offer['offerDescription']|unescape:"html"|strip_tags:true|truncate:250}
                                        </td>
                                {if $deletePrivilege || $editPrivilege}
                                <td align="left" valign="top" style="width:10%;">
                                        {html->anchor href="offer/view/id/{$offerID}/" class="preview icon-set"  title="{$language.lblView}" caption="" history="yes"}
                                        {if $editPrivilege}			  
                                                {if $offer.status=="A"}
                                                        {html->anchor title="Change Status" class="changeStatus status-active icon-set" id="{$offerID}" rel="I"}  
                                                {elseif $offer.status=="I"}
                                                        {html->anchor title="Change Status" class="changeStatus status-inactive icon-set" id="{$offerID}" rel="A" }
                                                {/if}
                                                {html->anchor href="offer/edit/id/$offerID/" class="edit02 icon-set"  title="{$language.lblEdit}" caption="" history="yes"}
                                        {/if}
                                        {if $deletePrivilege}
                                                {html->anchor 
                                                        confirm="{$language.msgDeleteItem}"  
                                                        confirm_head=$language.lblDelete
                                                        href="offer/destroy/id/$offerID/"
                                                        title="{$language.lblDelete}"  
                                                        class="delete02 icon-set" offerID="{$offerID}"}
                                        {/if} 
                                </td>
                                {/if}
                        </tr>
     </table>
</li>
                          {/foreach}
</ul>
                        </table>
                        <br>
                       
                        {if $editPrivilege || $deletePrivilege}
                                {if $deletePrivilege && $editPrivilege}
                                {assign var="statusoptions" 	
                                value="->{$language.lblDonotchange}~*A->{$language.lblActivate}~*I->{$language.lblInactivate}~*D->{$language.lblDelete}"}
                                {else if $deletePrivilege && (!$editPrivilege)} 
                                {assign var="statusoptions" value="->{$language.lblDonotchange}~*D->{$language.lblDelete}"} 
                                {else if (!$deletePrivilege) && $editPrivilege} 
                                {assign var="statusoptions" value="->{$language.lblDonotchange}~*A->{$language.lblActivate}~*I->{$language.lblInactivate}"} 
                        {/if} 

                        <div class="action_box">
                                {form->select name="select_status" class="select-box width-auto" options=$statusoptions value=""}
                                {form->submit name="changeStatus" id="submitBulkStatus" class="button04"  value="{$language.lblUpdate}"}
                        </div>
                        {/if} 
                        {form->close}
                     {*   <div class="fixing_right pagination_outer" >{paginate->layout  key="page" label_record="{$language.lblRecorsFound}" label_pages="{$language.lblPages}"} </div>*}
                        <div class="clear"></div>
                        {else}
                        <div class="message_info" id="common_message">{$language.msgNoRecords}</div>
                        {/if}
                  <!--End:From Listing--> 
                </div>
                <!--End:Border 3--> 
          </div>
          <!--End:Border 2--> 
        </div>
        <!--End: left Block-->
        <div class="clear"></div>
  </div>
  <!--End: Content--> 

  {include file='CommonBottom.tpl'} </div>
<!--***********************************************************************END CONTAINER SECTION******************************************************--> 
<!--End:Content Container--> 
<!--End:Outer Container--> 
{include file='CommonJavaScriptBottom.tpl'} 

<script type="text/javascript">
var msgDeleteItem	= '{$language.msgDeleteItem}';
var msgSelectItem	= '{$language.msgSelectItem}';
var lblSelectAction			= '{$language.lblSelectAction}';
var msgSelectSearchCriteria	= '{$language.msgSelectSearchCriteria}';
var lblSelectItem			= '{$language.lblSelectItem}';	
var lblAny              =   '{$language.lblAny}';
</script>
<script type="text/javascript" src="{$view_javascript}/offerlist.page.js"></script> 
 <style type="text/css">
.grid_table00 {
	margin-bottom:0!important;
	}
	.drag_table
	{
		border-bottom:#d3d4d8 solid 1px;
		cursor:move;
	}
        .no_drag
	{
		border-bottom:#d3d4d8 solid 1px;
                cursor:default;
	}
.drag_table td 
{
	border:#d3d4d8 solid 1px;
	border-bottom:0px;
	border-top:0px;
	padding:3px;
	font:12px Arial, Helvetica, sans-serif;
}
.drag_table tr:hover {
	background:#edf4f8;
	}
        .no_drag td 
{
	border:#d3d4d8 solid 1px;
	border-bottom:0px;
	border-top:0px;
	padding:3px;
	font:12px Arial, Helvetica, sans-serif;
}
.no_drag tr:hover {
	background:#edf4f8;
	}
.dd-placeholder{
	margin: 5px 0;padding: 0;min-height:25px;background: #f2fbff;border: 1px dashed #b6bcbf;box-sizing: border-box;
-moz-box-sizing: border-box;
}	
</style>
<script type="text/javascript">
    $(document).ready(function(){
       // $('#userOrderList').val(parseTree($("#sort1"),0,0));
       var offerGroupID=$('#offerGroupID').val();
       if(offerGroupID!=''){
       makeSortable();
   }
   });
        function makeSortable(){
      $( '#sort1.connectedSortable,#sort1 .connectedSortable' ).sortable({
        //handle: ".drag" ,
        connectWith: ".connectedSortable",
        placeholder: "dd-placeholder",
        cursor: "move",
        update:function(event,ui){
                /*$( '#sort1.connectedSortable li,#sort1 .connectedSortable li' ).each(function(){
                                var key=parseInt($(this).parents('ul').length);
                                $(this).find('.chk-bx').css('left',key*(-25)+"px");
                });
                */

                $("#sort1 li").each(function(){
                        var obj=$(this);
                        var ulCount=obj.find('ul').length;
                        var liCount=obj.find('li').not('.addNew').length;
                        if(!obj.hasClass('addNew')){
                                var level=parseInt(obj.parents('ul').length)-1;
                                obj.attr('data-level',level);
                        }
                        if(!ulCount ){
                                obj.append(' <ul class="connectedSortable  addOn"><li class="addNew"></li></ul>');
                        }
                        else{
                                obj.find('.addNew').remove();
                        }
                        if(liCount>0){
                                obj.find('.expand').removeClass('hide');
                        }
                        else{
                                obj.find('.expand').addClass('hide');
                        }

                });
                $("#sort1 li .addOn").each(function(){
                        if($.trim($(this).html())==''){
                                $(this).html('<li class="addNew"></li>');
                        }
                });
                ui.item.parent('ul').parent('li').find('.expand:first').addClass('minus').text("-");
                makeSortable();
        },
        over:function(event,ui){
                var currheight=ui.helper.css('height');
                $('.dd-placeholder').css('height',currheight);
        },
        receive:function(event,ui){
                $('#sort1').css('min-height',(parseInt($('#sort1').css('height'))+25)+"px");
        },
        beforeStop:function(event,ui){
               //$('#offerPriority').val(parseTree($("#sort1"),0,0));
                $.ajax({
                        type:"POST",
                        async: false,
                         data: 'offerPriority=' + parseTree($("#sort1"),0,0),
                         url:GLOBAL_BASE_PATH + "/offer/ajaxUpdateOfferPriority/",
                         success : function (data) { 
                        //location.reload(); 

                         }
                })
        }
}).disableSelection();
        }
	function parseTree(ul,val,preKey){
	var tags = "";
	var i=1;
	$('#sort1 li').each(function(){
		if(!$(this).hasClass('addNew')){
			if(typeof $(this).data("id")!='undefined'){
				var obj = $(this).data("id") + ":" + i;
				i=i+1;
				if(tags){
				tags=tags+","+obj;	
				}
				else{
					tags=obj;
				}
			}
		}
	});
	
	return tags;
}

                </script>
{html->messages_script id="common_message"}
</body>
</html>