fork download
  1. calc_computed = function() {
  2. this.computed = new Object();
  3. this.computed.pacing = -1;
  4. this.computed.projected = -1;
  5. var booked = 100000;
  6. var deliv = 56886;
  7. alert("deliv");
  8. if (booked > 0 && deliv > 0) {
  9. var ratio = deliv / booked;
  10. if (ratio < 20) {
  11. var start = this.data[FLDS.startdate];
  12. var end = this.data[FLDS.enddate];
  13. var pctcomp = 0; // see util.ctxinc: campaign_percent_complete
  14. if (end > start) {
  15. if (end <= RECORD_TODAY) {
  16. pctcomp = 1;
  17. }
  18. else {
  19. pctcomp = (RECORD_TODAY - start) / (end - start);
  20. }
  21. }
  22. if (pctcomp > 0) {
  23. ratio /= pctcomp;
  24. ratio *= 100;
  25. ratio = ratio.toFixed(2);
  26. this.computed.pacing = ratio;
  27. }
  28. }
  29. if (booked > deliv) {
  30. var owe = booked - deliv;
  31. var days_remain = (end - RECORD_TODAY) / 86400 + 1;
  32. this.computed.projected = parseInt(owe / days_remain, 10);
  33. return(this.computed.projected);
  34. }
  35. }
  36. return(this.computed.projected);
  37. };
  38.  
  39. function main()
  40. {
  41. calc_computed();
  42. }
Success #stdin #stdout 0.01s 4980KB
stdin
Standard input is empty
stdout
Standard output is empty