ruạṛ
<?php /** * List of customers * @version 0.9 * @author Robert Urquhart <programmer@activatedesign.co.nz> * @package WEP-CMS */ session_start(); require_once $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/universal.php'; require_once $_SERVER['DOCUMENT_ROOT'].'/admin/scripts-includes/display.php'; $connID = connect_to_db(); /** * define variables to be passed to header function * @var string $current section of site for navigation menu highlighting * @var string $title page title for browser * @var string $keywords meta keywords * @var string $keywords meta description */ $current = 'customers'; $title = 'Administration Panel'; $keywords = ''; $description = ''; /** * buffer then output page */ ob_start(); head($current,$title,$keywords,$description); this_page(); footer(); ob_end_flush(); /** * clean up and exit script */ exit; /** * function to display content specific to this page */ function this_page() { /** * @var int $dpp number of members per page * @var int $start record to start at for paging * @var resource $members mysql recordset containing members * @var int $num_members total number of members for paging */ $dpp = 25; if(!$start = is_numeric_id($_GET['start'],false)) { $start=0; } /** * searching, sorting * @var string $append query variables to pass to paging function * @var bool search flag for which version of the query to use * @var string $where1 where statement append for searching by name * @var string $where2 where statement append for filtering by customer type * @var string $filter collate search options for text output * @var string $order order statement append * @var string $sorted text output for sort option */ $search = false; $append = $where1 = $where2 = $filter = $order = $sorted = ''; if($w = clean_plain_data($_GET['searchname'])) { $search = true; $where1 = "and (full_name LIKE '%$w%' OR email LIKE '%$w%')"; $append .= '&searchname='.urlencode($w); $filter .= "Name: $w; "; } /* if($filter != '') { $filter = 'Results for '.$filter; } if($sorted != '') { $sorted = 'Ordered by '.$sorted; } */ if(!$search) { $customers = mysql_query("select * from users order by $order full_name, email limit $start, $dpp"); } else { $customers = mysql_query("select * from users where 1=1 $where1 $where2 order by full_name, email limit $start, $dpp"); // echo 'search',$where1,$where2; } echo mysql_error(),$order; $all = mysql_query("select * from users where 1=1 $where1 $where2"); $num_customers = mysql_num_rows($all); mysql_free_result($all); ?> <h1>Customers</h1> <form action="customers.php" method="GET" class="search"> <p>Search for <input name="searchname" type="text" maxlength="60" /> <?php /* ?> from <select name="type" id="type"> <option value="">Sellers or buyers</option> <option value="buyers">Buyers</option> <option value="sellers">Sellers</option> </select> sorted by <select name="sort" id="sort"> <option value="">Name</option> <option value="sales">Most sales</option> <option value="purchases">Most purchases</option> <option value="products">Most products</option> </select> <?php // */ ?> <input name="search_go" type="submit" value="Search" /> <span title="Searches customer name, customer email">[?]</span> | <a href="customer-manage.php">Add a customer</a> </p> </form> <?php // */ ?> <?php if($filter): ?> <p><?php echo $filter; ?></p> <?php endif; if($sorted): ?> <p><?php echo $sorted; ?></p> <?php endif; if(!$customers || mysql_num_rows($customers) < 1) { ?> <p class="center">No customers found.</p> <p> </p> <?php return; } //end if !members ?> <table class="control_panel customer"> <thead> <tr> <th class="pad"> </th> <th class="username">Name</th> <th class="left">Delivery Address</th> <th class="username">Contacts</th> <th class="control">Edit</th> <th class="control">Delete</th> <th class="pad"> </th> </tr> </thead> <tfoot></tfoot> <tbody> <?php while($c = mysql_fetch_assoc($customers)) { $id = $c['user_id']; ?> <tr> <td> </td> <td><?php echo ($c['full_name']!='') ? $c['full_name'] : $c['email']; echo ($c['suspended']) ? '<br />[suspended]' : ''; ?></td> <td class="left"><?php echo nl2br($c['address']); ?></td> <td class="left"><?php echo 'E: <a href="mailto:'.$c['email'].'">'.substr($c['email'],0,13).'...</a>'; echo ($c['phone'] != '') ? '<br />P: '.$c['phone'] : ''; ?></td> <td><a href="customer-manage.php?customer=<?php echo $id; ?>">Edit</a></td> <td><a href="processes/process-customer-delete.php?customer=<?php echo $id; ?>" onClick="if(confirm('Delete <?php echo ($c['full_name']!='') ? $c['full_name'] : $c['email']; ?>?')){return true}else{return false}" class="delete"><img src="images/img-del.png" alt="Delete" /></a></td> <td> </td> </tr> <?php } ?> </tbody> </table> <?php echo paging($num_customers,$dpp,$start,$append); ?> <p> </p> <?php } ?>
cải xoăn