Page 1 of 1

Help with column color change

Posted: Sun Feb 19, 2012 7:11 pm
by kenny724
I have done everything I know to change the color of the PA column to less than 7 days red, less than 14 days blue, and less than 21 days yellow. All the other columns must remain overdue red, less than 7 blue, and less than 14 yellow. What am I doing wrong??

Code: Select all

    .cv_late {  background-color:$red;  }
       .cv_1weeks  {  background-color:$blue;  }
       .cv_2weeks  {  background-color:$yellow;  }
        .cv_1weekspa  {  background-color:$red;  }
       .cv_2weekspa  {  background-color:$blue;  }
        .cv_3weekspa  {  background-color:$yellow;  }

       .cv_now  {  background-color:$red;  }

Code: Select all

               //-----------------------------------------------------------Date entries
                $('#example tbody td input[date=1]').attr({readonly: '1'}).datepicker({
                yearRange: '1909:2040',
                    changeMonth: true,
                    changeYear: true,
                onSelect: function(dateText){
                  // Build the post data
                  if($(this).val() == "01/01/1909") $(this).val("");
                  var postData = {
                      patientID: $(this).attr('patientID'),
                      field: $(this).attr('field'),
                      value: $(this).val()
                  };
                  var myparent = $(this).parent().attr('class');
                  var temp = $(this).val();
                  var thisdate = new Date();
                  var new_date = new Date(temp.substring(6,10),temp.substring(0,2)-1,temp.substring(3,5));
                  var dateDiff = Math.ceil((new_date - thisdate)/(1000*60*60*24));
               var padateDiff = Math.ceil((new_date - thisdate)/(1000*60*60*24));

                  var new_class = "";
                  var new_paclass = "";
                  if( dateDiff < 14 )
                       new_class == 'cv_2weeks';
                    if( dateDiff < 7 )
                       new_class == 'cv_1weeks';
                    if( dateDiff < 0 )
                       new_class == 'cv_now';
                    
                     if( padateDiff < 21 )
                       new_paclass == 'cv_3weekspa';
                    if( padateDiff < 14 )
                       new_paclass == 'cv_2weekspa';
                    if( padateDiff < 7 )
                       new_paclass == 'cv_1weekspa';
                 
                  //alert(var_diff);
                  $(this).parent().removeClass(myparent);
                  $(this).parent().addClass(new_class);
               $(this).parent().addClass(new_paclass);

                  // Update the database
                  $.post("ajax_update_patient.php", postData, function(data){
                      // if it was not ok show the error
                      if (data != "OK") {
                        alert(data);
                      }
                  });
                }
              }).addClass('ui-state-highlight ui-corner-all');

Code: Select all

    function my_get_days(&$in_date, $patient=0)
    {
       $color_var = "";
       
       if($in_date == '00/00/0000' || $in_date == NULL)
          $in_date  = '';
       elseif(strtoupper($in_date) == 'N/A')
          $in_date  = 'N/A';
       else
       {
          $dateDiff = floor( (strtotime($in_date) - strtotime(date('m/d/Y')))/(60*60*24) );
          if( $dateDiff < 14 )
             $color_var = $yellow;
          if( $dateDiff < 7 )
             $color_var = $blue;
          if( $dateDiff < 0 )
             $color_var = $red;
          $padateDiff = floor( (strtotime($in_date) - strtotime(date('m/d/Y')))/(60*60*24) );
          if( $padateDiff < 21 )
             $color_var = $yellow;
          if( $padateDiff < 14 )
             $color_var = $blue;
          if( $padateDiff < 7 )
             $color_var = $red;
      }
       return($color_var);
    }