Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php header ( "Content-type: text/javascript" ); ?>
- <?php include '../../../../../eindex.php'; ?>
- var data;
- var selectedShlsIds = new Array();
- var selectedShlsStr = "";
- $(document).ready
- (
- function()
- {
- $(".shls-search-term").keyup
- (
- function()
- {
- sendShlsSearchTerm($(this).val());
- }
- );
- }
- );
- function sendShlsSearchTerm(term)
- {
- $(".shls-search-res").html('<img src="<?php echo Reg::get("url")."web/images/system/interface/ajax-loader.gif"; ?>"/>');
- $.ajax
- (
- {
- type: "POST",
- url: '<?php echo Reg::get ( "url" ); ?>Units/Shls/Main/SearchAjax',
- async: false,
- dataType: "json",
- data:
- {
- term: term,
- } ,
- success:function(inside)
- {
- data = inside;
- var result;
- result += '<table class="shls-search-res">';
- result += "<thead>";
- result += "<td>کد</td>";
- result += "<td>نام</td>";
- result += "<td>مرکز</td>";
- result += "<td>عملیات</td>";
- result += "</thead>";
- result += "<tbody>";
- length = 0;
- length = data.shls.length;
- for(count = 0 ; count < length ; count ++)
- {
- className = (count % 2 == 0) ? 'even' : 'odd';
- result += "<tr onclick='set(data.shls["+count+"])' class='"+className+"'>";
- result += "<td>" + data.shls[count].code + "</td>";
- result += "<td>" + data.shls[count].name + "</td>";
- result += "<td>" + data.shls[count].shl_center + "</td>";
- result += "<td>" + "<input name='id_shls_"+data.shls[count].id+"' value ='"+data.shls[count].id+"' id='id_shls_"+data.shls[count].id+"' type='checkbox' />" + "</td>";
- result += "</tr>";
- }
- if(length > 0)
- {
- result += '<tr><td colspan="4" style="text-align: center;background-color: #6891C3;"><input type="button" id="shls-add-to-graph" value="اضافه" /></td></tr>';
- }
- result += '</tbody>';
- result += "</table>";
- $(".shls-search-res").html(result);
- }
- }
- )
- }
- function addToSelectedShls()
- {
- checkBoxes = $('table.shls-search-res input[type=checkbox]:checked');
- countCheckBoxes = checkBoxes.length;
- countSelectedShlsIds = selectedShlsIds.length;
- for(checkBoxesCounter = 0 ; checkBoxesCounter < countCheckBoxes ; checkBoxesCounter ++)
- {
- if( shlsExisted(checkBoxes[checkBoxesCounter].value) == false )
- {
- selectedShlsIds.push ( checkBoxes[checkBoxesCounter].value ) ;
- }
- }
- renderSelectedShls ();
- }
- function renderSelectedShls()
- {
- shlsSelectedLenth = selectedShlsIds.length;
- for( counter = 0 ; counter < shlsSelectedLenth ; counter++ )
- {
- selectedShlsStr += '<div id="id_shls_" ' + selectedShlsIds[counter] + ' class="selected-units-items">'+selectedShlsIds[counter]+'</div>';
- }
- if(shlsSelectedLenth > 0)
- selectedShlsStr += '<div style="clear: both;"><input id="draw-btn" type="button" name="draw" value="ترسیم"/></div>';
- $("#selected-units").html(selectedShlsStr);
- selectedShlsStr = "";
- }
- function shlsExisted( shlsId )
- {
- countSelectedShlsIds = selectedShlsIds.length;
- //console.log(shlsId);
- //console.log(selectedShlsIds);
- for(counter = 0 ; counter < countSelectedShlsIds ; counter++)
- {
- if( selectedShlsIds[counter] == shlsId )
- {
- return true;
- }
- }
- return false;
- }
- function removeSelectedItem()
- {
- }
- $("#shls-add-to-graph").click
- (
- function()
- {
- alert("hello");
- addToSelectedShls();
- }
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement