2013-07-30 3 views
-2

내 캘린더가 어떻게 보이는지 .. function.calender를 사용하여 캘린더를 만들었지 만 올바르게 작동하지만 이제는 토요일과 일요일 열을 비활성화하려고합니다. 내가 어떻게 해?내 캘린더 기능에서 토요일과 일요일의 열을 사용하지 않으려면

미리 감사드립니다.

아래 코드를 시도했습니다.

function draw_calendar($month,$year){ 

     if($month=='1') 
     { 
      $strmonth='january'; 
     } 
     else if($month=='2') 
     { 
      $strmonth='february'; 
     } 
     else if($month=='3') 
     { 
      $strmonth='march'; 
     } 
     else if($month=='4') 
     { 
      $strmonth='april'; 
     } 
     else if($month=='5') 
     { 
      $strmonth='may'; 
     } 
     else if($month=='6') 
     { 
      $strmonth='june'; 
     } 
     else if($month=='7') 
     { 
      $strmonth='july'; 
     } 
     else if($month=='8') 
     { 
      $strmonth='august'; 
     } 
     else if($month=='9') 
     { 
      $strmonth='september'; 
     } 
     else if($month=='10') 
     { 
      $strmonth='october'; 
     } 
     else if($month=='11') 
     { 
      $strmonth='november'; 
     } 
     else if($month=='12') 
     { 
      $strmonth='december'; 
     } 




    /* draw table */ 
    $calendar = '<table cellpadding="0" cellspacing="0" class="calendar" align="center" ><tr><td align="center" colspan="7" style="border:1px solid gray;text-transform:uppercase;border-left:none;color:chocolate;height:30px;font-size:30px;padding:5px;"><b>'.$strmonth.' &nbsp; '.$year.'</b></td></tr>'; 

    /* table headings */ 
    $headings = array('<font color="red">Sunday</font>','Monday','Tuesday','Wednesday','Thursday','Friday','<font color="red">Saturday</font>'); 

    $calendar.= '<tr class="calendar-row"><td class="calendar-day-head">'.implode('</td><td class="calendar-day-head">',$headings).'</td></tr>'; 

    /* days and weeks vars now ... */ 
    $running_day = date('w',mktime(0,0,0,$month,1,$year)); 
    $days_in_month = date('t',mktime(0,0,0,$month,1,$year)); 
    $days_in_this_week = 1; 
    $day_counter = 0; 
    $dates_array = array(); 


    /* if(($headings[0])) 
     { 
      $sday='style="color:red"'; 
     } 
     else 
     { 
      $sday='style="color:gray"'; 
     } 
    */ 


    /* row for week one */ 

    $calendar.= '<tr class="calendar-row" >'; 


    /* print "blank" days until the first of the current week */ 
    for($x = 0; $x < $running_day; $x++): 
     $calendar.= '<td class="calendar-day-np" > </td>'; 
     $days_in_this_week++; 
    endfor; 

    /* keep going with days.... */ 

    for($list_day = 1; $list_day <= $days_in_month; $list_day++): 

    if(isset($_SESSION['client']) && !empty($_SESSION['client'])) 
    { 

     $s="select * from tbl_job_schedule where jobdate='".$strmonth."-".$list_day."-".$_SESSION['yy']."' and clientname='".$_SESSION['client']."'"; 

     $q=mysql_query($s) or die($s); 
     $rw=mysql_fetch_array($q); 
    } 
    else if(isset($_SESSION['user']) && !empty($_SESSION['user'])) 
    { 
     $s="select * from tbl_job_schedule where jobdate='".$strmonth."-".$list_day."-".$_SESSION['yy']."' and username='".$_SESSION['user']."'"; 

     $q=mysql_query($s) or die($s); 
     $rw=mysql_fetch_array($q); 
    } 


     if($rw['status']=='schedule') 
     { 
      $strimg='<img src="images/schedule.png" height="35" width="35"/>'; 
     } 
     else if($rw['status']=='schwork') 
     { 
      $strimg='<img src="images/schedule.png" height="35" width="35"/>&nbsp;<img src="images/work.png" height="35" width="35"/>'; 
     } 
     else if($rw['status']=='schworkcmnt' && $rw['client_cmnt']=='') 
     { 
      $strimg='<img src="images/schedule.png" height="35" width="35"/>&nbsp;<img src="images/work.png"height="35" width="35" />'; 
     } 
     else if($rw['status']=='schworkcmnt' && $rw['client_cmnt']!='') 
     { 
      $strimg='<img src="images/schedule.png" height="35" width="35"/>&nbsp;<img src="images/work.png" height="35" width="35"/><br><img src="images/cmnt.png" height="35" width="35"/>'; 
     } 
     else 
     { 
      $strimg=''; 
     } 

     $calendar.= '<td class="calendar-day" onClick="OpenWin('.$list_day.');" >'; 

      $calendar.= '<div class="day-number" >'.$list_day.'</div><div style="height:90px;width:80px;border:0px solid yellow;float:right;padding-right:0px;padding-top:10px;" >'.$strimg.'</div><div style="height:40px;width:150px;padding:0px;border:0px solid yellow;float:left;margin-top:50px;margin-right:20px;font-size:14px;color:gray;text-transform:capitalize;" ><b>'.$rw['client_comp'].'</b></div>'; 

      /** QUERY THE DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM !! **/ 
      $calendar.= str_repeat('<p> </p>',2); 

     $calendar.= '</td>'; 
     if($running_day == 6): 
      $calendar.= '</tr>'; 
      if(($day_counter+1) != $days_in_month): 
       $calendar.= '<tr class="calendar-row">'; 
      endif; 
      $running_day = -1; 
      $days_in_this_week = 0; 
     endif; 
     $days_in_this_week++; $running_day++; $day_counter++; 
    endfor; 

    /* finish the rest of the days in the week */ 
    if($days_in_this_week < 8): 
     for($x = 1; $x <= (8 - $days_in_this_week); $x++): 
      $calendar.= '<td class="calendar-day-np"> </td>'; 
     endfor; 
    endif; 

    /* final row */ 
    $calendar.= '</tr>'; 

    /* end the table */ 
    $calendar.= '</table>'; 

    /* all done, return result */ 
    return $calendar; 


} 

/* sample usages */ 


?> 
+0

제안 : 모든'if ($ month == '1') .. else..else ... 대신'$ strmonth = strtolower (date ("F", mktime (0, 0, 0, $ month, 1))); ' – bansi

답변

0

이 시도 :

//all other code. Check if date of the week equals 0-sunday or 6-saturday 
if($running_day==0 || $running_day==6) { 
$calendar.= '<td>&nbsp;</td>'; 
} 
else 
{ 
$calendar.= '<td class="calendar-day" onClick="OpenWin('.$list_day.');" >'; 
//... all other code 
$calendar.= '</td>'; 
} 

참고 : 코드를 테스트하지.

+0

예 ... 그 작품은 이제 감사합니다 budy :-) –

관련 문제