Advertisement
joris

Form Tab Widget

Oct 10th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.48 KB | None | 0 0
  1. <script>
  2. $(document).ready(function(e) {
  3.     AmbilPlanNumb();
  4.    
  5.     $("#DistributionPlan_distribution_destination").change(function(){
  6.         var dis     = $(this).val();
  7.         var regid   = $("#DistributionPlan_destination_ro").val();
  8.         if(dis==2){
  9.             AmbilIC(regid);
  10.         }else{
  11.             $("#DistributionPlan_destination_ic").empty();
  12.             $("#DistributionPlan_destination_ic").attr("disabled", "disabled");
  13.         }
  14.     });
  15.    
  16.     $("#DistributionPlan_destination_ro").change(function(){
  17.         var disdes = $("#DistributionPlan_distribution_destination").val();
  18.         var regid  = $(this).val();
  19.         if(disdes==2){
  20.             $("#DistributionPlan_destination_ic").empty();
  21.             AmbilIC(regid);
  22.         }
  23.     });
  24.  
  25. });
  26.  
  27. function AmbilPlanNumb(){
  28.     $("#DistributionPlan_distribution_plan_number").val('');
  29.     $.ajax({
  30.         type: 'GET',
  31.         url: '<?php echo Yii::app()->createAbsoluteUrl("distributionplan/ambilplan"); ?>',
  32.         dataType: 'json',
  33.         cache: false,
  34.         success: function(result) {
  35.             $("#DistributionPlan_distribution_plan_number").val(result[0].distnumb);
  36.         },
  37.         error: function(jqXHR, exception){
  38.             alert('Error : Distribution plan number');
  39.         }
  40.     });
  41.    
  42.     var des_ic = $("#DistributionPlan_destination_ic");
  43.     des_ic.empty();
  44.     des_ic.attr("disabled", "disabled");
  45. }
  46.  
  47. function AmbilIC(id){
  48.     $("#DistributionPlan_destination_ic").val('');
  49.     $.ajax({
  50.         type: 'POST',
  51.         url: '<?php echo Yii::app()->createAbsoluteUrl("distributionplan/ambilic"); ?>',
  52.         data:{
  53.             regid: id
  54.         },
  55.         dataType: 'json',
  56.         cache: false,
  57.         success: function(result) {
  58.             $.each(result, function() {
  59.                 $("#DistributionPlan_destination_ic").append($('<option>', {
  60.                     value: this.id,
  61.                     text : this.partner_name
  62.                 }));
  63.             });
  64.             $("#DistributionPlan_destination_ic").removeAttr("disabled");
  65.         },
  66.         error: function(jqXHR, exception){
  67.             alert('Error : IC Data');
  68.         }
  69.     });
  70. }
  71. </script>
  72.  
  73. <div class="row-fluid">
  74.     <div class="span9">
  75.            
  76. <?php $form=$this->beginWidget('CActiveForm', array(
  77.     'id'=>'distribution-plan-form',
  78.     'enableAjaxValidation'=>false,
  79.     'enableClientValidation'=>true,
  80.     'clientOptions'=>array(
  81.         'validateOnSubmit'=>true,
  82.         'validateOnType'=>true,
  83.     ),
  84. )); ?>
  85.  
  86.  
  87. <?php
  88. /*$this->widget('zii.widgets.jui.CJuiTabs', array(
  89.     'tabs' => array(
  90.         'Distribution'  => $this->renderPartial('_form_tab_1', array('form' => $form, 'model' => $model), true),
  91.         'Ship To'       => $this->renderPartial('_form_tab_2', array('form' => $form, 'model' => $model), true),
  92.     ),
  93.     'options' => array(
  94.         'collapsible' => true,
  95.     ),
  96. ));*/
  97.  
  98. $tabs = array();
  99.  
  100. $tabs['Distribution'] = array(
  101.         'id'=>'dist',
  102.         'content'=>$this->renderPartial('_form_tab_1', array(
  103.                 'form' => $form,
  104.                 'model'=>$model,
  105.         ),
  106.         true),
  107. );
  108.  
  109. $tabs['Ship To'] = array(
  110.         'id'=>'ship',
  111.         'content'=>$this->renderPartial('_form_tab_2', array(
  112.                 'form' => $form,
  113.                 'model'=>$model,
  114.         ),
  115.         true),
  116. );
  117.  
  118. $this->widget('zii.widgets.jui.CJuiTabs', array(  
  119.         'tabs' => $tabs,
  120.         'options' => array(
  121.                 'collapsible' => false,
  122.         ),
  123. ));
  124.  
  125. ?>
  126.  
  127.  
  128. <?php $this->endWidget(); ?>
  129. </div>  
  130.    
  131.     <div class="span3">
  132.         <h3 class="heading">Menu</h3>
  133.             <ul class="list user_list">
  134.                 <li>
  135.                     <span class="label label-success pull-right sl_status">online</span>
  136.                     <a class="sl_name" href="index.html">List Data</a><br>
  137.                     <small class="s_color sl_email">Menu untuk melihat list data yg tersimpan</small>
  138.                 </li>
  139.             </ul>
  140.     </div>
  141. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement