public function actiongetTimetableRoom() { $room_arr = array(); $day = $_POST['TimeTableDetail']['day']; $lec = $_POST['TimeTableDetail']['lec']; $acdm_period_id = $_POST['TimeTableDetail']['acdm_period_id']; $type = null; $org_id = Yii::app()->user->getState('org_id'); $timetable_id = $_POST['TimeTableDetail']['timetable_id']; $room_category = (int) $_REQUEST['TimeTableDetail']['room_category']; //$room = RoomCategory::model()->findByAttributes(array('id'=>$class)); //$typeid= $room['id']; $room1 = Yii::app()->db->createCommand()->select('id')->from('room_details_master')->where('room_category=' . $room_category . ' and room_details_organization_id=' . $org_id . ' AND id NOT IN(select room_id from time_table_detail where day=' . $day . ' and lec=' . $lec . ' and acdm_period_id=' . $acdm_period_id . ' and timetable_id=' . $timetable_id . ')')->queryAll(); if (empty($room1)) { $f = 1; echo "<b style='color:red;'>No Room Availble.Create room first.</b>"; } else { foreach ($room1 as $n) { $temp = $n['id']; $room[$temp] = RoomDetailsMaster::model()->findByPk($n['id'])->room_name; } } foreach ($room as $value => $name) { echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true); } /*echo CJSON::encode(array( 'room'=>$room_arr, ));*/ }
protected function renderContent() { $day = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); if (Yii::app()->user->getState('stud_id')) { $date = date('Y-m-d'); $ts = strtotime($date); $week_number = date('W', $ts); $year = date('Y'); for ($day1 = 1; $day1 < 7; $day1++) { $alldate[] = date('d-m-Y', strtotime($year . "W" . $week_number . $day1)); } $criteria = new CDbCriteria(); //$criteria->select = 'academic_term_id'; // select fields which you want in output $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id'); $semname = AcademicTerm::model()->findAll($criteria); $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id'); $stud_model = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id')); $check_sem = in_array($stud_model->student_academic_term_name_id, $data); //var_dump($check_sem); exit; $timetableid = 0; if (!$check_sem) { echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>"; } else { $check_timetable = TimeTableDetail::model()->findByAttributes(array('acdm_name_id' => $stud_model->student_academic_term_name_id, 'division_id' => $stud_model->student_transaction_division_id)); if (empty($check_timetable)) { echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>"; } else { $timetableid = $check_timetable->timetable_id; $model = TimeTable::model()->findByPk($timetableid); $nooflec = $model->No_of_Lec; $sum = $nooflec; $lec_duration = LecDuration::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id ', $params = array(':table_id' => $timetableid)); $lec = array(); foreach ($lec_duration as $l) { $lec[] = $l['duration']; } $createdate = date_create($model->creation_date); $starti = 1; if ($model->zero_lec == 1) { $starti = 0; } $time = $model->clg_start_time; $time = date('H:i A', strtotime($time)); $timestamp = strtotime($time); $time = date('g:i A', $timestamp); ?> <table id="time-table-struc" bgcolor="#CBE7ED" border="2" style= width:auto;font-size:8px;border-collapse:collapse; height:auto;" align="center"> <th align=center> Day/Time </th> <?php $i = 0; while ($i < 6) { echo "<th>" . $day[$i] . "</br>(" . $alldate[$i] . ")</th>"; $i++; } $break = ""; $l = 0; $count = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0); for ($i = $starti; $i <= $nooflec; $i++) { $days = count($day); echo "<tr>"; $duration = NoOfBreakTable::model()->findByAttributes(array('timetable_id' => $timetableid, 'after_lec_break' => $i)); $dur = $duration['duration']; if ($dur) { $dur1 = date('i', strtotime($dur)); } if ($break) { echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + $dur1 * 60) . "</td><td colspan=7 align=center><font color='green'><b>Break</b></font></td></tr>"; $break = ""; $timestamp = strtotime($time) + $dur1 * 60; $time = date('g:i A', $timestamp); $i--; continue; } else { echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + 60 * $lec[$l]) . "</td>"; $timestamp = strtotime($time) + 60 * $lec[$l]; $l++; $time = date('g:i A', $timestamp); } for ($j = 1; $j <= $days; ++$j) { $subname = ""; $room = ""; $faculty = ""; $batch = ""; if ($count[$j] > 0) { $count[$j]--; continue; } $result = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id AND day = :day AND lec = :lec AND division_id = :div_id AND lecture_date = :lecdate and proxy_status <> :proxy_status', $params = array(':table_id' => $timetableid, ':day' => $j, ':lec' => $i, ':div_id' => $stud_model->student_transaction_division_id, ':lecdate' => date('Y-m-d', strtotime($alldate[$j - 1])), ':proxy_status' => 2)); $break = NoOfBreakTable::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id AND after_lec_break = :lec', $params = array(':table_id' => $timetableid, ':lec' => $i)); if ($result) { foreach ($result as $list) { if ($list['lect_hour'] > 1) { $count[$j] = $list['lect_hour'] - 1; } echo "<td rowspan=" . $list['lect_hour'] . " align=center style=background:#C0CCCC; width:100px;>"; break; } foreach ($result as $check) { if ($check->batch_id != 0) { $batch = "(" . Batch::model()->findByPk($check->batch_id)->batch_name . ")"; } $subname = SubjectMaster::model()->findByPk($check->subject_id)->subject_master_alias; $room = "(" . RoomDetailsMaster::model()->findByPk($check->room_id)->room_name . ")"; $faculty = "(" . EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $check->faculty_emp_id))->employee_name_alias . ")"; if ($batch) { echo "</br>" . $subname . "</br>" . $batch . "</br>" . $room . "</br>" . $faculty; } else { echo "</br>" . $subname . "</br>" . $room . "</br>" . $faculty; } } echo "</td>"; } else { echo "<td style=width:100px;>" . $subname . "</br>" . $batch . "</br>" . $room . "</br>" . $faculty . "</td>"; } } echo "</tr>"; } echo "</table>"; ?> <h5>Proxy details</h5> <table id="time-table-struc" style="font-size:10px;"> <tr> <th>Sr. No.</th> <th>Employee Name</th> <th>Proxy Employee Name</th> <th>Subject</th> <th>Lecture No.</th> <th>Date</th> </tr> <?php $proxy_data = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :timetable_id and division_id = :div_id and lecture_date >= :start and lecture_date< :end and proxy_status = :proxy order by lec', $params = array(':timetable_id' => $timetableid, ':div_id' => $stud_model->student_transaction_division_id, ':start' => date('Y-m-d', strtotime($alldate[0])), ':end' => date('Y-m-d', strtotime($alldate[5])), ':proxy' => 1)); $n = 0; foreach ($proxy_data as $list) { $result = TimeTableDetail::model()->findByPk($list->proxy_id); ?> <tr> <td><?php echo ++$n; ?> </td> <td><?php echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name; ?> </td> <td><?php echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $result->faculty_emp_id))->employee_first_name; ?> </td> <td><?php echo SubjectMaster::model()->findByPk($result->subject_id)->subject_master_alias; ?> </td> <td><?php echo $result->lec; ?> </td> <td><?php echo date('d-m-Y', strtotime($result->lecture_date)); ?> </td> </tr> <?php } ?> </table> <?php } //ELSE END } } else { if (Yii::app()->user->getState('emp_id')) { $timetableid = 0; $date = date('Y-m-d'); $ts = strtotime($date); $week_number = date('W', $ts); $alldate[0] = 'No'; $year = date('Y'); for ($day2 = 1; $day2 < 7; $day2++) { $alldate[$day2] = date('d-m-Y', strtotime($year . "W" . $week_number . $day2)); } $semname = AcademicTerm::model()->findAllByAttributes(array(), $condition = 'current_sem = :current_sem and academic_term_organization_id=:org_id', $params = array(':current_sem' => 1, ':org_id' => Yii::app()->user->getState('org_id'))); foreach ($semname as $s) { $semid = $s['academic_term_id']; $check = TimeTableDetail::model()->findByAttributes(array('acdm_name_id' => $semid, 'faculty_emp_id' => Yii::app()->user->getState('emp_id'))); if ($check) { $timetableid = $check['timetable_id']; break; } } if (!empty($timetableid)) { $day = array(" ", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); $model = TimeTable::model()->findByPk($timetableid); $nooflec = $model->No_of_Lec; $sum = $nooflec; $lec_duration = LecDuration::model()->findAllByAttributes(array(), $condition = 'timetable_id = :table_id ', $params = array(':table_id' => $timetableid)); $lec = array(); foreach ($lec_duration as $l) { $lec[] = $l['duration']; } $starti = 1; if ($model->zero_lec == 1) { $starti = 0; } $time = $model->clg_start_time; $time = date('H:i A', strtotime($time)); $createdate = date_create($model->creation_date); ?> <table id="time-table-struc" bgcolor="#CBE7ED" border="2" style="width:auto;font-size:9px;border-collapse:collapse; height:auto;" > <th> Day/Time </th> <?php $i = 0; while ($i < 7) { echo "<th style='font-size:8px'>" . $day[$i] . "</br>(" . $alldate[$i] . ")</th>"; $i++; } $l = 0; $break = ""; $dur1 = 0; $count = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0); for ($i = $starti; $i <= $nooflec; $i++) { $days = count($day); echo "<tr>"; $duration = NoOfBreakTable::model()->findByAttributes(array('timetable_id' => $timetableid, 'after_lec_break' => $i)); if ($duration) { $dur = $duration['duration']; $dur1 = date('i', strtotime($dur)); } if ($break) { echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + $dur1 * 60) . "</td><td colspan=7 align=center ><font color='green'><b>Break</b></font></td></tr>"; $break = ""; $timestamp = strtotime($time) + $dur1 * 60; $time = date('g:i A', $timestamp); $i--; continue; } else { echo "<td style=width:100px;>" . $time . "-</br>" . date('g:i A', strtotime($time) + 60 * $lec[$l]) . "</td><td style=width:25px;><b>" . $i . "</b></td>"; $timestamp = strtotime($time) + 60 * $lec[$l]; $l++; $time = date('g:i A', $timestamp); } for ($j = 1; $j <= $days - 1; ++$j) { $subname = ""; $room = ""; $faculty = ""; $batch = ""; if ($count[$j] > 0) { $count[$j]--; continue; } $result = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'day = :day AND lec = :lec AND faculty_emp_id = :emp_id AND timetable_id=:table_id AND lecture_date =:lecdate and proxy_status <> :status', $params = array(':table_id' => $timetableid, ':day' => $j, ':lec' => $i, ':emp_id' => Yii::app()->user->getState('emp_id'), ':lecdate' => date('Y-m-d', strtotime($alldate[$j])), ':status' => 2)); $break = NoOfBreakTable::model()->findAllByAttributes(array(), $condition = 'after_lec_break = :lec AND timetable_id=:table_id', $params = array(':table_id' => $timetableid, ':lec' => $i)); if ($result) { foreach ($result as $list) { if ($list['lect_hour'] > 1) { $count[$j] = $list['lect_hour'] - 1; } echo "<td rowspan=" . $list['lect_hour'] . " align=center style=background:#C0CCCC; border-color:black; width:150px;>"; break; } foreach ($result as $check) { if ($check->batch_id != 0) { $batch = "(" . Batch::model()->findByPk($check->batch_id)->batch_name . ")"; } $subname = SubjectMaster::model()->findByPk($check->subject_id)->subject_master_alias; $room = "(" . RoomDetailsMaster::model()->findByPk($check->room_id)->room_name . ")"; $div = Division::model()->findByPk($check->division_id)->division_code; //$faculty="(".EmployeeInfo::model()->findByPk($check->faculty_emp_id)->employee_name_alias.")"; if ($batch) { echo $subname . "</br>" . $batch . "</br>" . $room; } else { echo $subname . "</br>" . "(" . $div . ")" . "</br>" . $room; } } echo "</td>"; } else { echo "<td style=width:150px;>" . $subname . "</br>" . $batch . "</br>" . $room . "</td>"; } } //for j end echo "</tr>"; } //for i end echo "</table>"; ?> <h5>Proxy Lectures</h5> <table id="time-table-struc" border="1" style="font-size:10px;"> <tr> <th>Sr. No.</th> <th>Employee Name</th> <th>Division</th> <th>Subject</th> <th>Room</th> <th>Lecture No.</th> <th>Date</th> </tr> <?php $proxy_data = TimeTableDetail::model()->findAllByAttributes(array(), $condition = 'timetable_id = :timetable_id and proxy_employee_id = :emp_id and lecture_date >= :start and lecture_date< :end and proxy_status = :proxy order by lec', $params = array(':timetable_id' => $timetableid, ':emp_id' => Yii::app()->user->getState('emp_id'), ':start' => date('Y-m-d', strtotime($alldate[0])), ':end' => date('Y-m-d', strtotime($alldate[5])), ':proxy' => 1)); $n = 0; foreach ($proxy_data as $list) { $result = TimeTableDetail::model()->findByPk($list->proxy_id); ?> <tr> <td><?php echo ++$n; ?> </td> <td><?php echo EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name; ?> </td> <td><?php echo Division::model()->findByPk($result->division_id)->division_code; ?> </td> <td><?php echo SubjectMaster::model()->findByPk($result->subject_id)->subject_master_alias; ?> </td> <td><?php echo RoomDetailsMaster::model()->findByPk($result->room_id)->room_name; ?> </td> <td><?php echo $result->lec; ?> </td> <td><?php echo date('d-m-Y', strtotime($result->lecture_date)); ?> </td> </tr> <?php } ?> </table> <?php } else { echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>"; } } } }
} } print '<table id="time-table-struc" style="font-size:10px;">'; print '<tr>'; print '<th>Lecture No.</th>'; print '<th>Subject</th>'; print '<th>Faculty Name</th>'; print '<th>Room No.</th>'; print '<th>Time</th>'; foreach($check_timetable as $list) { if($list->subject_type != 1 && $list->batch_id !=$stud_model->student_transaction_batch_id) { continue; } print '<tr>'; print '<td>'.$list->lec.'</td>'; print '<td>'.SubjectMaster::model()->findByPk($list->subject_id)->subject_master_alias.'</td>'; print '<td>'.EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id'=>$list->faculty_emp_id))->employee_first_name.'</td>'; print '<td>'.RoomDetailsMaster::model()->findByPk($list->room_id)->room_name.'</td>'; print '<td>'.$time[$list->lec].'</td></tr>'; } print '</table>';?> </div> </div> </div> <?php } ?>
protected function renderContent() { $current_date = date('Y-m-d'); if (Yii::app()->user->getState('stud_id')) { $criteria = new CDbCriteria(); //$criteria->select = 'academic_term_id'; // select fields which you want in output $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id'); $semname = AcademicTerm::model()->findAll($criteria); $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id'); $stud_model = StudentTransaction::model()->findByPk(Yii::app()->user->getState('stud_id')); $check_sem = in_array($stud_model->student_academic_term_name_id, $data); $timetableid = 0; if (!$check_sem) { echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>"; } else { $check_timetable = TimeTableDetail::model()->findAllByAttributes(array('acdm_name_id' => $stud_model->student_academic_term_name_id, 'division_id' => $stud_model->student_transaction_division_id, 'lecture_date' => $current_date), 'proxy_status <> :status', array(':status' => 1)); if (empty($check_timetable)) { echo "<h3 align=center style=color:red>Sorry, No timetable available for this student.</h3>"; } else { $timetable = TimeTable::model()->findByPk($check_timetable[0]->timetable_id); $time1 = date('H:i A', strtotime($timetable['clg_start_time'])); if ($timetable->zero_lec == 1) { $time[] = $time1; } else { $time[1] = $time1; } $lec_dur = LecDuration::model()->findAll(array('condition' => 'timetable_id=' . $timetable['timetable_id'])); foreach ($lec_dur as $list) { $break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break' => $list['lecture'], 'timetable_id' => $timetable['timetable_id'])); if ($break) { $dur1 = date('i', strtotime($break['duration'])); $timestamp = strtotime($time1) + 60 * $dur1; $time1 = date('g:i A', $timestamp); $timestamp = strtotime($time1) + 60 * $list['duration']; $time1 = date('g:i A', $timestamp); $time[] = $time1; } else { $timestamp = strtotime($time1) + 60 * $list['duration']; $time1 = date('g:i A', $timestamp); $time[] = $time1; } } print '<table id="time-table-struc" style="font-size:10px;">'; print '<tr>'; print '<th>Lecture No.</th>'; print '<th>Subject</th>'; print '<th>Faculty Name</th>'; print '<th>Room No.</th>'; print '<th>Time</th>'; foreach ($check_timetable as $list) { if ($list->subject_type != 1 && $list->batch_id != $stud_model->student_transaction_batch_id) { continue; } print '<tr>'; print '<td>' . $list->lec . '</td>'; print '<td>' . SubjectMaster::model()->findByPk($list->subject_id)->subject_master_alias . '</td>'; print '<td>' . EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id' => $list->faculty_emp_id))->employee_first_name . '</td>'; print '<td>' . RoomDetailsMaster::model()->findByPk($list->room_id)->room_name . '</td>'; print '<td>' . $time[$list->lec] . '</td></tr>'; } print '</table>'; } } } else { if (Yii::app()->user->getState('emp_id')) { $criteria = new CDbCriteria(); //$criteria->select = 'academic_term_id'; $criteria->condition = 'current_sem = 1 AND academic_term_organization_id = ' . Yii::app()->user->getState('org_id'); $semname = AcademicTerm::model()->findAll($criteria); $data = CHtml::listData($semname, 'academic_term_id', 'academic_term_id'); $data_arr = implode(',', $data); $timetable_criteria = new CDbCriteria(); $timetable_criteria->condition = 'acdm_name_id in (' . $data_arr . ') AND faculty_emp_id = ' . Yii::app()->user->getState('emp_id') . ' AND lecture_date = "' . date('Y-m-d') . '"'; $time_table_details = TimeTableDetail::model()->findAll($timetable_criteria); if ($time_table_details) { $timetable = TimeTable::model()->findByPk($time_table_details[0]->timetable_id); $time1 = date('H:i A', strtotime($timetable['clg_start_time'])); if ($timetable->zero_lec == 1) { $time[] = $time1; } else { $time[1] = $time1; } $lec_dur = LecDuration::model()->findAll(array('condition' => 'timetable_id=' . $timetable['timetable_id'])); foreach ($lec_dur as $list) { $break = NoOfBreakTable::model()->findByAttributes(array('after_lec_break' => $list['lecture'], 'timetable_id' => $timetable['timetable_id'])); if ($break) { $dur1 = date('i', strtotime($break['duration'])); $timestamp = strtotime($time1) + 60 * $dur1; $time1 = date('g:i A', $timestamp); $timestamp = strtotime($time1) + 60 * $list['duration']; $time1 = date('g:i A', $timestamp); $time[] = $time1; } else { $timestamp = strtotime($time1) + 60 * $list['duration']; $time1 = date('g:i A', $timestamp); $time[] = $time1; } } print '<table id="time-table-struc" style="font-size:10px;">'; print '<tr>'; print '<th>Lecture No.</th>'; print '<th>Branch</th>'; print '<th>Sem</th>'; print '<th>Division</th>'; print '<th>Subject</th>'; print '<th>Room No.</th>'; print '<th>Time</th>'; foreach ($time_table_details as $list) { print '<tr>'; print '<td>' . $list->lec . '</td>'; print '<td>' . Branch::model()->findByPk($list->branch_id)->branch_name . '</td>'; print '<td>' . AcademicTerm::model()->findByPk($list->acdm_name_id)->academic_term_name . '</td>'; print '<td>' . Division::model()->findByPk($list->division_id)->division_code . '</td>'; print '<td>' . SubjectMaster::model()->findByPk($list->subject_id)->subject_master_alias . '</td>'; print '<td>' . RoomDetailsMaster::model()->findByPk($list->room_id)->room_name . '</td>'; print '<td>' . $time[$list->lec] . '</td></tr>'; } print '</table>'; } else { echo "<h3 align=center style=color:red>Sorry, No timetable available.</h3>"; } } } }
$f=0; continue; } else $rows=1; } $sub_array[] = $list->subject_id; print '<td rowspan='.$rows.'>'.$time[$list->lec].'</td>'; print '<td rowspan='.$rows.'>'.SubjectMaster::model()->findByPk($list->subject_id)->subject_master_name.'</td>'; print '<td rowspan='.$rows.'>'.EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id'=>$list->faculty_emp_id))->employee_first_name.'</td>'; if($list->batch_id != 0) print '<td rowspan='.$rows.'>'.Batch::model()->findByPk($list->batch_id)->batch_code.'</td>'; else print '<td rowspan='.$rows.'>-</td>'; print '<td rowspan='.$rows.'>'.RoomDetailsMaster::model()->findByPk($list->room_id)->room_name.'</td></tr>'; } print '</table>'; $sy_date = date('Y-m-d',strtotime($date)); $substr = implode(',',$sub_array); $syll = SubjectSyllabus::model()->findAll(array('condition'=>'sub_id in ('.$substr.') and start_date<="'.$sy_date.'" and end_date >="'.$sy_date.'"')); print '<div> </div>'; print '<table class="gradienttable" id="time-table-struc" style="font-size:15px;margin-top:50px;">'; print '<tr>'; print '<tr><td colspan=4 style="background:white"><b>Topics to be taught on '.$date.'</b></td></tr>'; print '<th>SI No.</th>'; print '<th>Subject Name</th>'; print '<th>Topic</th>';
$top = $top_desc = ''; foreach($syll as $lst) { $top_str .= "<h3>".$lst['topic_name'].'</h3>'.$lst['topic_description']; $top = $lst['topic_name']; $top_desc = $lst['topic_description']; } if($check->batch_id != 0 && $check->batch_id !=$stud_model->student_transaction_batch_id) { continue; } if($check->batch_id != 0) $batch="(".Batch::model()->findByPk($check->batch_id)->batch_code.")"; $subname = SubjectMaster::model()->findByPk($check->subject_id)->subject_master_name; $room="(".RoomDetailsMaster::model()->findByPk($check->room_id)->room_name.")"; $emp_row = EmployeeInfo::model()->findByAttributes(array('employee_info_transaction_id'=>$check->faculty_emp_id)); $faculty="(".$emp_row->employee_name_alias.")"; if($batch) $str = $subname."</br>".$batch."</br>".$room."</br>".$faculty; else $str = $subname."</br>".$room."</br>".$faculty; if($syll) echo "<u>".$str."</u>"; else echo $str; if($top_str == '') echo "</td>";