D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
public
/
js
/
Filename :
manager_price.js
back
Copy
$(function () { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, type: "post", }); $('#price_edit3').click(function () { canvasElement = document.querySelector('canvas'); if (canvasElement.width > 5500) { alert('Error! Width must be less then 5500px'); } else { var canvasData = canvasElement.toDataURL("image/png"); var clientId = $('#client_id').val(); //console.log(canvasData); $.ajax({ url: '/manager/ajax/price3', type: 'POST', data: { data: canvasData, client_id: clientId }, timeOut: 1000, beforeSend: function () { $('#getCroppedCanvasModal .modal-body').html('<p align="center"><img src="/img/loader.gif" class="loader"></p>'); }, success: function (data) { console.log('ok_success'); $('.modal-dialog').css('width', '300px'); document.location.href = '/manager/calculator/picture/' + data; }, error: function (data) { console.log(data); $('#modal_text').text('Some error! Please, try again with small picture or crop this one.'); $('#myModal').modal('show'); //document.location.href = '/'; } }); } }); $('#style').change(function () { var catalog = parseInt($(this).val()); var width = $('#width').val(); var height = $('#height').val(); getSize(width, height, catalog); }); $('#width').change(function () { var data = $(this).val(); var width = data; var width_out = $('#width_out').attr('data_real'); var height_out = $('#height_out').attr('data_real'); var height = Math.ceil(data * height_out / width_out); //var height = $('#height').val(); console.log(width, width_out, height_out, height); var catalog = parseInt($('#style').val()); var id = parseInt($('#print').attr('data-id')); $('#print').attr('href', '/manager/tattooprint/'+id+'/?width=' + width + '&height=' + height); $('#height_out').text(Math.round(height)); $('#size_out').text(Math.round(width) * Math.round(height)); $('#height').val(Math.round(height)); $('#height_b').val(Math.round(height)); $('#pic').width(width * 38).height($('#height').val() * 38); $('#width_out').text(width); $('#cropContainerPreload').width(width * 38).height($('#height').val() * 38); getSize(width, height, catalog); // document.location.href = '?width=' + width + '&height=' + $('#height').val() + '#calculate'; }); $('#saloon_select').change(function () { $('#service_order').hide(); $('#price_button').show(); $('#service_select').val(1); var id = $(this).val(); var artist_id = $('#artist_select').val(); if (id > 0) { var arts = $('#saloon_select [value=' + id + ']').attr('data-artists'); var arr = arts.split(','); //alert(arr[0]); var html = "<select name='artist_name' class='form-control'>"; arr.forEach(function (e) { html += "<option value='" + e + "'>" + e + "</option>"; }); html += "</select>"; $('#artist_hide').html(html).show(); $('#artist_select').hide(); } else { $('#artist_select').show(); $('#artist_hide').hide(); } }); $('#artist_select').change(function () { var id = $(this).val(); console.log(id); if (id > 0) { var saloon_id = $('#artist_select [value=' + id + ']').attr('data-saloon-id'); var saloon_name = $('#artist_select [value=' + id + ']').attr('data-saloon'); var html = saloon_name; $('#saloon_select').val(saloon_id); $('#saloon_hide').html(html); $('#saloon_select').hide(); } else { $('#saloon_hide').hide(); $('#saloon_select').show(); } }) }); function getSize(width, height, catalog) { if (!width) { width = 1; } if (!height) { height = 1; } if (!catalog) { catalog = 0; } $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, type: "post" }); $.ajax({ url: '/ajax/sum', data: 'width=' + width + '&height=' + height + '&catalog=' + catalog, success: function (data) { $('#sum').text(data); var wor = Math.ceil(data / 80) / 2; console.log(wor); $('#works_hours').text(wor); }, error: function (data) { console.log(data); } }); }