$arrClasses = array(); //The purpose of this page should only be to keep track of the residents who are currently in Netherhall. $today = date('Y-m-d'); $r = mysql_query("SELECT residents.resident_id, NAME, surname " . "FROM residents LEFT JOIN bookings ON residents.resident_id = bookings.resident_id " . "WHERE bookings.status='accepted' AND bookings.done=0 AND bookings.arrival <= '{$today}' " . "GROUP BY residents.resident_id ORDER BY surname, NAME"); if (mysql_num_rows($r)) { ?> <table align="center" border="1" cellpadding="4" cellspacing="0"> <?php while ($arrInfo = mysql_fetch_assoc($r)) { $total_outstanding = 0; $r2 = mysql_query("SELECT * FROM residents LEFT JOIN bookings ON residents.resident_id = bookings.resident_id " . "WHERE bookings.status='accepted' AND residents.resident_id={$arrInfo[resident_id]} " . "ORDER BY NAME, surname, bookings.arrival"); while ($arrData = mysql_fetch_assoc($r2)) { //ver_array("arrData",$arrData); $date_from = mostrar_fecha($arrData['arrival']); $date_to = mostrar_fecha($arrData['planned_departure']); $days = subtract_dates($date_from, $date_to); $total_rent = $days * ($arrData['weekly_rate'] / 7); $total_rent = round($total_rent, 2); $due = $total_rent + $arrData['laundry'] + $arrData['hc'] + $arrData['printing'] + $arrData['extra']; //$outstanding = $due - $arrData['deposit'] - $arrData['received']; $outstanding = $due - $arrData['received']; $outstanding = round($outstanding, 2); $name = ""; if ($arrData[surname] != "") { $name = $arrData[surname] . ", "; } $name .= $arrData[name]; if (mysql_num_rows($r2) < 2) { ?> <tr class="row1"> <td><?php
?> </table> </div> </td> </tr> <? $div_num++; } $r=mysql_query("SELECT * FROM bookings WHERE resident_id=$resident_id AND status='finished' ORDER BY arrival DESC"); while ($arrAccomodation=mysql_fetch_assoc($r)) { $date_from = mostrar_fecha($arrAccomodation['arrival']); $date_to_planned = mostrar_fecha($arrAccomodation['departure']); $date_to = mostrar_fecha($arrAccomodation['actual_departure']); $days=subtract_dates($date_from, $date_to_planned); // Search the name of the room if ($arrAccomodation[room_id]) { $r2=mysql_query("SELECT * FROM rooms WHERE room_id={$arrAccomodation[room_id]}"); $room = ""; if (mysql_numrows($r2)) $room=mysql_result($r2,0,"room"); } //ver_array("arrAccomodation",$arrAccomodation); $total_rent = $days * ($arrAccomodation['weekly_rate']/7); $total_rent = round($total_rent,2); $due = $total_rent + $arrAccomodation['laundry'] + $arrAccomodation['hc'] + $arrAccomodation['printing'] + $arrAccomodation['extra']; $invoice_number = "NO BILL"; $outstanding = $arrAccomodation['received'] - $due;
function otd_manage_panel() { otd_controller(); global $wpdb, $otd_tablename, $otd_tablename_users, $otd_location, $otd_message; // monta array para dropdown com os usuários $sql = "SELECT * FROM " . $otd_tablename_users; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $att[$result->ID] = $result->user_nicename; } } // monta array para dropdown com os usuários // monta array para dropdown com os idParent $sql = "SELECT * FROM " . $otd_tablename; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $idParent[$result->id] = $result->id; } } // monta array para dropdown com os idParent // monta array para dropdown com os sprintNumber $sql = "SELECT * FROM " . $otd_tablename; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $sprintNumber[$result->sprintNumber] = $result->sprintNumber; } } // monta array para dropdown com os sprintNumber // monta array para dropdown com os authors $sql = "SELECT * FROM " . $otd_tablename_users; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $author[$result->id] = $result->user_nicename; } } // monta array para dropdown com os authors $priority = array(0 => __('not set', 'otd'), 1 => __('important', 'otd'), 2 => __('normal', 'otd'), 3 => __('low', 'otd')); $tasktag = array(0 => __('not set', 'otd'), 1 => __('story', 'otd'), 2 => __('epic', 'otd'), 3 => __('theme', 'otd'), 4 => __('project', 'otd'), 5 => __('task', 'otd')); $status = array(0 => __('not set', 'otd'), 1 => __('notready', 'otd'), 2 => __('ready', 'otd'), 3 => __('running', 'otd'), 4 => __('done', 'otd')); ?> <?php if (!empty($otd_message)) { ?> <div id="message" class="updated fade"><p><?php echo $otd_message; ?> </p></div> <?php } ?> <?php if ($_GET['otd_action'] == 'edittd') { $id = $_GET['id']; $todo = otd_get_todo($id); $selection_att = ''; $selection_author = ''; $selection_sprintNumber = ''; foreach ($att as $id => $attendant) { $selected = $todo->att == $id ? 'selected="selected"' : ''; $selection_att .= " <option value=\"{$id}\" {$selected}>{$attendant}</option>\n"; } foreach ($idParent as $idPar => $parent) { $selected = $todo->idParent == $idPar ? 'selected="selected"' : ''; $selection_idParent .= " <option value=\"{$idPar}\" {$selected}>{$parent}</option>\n"; } foreach ($author as $idPo => $productOwner) { $selected = $todo->author == $idPo ? 'selected="selected"' : ''; $selection_author .= " <option value=\"{$idPo}\" {$selected}>{$productOwner}</option>\n"; } foreach ($sprintNumber as $idSn => $sprint) { $selected = $todo->sprintNumber == $idSn ? 'selected="selected"' : ''; $selection_sprintNumber .= " <option value=\"{$idSn}\" {$selected}>{$sprint}</option>\n"; } $selection_tasktag = ''; for ($h = 0; $h < count($tasktag); $h++) { $selected = $todo->tasktag == $h ? 'selected="selected"' : ''; $selection_tasktag .= " <option value=\"{$h}\" {$selected}>{$tasktag[$h]}</option>\n"; } $selection_status = ''; for ($j = 0; $j < count($status); $j++) { $selected = $todo->status == $j ? 'selected="selected"' : ''; $selection_status .= " <option value=\"{$j}\" {$selected}>{$status[$j]}</option>\n"; } $selection = ''; for ($k = 0; $k < count($priority); $k++) { $selected = $todo->priority == $k ? 'selected="selected"' : ''; $selection .= " <option value=\"{$k}\" {$selected}>{$priority[$k]}</option>\n"; } ?> <div class="wrap"> <h2><?php _e('Edit Backlog Entry', 'otd'); ?> </h2> <form method="post"> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr> <th width="33%" scope="row"><?php _e('Id Parent:', 'otd'); ?> </th> <td width="67%"> <select name='otd_idParent' class='postform'> <option value="0">0</option> <?php echo $selection_idParent; ?> </select> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Product Owner:', 'otd'); ?> </th> <td width="67%"> <select name='otd_author' class='postform'> <?php echo $selection_author; ?> </select> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Sprint Number:', 'otd'); ?> </th> <td width="67%"> <select name='otd_sprintNumber' class='postform'> <?php echo $selection_sprintNumber; ?> </select> </td> </tr> <tr> <th scope="row"><?php _e('Points:', 'otd'); ?> </th> <td colspan="5"> <input name="otd_points" type="text" style="width:37%;" value="<?php echo wp_specialchars($todo->points, 1); ?> "> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Scrum Master:', 'otd'); ?> </th> <td width="67%"> <select name='otd_att' class='postform'> <?php echo $selection_att; ?> </select> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('EntryTag:', 'otd'); ?> </th> <td width="67%"> <select name='otd_tasktag' class='postform'> <?php echo $selection_tasktag; ?> </select> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Status:', 'otd'); ?> </th> <td width="67%"> <select name='otd_status' class='postform'> <?php echo $selection_status; ?> </select> </td> </tr> <tr> <th width="33%" scope="row"><?php _e('Priority:', 'otd'); ?> </th> <td width="67%"> <select name='otd_priority' class='postform'> <?php echo $selection; ?> </select> <input type="hidden" name="id" value="<?php echo $todo->id; ?> " /> </td> </tr> <tr> <th scope="row"><?php _e('Description:', 'otd'); ?> </th> <td colspan="5"> <textarea name="otd_todotext" rows="5" cols="50" style="width:97%;"><?php echo wp_specialchars($todo->todotext, 1); ?> </textarea> </td> </tr> <tr> <th scope="row"><?php _e('Created At:', 'otd'); ?> </th> <td colspan="5"> <input name="otd_created_at" type="text" style="width:37%;" value="<?php echo wp_specialchars($todo->created_at, 1); ?> "> </td> </tr> <tr> <th scope="row"><?php _e('Starts:', 'otd'); ?> </th> <td colspan="5"> <input name="otd_starts_in" type="text" style="width:37%;" value="<?php echo wp_specialchars($todo->starts_in, 1); ?> "> </td> </tr> <tr> <th scope="row"><?php _e('End:', 'otd'); ?> </th> <td colspan="5"> <input name="otd_ended_in" type="text" style="width:37%;" value="<?php echo wp_specialchars($todo->ended_in, 1); ?> "> </td> </tr> </table> <p class="submit"> <input type="hidden" name="otd_action" value="updatetd" /> <input type="submit" name="submit" value="<?php _e('Update Todo', 'otd'); ?> " /> </p> </form> <p><a href="<?php echo $otd_location; ?> "><?php _e('« Return to todo list', 'otd'); ?> </a></p> </div> <?php } else { ?> <div class="wrap"> <h2><?php _e('Stories on Sprint', 'otd'); ?> (<a href="#addtd"><?php _e('add new', 'otd'); ?> </a>)</h2> <table class="widefat" id="todo-list" width="100%" cellpadding="3" cellspacing="3"> <thead> <tr> <th><?php _e('Done it!', 'otd'); ?> </th> <th><?php _e('Id', 'otd'); ?> </th> <th><?php _e('Par.', 'otd'); ?> </th> <th><?php _e('Scrum M.', 'otd'); ?> </th> <th><?php _e('Type', 'otd'); ?> </th> <th><?php _e('Start', 'otd'); ?> </th> <th><?php _e('Priority', 'otd'); ?> </th> <th><?php _e('Desc.', 'otd'); ?> </th> <th><?php _e('Status', 'otd'); ?> </th> <th colspan="2"><?php _e('Action', 'otd'); ?> </th> </tr> </thead> <tbody> <?php $sql = "SELECT id, idParent, author, att, tasktag, status, priority, todotext, created_at, starts_in FROM " . $otd_tablename . " WHERE status = 3 ORDER BY priority, todotext"; $results = $wpdb->get_results($sql); global $current_user; get_currentuserinfo(); if ($results) { foreach ($results as $result) { $user = get_userdata($result->author); $idParent_str = $result->idParent; $class = 'alternate' == $class ? '' : 'alternate'; $priority_str = $priority[$result->priority]; $att_str = get_userdata($result->att); $status_str = $status[$result->status]; $tasktag_str = $tasktag[$result->tasktag]; $edit = '<a href="' . $otd_location . '&otd_action=edittd&id=' . $result->id . '" class="edit">' . __('Edit', 'otd') . '</a> ' . '<a href="' . $otd_location . '&otd_action=trashtd&id=' . $result->id . '" class="delete">' . __('Delete', 'otd') . '</a> ' . '<a href="' . $otd_location . '&otd_action=take&id=' . $result->id . '¤t_user_id=' . $current_user->id . '" class="edit">' . __('Take', 'otd') . '</a>'; echo "<tr id=\"otd-{$result->id}\" class=\"{$class}\">\r\n <td width=\"1%\" ><input type=\"checkbox\" id=\"td-{$result->id}\"\r\n onclick=\"window.location='{$otd_location}&otd_action=comptd&status=4&id={$result->id}';\" /></td>\r\n\r\n\t <td>#{$result->id}</td>\r\n\t <td>#{$idParent_str}</td>\r\n <td>{$att_str->user_nicename}</td>\r\n <td>{$tasktag_str}</td>\r\n\t <td>{$result->starts_in}</td>\r\n <td>{$priority_str}</td>\r\n\t <td>{$result->todotext}</td>\r\n <td>{$status_str}</td>\r\n <td>{$edit}</td>\r\n </tr>"; } } else { echo '<tr><td colspan="9">' . __('There is nothing to do..', 'otd') . '</td></tr>'; } ?> </tbody> </table> </div> <div class="wrap"> <h2><?php _e('Product Backlog', 'otd'); ?> (<a href="#addtd"><?php _e('add new', 'otd'); ?> </a>) </h2> <table class="widefat" id="todo-list" width="100%" cellpadding="3" cellspacing="3"> <thead> <tr> <th><?php _e('Sprint it!', 'otd'); ?> </th> <th><?php _e('Id', 'otd'); ?> </th> <th><?php _e('Par.', 'otd'); ?> </th> <th><?php _e('Sprint', 'otd'); ?> </th> <th><?php _e('Pts.', 'otd'); ?> </th> <th><?php _e('P.O', 'otd'); ?> </th> <th><?php _e('Scrum M.', 'otd'); ?> </th> <th><?php _e('Type', 'otd'); ?> </th> <th><?php _e('Created', 'otd'); ?> </th> <th><?php _e('Prior.', 'otd'); ?> </th> <th><?php _e('Desc.', 'otd'); ?> </th> <th><?php _e('Status', 'otd'); ?> </th> <th><?php _e('Action', 'otd'); ?> </th> </tr> </thead> <tbody> <?php global $current_user; get_currentuserinfo(); $sql = "SELECT id, idParent, sprintNumber, points, author, att, tasktag, status, priority, todotext, created_at FROM " . $otd_tablename . " WHERE status <= 2 ORDER BY priority"; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $user = get_userdata($result->author); $class = 'alternate' == $class ? '' : 'alternate'; //$att_str = $att[ $result->att ]; $idParent_str = $result->idParent; $sprintNumber_str = $result->sprintNumber; $points_str = $result->points; $author_str = get_userdata($result->author); $att_str = get_userdata($result->att); $tasktag_str = $tasktag[$result->tasktag]; $prstr = $priority[$result->priority]; $status_str = $status[$result->status]; $edit = '<a href="' . $otd_location . '&otd_action=edittd&id=' . $result->id . '" class="edit">' . __('Edit', 'otd') . '</a> ' . '<a href="' . $otd_location . '&otd_action=trashtd&id=' . $result->id . '" class="delete">' . __('Delete', 'otd') . '</a> ' . '<a href="' . $otd_location . '&otd_action=take&id=' . $result->id . '¤t_user_id=' . $current_user->id . '" class="edit">' . __('Take', 'otd') . '</a>'; echo "<tr id=\"otd-{$result->id}\" class=\"{$class}\">\r\n <td width=\"1%\" ><input type=\"checkbox\" id=\"td-{$result->id}\"\r\n onclick=\"window.location='{$otd_location}&otd_action=incoming&status=3&id={$result->id}';\" /></td>\r\n\r\n\r\n\t <td>#{$result->id}</td>\r\n\r\n\t <td>#{$idParent_str}</td>\r\n\t <td>#{$sprintNumber_str}</td>\r\n\t <td>{$points_str}</td>\r\n\r\n <td>{$author_str->user_nicename}</td>\r\n\r\n <td>{$att_str->user_nicename}</td>\r\n <td>{$tasktag_str}</td>\r\n\t <td>{$result->created_at}</td>\r\n\r\n <td>{$prstr}</td>\r\n\t <td>{$result->todotext}</td>\r\n <td>{$status_str}</td>\r\n <td>{$edit}</td>\r\n </tr>"; } } else { echo '<tr><td colspan="9">' . __('There is nothing to do..', 'otd') . '</td></tr>'; } ?> </tbody> </table> </div> <div class="wrap"> <h2><?php _e('Completed Stories', 'otd'); ?> (<a href="<?php echo $otd_location; ?> &otd_action=purgetd"><?php _e('purge', 'otd'); ?> </a>)</h2> <table class="widefat" id="todo-list" width="100%" cellpadding="3" cellspacing="3"> <thead> <tr> <th><?php _e('Undone it!', 'otd'); ?> </th> <th><?php _e('Id', 'otd'); ?> </th> <th><?php _e('Srum M.', 'otd'); ?> </th> <th><?php _e('Type', 'otd'); ?> </th> <th><?php _e('Solved in', 'otd'); ?> </th> <th><?php _e('Priority', 'otd'); ?> </th> <th><?php _e('Desc.', 'otd'); ?> </th> <th><?php _e('Status', 'otd'); ?> </th> <th colspan="2"><?php _e('Action', 'otd'); ?> </th> </tr> </thead> <tbody> <?php $sql = "SELECT id, author, att, tasktag, status, priority, todotext, starts_in, ended_in FROM " . $otd_tablename . " WHERE status = 4 ORDER BY ended_in"; $results = $wpdb->get_results($sql); function subtract_dates($begin_date, $end_date) { return round((strtotime($end_date) - strtotime($begin_date)) / 86400); } if ($results) { foreach ($results as $result) { $user = get_userdata($result->author); $class = 'alternate' == $class ? '' : 'alternate'; $att_str = get_userdata($result->att); $tasktag_str = $tasktag[$result->tasktag]; $prstr = $priority[$result->priority]; $status_str = $status[$result->status]; $edit = '<a href="' . $otd_location . '&otd_action=trashtd&id=' . $result->id . '" class="delete">' . __('Delete', 'otd') . '</a>'; $date_diff = subtract_dates($result->starts_in, $result->ended_in); $time_to_solve = $date_diff . " days"; echo "<tr id=\"otd-{$result->id}\" class=\"{$class}\">\r\n <td width=\"1%\"><input type=\"checkbox\" id=\"td-{$result->id}\" checked=\"checked\"\r\n onclick=\"window.location = '{$otd_location}&status=3&otd_action=uncomptd&id={$result->id}';\" /></td>\r\n\r\n\r\n \t <td>#{$result->id}</td>\r\n <td>{$att_str->user_nicename}</td>\r\n <td>{$tasktag_str}</td>\r\n\t <td>{$time_to_solve}</td>\r\n\r\n <td>{$prstr}</td>\r\n\t <td>{$result->todotext}</td>\r\n <td>{$status_str}</td>\r\n <td>{$edit}</td>\r\n\r\n\r\n </tr>"; } } else { echo $sql . '<tr><td colspan="4">' . __('There are no completed tasks.', 'otd') . '</td></tr>'; } ?> </tbody> </table> </div> <div class="wrap"> <h2><?php _e('Add Backlog Entry', 'otd'); ?> </h2> <form name="addtd" id="addtd" method="post"> <p> <?php _e('Parent ID:', 'otd'); ?> <br /> <input type="text" name="otd_idParent" class='postform' value="0"> </p> <p> <?php _e('Sprint Number:', 'otd'); ?> <br /> <input type="text" name="otd_sprintNumber" class='postform' value="0"> </p> <p> <?php _e('Points:', 'otd'); ?> <br /> <input type="text" name="otd_points" class='postform' value="0"> </p> <p> <?php _e('Attendant:', 'otd'); ?> <br /> <!--// monta dropdown com os usuários--> <select name='otd_att' class='postform'> <option value='0'><?php _e('select one', 'otd'); ?> </option> <?php $sql = "SELECT * FROM " . $otd_tablename_users; $results = $wpdb->get_results($sql); if ($results) { foreach ($results as $result) { $usridstr = $result->ID; $usrfirstnamestr = $result->user_nicename; echo "<option value='{$usridstr}'>{$usrfirstnamestr}</option>"; } } ?> </select> <!--// monta dropdown com os usuários--> </p> <p> <?php _e('Entry Type:', 'otd'); ?> <br /> <select name='otd_tasktag' class='postform'> <option value='0'><?php _e('select one', 'otd'); ?> </option> <option value='1'><?php _e('story', 'otd'); ?> </option> <option value='2'><?php _e('epic', 'otd'); ?> </option> <option value='3'><?php _e('theme', 'otd'); ?> </option> <option value='4'><?php _e('project', 'otd'); ?> </option> <option value='5'><?php _e('task', 'otd'); ?> </option> </select> </p> <p> <?php _e('Priority:', 'otd'); ?> <br /> <select name='otd_priority' class='postform'> <option value='0'><?php _e('select one', 'otd'); ?> </option> <option value='1'><?php _e('important', 'otd'); ?> </option> <option value='2' selected="selected"><?php _e('normal', 'otd'); ?> </option> <option value='3'><?php _e('low', 'otd'); ?> </option> </select> </p> <p> <?php _e('Status:', 'otd'); ?> <br /> <select name='otd_status' class='postform'> <option value='0'><?php _e('select one', 'otd'); ?> </option> <option value='1' selected="selected"><?php _e('notready', 'otd'); ?> </option> <option value='2'><?php _e('ready', 'otd'); ?> </option> <option value='3'><?php _e('incoming', 'otd'); ?> </option> <option value='4'><?php _e('done', 'otd'); ?> </option> </select> </p> <p> <?php _e('Description:', 'otd'); ?> <br /> <textarea name="otd_description" rows="5" cols="50" style="width: 97%;"></textarea> </p> <p class="submit"> <input type="hidden" name="otd_created_at" value="<?php printf(__('%2$s'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'))); ?> " /> <input name="otd_starts_in" type="hidden" style="width:37%;" value="0000-00-00 00:00:00"> <input name="otd_ended_in" type="hidden" style="width:37%;" value="0000-00-00 00:00:00"> <input type="hidden" name="otd_action" value="addBacklog" /> <input type="submit" name="submit" value="<?php _e('Add Backlog »', 'otd'); ?> " /> </p> </form> </div> <div class="wrap"> <h2><?php _e('Install', 'otd'); ?> </h2> <p><?php printf(__('If you are running Wordpress 1.5 you will need to run %sthis script%s to install the required database table. Maeka. Go! Go! Go!', 'otd'), '<a href="' . $otd_location . '&otd_action=setuptd">', '</a>'); ?> </p> </div> <?php } }