
<script type="text/javascript">
//check if user choosed any item, otherwise do nothing and show an alert
function countChoosenProducts()
{
	
	if ($('.choosenItem:checked').length > 0) {  
	// the "> 0" part is unnecessary, actually
	//  var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
   	 	$("#form1").attr("action","assetTypeController.php?do=execute");
	   
	   // spryselect1.destroy();
		$("#form1").submit();
			return true;
		
	}	
	else
	{
		//alert('ff');
		
		$("#form1").attr("action","");
		  alert("يجب اختيار العناصر أولا");
	//	break; 
	    
		$('#form1').submit(function() {
 	     
        return false;});
		//spryselect1.slice();
		
	}
	
		
}   

$(document).ready(function(e) {
	//fadeout outputString
 	$("#outputString").fadeOut(20000);
	/*----------------------------------------*/
	//check or uncheck all
	// Listen for click on toggle checkbox
	$('#checkAll').click(function(event) {   
		if(this.checked) {
			// Iterate each checkbox
			$('.choosenItem').each(function() {
				this.checked = true;                        
			});
		}
		else { 
			// Iterate each checkbox 
			$(".choosenItem").each(function() {
				 this.checked = false; 
			}); 
		}
	});

});

</script>
<script src="../../../SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<link href="../../../SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />

<div id="outputString">
<h3><p>{$outputString}</p></h3>
</div>
<form id="form1"  method="post" \>
  <table>
    <tr bgcolor="#CCCCCC">
      <th >م</th>
      <th>اسم نوع  الاصل</th>
      <th >تعديل</th>
      <th>حذف</th>
      <th class="noprint">   
        <label>
          <input type="checkbox" name="checkAll" id="checkAll"/>
        </label>
      </th>
    </tr>
    {foreach $name as $na}
    
    {if {$na->del} eq 1}
    <tr id="tt"  style="background:#FB888B">
      {elseif {$na->del} eq 0}
      <tr class="gradeA">
        {/if}
        
        <td>{$na->assetscatid}</td>
        <td>{$na->cattitel}</td>
        <td><a href="assetTypeController.php?do=edit&id={$na->assetscatid}">تعديل</a></td>
        <td>
          {if {$na->del} eq 0}
          <a href="assetTypeController.php?do=delete&id={$na->assetscatid}">حذف</a>
          {else}
          <a href="assetTypeController.php?do=ruturndelete&id={$na->assetscatid}">اعاده الحذف</a>
          {/if}
        </td>
        <td class="noprint">
          <label>
            <input type="checkbox" name="choosedItem[]" id="checked{$i}" class="choosenItem" value="{$na->assetscatid}" />
          </label>
        </td>
    </tr>
    {/foreach}
    
    <tr>
      <td colspan="5">
        <br />
        
        <label for="operation"></label>
        <span id="spryselect1">
        <select name="operation" id="operation" data-placeholder="اختر العملية" class="chzn-select" style="max-width:350px; width:200px;" tabindex="1">
          <option></option>
          <option value="1">حذف مؤقت</option>
          <option value="2">إلغاء الحذف</option>
        </select>
        <span class="selectRequiredMsg">من فضلك اخر العمليه.</span></span>        <input name=""  onclick="countChoosenProducts();"  type="button" value="تنفيذ"/>
  </td>
  </tr>
    <tr>
      <td colspan="5"> {paginate_prev} {paginate_middle format="page"} {paginate_next}</td>
    </tr>
    
  </table>
  
</form>
{literal}
<script type="text/javascript">
//var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
</script>
{/literal}