You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
5.3KB

  1. $(document).ready(function() {
  2. chat_calendar() ;
  3. chat_datepicker() ;
  4. chat_vrac() ;
  5. chat_email_masse() ;
  6. $('button[data-toggle=popover]').popover() ;
  7. chat_ordre_produits() ;
  8. chat_liste_produits_index_commandes() ;
  9. }) ;
  10. function chat_liste_produits_index_commandes() {
  11. $('#produits-production .td-max input').click(function() {
  12. $(this).select() ;
  13. }) ;
  14. $('#produits-production .td-actif input').change(function() {
  15. if($(this).prop('checked')) {
  16. $(this).parent().parent().addClass('active') ;
  17. }
  18. else {
  19. $(this).parent().parent().removeClass('active(') ;
  20. }
  21. }) ;
  22. }
  23. function chat_ordre_produits() {
  24. var fixHelper = function(e, ui) {
  25. ui.children().each(function() {
  26. $(this).width($(this).width());
  27. });
  28. return ui;
  29. };
  30. $(".produit-index table tbody").sortable({
  31. items: "> tr",
  32. appendTo: "parent",
  33. //helper: "clone"
  34. helper: fixHelper,
  35. stop: function(event, ui) {
  36. var tab_ordre = {} ;
  37. var ordre = 1 ;
  38. $(".produit-index table tbody tr").each(function() {
  39. tab_ordre[$(this).attr('data-key')] = ordre ;
  40. ordre++ ;
  41. }) ;
  42. console.log(tab_ordre) ;
  43. $.get('index.php',{
  44. r: 'produit/ordre',
  45. tab: JSON.stringify(tab_ordre)
  46. }) ;
  47. }
  48. }).disableSelection();
  49. }
  50. function chat_email_masse() {
  51. $('#ids-users .label').click(function() {
  52. if($(this).hasClass('label-default')) {
  53. $(this).removeClass('label\-default') ;
  54. $(this).addClass('label-danger') ;
  55. }
  56. else if($(this).hasClass('label-danger'))
  57. $(this).removeClass('label-danger').addClass('label-default') ;
  58. }) ;
  59. $('#email-masse-form button[type=submit]').click(function() {
  60. $(this).attr('disabled','disabled').html('Envoyer ...') ;
  61. chat_email_masse_send() ;
  62. return false ;
  63. }) ;
  64. }
  65. function chat_email_masse_send() {
  66. var user = $('#ids-users .label-default:first') ;
  67. if(user.size()) {
  68. $('input[name=id_user]').val(user.data('id')) ;
  69. $.post('index.php?r=user/mail',$('#email-masse-form').serialize(), function(retour) {
  70. user.removeClass('label-default').addClass('label-success') ;
  71. setTimeout("chat_email_masse_send()",30000) ;
  72. }) ;
  73. }
  74. else {
  75. alert('Fini !') ;
  76. }
  77. }
  78. function chat_vrac() {
  79. $('.edit-vrac').click(function() {
  80. if($('.vrac').css('display') == 'none')
  81. $('.vrac').show() ;
  82. else
  83. $('.vrac').hide() ;
  84. }) ;
  85. }
  86. function chat_datepicker() {
  87. $('.datepicker').datepicker({dateFormat:'dd/mm/yy'}) ;
  88. }
  89. function chat_calendar() {
  90. if($('#page-commande').size()) {
  91. var events = new Array ;
  92. $('ul#jours-production li').each(function() {
  93. var date = $(this).html() ;
  94. events.push({
  95. title: 'Production',
  96. start: date,
  97. allDay: true
  98. }) ;
  99. }) ;
  100. jQuery('#calendar').fullCalendar({
  101. header: {
  102. left:"prev,next",
  103. center: "title",
  104. //right:"month,agendaWeek,agendaDay"
  105. right:""
  106. },
  107. lang:"fr-fr",
  108. loading:function loading(bool) {
  109. if (bool) $('#loading').show();
  110. else $('#loading').hide();
  111. },
  112. dayClick: function(date, jsEvent, view) {
  113. var url = $(location).attr('href') ;
  114. var tab_url = url.split('?') ;
  115. $(location).attr('href',tab_url[0]+'?r=commande/index&date='+date.format());
  116. },
  117. eventRender: function (event, element) {
  118. var dataToFind = moment(event.start).format('YYYY-MM-DD');
  119. $("td[data-date='"+dataToFind+"']").addClass('dayWithEvent');
  120. },
  121. //eventBackgroundColor: '#000000',
  122. events: events,
  123. id:"calendar"
  124. });
  125. if($('#current-date').val())
  126. $('td[data-date='+$('#current-date').val()+']').addClass('current-date') ;
  127. }
  128. }
  129. /* French initialisation for the jQuery UI date picker plugin. */
  130. /* Written by Keith Wood (kbwood{at}iinet.com.au),
  131. Stéphane Nahmani (sholby@sholby.net),
  132. Stéphane Raimbault <stephane.raimbault@gmail.com> */
  133. (function( factory ) {
  134. if ( typeof define === "function" && define.amd ) {
  135. // AMD. Register as an anonymous module.
  136. define([ "../jquery.ui.datepicker" ], factory );
  137. } else {
  138. // Browser globals
  139. factory( jQuery.datepicker );
  140. }
  141. }(function( datepicker ) {
  142. datepicker.regional['fr'] = {
  143. closeText: 'Fermer',
  144. prevText: 'Précédent',
  145. nextText: 'Suivant',
  146. currentText: 'Aujourd\'hui',
  147. monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
  148. 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
  149. monthNamesShort: ['janv.', 'févr.', 'mars', 'avril', 'mai', 'juin',
  150. 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
  151. dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
  152. dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
  153. dayNamesMin: ['D','L','M','M','J','V','S'],
  154. weekHeader: 'Sem.',
  155. dateFormat: 'dd/mm/yy',
  156. firstDay: 1,
  157. isRTL: false,
  158. showMonthAfterYear: false,
  159. yearSuffix: ''};
  160. datepicker.setDefaults(datepicker.regional['fr']);
  161. return datepicker.regional['fr'];
  162. }));