
<script type="text/javascript">


      var mydata = new Array();
var newString=null;
//for products
    function showElements(f)
    {
     
      oText = f.elements["spproduct"];
    
      valu=oText.value;
      oText.value='';
      frmElement = f.elements["product"];
      frmElement.value = frmElement.value + "'" +valu + "',";
//      frmElement.value = frmElement.value.slice(0, -1);
      
       
      }
  //TO RESET PRODUCTS
  function deleteProducts(f)
    {
     
      oText = f.elements["product"];
    
      valu=oText.value;
      oText.value='';
       
      }

  //  categories
function showCategories(f)
    {

   var selected_index = f.elements["Categories"].selectedIndex;
   if(selected_index > 0)
{
   var selected_option_value = f.elements["Categories"].options[selected_index].value;
   var selected_option_text = f.elements["Categories"].options[selected_index].text;

   //   alert(selected_option_text);

     value=selected_option_text;
      frmElement = f.elements["Categorytotal"];
      frmElement.value = frmElement.value + "'" +value + "',";
}
else
{
   alert(' Select  Product Category from the drop down list');
}
      }
//TO RESET CATEGORY
  function deleteCategory(f)
    {

      oText = f.elements["Categorytotal"];

      valu=oText.value;
      oText.value='';

      }

function getSelectedOptions(oList)
  {
   var sdValues = [];
   for(var i = 1; i < oList.options.length; i++)
   {
      if(oList.options[i].selected == true)
      {
      sdValues.push(oList.options[i].value);
      }
   }
   return sdValues;
}

         var lines = new Array();
    $(function(){
        $( "#showhidesearch" ).button({
            icons: {
                primary: "ui-icon-search"
            },
            text: true
        });
        $('#datepicker').datepicker({ dateFormat: 'yy-mm-dd' });
        $('#datepicker2').datepicker({ dateFormat: 'yy-mm-dd' });
        $("#search").click(function(){

            loadGrid();

        });


        $("#showhidesearch").click(function(){
            if(document.getElementById('searchbartop').style.display == 'none')
                $("#searchbartop").show("blind", { direction: "vertical" }, 300);
            else
                $("#searchbartop").hide("blind", { direction: "vertical" }, 300);
        });
          $(function(){
           $("#view").click(function(){

if(lines.length>0)

             $.ajax({
                 url: "<?= site_url() ?>closecash/getclosecashdetails2",
                 data: {idlist: escape(serialize(lines))},
                    dataType: "json",
                    type: "POST",
                   success: function(data){

                        document.location.href="<?= site_url() ?>closecash/getclosecashdetails";
                    },
                   error: function(xhr, ajaxOptions, thrownError){
                        alert(thrownError);

                    }
                });
 loadgrid();
        });


        });
//        jQuery("#view").click( function()
//        {
//            var rowid;
//            rowid = jQuery("#lines").jqGrid('getGridParam','selarrrow');
//            if( rowid != 0){
//                var selid = jQuery("#lines").jqGrid('getCell', rowid, 'ID');
//                if(selid!=false){
//                    document.location.href="<?= site_url() ?>closecash/getclosecashdetails/"+selid;
//                }
//            }
//            else{
//                $( "#dialog" ).dialog( "open" );
//            }
//        });



    });
    function loadGrid(){
        var datefrom = document.getElementById('datepicker');
        var dateto = document.getElementById('datepicker2');
        var hostsequence = document.getElementById('hostsequence');
        //        var paymenttype = document.getElementById('select_custom');
        $("#lines").GridUnload();
        jQuery("#lines").jqGrid({

            url:'<?= site_url() ?>sales/closecash/getclosecash',
            postData: {datefrom: datefrom.value, dateto: dateto.value, hostsequence: hostsequence.value},
            datatype: "json",
            mtype : "post",
            colNames:['ID',  'STATION', 'SEQUENCE','START DATE','END DATE', 'TOTAL'],
            colModel:[
                {name:'ID',index:'ID', width:20,editable:true,hidden:true,editoptions:{readonly:true,size:10}},
                //                {name:'PAYMENT DATE',index:'DATENEW', width:120,align:"center",sorttype:'date', formatter:'date', formatoptions: {srcformat:'ISO8601Long', newformat:'d-M-Y h:i:s a'}},
                {name:'HOST',index:'HOST', width:50,align:"center",editoptions:{size:10}},
                {name:'HOST SEQUENCE',index:'HOSTSEQUENCE', width:10,align:"center",editoptions:{size:10}},
                {name:'DATESTART',index:'DATESTART', width:50,align:"center",editoptions:{size:10}},
                {name:'DATEEND',index:'DATEEND', width:50,align:"center",editoptions:{size:10}},
                {name:'TOTAL',index:'TOTAL', width:50, formatter:'currency', formatoptions: {thousandsSeparator:','}, align:"right"}
                //                 {name:'TOTAL',index:'TOTAL', width:50,align:"center",editoptions:{size:10}}

                //                {name:'TOTAL',index:'TOTAL', width:100, formatter:'currency', formatoptions: {thousandsSeparator:','}, editable:true,align:"right",editoptions:{size:10}}
            ],
            rowNum:15,
            rowList:[25,50,100],
            rownumbers: true,
            key: true,
            rownumWidth: 40,
            height: 200,
            autowidth: true,

            pager: '#pgtoolbar1',
            sortname: 'HOSTSEQUENCE',
            viewrecords: true,
            sortorder: "desc",
            multiselect: true,
            reloadAfterEdit: true,
            reloadAfterSubmit: true,
             beforeSelectRow: function(rowid, e)
{
    jQuery("#lines").jqGrid('resetSelection');
    return(true);
},
            editurl:"<?= site_url() ?>.payments.php",
             onSelectRow: function(ids,status) {

                var rowid = jQuery("#lines").jqGrid('getGridParam','selarrrow');
//                var selpostatus = jQuery("#lines").jqGrid('getCell', rowid, 'REQUESTSTATUS');
//                  pid = null;
//
//                        pid = jQuery("#lines").jqGrid('getCell', ids, 'ID');
var selid = null;
var fselidd = null;
    selid = jQuery("#lines").jqGrid('getCell', ids, 'ID');

                         var idlist=0;
                         if(status==true)
                        {

                          lines.push({ID:selid});
                          idlist = serialize(lines);
                            oForm = document.forms[0];
                      oLines = oForm.elements["lineitems"];
                      oLines.value = serialize(lines);

                        }
                       else{
                               for(var i=0;i<lines.length;i++)
                              {
                                   if(lines[i]['ID']==selid)
                                  {
                                     lines.splice(i, 1);
                                     break;
                                  }
                              }
                           }



             }

//            beforeSelectRow: function(rowid, e)
//            {
//                jQuery("#lines").jqGrid('resetSelection');
//                return(true);
//            }


        });
    }

    $(document).ready(function() {
        $("button").button();
$( "#includepro" ).buttonset();
$( "#includecat" ).buttonset();

        loadGrid(null);



    });


</script>
<script>
	// increase the default animation speed to exaggerate the effect
	$.fx.speeds._default = 1000;
	$(function() {
		$( "#dialog" ).dialog({
			autoOpen: false,
			show: "blind",
			hide: "explode",buttons: {
				Ok: function() {
					$( this ).dialog( "close" );
				}
			}

		});

	});
	</script>
<script type="text/javascript">
    $(function() {
        $( "#spproduct" ).autocomplete({
            source: function(request, response) {
                $.ajax({ url: "<?php echo site_url('inventory/searchproducts/getproductsautocomplete'); ?>",
                    data: { term: $("#spproduct").val()},
                    dataType: "json",
                    type: "POST",
                    success: function(data){
                        response(data);

                    }
                });
            },
            minLength: 1
        });
         $( "#spbarcode" ).autocomplete({
            source: function(request, response) {
                $.ajax({ url: "<?php echo site_url('inventory/searchmaterials/getreferenceautocomplete'); ?>",
                    data: { term: $("#spbarcode").val()},
                    dataType: "json",
                    type: "POST",
                    success: function(data){
                        response(data);

                    }
                });
            },
            minLength: 1
        });
    });

</script>



<div class="main content clearfix">
    <div class="page-heading">
        <h2>Delete Transactions</h2></div>

    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized"><img src="<?= site_url() ?>images/shared/side_shadowleft.jpg" width="100%" height="300" alt="" /></th>
            <th class="topleft"></th>
            <td id="tbl-border-top">&nbsp;</td>
            <th class="topright"></th>
            <th rowspan="3" class="sized"><img src="<?= site_url() ?>images/shared/side_shadowright.jpg" width="100%" height="300" alt="" /></th>
        </tr>
        <tr>
            <td id="tbl-border-left"></td>
            <td>
                <div id="content-table-inner">
                    <div id="table-content">

                        <table border="0" width="100%" height="50%" cellpadding="0" cellspacing="0">
                            <tr valign="top">
                                <td>

                                    <?=
validation_errors('<div id="message-red"><table border="0" width="100%" cellpadding="0" cellspacing="0"><tr><td class="red-left">', '</td><td class="red-right"><a class="close-red"><img src="' . site_url() . '/images/table/icon_close_red.gif" alt="" /></a></td></tr></table></div>');
?>
    <?php
    if ($this->session->flashdata('msgt') == 'S') {
                                echo '
					<div id="message-green">
					<table border="0" width="100%" cellpadding="0" cellspacing="0">
					<tr>
						<td class="green-left">' . $this->session->flashdata('msg') . '</a></td>
						<td class="green-right"><a class="close-green"><img src="' . site_url() . 'images/table/icon_close_green.gif"   alt="" /></a></td>
					</tr>
					</table>
					</div>
					';
                            }
                            ?>
 <?php
                        $date = date('Y-m-d');
