<?php require_once('../Connections/oprmConn.php'); include('check-admin-session.php'); 
 

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 

{

  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;



  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;    

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}



$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}



if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "create_pro_form")) {

  $insertSQL = sprintf("INSERT INTO weby_projects (project_name, project_description, status, created_by, crated_date) VALUES (%s, %s, %s, %s, %s)",

                       GetSQLValueString($_POST['project_name'], "text"),

                       GetSQLValueString($_POST['project_desc'], "text"),

                       GetSQLValueString($_POST['status'], "text"),

                       GetSQLValueString($_POST['created_by'], "int"),

                       GetSQLValueString($_POST['created_date'], "date"));



  mysql_select_db($database_oprmConn, $oprmConn);

  $Result1 = mysql_query($insertSQL, $oprmConn) or die(mysql_error());



  $insertGoTo = "project-list.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

    $insertGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $insertGoTo));

}



$maxRows_getRes = 2;

$pageNum_getRes = 0;

if (isset($_GET['pageNum_getRes'])) {

  $pageNum_getRes = $_GET['pageNum_getRes'];

}

$startRow_getRes = $pageNum_getRes * $maxRows_getRes;



mysql_select_db($database_oprmConn, $oprmConn);

$query_getRes = "SELECT weby_users.user_id, weby_users.email_address, weby_users.caeated_date, weby_profiles.profile_id, weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_pic FROM weby_users, weby_profiles WHERE weby_users.status = 'P' AND weby_profiles.user_id = weby_users.user_id";

$query_limit_getRes = sprintf("%s LIMIT %d, %d", $query_getRes, $startRow_getRes, $maxRows_getRes);

$getRes = mysql_query($query_limit_getRes, $oprmConn) or die(mysql_error());

$row_getRes = mysql_fetch_assoc($getRes);



if (isset($_GET['totalRows_getRes'])) {

  $totalRows_getRes = $_GET['totalRows_getRes'];

} else {

  $all_getRes = mysql_query($query_getRes);

  $totalRows_getRes = mysql_num_rows($all_getRes);

}

$totalPages_getRes = ceil($totalRows_getRes/$maxRows_getRes)-1;



$maxRows_getRes1 = 2;

$pageNum_getRes1 = 0;

if (isset($_GET['pageNum_getRes1'])) {

  $pageNum_getRes1 = $_GET['pageNum_getRes1'];

}

$startRow_getRes1 = $pageNum_getRes1 * $maxRows_getRes1;



mysql_select_db($database_oprmConn, $oprmConn);

$query_getRes1 = "SELECT weby_users.user_id, weby_users.email_address, weby_users.caeated_date, weby_profiles.profile_id, weby_profiles.full_name, weby_profiles.job_title, weby_profiles.skill_set, weby_profiles.profile_pic FROM weby_users, weby_profiles WHERE weby_users.status = 'A' AND weby_users.user_role <> 1 AND weby_profiles.user_id = weby_users.user_id";

$query_limit_getRes1 = sprintf("%s LIMIT %d, %d", $query_getRes1, $startRow_getRes1, $maxRows_getRes1);

$getRes1 = mysql_query($query_limit_getRes1, $oprmConn) or die(mysql_error());

$row_getRes1 = mysql_fetch_assoc($getRes1);



if (isset($_GET['totalRows_getRes1'])) {

  $totalRows_getRes1 = $_GET['totalRows_getRes1'];

} else {

  $all_getRes1 = mysql_query($query_getRes1);

  $totalRows_getRes1 = mysql_num_rows($all_getRes1);

}

$totalPages_getRes1 = ceil($totalRows_getRes1/$maxRows_getRes1)-1;





?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>SS WEB TECHNOLOGIES - Tool Admin Create Project</title>

    <link rel="stylesheet" href="../css/style.css" type="text/css">

    <!-- IE Fix for HTML5 Tags -->

    <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 

	<![endif]-->

    <script type="text/javascript">

<!--

function MM_validateForm() { //v4.0

  if (document.getElementById){

    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;

    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);

      if (val) { nm=val.name; if ((val=val.value)!="") {

        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');

          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';

        } else if (test!='R') { num = parseFloat(val);

          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';

          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');

            min=test.substring(8,p); max=test.substring(p+1);

            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';

      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }

    } if (errors) alert('The following error(s) occurred:\n'+errors);

    document.MM_returnValue = (errors == '');

} }

//-->

    </script>
