PageRenderTime 44ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/application/views/subcontent/browse_old.php

https://gitlab.com/wildanoo/E-procurement
PHP | 228 lines | 196 code | 20 blank | 12 comment | 9 complexity | ebe0d5617cbdc4532e3564d56705fd85 MD5 | raw file
  1. <html>
  2. <head>
  3. <title>Browse</title>
  4. <style type="text/css"></style>
  5. <script type="text/javascript">
  6. $(document).ready(function(){
  7. $(function(){ });
  8. var baseUrl = "<?php echo base_url(); ?>";
  9. $("#srch-term").autocomplete({
  10. source: baseUrl + 'content/get_subcontent_tags',
  11. minLength:1
  12. });
  13. $("#btn_search").click(function(){
  14. var search = $("#srch-term").val(); // alert(search);
  15. var csrf = '<?php echo $this->security->get_csrf_token_name(); ?>';
  16. var token = '<?php echo $this->security->get_csrf_hash(); ?>';
  17. $.ajax({
  18. url : baseUrl + 'content/set_sess_search_subcontent',
  19. type : "POST",
  20. data : csrf +'='+ token +'&search='+search,
  21. success: function(resp){ $("#debug").html(resp);
  22. document.location.href= baseUrl + 'content/subcontent';
  23. }
  24. });
  25. });
  26. $('#btn_create').click(function(){
  27. form_create();
  28. //alert('test');
  29. });
  30. });
  31. function form_create(){
  32. var baseUrl = "<?php echo base_url(); ?>";
  33. var csrf = '<?php echo $this->security->get_csrf_token_name(); ?>';
  34. var token = '<?php echo $this->security->get_csrf_hash(); ?>';
  35. BootstrapDialog.show({
  36. title: 'Create Sub Content',
  37. message: $('<div></div>').load(baseUrl + "content/form_create_subcontent/"),
  38. buttons: [{ label: 'Submit',
  39. cssClass: 'btn btn-primary btn-sm',
  40. action: function(dialogRef){
  41. var content_id = $("#content_id").val();
  42. var subtype_name = $("#subtype_name").val();
  43. var document_req = $("#document_req").val;
  44. var behavior_id = $("#behavior_id").val;
  45. $.post( baseUrl + 'content/is_exist_subcontent', { csrf: token , content_id : content_id , subtype_name : subtype_name , document_req : document_req , behavior_id : behavior_id })
  46. .done(function( resp ) {
  47. //$('#debug').html(resp);
  48. //dialogRef.close();
  49. var json = $.parseJSON(resp);
  50. if (json.status=='true'){
  51. var values = $("#form").serializeArray();
  52. values.push({ name: csrf,value: token });
  53. values = jQuery.param(values);
  54. $.ajax({
  55. url : baseUrl + 'content/create_subcontent',
  56. type : "POST",
  57. data : values,
  58. success: function(resp){
  59. //$('#debug').html(resp);
  60. //dialogRef.close();
  61. //alert(values);
  62. document.location.href= baseUrl + 'content/subcontent';
  63. }
  64. });
  65. } else {
  66. $("#msg1").html(json.msg1);
  67. $("#msg2").html(json.msg2);
  68. }
  69. });
  70. }
  71. }, {
  72. label: 'Close',cssClass: 'btn btn-primary btn-sm',
  73. action: function(dialogRef) {
  74. document.location.href= baseUrl + 'content/subcontent';
  75. dialogRef.close();
  76. }
  77. }]
  78. });
  79. }
  80. function form_update(id){
  81. var baseUrl = "<?php echo base_url(); ?>";
  82. var csrf = '<?php echo $this->security->get_csrf_token_name(); ?>';
  83. var token = '<?php echo $this->security->get_csrf_hash(); ?>';
  84. BootstrapDialog.show({
  85. title: 'Update Sub Content',
  86. message: $('<div></div>').load(baseUrl + "content/form_update_subcontent/" + id),
  87. buttons: [{
  88. label: 'Submit',
  89. cssClass: 'btn btn-primary btn-sm',
  90. action: function(dialogRef)
  91. {
  92. var content_id = $("#content_id").val();
  93. var subtype_name = $("#subtype_name").val();
  94. var document_req = $("#document_req").val();
  95. $.post( baseUrl + 'content/is_exist_subcontent', { csrf: token ,content_id : content_id, subtype_name : subtype_name , document_req : document_req })
  96. .done(function( resp ) {
  97. //alert(id);
  98. // $('#debug').html(resp);
  99. // dialogRef.close();
  100. var json = $.parseJSON(resp);
  101. if (json.status=='true'){
  102. var values = $("#form").serializeArray();
  103. values.push({ name: csrf,value: token });
  104. values = jQuery.param(values);
  105. $.ajax({
  106. url : baseUrl + 'content/update_subcontent',
  107. type : "POST",
  108. data : values,
  109. success: function(resp){
  110. //alert(values);
  111. //$('#debug').html(resp);
  112. //dialogRef.close();
  113. document.location.href= baseUrl + 'content/subcontent';
  114. }
  115. });
  116. } else {
  117. $("#msg1").html(json.msg1);
  118. $("#msg2").html(json.msg2);
  119. }
  120. });
  121. }
  122. }, {
  123. label: 'Close',cssClass: 'btn btn-primary btn-sm',
  124. action: function(dialogRef) {
  125. document.location.href= baseUrl + 'content/subcontent';
  126. dialogRef.close();
  127. }
  128. }]
  129. });
  130. }
  131. </script>
  132. </head>
  133. <body>
  134. <div id="debug"></div>
  135. <div class="row">
  136. <div class="col-md-12">
  137. <div class="widget widget-nopad">
  138. <div class="col-md-12">
  139. <div class="box box-info">
  140. <div class="box-header with-border">
  141. <h3 class="box-title">Manage Sub Content</h3>
  142. </div><!-- /.box-header -->
  143. <br>
  144. <div class="col-md-2 pull-left">
  145. <input type="button" id="btn_create" class="btn btn-primary btn-sm" title="Create New Sub Content" value="New Sub Content" style="width:130px;" title="Create New Sub Content"/>
  146. <?php $msg = $this->session->flashdata('message');
  147. if(strpos($msg,'failed')) $color="#bc0505";
  148. else $color = "#487952"; ?>
  149. <font color='<?php echo $color; ?>'><i><? echo $msg; ?></i></font>
  150. </div>
  151. <div class = "col-md-10 pull-right">
  152. <div class="input-group pull-right" style="width: 200px;">
  153. <input type="text" class="form-control input-sm pull-right" name="srch-term" id="srch-term"
  154. placeholder="Search" style="height: 28px;">
  155. <div class="input-group-btn">
  156. <button id="btn_search" class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="box-body">
  161. <table id="example2" class="table table-bordered table-hover text-center">
  162. <thead>
  163. <tr>
  164. <!--th><input type="checkbox" name="cba[]" id="cba" /></th-->
  165. <th>No</th>
  166. <th>Content</th>
  167. <th>Sub Content</th>
  168. <th>Document Requirement</th>
  169. <!-- th>Is Active</th> -->
  170. <th>Created Date</th>
  171. <th>Updated Date</th>
  172. <th>Updated Date</th>
  173. <th>Action</th>
  174. </tr>
  175. </thead>
  176. <tbody>
  177. <?php
  178. if($browse){ $i=1;
  179. foreach($browse as $row){ ?>
  180. <tr>
  181. <td><?php echo $num = $num+1;; ?></td>
  182. <td><?php echo $row->content_id; ?></td>
  183. <td><?php echo $row->subtype_name; ?></td>
  184. <td style="text-align: left;"><?php echo "{".$row->document_req."}"; ?></td>
  185. <!-- td><?php //if($row->status==1) echo "Yes"; else echo "No"; ?></td> -->
  186. <td><?php echo date('M d, Y',strtotime($row->created_date)); ?></td>
  187. <td><?php echo date('M d, Y',strtotime($row->last_updated)); ?></td>
  188. <td><?php echo $row->created_id;?></td>
  189. <td><?php
  190. echo '<i class="fa fa-pencil" onclick="form_update('.$row->id.')"/></i>';
  191. $trash = '<i class="fa fa-trash"></i>';
  192. $js = "if(confirm('Are you sure to delete subcontent ?')){ return true; } else {return false; }";
  193. echo anchor('content/delete_subcontent/'.$row->id, $trash,array('class'=>'default_link','title'=>'Delete Sub Content','onclick'=>$js));?>
  194. </td>
  195. </tr>
  196. <?php $i++; } ?>
  197. <tr><td colspan="8"><?php echo $pagination;?></td></tr>
  198. <?php } else { ?>
  199. <tr><td colspan="8" align="center">-</td></tr>
  200. <?php } ?>
  201. </tbody>
  202. </table>
  203. </div><!-- /.box-body -->
  204. </div><!-- /.box-info-->
  205. </div><!-- /col-md-12 -->
  206. </div><!-- /.widget -->
  207. </div><!-- /.col-md-12-->
  208. </div><!-- /row -->