Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.25 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(function () {
  3. // Display the create reservations modal
  4. $('#create-reservations').modal('show');
  5.  
  6. $('#create-reservations').on('shown', function () {
  7. $("#client_name").focus();
  8. });
  9.  
  10. $().ready(function () {
  11. $("[name='client_name']").select2({
  12. createSearchChoice: function (term, data) {
  13. if ($(data).filter(function () {
  14. return this.text.localeCompare(term) === 0;
  15. }).length === 0) {
  16. return {id: term, text: term};
  17. }
  18. },
  19. multiple: false,
  20. allowClear: true,
  21. data: [
  22. <?php
  23. $i=0;
  24. foreach ($clients as $client){
  25. echo "{
  26. id: '".str_replace("'","\'",$client->client_name)."',
  27. text: '".str_replace("'","\'",$client->client_name)."'
  28. }";
  29. if (($i+1) != count($clients)) echo ',';
  30. $i++;
  31. }
  32. ?>
  33. ]
  34. });
  35. $("#client_name").focus();
  36. });
  37.  
  38. // Creates the reservations
  39. $('#reservations_create_confirm').click(function () {
  40. console.log('clicked');
  41. // Posts the data to validate and create the reservations;
  42. // will create the new client if necessary
  43. $.post("<?php echo site_url('reservations/ajax/create'); ?>", {
  44. client_name: $('#client_name').val(),
  45. reservations_date_created: $('#reservations_date_created').val(),
  46. reservations_password: $('#reservations_password').val(),
  47. user_id: '<?php echo $this->session->userdata('user_id'); ?>',
  48. invoice_group_id: $('#invoice_group_id').val()
  49. },
  50. function (data) {
  51. var response = JSON.parse(data);
  52. if (response.success == '1') {
  53. // The validation was successful and reservations was created
  54. window.location = "<?php echo site_url('reservations/view'); ?>/" + response.reservations_id;
  55. }
  56. else {
  57. // The validation was not successful
  58. $('.control-group').removeClass('has-error');
  59. for (var key in response.validation_errors) {
  60. $('#' + key).parent().parent().addClass('has-error');
  61. }
  62. }
  63. });
  64. });
  65. });
  66.  
  67. </script>
  68.  
  69. <div id="create-reservations" class="modal col-xs-12 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2"
  70. role="dialog" aria-labelledby="modal_create_reservations" aria-hidden="true">
  71. <form class="modal-content">
  72. <div class="modal-header">
  73. <a data-dismiss="modal" class="close"><i class="fa fa-close"></i></a>
  74.  
  75. <h3><?php echo lang('create_reservations'); ?></h3>
  76. </div>
  77. <div class="modal-body">
  78.  
  79. <div class="form-group">
  80. <label for="client_name"><?php echo lang('client'); ?></label>
  81. <input type="text" name="client_name" id="client_name" class="form-control"
  82. autofocus="autofocus"
  83. <?php if ($client_name) echo 'value="' . html_escape($client_name) . '"'; ?>>
  84. </div>
  85.  
  86. <div class="form-group has-feedback">
  87. <label for="reservations_date_created">
  88. <?php echo lang('reservations_date'); ?>
  89. </label>
  90.  
  91. <div class="input-group">
  92. <input name="reservations_date_created" id="reservations_date_created"
  93. class="form-control datepicker"
  94. value="<?php echo date(date_format_setting()); ?>">
  95. <span class="input-group-addon">
  96. <i class="fa fa-calendar fa-fw"></i>
  97. </span>
  98. </div>
  99. </div>
  100.  
  101. <div class="form-group">
  102. <label for="reservations_password"><?php echo lang('reservations_password'); ?></label>
  103. <input type="text" name="reservations_password" id="reservations_password" class="form-control"
  104. value="<?php if ($this->mdl_settings->setting('reservations_pre_password') == '') {
  105. echo '';
  106. } else {
  107. echo $this->mdl_settings->setting('reservations_pre_password');
  108. } ?>" style="margin: 0 auto;" autocomplete="off">
  109. </div>
  110.  
  111. <div class="form-group">
  112. <label for="invoice_group_id"><?php echo lang('invoice_group'); ?>: </label>
  113.  
  114. <div class="controls">
  115. <select name="invoice_group_id" id="invoice_group_id"
  116. class="form-control">
  117. <option value=""></option>
  118. <?php foreach ($invoice_groups as $invoice_group) { ?>
  119. <option value="<?php echo $invoice_group->invoice_group_id; ?>"
  120. <?php if ($this->mdl_settings->setting('default_reservations_group') == $invoice_group->invoice_group_id) { ?>selected="selected"<?php } ?>><?php echo $invoice_group->invoice_group_name; ?></option>
  121. <?php } ?>
  122. </select>
  123. </div>
  124. </div>
  125.  
  126. </div>
  127.  
  128. <div class="modal-footer">
  129. <div class="btn-group">
  130. <button class="btn btn-danger" type="button" data-dismiss="modal">
  131. <i class="fa fa-times"></i> <?php echo lang('cancel'); ?>
  132. </button>
  133. <button class="btn btn-success ajax-loader" id="reservations_create_confirm" type="button">
  134. <i class="fa fa-check"></i> <?php echo lang('submit'); ?>
  135. </button>
  136. </div>
  137. </div>
  138.  
  139. </form>
  140.  
  141. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement