ruạṛ
<?php /** * Manage customer * @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); this_page(); footer(); ob_end_flush(); /** * clean up and exit script */ exit; /** * function to display content specific to this page * @global int $cust_id */ function this_page() { /** * new or existing customer? * @var int $cust_id * @var object $customer * @var string $h1 * @var string $action * @var string $button */ if(!$cust_id = is_numeric_id($_GET['customer'],false)) { $customer = new user(); $customer->suspended = 0; if(isset($_SESSION['passback'])) { $customer->load_from_data($_SESSION['passback']); } $button = $h1 = 'Add customer'; $action = 'process-customer-new.php'; $new = true; } else { $customer = new user($cust_id); //print_r($customer); if(!$customer->user_id) { echo '<p class="center">Customer not found.</p>'; return; } $customer->load_orders(); $action = 'process-customer-edit.php'; $button = 'Update customer'; $h1 = $customer->name; } /** * list shipping options * @var string $ship_select * @var resource $shipping */ $ship_select = ''; $shipping = mysql_query("select * from shipping where active='1' order by position, location"); if($shipping && mysql_num_rows($shipping)>0) { $ship_select = '<select name="shipping" id="shipping"> <option value="">Please select shipping area</option> '; while($s = mysql_fetch_assoc($shipping)) { $ship_select .= '<option value="'.$s['ship_id'].'"'; $ship_select .= ($s['ship_id']==$customer->shipping_location) ? ' selected="selected"' : ''; $ship_select .= '>'.$s['location'].'</option> '; // client may want this added back in ($'.number_format($s['shipping_cost'],2).') } $ship_select .=' </select>'; } ?> <h1><?php echo $h1; ?></h1> <?php /* ?> <p>Added <?php echo date('j-m-Y',$date_added); ?></p> <?php // */ ?> <div class="tabs"> <ul> <li><a href="#tab1">Details</a></li> <?php if($customer->user_id): ?> <li><a href="#tab2">Orders</a></li> <?php endif; ?> </ul> <div class="mock_table" id="tab1"> <form method="post" action="processes/<?php echo $action; ?>" name="customer_edit" id="customer_edit" enctype="multipart/form-data" class="edit"> <input name="customer_id" id="customer_id" type="hidden" value="<?php echo $customer->user_id; ?>" /> <label for="customer_name"><span class="right">Customer name:</span><span class="left"><input name="customer_name" id="customer_name" type="text" value="<?php echo $customer->name; ?>" /></span></label> <label for="email"><span class="right">Email:</span><span class="left"><input name="email" id="email" type="text" value="<?php echo $customer->email; ?>" /></span></label> <label for="phone"><span class="right">Phone:</span><span class="left"><input name="phone" id="phone" type="text" value="<?php echo $customer->phone; ?>" /></span></label> <label for="address"> <span class="right">Default address:</span> <span class="left"><textarea name="address" id="address"><?php echo $customer->address; ?></textarea></span> </label> <?php if($ship_select != ''): ?> <label for="shipping"> <span class="right">Default Shipping location:</span> <span class="left"><?php echo $ship_select; ?></span> </label> <?php endif; ?> <?php if(MODULE_CUSTOMER_DISCOUNT): ?> <label for="discount"><span class="right">Discount:</span><span class="left"><input name="discount" id="discount" type="text" size="3" value="<?php echo number_format($customer->discount,2); ?>" />% </span></label> <?php endif; ?> <?php if(MODULE_CUSTOMER_WHOLESALE): ?> <label for="wholesale"><span class="right">Wholesale:</span><span class="left"><input name="wholesale" id="wholesale" type="checkbox" value="1" <?php if($customer->wholesale){ echo 'checked="checked"'; } ?> /></span></label> <?php endif; ?> <?php if(MODULE_CUSTOMER_INTERESTS): ?> <label for="newsletter"><span class="right">Newsletter:</span><span class="left"><input name="newsletter" id="newsletter" type="checkbox" value="1" <?php if($customer->newsletter){ echo 'checked="checked"'; } ?> /></span></label> <br class="clear" /> <p><span class="right"><b>Interests</b></span><span class="left"><?php echo build_interest_checkboxes($customer->interest_list, $customer->interests); ?></span></p> <br class="clear" /> <?php endif; ?> <?php //* ?> <label for="suspended"><span class="right">Suspended:</span><span class="left"><input name="suspended" id="suspended" type="checkbox" value="1" <?php if($customer->suspended){ echo 'checked="checked"'; } ?> /></span></label> <?php // */ ?> <label for="notes"> <span class="right">Internal notes:</span> <span class="left"><textarea name="notes" id="notes"><?php echo $customer->notes; ?></textarea></span> </label> <label for="pwd"> <span class="right">New Password:</span> <span class="left"><input type="text" name="pwd" id="pwd" autocomplete="off" /><br /> (leave blank to retain existing password)</span> </label> <p> </p> <p class="center"> <input name="submit" id="submit" type="submit" value="<?php echo $button; ?>" /> </p> </form> </div> <!-- end #tab1.mock_table --> <?php /** * if existing customer */ if($customer->user_id) { ?> <div class="mock_table<?php if($_GET['tab']=='orders'){ echo ' active'; } ?>" id="tab2"> <h2>Orders</h2> <?php if(empty($customer->orders)) { ?> <p>No orders found</p> <?php } else { /* * display order list */ /** * concatenate order_ids for sql query * @var string $in */ $in = '('; foreach($customer->orders as $order_id) { $in .= "'$order_id', "; } $in = rtrim($in, ', ').')'; /* * rather than loading every order as a cart just to get summary * @todo order object extends cart starts with summary method to load * would probably still do this and load_from_data */ $summary = mysql_query("select * from orders where order_id in $in order by order_ref desc"); ?> <table class="control_panel orders"> <thead> <tr> <th class="ref">Reference</th> <th class="date">Date</th> <th class="desc left">Order description</th> <th class="price right">Order total</th> <th class="control">Paid</th> <th class="control">Manage</th> <th class="control">Delete</th> </tr> </thead> <tfoot> </tfoot> <tbody> <?php while($o = mysql_fetch_assoc($summary)) { $oid = $o['order_id']; echo '<tr> <th class="ref">'.$o['order_ref'].'</th> <td class="date">'.date('d M Y',$o['order_ref']).'</td> <td class="desc left">'.$o['order_description'].'</td> <td class="price right">'.format_price($o['order_total']).'</td> <td><a class="toggle" href="processes/process-switch.php?f=paid&order='.$oid.'">'.onOrOff($o['paid']).'</a></td> <td class="link control"><a href="edit-order.php?order='.$oid.'">Manage</a></td> <td><a href="processes/process-order-delete.php?order='.$oid.'" onClick="if(confirm(\'Delete '.$o['order_ref'].'?\')){return true}else{return false}" class="delete"><img src="images/img-del.png" alt="Delete" /></a></td> </tr> '; } ?> </tbody> </table> <?php }//end if $customer->orders ?> </div> <!-- end #tab1.mock_table --> <?php } // end if user_id ?> </div><!-- end .tabs --> <?php } ?>
cải xoăn