Location: PHPKode > projects > WH Community > wh_community/todo.php
<?php require('layout/header.php'); ?>

    <script type="text/javascript">
    	function showSuccessMessage() {
    	showNotification({
    	type : "success",
    	message: "<?php echo $lang['success_todo']; ?>"
    	});    
        }                                
    
    function showErrorMessage() {
    	showNotification({
    	type : "error",
    	message: "<?php echo $lang['couldnot_todo']; ?>"
    	});    
        }                                
    </script>

<div id="content_wrapper">
    <div class="content"><?php

        if(!isset($_SESSION['signed_in'])) {
        
		echo '<p class="false">' . $lang['just_for_users'] . '!</p>
              <p>' . $lang['you_need_to'] . ' <a href="signin.php">' . $lang['signin_s'] . '</a>.
              - ' . $lang['not_yet'] . ' <a href="signup.php">' . $lang['registered'] . '</a>?</p>';

		}else{

		echo '<table align="center" class="usertable">
		<tr>
			<td align="center"><ul class="usermenu">
				<li><a href="myprofile.php">' . $lang['my_profile'] . '</a></li>
				<li><a href="guestbook.php">' . $lang['guestbook'] . '</a></li>
				<li><a href="messagebox.php">' . $lang['messagebox'] . '</a></li>
				<li><a href="password.php">' . $lang['password'] . '</a></li>
				<li><a href="inbox.php">' . $lang['inbox'] . '</a></li>
				<li><a href="outbox.php">' . $lang['outbox'] . '</a></li>
				<li><a href="create_pm.php">' . $lang['m_newpm'] . '</a></li>
				<li><a href="mypostings.php">' . $lang['my_posts'] . '</a></li>
				<li><a href="infos.php">' . $lang['informations'] . '</a></li>
				<li><a href="todo.php">' . $lang['m_todo'] . '</a></li>
				<li><a href="news.php">' . $lang['news'] . '</a></li>
			</ul></td>
		</tr>
		<tr>
			<td><h1>' . $lang['my_todo_list'] . '</h1></td>
		</tr>';
			
		$goto = 'todo.php';
		$autoforward = 2;
					
		echo '<form action="todo.php" method="post" name="todo">
    		  <tr><td><p><label for="inputField"><strong>' . $lang['add_new_task'] . '...</strong></label></p></td></tr>
    		  <tr><td height="50"><input name="task" type="text" size="40" maxlength="40"  class="fields"></td></tr>
    		  <tr><td height="50"><select name="priority" class="fields" title="' . $lang['priority'] . '">
    		  <option>1</option>
    		  <option>2</option>
    		  <option selected="selected">3</option>
    		  <option>4</option>
    		  <option>5</option>
    		  </select><br><small><strong>' . $lang['priority'] . '</strong></small></td></tr>
    		  <tr><td height="50"><input type="submit" name="newtodo" class="button" value="' . $lang['add_task'] . '"></td></tr>
    		  </form>';
		
		echo '<tr><td><br><div id="blog_line">&nbsp;</div><br>';
		
		if(isset($_REQUEST['newtodo'])) {
		
		$newtask = mysql_query("INSERT INTO todo (`do_id`,`do_id2`,`task`,`priority`,`success`) VALUES (NULL,'" . (int)$_SESSION['user_id'] . "','" . $_REQUEST['task'] . "','" . $_REQUEST['priority'] . "','0')") OR die(mysql_error());
		
			if($newtask == TRUE) {
			echo '<p class="right">' . $lang['success_todo'] . '</p>
			      <meta http-equiv="refresh" content="' . $autoforward . '; URL=' . $goto . '">';
			      }
		    }
		
		$checktask = mysql_query("SELECT * FROM todo WHERE `do_id2`='" . (int)$_SESSION['user_id'] . "' AND `success`='0' ORDER BY priority DESC") OR die(mysql_error());
		
        if(!$checktask) {
        
        echo '<span class="false">' . $lang['no_tasks'] . '.</span><br>';
        
            }else{
            
            if(intval(mysql_num_rows($checktask)) == 0) {
            
            echo '<span class="false">' . $lang['no_tasks'] . '.</span><br>';
        
        }else{
		
        while($row = mysql_fetch_array($checktask)) {
		
    		echo '<table width="100%" cellpadding="5" class="pmtable">
        		  <tr>
        		  <td colspan="3"><span class="false"><strong>' . $lang['pending_task'] . '</strong></span></td>
        		  </tr>
        		  <tr>
        		  <td width="11"><a href="todo.php?success=1&do_id=' . (int)$row['do_id'] . '"><img src="images/done.png" border="0" title="' . $lang['done'] . '"></a></td>
        		  <td width="11"><a href="todo.php?del=true&do_id=' . (int)$row['do_id'] . '"><img src="images/delete.png" border="0" title="' . $lang['delete'] . '"></a></td>
        		  <td><strong>' . htmlentities($row['task'], ENT_QUOTES) . '</strong></td>
        		  </tr></table>';
                  }
        }}
					
		$checktask = mysql_query("SELECT * FROM todo WHERE `do_id2`='" . (int)$_SESSION['user_id'] . "' AND `success`='1' ORDER BY priority DESC") OR die(mysql_error());
		
        while($row = mysql_fetch_array($checktask)) {
		
    		echo '<table width="100%" cellpadding="5" class="pmtable">
        		  <tr>
        		  <td colspan="2"><span class="right"><strong>' . $lang['done_task'] . '</strong></span></td>
        		  </tr>
        		  <tr>
        		  <td width="11"><a href="todo.php?del=true&do_id=' . (int)$row['do_id'] . '"><img src="images/delete.png" border="0" title="' . $lang['delete'] . '"></a></td>
        		  <td><strong>' . htmlentities($row['task'], ENT_QUOTES) . '</strong></td>
        		  </tr></table>';
        		  }
					
		if(isset($_REQUEST['success'])) {
		
		$uptask = mysql_query("UPDATE todo SET `success` = '1' WHERE `do_id` = '" . (int)$_REQUEST['do_id'] . "' AND `do_id2`='" . (int)$_SESSION['user_id'] . "'") OR die(mysql_error());
		
			if($uptask == TRUE) {
			echo '<p class="right">' . $lang['completed_task'] . '</p>
			      <meta http-equiv="refresh" content="' . $autoforward . '; URL=' . $goto . '">';
			      }
		    }
		
		if(isset($_REQUEST['del'])) {
		
		$deltask = mysql_query("DELETE FROM todo WHERE `do_id` = '" . (int)$_REQUEST['do_id'] . "' AND `do_id2`='" . (int)$_SESSION['user_id'] . "'") OR die(mysql_error());
		
			if($deltask == TRUE) {
			echo '<p class="right">' . $lang['deleted_task'] . '</p>
			      <meta http-equiv="refresh" content="' . $autoforward . '; URL=' . $goto . '">';
			      }
		    }
		
		echo '<br></td></tr>';
		}
		
		echo '</table>';
		
		echo '<div class="spacer_div">&nbsp;</div>';

		?>
    </div>
</div>

<div id="infobox_wrapper">
    <div class="infobox">
        <?php include('layout/infobox.php'); ?>
    </div>
</div>

<?php require('layout/footer.php'); ?>
Return current item: WH Community