?>
                                    <!-- start id-form -->
                                    <div class="myform-outer" style="height:350px">
                                        <div class="myform">
                                            <form action="<?= site_url() . 'settings/deletetransactions/ticketsupdate' ?>" method="post">
                                                <div class="myform-controls">

                                                    <table border="0" cellpadding="0" cellspacing="0"  id="id-form">
                                                        <tr>
                                                            <td>  <label><span style="color:red;">*</span>Cut %</label>
                                                    <input name="cutt" type="text" class="inp-form" /></td>
                                                        </tr>


                                                        <tr>
                                                      <td>
                                                    <label>Receipts:</label>
                                                    <textarea name="notes" rows="" cols=""></textarea>

                                                </td>
                                                        </tr>
                                                        <tr>
                                                <td> <label>Product:</label>   <input id="spproduct"  name="spproduct"   type="text" class="inp-form"/>
                                                     <button id="addpro" name="addpro" type="button" onClick='showElements(this.form)'>Add</button>
                                                     <button id="deletepro" name="deletepro" type="button" onClick='deleteProducts(this.form)'>Delete</button>
                                                </td>
                                                

                                                <td>Products<br/><textarea name="product" rows="" cols=""></textarea></td>
                                                <td>
                                                <div id="includepro">
    <input type="radio" id="proin" name="proinc" checked="checked" value="1" /><label for="proin">Include</label>
    <input type="radio" id="proex" name="proinc" value="2" /><label for="proex">Exculde</label>
</div>
                                                
                                                </td>


                                            </tr>
                                                        <!--a.e-->
                                                         <tr>
                                                <td> <label>    Category:</label>  
                                               
                                                    <select id="Categories" name="Categories">
                                                <?= $categories ?>
                                            </select>
                                                    <button id="addcat" name="addcat" type="button" onClick='showCategories(this.form)'>Add</button>
                                                     <button id="deletecat" name="deletecat" type="button" onClick='deleteCategory(this.form)'>Delete</button>

                                                </td>
                                           
                                                         
                                                <td>Categories<textarea name="Categorytotal" rows="" cols=""></textarea></td>
                                                <td>
                                                    <div id="includecat">
    <input type="radio" id="catin" name="catinc" checked="checked" value="1" /><label for="catin">Include</label>
    <input type="radio" id="catex" name="catinc" value="2" /><label for="catex">Exculde</label>
</div>
                                                </td>

                                            </tr>

<tr>
                                        <td>
 <input type="hidden" name="lineitems" value="" />
                                               <input type="hidden" name="lineitemsk" value="" />
                                                    <input type="submit" value="Update" name="submit">
                                        </td><td></td><td></td>
                                                        </tr>
                                                        <tr><td></td></tr>
                                                    </table>
                                                </div>
                                            
                                            
                                            </form></div></div>

                                </td>

                            </tr>

                        </table>

                         <div>
     <div id="searchbartop" style="display:none">
                            <div class="myform-search clearfix">
                                <table>
                                    <tr>
                                    <form>
                                        <td>Host Sequence<br>
                                            <select id="hostsequence" name="hostsequence" class="styledselect_form_1">
                                                <?= $hostsequence ?>
                                            </select>
                                        </td>
<!--                                            <td>Payment Type<br>
                                            <select id="select_custom" name="type" class="styledselect_form_1">
                                                <option value="" selected=’selected’>Select type</option>
                                                 <option value="cash">Cash</option>
                                                <option value="cashin">Cash In</option>
                                                <option value="cashout">Cash Out</option>
                                                 <option value="debt">Debt</option>
                                                 <option value="debtpaid">Debt Paid</option>
                                                  <option value="creditpaid">Credit Paid</option>
                                                  <option value="cashrefund">Refund</option>
                                            </select>
                                        </td>-->
                                        <td>Date From<br>
                                            <input name="datefrom" type="text" id="datepicker" class="inp-form-small"/>
                                        </td>

                                        <td>To<br>
                                            <input name="dateto" type="text" id="datepicker2" class="inp-form-small"/>
                                        </td>
                                        <td>
                                            <br>
                                            <button type="reset" value="Reset">Reset</button>
                                        </td>
                                        </form>
                                        <td>
                                            <br>
                                            <button id="search" name="search">Search</button>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                         <table id="lines"></table>
                        <div id="pgtoolbar1"></div>
                         <input type="hidden" name="lineitems" value="" />

                        <!--  end content-table-inner  -->
                    </div></div>
                </div>
            </td>
            <td id="tbl-border-right"></td>
        </tr>
        <tr>
            <th class="sized bottomleft"></th>
            <td id="tbl-border-bottom">&nbsp;</td>
            <th class="sized bottomright"></th>
        </tr>
    </table>
</div>



