<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-04-2008                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet services 	 #
# such as webdesign etc.                                         #
##################################################################
*/

require_once ("config.inc.php");
require_once ("includes/mysql.inc.php");
require_once ("includes/arrays.inc.php");
require_once ("classes/userside.class.php");
require_once ("classes/misc.class.php");
require_once ("includes/Pager/Pager.php");

$message	= "";
$pages		= "";
$count		= 0;
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";
$data		= array();

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objC		= new check();
	$objU		= new userside($objDB);
	$objM		= new misc($objDB);

	if (isset($_POST['DelNow'])) {
           $message	= $objM->delete_stories($_POST);
	}elseif($_REQUEST['mode']=='delete'){
            $data_array['ids']= array($_REQUEST[id]);
            $message	= $objM->delete_stories($data_array);
            
        }
	
	$count		= $objM->get_my_story_count($_SESSION['user_id']);
	$params 	= array(
		'mode'      => 'Sliding',
		'perPage'   => PAGESIZE,
		'urlVar'    => 'page',
		'extraVars' => array(),
		'totalItems' => $count,
		'delta'		=> 7
	);
	$objP 		= & Pager::factory($params);
	if ($count > 0) {
		$data  		= $objM->get_my_story_page($_SESSION['user_id'], ($page-1)*PAGESIZE, PAGESIZE);
		$pages		= $objP->links;
	} else
		$message	= "No success stories found.<br>";		
	$script		= $objU->get_script($message);
	$message	= $objU->remove_script($message);
}
include_once ("title.inc.php");
include_once ("tophtml.inc.php");
?>
<!--<link href="js/facebox.css" media="screen" rel="stylesheet" type="text/css"/>-->
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/facebox.js" type="text/javascript"></script>
<script type="text/javascript" language="javascript">
    jQuery(document).ready(function($) {
      $('a[rel*=facebox]').facebox()
    })
  </script>
  
  

<div class="row">
	<div class="eight columns">
		<div class="search-rslts">
			<div class="row"><div class="inenr-hd"><h2>Success Stories</h2></div></div>
			<div class="row">
				<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
					<div class="full_row" align="right">
						<a href="manage_my_story.php?page=<?php echo $page ?>" class="add-story01">Add New Success Story</a>
					</div>
					
					<?php
				  	if (isset($message) && trim($message) != '') {
					  ?>
					<div class="full_row">
						<div class="maintext1 warning"><?php echo $message; ?></div>
					</div>
					<?php
						}//end if
						if (!empty($data)) {
						foreach ($data as $key => $value) {
					?>
																  
					<div class="full_row  border-bottom-new maintext1">
							<div class="two columns">
								<a href="<?php echo $value['vPicURL'] <> "" ? $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . $value['vPicURL'] : ($objM->vGender == "Male" ? $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . "nophotosuccess.gif" : $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . "nophotosuccess1.gif") ?>" class="story_img" rel="facebox"><img src="<?php echo $value['vPicURL'] <> "" ? $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . "sthumb_" . $value['vPicURL'] : ($value['vGender'] == "Male" ? $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . "nophotosuccess.gif" : $siteSettings['site_normal_url'] . STORY_IMAGE_URL . '/' . "nophotosuccess1.gif") ?>" width="100" height="100" border="0" style="padding: 0px 0px 24px 0px; "></a>
							</div>
							<div class="eight columns ">
								<div class="full_row"><b><?php echo htmlspecialchars(stripslashes($value['vStory_Title'])) ?></b></div>
								<div class="full_row"><?php echo nl2br(htmlspecialchars(stripslashes($value['tStory']))) ?></div>
							</div>
							<div class="two columns" align="right">
								<div class="full_row" style="padding:0 0 10px 0; ">Posted On<br/><?php echo date('m/d/Y', strtotime($value['dDay'])) ?></div>
								<div class="full_row">
									<a href="manage_my_story.php?id=<?php echo $value['nStory_Id'] ?>&page=<?php echo $page ?>" class="signupbutton01">Edit</a>|<a href="my_stories.php?id=<?php echo $value['nStory_Id'] ?>&page=<?php echo $page ?>&mode=delete" class="signupbutton01">Delete </a>
									<input type="checkbox" name="ids[]" value="<?php echo $value['nStory_Id'] ?>">
								</div>
							</div>
							<div class="clear"></div>
					</div>
					 <?php
							  }//end foreach
						  }//end if
						  ?>
					  
							  
					  <?php
					  if (!empty($data)) {
						  ?>
						  
					<div class="full_row">
						<div class="three columns">&nbsp;</div>
						<div class="nine columns" align="right" style="padding:10px 0 0 0; ">
							<input name="DelNow" type="submit" class="button_stylenew" id="DelNow" value="Delete Stories"><input type="hidden" name="page" value="<?php echo $page ?>">
						</div>
					</div>
					
					<?php }//end if ?>
                </form>
					<div class="clear"></div>
					<?php
					if ($pages <> "") {
					  ?>
					
					<div class="full_row">
						<div class="row">
							<?php echo $pages ?>
						</div>
					</div>
					<?php } ?>
				</div>			
		</div>
	</div>
	<div class="four columns right search_result_R"><?php include_once ("left.inc.php"); ?></div>
</div>

  <?php include_once('bottomhtml.inc.php'); ?>
    