PHP File Manager
Editing File: view.php
<?php if(isset($customer_info->customer_id)): ?> <div id="top-right-buttons"> <a href="/orders/edit/customer/<?php echo $customer_info->customer_id; ?>" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-import"></span> Place customer order</a> <?php if(!$customer_info->is_archived): ?> <a href="/customers/archive/<?php echo $customer_info->customer_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to move this customer to the archives?');"><span class="glyphicon glyphicon-briefcase"></span> Archive customer</a> <?php else: ?> <a href="/customers/unarchive/<?php echo $customer_info->customer_id; ?>" class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-share-alt"></span> Restore customer</a> <?php endif; ?> <a href="/customers/delete/<?php echo $customer_info->customer_id; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure you want to delete this customer?');"><span class="glyphicon glyphicon-trash"></span> Delete customer</a> </div> <?php endif; ?> <div class="row-fluid"> <div class="col-sm-5"> <h3>Customer details</h3> <form action="" class="form-horizontal" method="post"> <?php if(isset($customer_info->retail_customer) && $customer_info->retail_customer): ?> <div class="alert alert-warning"><strong>Notice:</strong> This customer is a retail customer</div> <?php endif; ?> <?php if(isset($customer_info->is_archived) && $customer_info->is_archived): ?> <div class="alert alert-warning"><strong>Notice:</strong> This customer has been archived</div> <?php endif; ?> <?php echo $this->common->getResponseMessage(true); ?> <?php if(isset($customer_info->username)): ?> <div class="form-group"> <label class="col-sm-3 control-label">Username</label> <div class="col-sm-5"> <input type="text" class="form-control input-large" value="<?php echo input_value($customer_info->username); ?>" readonly="readonly" /> </div> </div> <?php endif; ?> <div class="form-group"> <label class="col-sm-3 control-label">First name</label> <div class="col-sm-5"> <input type="text" class="form-control input-large" name="first_name" value="<?php echo input_value(($this->input->post('first_name')) ? $this->input->post('first_name') : ((isset($customer_info->first_name)) ? $customer_info->first_name : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Last name</label> <div class="col-sm-5"> <input type="text" class="form-control input-large" name="last_name" value="<?php echo input_value(($this->input->post('last_name')) ? $this->input->post('last_name') : ((isset($customer_info->last_name)) ? $customer_info->last_name : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Business</label> <div class="col-sm-5"> <input type="text" class="form-control input-large" name="business" value="<?php echo input_value(($this->input->post('business')) ? $this->input->post('business') : ((isset($customer_info->business)) ? $customer_info->business : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Address</label> <div class="col-sm-7"> <input type="text" class="form-control input-xlarge" name="address_1" value="<?php echo input_value(($this->input->post('address_1')) ? $this->input->post('address_1') : ((isset($customer_info->address_1)) ? $customer_info->address_1 : '')); ?>" /> </div> </div> <div class="form-group"> <div class="col-sm-7 col-sm-offset-3"> <input type="text" class="form-control input-xlarge" name="address_2" value="<?php echo input_value(($this->input->post('address_2')) ? $this->input->post('address_2') : ((isset($customer_info->address_2)) ? $customer_info->address_2 : '')); ?>" /> </div> </div> <div class="form-group"> <div class="col-sm-7 col-sm-offset-3"> <input type="text" class="form-control input-xlarge" name="address_3" value="<?php echo input_value(($this->input->post('address_3')) ? $this->input->post('address_3') : ((isset($customer_info->address_3)) ? $customer_info->address_3 : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Town</label> <div class="col-sm-4"> <input type="text" class="form-control input-small" name="town" value="<?php echo input_value(($this->input->post('town')) ? $this->input->post('town') : ((isset($customer_info->town)) ? $customer_info->town : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">County</label> <div class="col-sm-3"> <input type="text" class="form-control input-small" name="county" value="<?php echo input_value(($this->input->post('county')) ? $this->input->post('county') : ((isset($customer_info->county)) ? $customer_info->county : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Postcode</label> <div class="col-sm-2"> <input type="text" class="form-control input-mini postcode-field" name="postcode" value="<?php echo input_value(($this->input->post('postcode')) ? $this->input->post('postcode') : ((isset($customer_info->postcode)) ? $customer_info->postcode : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Country</label> <div class="col-sm-6"> <?php echo countries_dropdown('country', ($this->input->post('country')) ? $this->input->post('country') : ((isset($customer_info->country_code)) ? $customer_info->country_code : ''), 'class="form-control"'); ?> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Email</label> <div class="col-sm-9"> <div class="row"> <div class="col-sm-8"> <input type="email" class="form-control input-large input-lookup" name="email" id="check-used-email" value="<?php echo input_value(($this->input->post('email')) ? $this->input->post('email') : ((isset($customer_info->email)) ? $customer_info->email : '')); ?>" /> </div> </div> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">CC Email</label> <div class="col-sm-9"> <div class="row"> <div class="col-sm-8"> <input type="email" class="form-control input-large" name="cc_email" value="<?php echo input_value(($this->input->post('cc_email')) ? $this->input->post('cc_email') : ((isset($customer_info->cc_email)) ? $customer_info->cc_email : '')); ?>" /> </div> </div> <p class="help-block">This is only used for CC'ing order confirmations and invoices</p> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Phone</label> <div class="col-sm-5"> <input type="tel" class="form-control input-medium" name="phone" value="<?php echo input_value(($this->input->post('phone')) ? $this->input->post('phone') : ((isset($customer_info->phone)) ? $customer_info->phone : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Mobile</label> <div class="col-sm-5"> <input type="tel" class="form-control input-medium" name="mobile" value="<?php echo input_value(($this->input->post('mobile')) ? $this->input->post('mobile') : ((isset($customer_info->mobile)) ? $customer_info->mobile : '')); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Referral</label> <div class="col-sm-5"> <?php echo referrals_dropdown('referral', ($this->input->post('referral')) ? $this->input->post('referral') : ((isset($customer_info->referral)) ? $customer_info->referral : 1), 'class="form-control"'); ?> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">In mailing list?</label> <div class="col-sm-9"> <label class="checkbox-inline"> <input type="checkbox" name="subscribe_mail_list" value="1"<?php echo ($this->input->post('subscribe_mail_list') || (!$this->input->post() && isset($customer_info->subscribed_newsletter) && (bool) $customer_info->subscribed_newsletter)) ? ' checked="checked"' : ''; ?> /> </label> <p class="help-block">Uncheck to remove customer from future newsletters</p> </div> </div> <?php if(false): ?> <h3>Default settings</h3> <div class="form-group"> <label class="col-sm-3 control-label">Delivery time</label> <div class="col-sm-9"> <div class="row"> <div class="col-sm-4"> <select name="preferred_delivery_time" class="form-control input-medium"> <option value="">No preference</option> <?php for($i = 6; $i <= 11; $i++): ?> <?php foreach(array('00', '30') as $j => $minute): ?> <option value="<?php echo $i . ':' . $minute; ?>"<?php echo ((($this->input->post('preferred_delivery_time')) ? $this->input->post('preferred_delivery_time') : (isset($customer_info->preferred_delivery_time) && $customer_info->preferred_delivery_time) ? $customer_info->preferred_delivery_time : '') == ($i . ':' . $minute)) ? ' selected="selected"' : ''; ?>> <?php echo $i . ':' . $minute . ' - ' . (($minute == '30') ? $i + 1 : $i) . ':' . (($minute == '30') ? '00' : ($minute + 30)); ?> </option> <?php endforeach; ?> <?php endfor; ?> </select> </div> </div> </div> </div> <?php if(isset($customer_info->customer_id)): ?> <div class="form-group"> <label class="col-sm-3 control-label">Discount</label> <div class="col-sm-9 form-inline"> <select name="discount_type" class="form-control input-mini" id="discount-type"> <?php foreach(array(DISCOUNT_PERCENTAGE => '%', DISCOUNT_AMOUNT => '£') as $discount_type => $discount_label): ?> <option value="<?php echo $discount_type; ?>"<?php echo ($customer_info->default_discount_type == $discount_type) ? ' selected="selected"' : ''; ?>><?php echo $discount_label; ?></option> <?php endforeach; ?> </select> <input type="text" class="form-control input-mini" name="discount_amount" id="discount-amount" value="<?php echo ($customer_info->default_discount > 0) ? $customer_info->default_discount : ''; ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-3 control-label">Order charges</label> <div class="col-sm-9 form-inline"> <label class="radio-inline"> <input type="radio" name="no_charges" value="0"<?php echo (($this->input->post('no_charges') && $this->input->post('no_charges') === '0') || (isset($customer_info->no_charges) && $customer_info->no_charges == 0)) ? ' checked="checked"' : ''; ?> /> Yes </label> <label class="radio-inline"> <input type="radio" name="no_charges" value="1"<?php echo (($this->input->post('no_charges') && $this->input->post('no_charges') == 1) || (isset($customer_info->no_charges) && $customer_info->no_charges == 1) || ($this->input->post('no_charges') === NULL && !isset($customer_info->no_charges))) ? ' checked="checked"' : ''; ?> /> No </label> <p class="help-block">All default settings will only affect future orders</p> </div> </div> <?php endif; ?> <?php endif; ?> <div class="form-group"> <div class="col-sm-9 col-sm-offset-3"> <div class="btn-group"> <button type="submit" class="btn btn-primary" name="<?php echo (isset($customer_info->customer_id)) ? 'update_customer' : 'save_customer'; ?>" value="1">Save details</button> <?php if(!isset($customer_info->customer_id)): ?> <button type="submit" class="btn btn-default" name="save_customer_do_order" value="1">Save and place order</button> <?php endif; ?> </div> </div> </div> <?php if(false): ?> <h3>Account reset</h3> <div class="form-group"> <label class="col-sm-3 control-label">Password</label> <div class="col-sm-9"> <div class="row"> <div class="col-sm-7"> <div class="input-group"> <input type="password" class="form-control input-medium" name="new_password" value="" /> <div class="input-group-btn"> <button type="button" class="btn btn-primary" id="generate-password"><span class="glyphicon glyphicon-refresh" data-show-password="<?php echo (!isset($customer_info->email)); ?>"></span></button> </div> </div> </div> </div> <p class="help-block"> <?php if(isset($customer_info->email)): ?> The new password will be sent to the user <?php else: ?> The password will need to be given to the user <?php endif; ?> </p> </div> </div> <?php endif; ?> </form> </div> <?php if(isset($customer_info->customer_id)): ?> <div class="col-sm-7"> <?php if(isset($customer_info->trade_request)): ?> <h3>Trade request</h3> <p> <a href="/customers/view/<?php echo $customer_info->customer_id; ?>/request/approve" class="btn btn-success btn-sm" onclick="return confirm('Are you sure you want to approve this trader?');"><span class="glyphicon glyphicon-ok"></span> Approve</a> <a href="/customers/view/<?php echo $customer_info->customer_id; ?>/request/approve/no-confirmation" class="btn btn-success btn-sm" onclick="return confirm('Are you sure you want to approve this trader? No email will be sent to the trader');"><span class="glyphicon glyphicon-ok"></span> Approve (no confirmation)</a> <a href="/customers/view/<?php echo $customer_info->customer_id; ?>/request/reject" class="btn btn-warning btn-sm" onclick="return confirm('Are you sure you want to reject this request? This will also delete the trader');"><span class="glyphicon glyphicon-remove"></span> Reject</a> </p> <?php endif; ?> <h3>Payments</h3> <div class="row payments-grid bottom-border"> <div class="col-sm-3 grid-block"> <span class="number-amount"><?php echo display_money($customer_info->total_inc_vat); ?></span> <span class="amount-label">Total</span> </div> <div class="col-sm-3 grid-block"> <span class="number-amount"><?php echo display_money($customer_info->total_outstanding); ?></span> <span class="amount-label">Outstanding</span> </div> <div class="col-sm-3 grid-block"> <span class="number-amount"><?php echo display_money($customer_info->total_paid); ?></span> <span class="amount-label">Paid</span> </div> <div class="col-sm-3 grid-block"> <span class="number-amount"> <?php echo round((($customer_info->percentage_paid > 0) ? (($customer_info->percentage_paid > 100) ? 100 : $customer_info->percentage_paid) : 0), 2); ?>% <?php echo (($remainder = ($customer_info->percentage_paid - 100)) > 0) ? ' <small>+' . round($remainder, 2) . '%</small>' : ''; ?> </span> <span class="amount-label">Orders allocated</span> </div> </div> <?php if(false): ?><a href="/customers/view/<?php echo $customer_info->customer_id; ?>/payments" class="btn btn-primary btn-sm">View all payments</a><?php endif; ?> <h3>Customer notes</h3> <form action="/customers/view/<?php echo $customer_info->customer_id; ?>/notes" method="post"> <div class="row"> <div class="col-xs-10"> <p><textarea name="note" rows="1" class="form-control" onfocus="this.rows = 6;" onblur="this.rows = 1;" placeholder="Add any notes about this customer here..."></textarea></p> </div> <div class="col-xs-2 no-left-gutter"> <p><button type="submit" class="btn btn-primary btn-sm" name="save_note" value="1">Save note</button></p> </div> </div> <div id="customer-notes"> <?php if(!empty($customer_notes)): ?> <?php foreach($customer_notes as $note_info): ?> <div class="row"> <div class="col-xs-12"> <p class="note-creator"> <strong><?php echo date('jS F Y - H:i', $note_info->date); ?></strong> by <?php echo $note_info->created_by; ?> <span class="pull-right"> <a href="/customers/notes/delete/<?php echo $note_info->note_id; ?>" onclick="return confirm('Are you sure you want to delete this note?');"><img src="/assets/images/icons/delete.png" alt="" /></a> </span> </p> <p class="note-content"><?php echo nl2br($note_info->note); ?></p> </div> </div> <?php endforeach; ?> <p><a href="/customers/view/<?php echo $customer_info->customer_id; ?>/notes" class="btn btn-primary btn-xs">View all notes</a></p> <?php else: ?> <em>There are no customer notes</em> <?php endif; ?> </div> </form> <h3>Placed orders <small>- <?php echo ($customer_total_orders) ? number_format($customer_total_orders) : 'No'; ?> orders - <a href="/orders/customer/<?php echo $customer_info->customer_id; ?>">view all orders</a></small></h3> <table class="table table-striped table-bordered" width="100%"> <thead> <tr> <th width="80">Order ID</th> <th width="150">Order placed</th> <th width="150">Shipping date</th> <th width="43"><abbr title="Dispatched" class="tooltipped">Disp</abbr></th> <th width="43">Paid</th> <th width="30">Items</th> <th width="80">Total Price</th> <th width="80">Discount</th> <th width="60">Actions</th> </tr> </thead> <tbody> <?php if(!empty($customer_orders)): ?> <?php foreach($customer_orders as $order_info): ?> <tr> <td><a href="/orders/view/<?php echo $order_info->order_id; ?>">#<?php echo $order_info->order_number; ?></a></td> <td><?php echo date('jS M Y H:i', $order_info->ordered_date); ?></td> <td><?php echo date('jS M Y', $order_info->delivery_date); ?></td> <td><?php echo ($order_info->has_dispatched) ? 'Yes' : 'No'; ?></td> <td><?php echo ($order_info->order_fully_paid) ? 'Yes' : 'No'; ?></td> <td><?php echo $order_info->total_quantities; ?></td> <td><?php echo display_money($order_info->total_inc_vat); ?></td> <td><?php echo ($order_info->discount > 0) ? (($order_info->discount_type == DISCOUNT_PERCENTAGE) ? number_format($order_info->discount, 2) . '%' : display_money($order_info->discount)) : '<em>None</em>'; ?></td> <td> <a href="/orders/edit/<?php echo $order_info->order_id; ?>"><img src="/assets/images/icons/pencil.png" alt="Edit" /></a> <a href="/orders/invoice/<?php echo $order_info->order_id; ?>"><img src="/assets/images/icons/printer.png" alt="Print" /></a> <a href="/orders/delete/<?php echo $order_info->order_id; ?>" onclick="return confirm('Are you sure you want to delete this order?');"><img src="/assets/images/icons/delete.png" alt="Delete" /></a> </td> </tr> <?php endforeach; ?> <tr> <td colspan="6" class="text-right">Total outstanding</td> <td><strong><?php echo display_money($customer_info->total_outstanding); ?></strong></td> <td colspan="2"></td> </tr> <?php else: ?> <tr> <td colspan="9">No orders</td> </tr> <?php endif; ?> </tbody> </table> <?php echo $this->common->generatePagination('/customers/view/' . $customer_info->customer_id . '/orders/', 5, NULL, $customer_total_orders, 6); ?> <h3>Agreed product prices</h3> <table class="table table-striped table-bordered"> <thead> <tr> <th>Product</th> <th width="80">Price</th> <th width="80">Default</th> <th colspan="2">Diff</th> </tr> </thead> <tbody> <?php if(!empty($fixed_products)): ?> <?php foreach($fixed_products as $product_info): ?> <tr> <td><a href="/products/view/<?php echo $product_info->product_id; ?>"><?php echo $product_info->name; ?></a></td> <td><?php echo display_money($product_info->price); ?></td> <td><?php echo display_money($product_info->default_price); ?></td> <td width="80"><?php echo display_money($product_info->price_difference); ?></td> <td width="16"> <a href="/customers/view/<?php echo $customer_info->customer_id; ?>/agreement/delete/<?php echo $product_info->fix_id; ?>" onclick="return confirm('Are you sure you want to delete this agreement?');"><img src="/assets/images/icons/delete.png" alt="Delete" /></a> </td> </tr> <?php endforeach; ?> <?php else: ?> <tr> <td colspan="5">There are no agreed prices</td> </tr> <?php endif; ?> <tr> <td colspan="5"><a href="/customers/view/<?php echo $customer_info->customer_id; ?>/agreement/edit" class="btn btn-primary btn-xs">Edit agreed prices</a></td> </tr> </tbody> </table> </div> <?php endif; ?> </div> <script type="text/javascript"> $(function() { var emailCheckWait, emailCheckReq = null; $('#check-used-email').on('keyup blur change', function(event) { clearTimeout(emailCheckWait); if(emailCheckReq !== null) { emailCheckReq.abort(); emailCheckReq = null; } if(event.keyCode === 13) { return false; } var self = $(this), emailAddress = $.trim(self.val()); emailCheckWait = setTimeout(function() { emailCheckReq = $.post('', { check_email: emailAddress }, function(response) { self.removeClass('cannot-use can-use is-invalid'); if(emailAddress !== '') { if(response.valid_email) { self.addClass(((response.email_used) ? 'cannot' : 'can') + '-use'); } else { self.addClass('is-invalid'); } } }, 'json'); }, 500); }); $('#generate-password').click(function() { var self = $(this), mustShowPassword = self.data('show-password'), inputField = self.parent().prev(), currentValue = inputField.val(), randomCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.split(''), generatedPassword = ''; for(i = 0; i <= 8; i++) { generatedPassword += randomCharacters[Math.floor(Math.random() * ((randomCharacters.length - 1) - 0))]; randomCharacters.shuffle(); } if(mustShowPassword && inputField.prop('type') !== 'text') { inputField.replaceWith($('<div />').append(inputField.clone()).html().replace('type="password"', 'type="text"')); } self.parent().prev().val(generatedPassword); }) }) </script>
Cancel