PHP File Manager
Editing File: settings.php
<ul class="nav nav-tabs" role="tablist" id="settings-tabs"> <li class="active"><a href="#common" role="tab" data-toggle="tab">Common</a></li> <?php /*<li><a href="#shop" role="tab" data-toggle="tab">Shop settings</a></li>*/ ?> <li><a href="#address" role="tab" data-toggle="tab">Address & contact information</a></li> <?php /*<li><a href="#locations" role="tab" data-toggle="tab">Delivery locations</a></li> <li><a href="#delivery" role="tab" data-toggle="tab">Shipping types</a></li> <li><a href="#rates" role="tab" data-toggle="tab">Postcode rates</a></li> <li><a href="#stocks" role="tab" data-toggle="tab">Stock levels</a></li> <li><a href="#dozen" role="tab" data-toggle="tab">Doorstep Dozen</a></li> <li><a href="#apis" role="tab" data-toggle="tab">APIs</a></li>*/ ?> </ul> <div class="tab-content" id="common-settings"> <div class="tab-pane active" id="common"> <form action="" class="form-horizontal" method="post"> <?php foreach($settings as $setting_name => $setting_info): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $setting_info[0]; ?></label> <div class="col-sm-10"> <div class="row"> <div class="<?php echo (isset($setting_info[3])) ? $setting_info[3] : 'col-sm-2'; ?>"> <div class="input-group"> <?php if(isset($setting_info[2])): ?> <div class="input-group-addon"><?php echo $setting_info[2]; ?></div> <?php endif; ?> <input type="text" name="<?php echo $setting_name; ?>" value="<?php echo input_value($this->config->item($setting_name)); ?>" class="form-control <?php echo (isset($setting_info[3]) && $setting_info[3] !== NULL) ? ' ' . $setting_info[3] : ''; ?>" /> </div> </div> </div> <?php if(isset($setting_info[1]) || $setting_info[1] !== NULL): ?> <p class="help-block"><?php echo $setting_info[1]; ?></p> <?php endif; ?> </div> </div> <?php endforeach; ?> <div class="form-group"> <div class="col-sm-10 col-sm-offset-1"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Update settings</button> </div> </div> </form> </div> <?php /*<div class="tab-pane" id="shop"> <form action="" class="form-horizontal" method="post"> <ul class="nav nav-pills" role="tablist" id="shop-tabs"> <li class="active"><a href="#shop-common" role="tab" data-toggle="tab">Common</a></li> <li><a href="#shop-delivery" role="tab" data-toggle="tab">Delivery</a></li> <li><a href="#shop-paypal" role="tab" data-toggle="tab">PayPal</a></li> </ul> <div class="tab-content"> <div class="tab-pane active" id="shop-common"> <?php foreach($shop_settings['common'] as $setting_name => $setting_info): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $setting_info[0]; ?></label> <div class="col-sm-10"> <div class="row"> <div class="<?php echo (isset($setting_info[3])) ? $setting_info[3] : 'col-sm-4'; ?>"> <div class="input-group"> <?php if(isset($setting_info[2])): ?> <div class="input-group-addon"><?php echo $setting_info[2]; ?></div> <?php endif; ?> <input type="text" name="<?php echo $setting_name; ?>" value="<?php echo input_value($this->config->item($setting_name)); ?>" class="form-control <?php echo (isset($setting_info[3]) && $setting_info[3] !== NULL) ? ' ' . $setting_info[3] : ''; ?>" /> </div> </div> </div> <?php if(isset($setting_info[1])): ?> <p class="help-block"><?php echo $setting_info[1]; ?></p> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> <div class="tab-pane" id="shop-delivery"> <?php foreach($shop_settings['delivery'] as $setting_name => $setting_info): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $setting_info[0]; ?></label> <div class="col-sm-10"> <div class="row"> <div class="<?php echo (isset($setting_info[3])) ? $setting_info[3] : 'col-sm-4'; ?>"> <div class="input-group"> <?php if(isset($setting_info[2])): ?> <div class="input-group-addon"><?php echo $setting_info[2]; ?></div> <?php endif; ?> <input type="text" name="<?php echo $setting_name; ?>" value="<?php echo input_value($this->config->item($setting_name)); ?>" class="form-control <?php echo (isset($setting_info[3]) && $setting_info[3] !== NULL) ? ' ' . $setting_info[3] : ''; ?>" /> </div> </div> </div> <?php if(isset($setting_info[1])): ?> <p class="help-block"><?php echo $setting_info[1]; ?></p> <?php endif; ?> </div> </div> <?php endforeach; ?> <div class="form-group"> <label class="col-sm-1 control-label">Delivery days</label> <div class="col-sm-10"> <?php foreach(array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday') as $delivery_day): ?> <label class="radio-inline"> <input type="radio" name="delivery_<?php echo $delivery_day; ?>" value="1"<?php echo ((bool) $this->config->item('delivery_' . $delivery_day)) ? ' checked="checked"' : ''; ?> /> Yes </label> <label class="radio-inline"> <input type="radio" name="delivery_<?php echo $delivery_day; ?>" value="0"<?php echo ((bool) $this->config->item('delivery_' . $delivery_day)) ? '' : ' checked="checked"'; ?> /> No </label> <label class="radio-inline"> <strong><?php echo ucfirst($delivery_day); ?></strong> </label><br /> <?php endforeach; ?> </div> </div> </div> <div class="tab-pane" id="shop-paypal"> <?php foreach($shop_settings['paypal'] as $setting_name => $setting_info): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $setting_info[0]; ?></label> <div class="col-sm-10"> <div class="row"> <div class="<?php echo (isset($setting_info[3])) ? $setting_info[3] : 'col-sm-4'; ?>"> <div class="input-group"> <?php if(isset($setting_info[2])): ?> <div class="input-group-addon"><?php echo $setting_info[2]; ?></div> <?php endif; ?> <input type="text" name="<?php echo $setting_name; ?>" value="<?php echo input_value($this->config->item($setting_name)); ?>" class="form-control <?php echo (isset($setting_info[3]) && $setting_info[3] !== NULL) ? ' ' . $setting_info[3] : ''; ?>" /> </div> </div> </div> <?php if(isset($setting_info[1])): ?> <p class="help-block"><?php echo $setting_info[1]; ?></p> <?php endif; ?> </div> </div> <?php endforeach; ?> </div> <div class="form-group"> <div class="col-sm-10 col-sm-offset-1"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Update settings</button> </div> </div> </div> </form> </div>*/ ?> <div class="tab-pane" id="address"> <form action="" class="form-horizontal" method="post"> <?php /*<div class="alert alert-info alert-icon"> <div class="icon"><span class="icon-helper"><img src="/assets/images/icons/information.png" alt="" /></span></div> Please use your main address & contact details if you have more than one location </div>*/ ?> <?php foreach(array('company_name' => 'Name', 'company_address_1' => 'Address', 'company_address_2' => NULL, 'company_address_3' => NULL, 'company_town' => 'Town', 'company_county' => 'County', 'company_postcode' => 'Postcode', 'company_phone' => 'Phone', 'company_phone_alt' => 'Alt Phone', 'company_email' => 'Email', 'facebook_link' => 'Facebook link', 'twitter_link' => 'Twitter link') as $key_name => $label_name): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $label_name; ?></label> <div class="col-sm-4"> <input type="text" name="<?php echo $key_name; ?>" class="form-control" value="<?php echo input_value($this->config->item($key_name)); ?>" /> </div> </div> <?php endforeach; ?> <div class="form-group"> <label class="col-sm-1 control-label">Email enquiries</label> <div class="col-sm-11"> <?php foreach(array('Yes' => 1, 'No' => 0) as $label_type => $label_bool): ?> <label class="radio-inline"> <input type="radio" name="send_email_enquiries" value="<?php echo $label_bool; ?>"<?php echo ($this->config->item('send_email_enquiries') == $label_bool) ? ' checked="checked"' : ''; ?> /> <?php echo $label_type; ?> </label> <?php endforeach; ?> <p class="help-block">If enabled, enquiries via the contact form will be forwarded via email</p> </div> </div> <?php /*foreach(array('contact_enquiry_email' => 'Send enquiries to', 'trades_request_email' => 'Send trades to') as $enquiry_key => $label_name): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $label_name; ?></label> <div class="col-sm-4"> <input type="email" name="<?php echo $enquiry_key; ?>" class="form-control" value="<?php echo input_value($this->config->item($enquiry_key)); ?>" /> </div> </div> <?php endforeach;*/ ?> <div class="form-group"> <label class="col-sm-1 control-label">Force captcha?</label> <div class="col-sm-11"> <?php foreach(array('Yes' => 1, 'No' => 0) as $label_type => $label_bool): ?> <label class="radio-inline"> <input type="radio" name="contact_captcha" value="<?php echo $label_bool; ?>"<?php echo ($this->config->item('contact_captcha') == $label_bool) ? ' checked="checked"' : ''; ?> /> <?php echo $label_type; ?> </label> <?php endforeach; ?> <p class="help-block">If enabled, the contact form will include a security captcha to stop spam</p> </div> </div> <?php foreach(array('recaptcha_site_key' => 'reCAPTCHA site key', 'recaptcha_secret_key' => 'reCAPTCHA secret key') as $config_key => $label_name): ?> <div class="form-group"> <label class="col-sm-1 control-label"><?php echo $label_name; ?></label> <div class="col-sm-4"> <input type="text" name="<?php echo $config_key; ?>" class="form-control" value="<?php echo input_value($this->config->item($config_key)); ?>" /> </div> </div> <?php endforeach; ?> <div class="form-group"> <div class="col-sm-10 col-sm-offset-1"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Update details</button> </div> </div> </form> </div> <?php /*<div class="tab-pane" id="locations"> <form action="" method="post"> <table class="table table-striped table-bordered"> <thead> <tr> <th>Address 1</th> <th>Address 2</th> <th>Address 3</th> <th>Town</th> <th>County</th> <th>Postcode</th> <th>Country</th> <th>Phone</th> <th>Email</th> <th colspan="2"><abbr title="Free delivery range (in miles) - leave blank to disable" class="tooltipped">FDR</abbr></th> </tr> </thead> <tbody> <?php foreach($origin_locations as $location_info): ?> <tr> <?php foreach(array('address_1', 'address_2', 'address_3', 'town', 'county', 'postcode') as $address_component_key): ?> <td><input type="text" name="<?php echo $address_component_key; ?>[]" value="<?php echo ($location_info === -1) ? '' : ((isset($location_info->$address_component_key)) ? $location_info->$address_component_key : ''); ?>" class="form-control input-sm"<?php echo (in_array($address_component_key, array('address_1', 'postcode'))) ? ' required="required"' : ''; ?> /></td> <?php endforeach; ?> <td> <?php echo countries_dropdown('country[]', ($location_info === -1) ? '' : ((isset($location_info->country)) ? $location_info->country : ''), 'class="form-control input-sm"'); ?> </td> <?php foreach(array('phone', 'email') as $contact_key): ?> <td><input type="text" name="<?php echo $contact_key; ?>[]" value="<?php echo ($location_info === -1) ? '' : ((isset($location_info->$contact_key)) ? $location_info->$contact_key : ''); ?>" class="form-control input-sm" /></td> <?php endforeach; ?> <td width="110"><input type="number" name="free_delivery_range[]" min="0" step="0.01" class="form-control input-sm" placeholder="in miles..." value="<?php echo ($location_info === -1) ? '' : ((isset($location_info->free_delivery_range)) ? $location_info->free_delivery_range : ''); ?>" /></td> <td> <input type="hidden" name="existing_location[]" value="<?php echo ($location_info !== -1 && isset($location_info->location_id)) ? $location_info->location_id : ''; ?>" /> <button type="button" class="btn btn-danger btn-sm remove-location">Delete</button> </td> </tr> <?php endforeach; ?> <tr> <td colspan="11"> <button type="button" class="btn btn-primary btn-sm" id="add-another-location"><span class="glyphicon glyphicon-plus"></span> Add another</button> <button type="submit" class="btn btn-primary btn-sm" name="save_locations" value="1">Save</button> </td> </tr> </tbody> </table> </form> </div> <div class="tab-pane" id="delivery"> <form action="" method="post"> <div class="row"> <div class="col-sm-8"> <table class="table table-striped table-bordered"> <thead> <tr> <th>Name</th> <th width="130">Cost</th> <th width="130">Maximum days</th> <th width="140">Multiplied by item?</th> <th width="130">Priority</th> <th width="60">Actions</th> </tr> </thead> <tbody> <?php foreach($delivery_types as $delivery_info): $type_index = (isset($delivery_info->delivery_id)) ? $delivery_info->delivery_id : NULL; ?> <tr> <td valign="middle"> <?php echo (isset($delivery_info->label)) ? input_value($delivery_info->label) : ''; ?> <input type="<?php echo (isset($delivery_info->label)) ? 'hidden' : 'text'; ?>" name="name[]" value="<?php echo ($delivery_info !== -1) ? input_value($delivery_info->label) : ''; ?>" class="form-control" /> </td> <td valign="middle"><input type="number" name="cost[]" step="0.01" min="0" value="<?php echo ($delivery_info !== -1) ? (($delivery_info->costs > 0) ? $delivery_info->costs : '') : ''; ?>" class="form-control" placeholder="0.00" /></td> <td valign="middle"><input type="number" name="days[]" step="1" min="1" value="<?php echo ($delivery_info !== -1) ? $delivery_info->delivery_days : ''; ?>" class="form-control" placeholder="1" /></td> <td valign="middle"> <select name="multiplied[]" class="form-control"> <?php foreach(array(0 => 'No', 1 => 'Yes') as $opt_bool => $opt_label): ?> <option value="<?php echo $opt_bool; ?>"<?php echo ($delivery_info !== -1 && $delivery_info->per_item == $opt_bool) ? ' selected="selected"' : ''; ?>><?php echo $opt_label; ?></option> <?php endforeach; ?> </select> </td> <td valign="middle"> <select name="priority[]" class="form-control"> <?php for($i = 1; $i <= 3; $i++): ?> <option value="<?php echo $i; ?>"<?php echo ($delivery_info !== -1 && $delivery_info->priority == $i) ? ' selected="selected"' : ''; ?>><?php if($i === 1): ?>None<?php else: for($j = 1; $j < $i; $j++): ?>*<?php endfor; endif; ?></option> <?php endfor; ?> </select> </td> <td valign="middle"> <input type="hidden" name="existing_delivery[]" value="<?php echo $type_index; ?>" /> <?php if($type_index != 1 && $delivery_info !== -1): ?> <button type="button" class="btn btn-danger btn-sm remove-delivery-type">Delete</button> <?php endif; ?> </td> </tr> <?php endforeach; ?> </tbody> </table> <button type="submit" name="save_delivery_types" value="1" class="btn btn-primary">Save</button> </div> </div> </form> </div> <div class="tab-pane" id="rates"> <div class="alert alert-warning alert-icon"> <div class="icon"><span class="icon-helper"><img src="/assets/images/icons/information.png" alt="" /></span></div> Rates are prioritised by the matching postcode from right to left. For example if there is a <strong>CT188</strong> rate, it will be used instead of <strong>CT</strong>. <br />If none is matched, then will be prompted about destinations outside the UK </div> <p> <button type="button" class="btn btn-primary" id="add-postcode-rate"><span class="glyphicon glyphicon-plus"></span> Add postcode</button> </p> <table class="table table-striped table-bordered" id="postcode-rates-table"> <thead> <tr> <th width="60">Postcode</th> <th>Delivery type</th> <th width="100">Cost</th> <th width="60">Actions</th> </tr> </thead> <tbody> <?php foreach($postcode_rates as $rate_info): ?> <tr> <td><?php echo $rate_info->postcode; ?></td> <td><?php echo $rate_info->delivery_label; ?></td> <td><?php echo display_money($rate_info->costs); ?></td> <td> <a href="#" class="edit-rate" data-rate-id="<?php echo $rate_info->rate_id; ?>"><img src="/assets/images/icons/pencil.png" alt="Edit" /></a> <a href="#" class="delete-rate" data-rate-id="<?php echo $rate_info->rate_id; ?>"><img src="/assets/images/icons/delete.png" alt="Delete" /></a> </td> </tr> <?php endforeach; ?> </tbody> </table> </div> <div class="tab-pane" id="stocks"> <form action="" class="form-horizontal" method="post"> <div class="col-md-8"> <div class="alert alert-warning alert-icon"> <div class="icon"><span class="icon-helper"><img src="/assets/images/icons/information.png" alt="" /></span></div> The number will categorise each stock product from its current stock count respectively </div> <div class="form-group"> <label class="col-sm-2 control-label">High <img src="/assets/images/icons/flag_green.png" alt="" /></label> <div class="col-sm-2"> <input type="number" step="1" min="1" name="<?php echo STOCK_LEVEL_HIGH; ?>" class="form-control" value="<?php echo $this->config->item(STOCK_LEVEL_HIGH); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">Moderate <img src="/assets/images/icons/flag_yellow.png" alt="" /></label> <div class="col-sm-2"> <input type="number" step="1" min="1" name="<?php echo STOCK_LEVEL_MODERATE; ?>" class="form-control" value="<?php echo $this->config->item(STOCK_LEVEL_MODERATE); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">Low <img src="/assets/images/icons/flag_orange.png" alt="" /></label> <div class="col-sm-2"> <input type="number" step="1" min="1" name="<?php echo STOCK_LEVEL_LOW; ?>" class="form-control" value="<?php echo $this->config->item(STOCK_LEVEL_LOW); ?>" /> </div> </div> <div class="form-group"> <label class="col-sm-2 control-label">Auto update stock</label> <div class="col-sm-10"> <?php foreach(array('MANUALLY' => 'Disabled (manually update, not recommended)', 'DISPATCH' => 'After order is dispatched', 'PAYMENT' => 'After payment is received (recommended)') as $update_from_key => $update_label): ?> <label class="radio-inline"> <input type="radio" name="stock_update_after" value="<?php echo $update_from_key; ?>"<?php echo ($this->config->item('stock_update_after') == $update_from_key) ? ' checked="checked"' : ''; ?> /> <?php echo $update_label; ?> </label><br /> <?php endforeach; ?> <p class="help-block">The stock levels will be updated from an order after the above selected action</p> </div> </div> <div class="form-group"> <div class="col-sm-10 col-sm-offset-2"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Update levels</button> </div> </div> </div> <div class="clearfix"></div> </form> </div> <div class="tab-pane" id="dozen"> <form action="" class="form-horizontal" method="post"> <div class="col-md-7"> <?php foreach(array('gold', 'silver', 'bronze') as $colour_type): ?> <h3><?php echo ucfirst($colour_type); ?></h3> <?php foreach(array('month' => 'Monthly', 'bi_month' => 'Bi-monthly', 'quarter' => 'Quarterly') as $interval_type => $interval_label): ?> <div class="form-group"> <label class="col-sm-2 control-label"><?php echo $interval_label; ?></label> <div class="col-sm-2"> <div class="input-group"> <div class="input-group-addon">£</div> <input type="number" name="<?php echo 'dozen_club_' . $colour_type . '_' . $interval_type; ?>" min="0" step="0.01" class="form-control" value="<?php echo number_format($this->config->item('dozen_club_' . $colour_type . '_' . $interval_type), 2, '.', ''); ?>" /> </div> </div> </div> <?php endforeach; ?> <?php endforeach; ?> <div class="form-group"> <div class="col-sm-10 col-sm-offset-2"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Save details</button> </div> </div> </div> <div class="clearfix"></div> </form> </div> <div class="tab-pane" id="apis"> <form action="" class="form-horizontal" method="post"> <div class="col-md-8"> <ul class="nav nav-pills" role="tablist" id="shop-tabs"> <li class="active"><a href="#apis-ups" role="tab" data-toggle="tab">UPS</a></li> <li><a href="#apis-interlink" role="tab" data-toggle="tab">Interlink Express</a></li> </ul> <div class="alert alert-warning alert-icon"> <div class="icon"><span class="icon-helper"><img src="/assets/images/icons/information.png" alt="" /></span></div> Only UPS and Interlink Express are the available courier services provided in this system </div> <div class="tab-content"> <div class="tab-pane active" id="apis-ups"> <h3>UPS courier</h3> <?php foreach(array('Access key' => 'ups_access_key', 'Shipper number' => 'ups_shipper_number', 'Username' => 'ups_username', 'Password' => 'ups_password') as $courier_label => $courier_input_name): ?> <div class="form-group"> <label class="col-sm-2 control-label"><?php echo $courier_label; ?></label> <div class="col-sm-4"> <input type="text" name="<?php echo $courier_input_name; ?>" class="form-control" value="<?php echo $this->config->item($courier_input_name); ?>" /> </div> </div> <?php endforeach; ?> </div> <div class="tab-pane" id="apis-interlink"> <h3>Interlink Express courier</h3> <?php foreach(array('Account number' => 'interlink_account_number', 'Username' => 'interlink_username', 'Password' => 'interlink_password') as $courier_label => $courier_input_name): ?> <div class="form-group"> <label class="col-sm-2 control-label"><?php echo $courier_label; ?></label> <div class="col-sm-4"> <input type="text" name="<?php echo $courier_input_name; ?>" class="form-control" value="<?php echo $this->config->item($courier_input_name); ?>" /> </div> </div> <?php endforeach; ?> </div> </div> <div class="form-group"> <div class="col-sm-10 col-sm-offset-2"> <button type="submit" name="update_settings" value="1" class="btn btn-primary">Save details</button> </div> </div> </div> <div class="clearfix"></div> </form> </div> </div> <div id="postcode-modal" class="modal fade"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h4 class="modal-title">Postcode rates</h4> </div> <div class="modal-body"> <div id="postcode-modal-errors"></div> <form action="" method="post" class="form-horizontal"> <div class="form-group"> <div class="col-xs-12"> <p><strong>Postcode</strong></p> <input type="text" name="postcode" value="" class="form-control input-lg text-center postcode-field" maxlength="8" /> </div> </div> <div class="form-group"> <div class="col-xs-12"> <p><strong>Delivery type</strong></p> <select name="delivery_type" class="form-control"> <?php foreach($this->orders->getDeliveryTypes() as $delivery_type): ?> <option value="<?php echo $delivery_type->delivery_id; ?>"<?php echo ($this->input->post('delivery_type') == $delivery_type->delivery_id) ? ' selected="selected"' : ''; ?>><?php echo $delivery_type->label; ?></option> <?php endforeach; ?> </select> </div> </div> <div class="form-group"> <div class="col-xs-12"> <p><strong>Delivery charge</strong></p> <div class="input-group"> <div class="input-group-addon">£</div> <input type="number" name="charge" step="0.01" min="0" value="" class="form-control input-lg" /> </div> <p class="help-block">Leave blank for the default charge from the selected delivery type</p> </div> </div> <div class="form-group"> <div class="col-xs-12 text-center"> <input type="hidden" name="rate_id" value="" /> <input type="hidden" name="save_rate" value="1" /> <button type="submit" class="btn btn-primary">Save</button> </div> </div> </form> </div> </div> </div>*/ ?> </div> <script type="text/javascript"> $(function() { $('.remove-delivery-type', '#delivery').click(function() { if(confirm('Are you sure you want to remove this delivery type?')) { $(this).closest('tr').remove(); } }); $('#add-another-location').click(function() { var self = $(this), tableRow = self.closest('tr'), clonedRow = tableRow.prev().clone(); clonedRow.find('input, select').val('').prop('selectedIndex', 0); clonedRow.insertBefore(tableRow); }); $('#locations').on('click', '.remove-location', function() { if(confirm('Are you sure you want to remove this location?')) { var self = $(this), currentRow = self.closest('tr'); if(currentRow.siblings('tr').length === 1) { $('input, select', currentRow).val('').prop('selectedIndex', 0); } else { currentRow.remove(); } } }); var postcodeModal = $('#postcode-modal'); $('#add-postcode-rate').click(function() { $('form', postcodeModal).get(0).reset(); postcodeModal.modal('show'); }); $('.edit-rate, .delete-rate', '#postcode-rates-table').click(function(event) { event.preventDefault(); var self = $(this), rateId = self.data('rate-id'); if(self.hasClass('edit-rate')) { $.post('', { get_rate: rateId }, function(response) { if(response.success) { $('.postcode-field', postcodeModal).val(response.rate.postcode); $('input[name="rate_id"]', postcodeModal).val(response.rate.rate_id); $('select[name="delivery_type"]', postcodeModal).val(response.rate.delivery_type); if(response.override_cost !== null) { $('input[name="charge"]', postcodeModal).val(response.rate.override_cost); } postcodeModal.modal('show'); } }); } else if(self.hasClass('delete-rate')) { $.post('', { delete_rate: rateId }, function(response) { if(response.success) { self.closest('tr').fadeOut('fast', function() { $(this).remove(); }); } }); } }); $('form', postcodeModal).submit(function(event) { event.preventDefault(); var self = $(this), saveBtn = $('button', postcodeModal).prop('disabled', true), formData = self.serializeArray(); $.post('', formData, function(response) { if(response.success) { window.location.reload(); } else { saveBtn.prop('disabled', false); $('#postcode-modal-errors').html('<div class="alert alert-danger">' + response.msg + '</div>'); } }); }); $('a', '#settings-tabs, #shop-tabs').click(function() { $(window).scrollTop(0).get(0).location.hash = this.hash; }); if(window.location.hash) { $(window).triggerHandler('hashchange'); } $(window).on('hashchange', function() { var hashIdentifier = sectionIdentifier = window.location.hash; if(hashIdentifier.indexOf('-') >= 0) { sectionIdentifier = hashIdentifier.split('-')[0]; $('a[href="' + window.location.hash + '"]', '.nav').tab('show'); } $('a[href="' + sectionIdentifier + '"]', '#settings-tabs').tab('show'); }) .triggerHandler('hashchange'); }) </script>
Cancel