<style>
.act_prjt { background: #373938;
  color: #fff;}
</style>
    </head>



    <body>



<!-- Wrapper Starts -->

<div class="wrapper">

    <?php  require_once('../includes/header.php'); ?>
    
<?php  require_once('../includes/tools-menu.php'); ?>
  <!-- Content Goes here -->


      <article class="inside_wrapper clear_fix"> 

    

    <!-- Main Content Goes here -->

    <section class="main_content">

          <h1>Create Project / Edit Project</h1>

             <!--<div class="welcome_box">

                <div class="timesheet_type"><div class="welcome_txt arrow">Welcome Admin

            	<ul> <li><a href="index.php">Dashboard</a></li>

                <li><a href="timesheet-all.php">Time sheet</a></li>

                <li><a href="project-list.php">Projects</a></li>

            	<li><a href="resources-list.php">Resources</a></li>

            	<li><a href="profile.php">Profile</a></li>

                <li><a href="leave-list.php">Leave Manager</a></li>

                 <li><a href="reports.php">Records</a></li>

            	<li><a href="logout.php">Logout</a></li>

            	</ul>	

                </div>

                </div>	

             </div> -->

          <!-- Timesheets Goes here -->

          <div class="admin_container">

        <form name="create_pro_form" action="<?php echo $editFormAction; ?>" method="POST" id="create_pro_form">

              <div class="field_item">

            <label for="project_name">Project Name:</label>

            <input type="text" name="project_name" id="project_name" class="required"/>

          </div>

              <div class="field_item">

            <label for="project_desc">Description:</label>

            <textarea rows="8" cols="36" name="project_desc" id="project_desc" class="required"></textarea>

          </div>

              <div class="field_item">

            <label for="status">Status:</label>

            <select name="status" id="status">

                  <option value="A">Active</option>

                  <option value="P">Pending</option>

                  <option value="C">Closed</option>

                </select>

            <input type="hidden" name="created_by" id="created_by" value="<?php echo $_SESSION['user_id']; ?>" />

            <input type="hidden" name="created_date" id="created_date" value="<?php echo date('Y-m-d'); ?>" />

          </div>

              <div class="action_items">

            <input name="submit" type="submit" class="save_btn" onclick="MM_validateForm('project_name','','R','project_desc','','R');return document.MM_returnValue" value="Save">

            <input type="reset" value="Cancel" onClick="location.href='project-list.php'" class="reset_btn">

          </div>

              <div class="clear-fix">&nbsp;</div>

              <input type="hidden" name="MM_insert" value="create_pro_form" />

            </form>

      </div>

        </section>

    

    <!-- Sidebar Goes here -->

    <aside class="sidebar">

          <?php /*?><div class="featured">

        <h2 class="white_txt">PENDING RESOURCES</h2>

        <?php if($totalRows_getRes >0) { do { ?>

        <div class="profile_box"> <a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><img src="/RM/images/<?php if(!empty($row_getRes['profile_pic'])) echo $row_getRes['profile_pic']; else echo "black-img.jpg";?>" width="68" /></a>

              <p class="profile_title"><a href="resources-view.php?user_id=<?php echo $row_getRes['user_id']; ?>"><?php echo $row_getRes['full_name']; ?></a><span class="desig"><br />

                <?php echo $row_getRes['job_title']; ?></span></p>

              <p class="profile_desc"><?php echo $row_getRes['skill_set']; ?></p>

              <div class="clear-fix">&nbsp;</div>

            </div>

        <?php } while ($row_getRes = mysql_fetch_assoc($getRes)); }?>

      </div><?php */?>

          <h2>ACTIVE RESOURCES</h2>

          <form action="resources-list.php" method="post" id="act_resource_search">

        <input name="search" class="search" type="text" size="30" />

        <input name="submit2" class="search-sub" type="submit" value="Search" />

      </form>

          <?php do { ?>

            <div class="profile_box"> <a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>"><img src="/RM/images/<?php if(!empty($row_getRes1['profile_pic'])) echo $row_getRes1['profile_pic']; else echo "black-img.jpg";?>" width="68" /></a>

            <p class="profile_title"><a href="resources-view.php?user_id=<?php echo $row_getRes1['user_id']; ?>"><?php echo $row_getRes1['full_name']; ?></a><span class="desig"><br />

              <?php echo $row_getRes1['job_title']; ?></span></p>

            <p class="profile_desc"><?php echo $row_getRes1['skill_set']; ?></p>

            <div class="clear-fix">&nbsp;</div>

          </div>

            <?php } while ($row_getRes1 = mysql_fetch_assoc($getRes1)); ?>

          <p><a href="resources-list.php">View all &gt;&gt;</a></p>

        </aside>

    <div class="clear-fix">&nbsp;</div>

  </article>

      <div class="clear-fix">&nbsp;</div>

      <!-- Footer Goes here -->

   
     <?php  require_once('../includes/footer.php'); ?>
    </div>

</body>

</html>

<?php

mysql_free_result($getRes);



mysql_free_result($getRes1);

?>