11var spinner = $ ( '#loader' ) ;
2- const scriptURLC = 'https://script.google.com/macros/s/AKfycbxB8ZYOIRQoGRcB8nm4rTXR6kBaP2JM9m6hrp1qgVEfdFOoDc20CKC-iqsihtA6YD_B /exec' ;
2+ const scriptURLC = 'https://script.google.com/macros/s/AKfycbwChFoeZe8vagm2tXzhIfFssGjYbItkuaFE-BHiS87MSJItse8kHuxU53z9oUNsPNGR /exec' ;
33const serverlessForm = document . forms [ 'serverless-form' ] ;
44var timerOn = false ;
55var bgAnimate = false ;
@@ -41,11 +41,18 @@ $("#restart-button").click(function(){
4141} )
4242
4343$ ( "#stop-button" ) . click ( function ( ) {
44- console . log ( "stop button Clicked" ) ;
44+ console . log ( "Stop button Clicked" ) ;
4545 resetTimer ( ) ;
4646
4747} )
4848
49+ $ ( "#progress-btn" ) . click ( function ( ) {
50+
51+ console . log ( "Order Progress Button Clicked" ) ;
52+ getOrderProgress ( orderID ) ;
53+
54+ } )
55+
4956function resetTimer ( ) {
5057
5158 timerOn = false ;
@@ -117,16 +124,13 @@ function runTimer(){
117124
118125}
119126
120- // $("#order-id").change(function(){
121- //
122- //
123- // })
124127
125128//Get Order Notes
126129$ ( '#order-id' ) . change ( function ( ) {
127130
128131 var orderID = $ ( '#order-id' ) . val ( ) ;
129132 var tapeName = orderID . split ( "_" ) ;
133+ $ ( "#logged-text" ) . html ( "" ) ;
130134
131135 if ( tapeName . length > 1 ) {
132136
@@ -151,6 +155,7 @@ $('#tape-num').change(function(){
151155
152156 currentOrderID = $ ( '#order-id' ) . val ( ) ;
153157 currentTech = $ ( '#initials' ) . val ( ) ;
158+ $ ( "#logged-text" ) . html ( "" ) ;
154159
155160 $ ( '#existing-qc-notes' ) . html ( "Retrieving Tape Notes" ) ;
156161 getOrderDetails ( currentOrderID , $ ( '#tape-num' ) . val ( ) , currentTech ) ;
@@ -171,8 +176,6 @@ $('#initials').change(function(){
171176//~~~~~~~~~~~~~~~~~~~~~~~~~Form Submission~~~~~~~~~~~~~~~~~~~~~~~~~
172177//-----------------------------------------------------------------
173178
174-
175-
176179function getFormDetails ( ) {
177180
178181 orderID = $ ( '#order-id' ) . val ( ) ;
@@ -205,15 +208,55 @@ serverlessForm.addEventListener('submit', e => {
205208
206209 console . log ( "Tape Number: " + tapeNum ) ;
207210
208- Swal . fire ( {
211+ var standardMessage = {
212+
209213 title : 'Ready to Log Tape <br/>' + orderID + '_' + lastName + '_ ' + tapeNum + '?' ,
210214 text : 'Has the file been reviewed? Ready to Log Tape?' ,
211215 icon : 'question' ,
212216 showCancelButton : true ,
213217 confirmButtonText : 'Log Tape' ,
214218 returnFocus : false ,
215219 focusCancel : true
216- } ) . then ( ( result ) => {
220+
221+ } ;
222+
223+ var loggedMessage = {
224+
225+ title : 'TAPE IS ALREADY LOGGED! <br/>' + orderID + '_' + lastName + '_ ' + tapeNum ,
226+ text : 'This tape has already been logged! Please confirm the tape information is correct and select "Log Notes Only" to log the tape.' ,
227+ icon : 'warning' ,
228+ showCancelButton : true ,
229+ showConfirmButton : false ,
230+ confirmButtonText : 'Log Tape' ,
231+ returnFocus : false ,
232+ focusCancel : true
233+
234+ } ;
235+
236+ var message = { } ;
237+
238+ if ( $ ( "#logged-text" ) . html ( ) != "" ) {
239+
240+ if ( ! $ ( "#notes-only" ) . prop ( 'checked' ) ) {
241+
242+ message = loggedMessage ;
243+
244+ } else {
245+
246+ loggedMessage . showConfirmButton = true ;
247+ loggedMessage . text = "Tape has already been logged! Confirm you would like to log notes only!" ;
248+
249+ message = loggedMessage ;
250+
251+ }
252+
253+ } else {
254+
255+ message = standardMessage ;
256+
257+ }
258+
259+ Swal . fire ( message ) . then ( ( result ) => {
217260 if ( result . isConfirmed ) {
218261 // Swal.fire('Saved!', '', 'success')
219262 logTape ( e )
@@ -238,7 +281,7 @@ function logTape(e){
238281 notesOnly : notesOnly ,
239282 billingNotes : billingNotes ,
240283 orderCategory : "video" ,
241- getOrderDetails : false
284+ requestType : "logTape"
242285 } ) ;
243286
244287 console . log ( "Notes Only: " + notesOnly ) ;
@@ -280,6 +323,7 @@ function logTape(e){
280323 $ ( '#notes-only' ) . prop ( 'checked' , false ) ;
281324 $ ( '#existing-qc-notes' ) . html ( "" ) ;
282325 $ ( '#tape-num' ) . focus ( ) ;
326+ $ ( '#logged-text' ) . html ( "" ) ;
283327 }
284328 } ) ;
285329 } else { //There was a logging error
@@ -302,8 +346,6 @@ function logTape(e){
302346
303347 } ) ;
304348
305-
306-
307349 document . getElementById ( 'submitForm' ) . classList . remove ( 'loading' ) ;
308350
309351 } )
@@ -325,7 +367,7 @@ function getOrderDetails(orderID, tapeNum, initials){
325367 tapeNum : tapeNum ,
326368 initials : initials ,
327369 checkOrderStatus : checkOrderStatus ,
328- getOrderDetails : true
370+ requestType : "getOrderDetails"
329371 } ) ;
330372
331373 fetch ( scriptURLC , {
@@ -366,11 +408,95 @@ function getOrderDetails(orderID, tapeNum, initials){
366408 $ ( '#qc-notes' ) . focus ( ) ;
367409 }
368410
411+
412+ try {
413+ // Your asynchronous code here
414+ if ( data . logged === true ) {
415+ $ ( "#logged-text" ) . html ( "(Tape Already logged)" ) ;
416+ }
417+ } catch {
418+ console . log ( "Error occurred: " + error . message ) ;
419+ console . log ( "No logging information Present" ) ;
420+ }
421+
369422 console . log ( data )
370423 } ) ;
371424
372425}
373426
427+ function getOrderProgress ( orderID ) {
428+
429+ spinner . show ( ) ;
430+
431+ getFormDetails ( ) ;
432+
433+ var params = new URLSearchParams ( {
434+ orderID : orderID ,
435+ requestType : "getOrderProgress"
436+ } ) ;
437+
438+ console . log ( "Getting Order Progress" ) ;
439+
440+ var tapeProgress = "" ;
441+
442+ fetch ( scriptURLC , {
443+ method : 'POST' ,
444+ body : params
445+ } )
446+ . then ( res => {
447+
448+ console . log ( res ) ;
449+ spinner . hide ( ) ;
450+
451+ res . json ( ) . then ( function ( data ) {
452+ console . log ( data ) ;
453+ tapeProgress = data . tapeProgress ;
454+
455+ if ( res [ 'status' ] == 200 ) {
456+
457+ if ( data . errorTitle == "" ) {
458+ Swal . fire ( {
459+ title : "Current Order Progress" ,
460+ html : data . tapeProgress ,
461+ icon : "success" ,
462+ returnFocus : false
463+ } ) . then ( ( result ) => {
464+ if ( result . isConfirmed ) {
465+
466+ }
467+ } ) ;
468+ } else { //There was a logging error
469+
470+ Swal . fire ( {
471+ title : data . errorTitle ,
472+ html : data . errorText ,
473+ icon : "error" ,
474+ returnFocus : false
475+ } ) ;
476+
477+ }
478+
479+ return true ;
480+
481+ } else {
482+ Swal . fire ( "Something went wrong!" , "Please Try Again or Contact Admin" , "error" ) ;
483+
484+ }
485+
486+ } ) ;
487+
488+ document . getElementById ( 'submitForm' ) . classList . remove ( 'loading' ) ;
489+
490+ } )
491+ . catch ( error => {
492+ spinner . hide ( ) ;
493+ // document.getElementById('submitForm').classList.remove('loading');
494+ Swal . fire ( "Something went wrong!" , "Review Footage Log and/or contact Admin" , "error" ) ;
495+ // todo enable submit button
496+
497+ } )
498+ }
499+
374500function copyToClipboard ( value ) {
375501 var tempInput = document . createElement ( "input" ) ;
376502 tempInput . value = value ;
0 commit comments