Advertisement
asrulsibaoel

asking ajaxsubmitbutton

Dec 16th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. ini view nya:
  2.  
  3. <?php
  4. $form = $this->beginWidget('CActiveForm', array(
  5. 'id' => 'input-pekerjaan',
  6. 'enableAjaxValidation' => false,
  7. ));
  8. ?>
  9. <div class="modal-body">
  10.  
  11. <table>
  12. <tr>
  13. <td>Nama Pengambil</td>
  14. <td> : </td>
  15. <td><?php
  16. $data = array(0 => t('choose', 'global')) + CHtml::listData((User::model()->listPegawai()), 'id', 'name');
  17. $this->widget('bootstrap.widgets.TbSelect2', array(
  18. 'asDropDownList' => TRUE,
  19. 'data' => $data,
  20. 'name' => 'pegawai',
  21. 'options' => array(
  22. "placeholder" => t('choose', 'global'),
  23. "allowClear" => true,
  24. ),
  25. 'htmlOptions' => array(
  26. 'id' => 'pegawai',
  27. 'style' => 'width:250px;'
  28. ),
  29. ));
  30. ?></td>
  31. </tr>
  32. <tr>
  33. <td>Kolom</td>
  34. <td>:</td>
  35. <td id="Kolom"></td>
  36. <!-- <input type="hidden" name='idNopot' id="idNopot" value="">
  37. <input type="hidden" name='workId' id="workId" value="">
  38. <input type="hidden" name='worksplit' id="worksplit" value="">-->
  39. <input type="hidden" name='workProccess' id="workProccess" value="">
  40. <input type="hidden" name='nopot' id="nopot" value="">
  41. </tr>
  42. <tr>
  43. <td>Dari</td>
  44. <td> : </td>
  45. <td><?php echo user()->name; ?></td>
  46. </tr>
  47. <tr>
  48. <td>Jumlah Awal</td>
  49. <td> : </td>
  50. <td><input type="text" name="jml_awal" class="angka"></td>
  51. </tr>
  52. <tr>
  53. <td>Deskripsi</td>
  54. <td> : </td>
  55. <td><textarea name="description"></textarea></td>
  56. </tr>
  57. </table>
  58. </div>
  59. <div class="modal-footer">
  60. <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
  61. <?php
  62. echo CHtml::ajaxSubmitButton('Tambah', Yii::app()->createUrl('workorder/ambilNopot'), array(
  63. 'type' => 'POST',
  64. 'success' => 'function(data){
  65. var id = $("#idNopot").val();
  66. $("#"+id+"").replaceWith(data);
  67. $("#createNew").modal("hide");
  68. }'
  69. ), array(
  70. 'class' => 'btn btn-primary',
  71. )
  72. );
  73. ?>
  74.  
  75. </div>
  76. <?php
  77. $this->endWidget();
  78. ?>
  79.  
  80.  
  81. ini controller nya:
  82.  
  83. public function actionAmbilNopot() {
  84. // $isi = $_POST['idData'];
  85.  
  86. if (isset($_POST['pegawai'])) {
  87. $model = new WorkorderProcess();
  88. $model->start_from_user_id = $_POST['pegawai'];
  89. $model->work_process_id = $_POST['workProccess'];
  90. $model->workorder_split_id = $_POST['nopot'];
  91. $model->code = SiteConfig::model()->formatting('workorder_process', false);;
  92. $model->time_start = date('Y-m-d h:i:s');
  93. $model->start_user_id = user()->id;
  94. $model->end_user_id = null;
  95. $model->start_qty = $_POST['jml_awal'];
  96. $model->end_qty = 0;
  97. $model->description = $_POST['description'];
  98. $model->is_payment = 0;
  99. $model->charge = 0;
  100. $model->loss_qty = 0;
  101. $model->loss_charge = null;
  102.  
  103. $model->save();
  104. }
  105.  
  106. echo '<label class="label label-info">Dari : '.$model->StartFromUser->name
  107. . '<hr style="margin:0px"/><span style="font-size:10px">Mulai:'.$model->time_start
  108. . '</span></br><span style="font-size:10px">Selesai: - </span></label>';
  109. echo '<br>';
  110. echo '<a href="#" data-toggle="modal" class="btn btn-mini">'
  111. . '<div class="tombol" id="tb[' . $model->work_process_id . ']" pekerja="' . $model->start_from_user_id . '" dari="' . $model->start_user_id . '" penerima="' . $model->end_user_id . '" jml_awal="' . $model->start_qty . '" jml_akhir="' . $model->end_qty . '" loss="' . $model->loss_qty . '" denda="' . $model->loss_charge . '" date_start="' . $model->time_start . '" date_end="' . $model->time_end . '">'
  112. . '<i class="icon-eye-open"></i></div></a>'
  113. . '<a href="#" id="yw1" class="btn btn-mini"><i class="icon-pencil" rel="tooltip" title="edit"></i></a>'
  114. . '<a href="#" id="yw2" class="btn btn-mini"><i class="icon-trash" rel="tooltip" title="hapus"></i></a>';
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement