Senin, 10 Juni 2013

JSON

 GET Value from input kriteria
====================$(function(){
  
    $('#_setup_customer_id_').blur( function(){
      
        var slctVal=$('#setup_customer_id :selected').val();
        //alert(slctVal);
        var uri = basePath + '/' + namePath + '/findJO/';
        if (slctVal) {
        
        $('#_trans_job_order_id_').remove();
        $('#trans_job_order_id').attr('class', '');
        $('#_trans_job_order_id_').attr('class', '');
        $('#_trans_job_order_id_').attr('class', 'required');
        $('#trans_job_order_id').select_autocomplete();
        
        $.getJSON(uri, {setup_customer_id: slctVal}, function( data ) {
            $('#trans_job_order_id').empty();
            if(data[0]) {
                $('#trans_job_order_id').append('');
                for(var x=0; x                
                    $('#trans_job_order_id').append('');
                }
            }else {
                $('#trans_job_order_id').empty();
                $('#trans_job_order_id').append("");
            }
        });
        
        //$('#_setup_service_id_').attr('onBlur', '');
        //$('#setup_agreement_id').empty();
        //$('#setup_agreement_id').append('');
        //$('#_setup_service_id_').attr('onBlur', 'getAgreement()');
        }
    });
 --------------------------------------------------------------------------------------------------

function getAgreement(){
    var slctVal = $('#setup_customer_id :selected').val();
    var slctVal2 = $('#setup_service_id :selected').val();
   
        if(slctVal) {
            var uri = basePath + '/' + namePath + '/findAgreement/';
           
            $.getJSON(uri, {setup_customer_id: slctVal, setup_service_id: slctVal2}, function(data) {
                console.log(data);
               
                $('#_setup_agreement_id_').remove();
                $('#setup_agreement_id').attr('class', '');
                $('#_setup_agreement_id_').attr('class', '');
                $('#_setup_agreement_id_').attr('class', 'required');
                $('#setup_agreement_id').select_autocomplete();

                if(data[0]) {
                   
                    $('#setup_agreement_id').append('');
                    for(var x=0; x                       
                        $('#setup_agreement_id').append('');
                    }
                   
                } else {
                    $('#setup_agreement_id').append("");
                }
               
                $('#process_m_route_id').html('');
            //    $('#setup_agreement_id').select_autocomplete();
               
            });
        }
}


-------------------------------------------------------------------------


function findActivity(){
        /*if(Configure::write('debug')>0){
            Configure::write('debug', 0);
        }*/

        $this->loadModel('TAgreementDetail');
        $options = $result = array();
        $options['recursive'] = 1;
        $options['conditions']['TAgreementDetail.t_agreement_id ='] = $this->params['url']['t_agreement_id'];
        $options['conditions']['TAgreementDetail.m_route_id ='] = $this->params['url']['m_route_id'];
        $options['conditions']['TAgreementDetail.m_activity_id ='] = $this->params['url']['m_activity_id'];
        $options['conditions']['TAgreementDetail.status ='] = 'Y';
        $options['group'] = array('TAgreementDetail.m_activity_id');
        $result = $this->TAgreementDetail->find('all', $options);

        $this->layout= 'json/default';
        $this->viewPath="common";

        $this->set('result', $result);
        $this->render('autocomplete');
  }
 

0 komentar:

Posting Komentar