Project:Corrdyn
EntryPoint______________
define(
'CD.Sweepstakes.Sweepstakes', [
'CD.Sweepstakes.Sweepstakes.View', "CD.Sweepstakes.Sweepstakes.Router"
],
function(
SweepstakesView, CDSweepstakesSweepstakesRouter
) {
'use strict';
return {
mountToApp: function mountToApp(container) {
return new CDSweepstakesSweepstakesRouter(container)
}
};
});
Model_________
// Model.js
// -----------------------
// @module Case
define("CD.Sweepstakes.Sweepstakes.Model", ["Backbone", 'underscore', 'jQuery', 'Utils'], function(
Backbone, _, jQuery,
Utils
) {
"use strict";
console.log('teststststst')
// @class Case.Fields.Model @extends Backbone.Model
return Backbone.Model.extend({
//@property {String} urlRoot
urlRoot: Utils.getAbsoluteUrl(getExtensionAssetsPath("services/Sweepstakes.Service.ss")),
validation: {
firstname: {
required: true,
msg: _('First name is required').translate()
},
lastname: {
required: true,
msg: _('Last name is required').translate()
},
email: {
required: true,
msg: _('Email is required').translate(),
pattern: 'email'
},
phone: {
required: true,
msg: _('Phone Number is required').translate()
}
},
parse: function(response) {
return response;
}
});
});
Router_______________
define(
'CD.Sweepstakes.Sweepstakes.Router', [
'CD.Sweepstakes.Sweepstakes.View', 'CD.Sweepstakes.Sweepstakes.Model','CD.Sweepstakes.instagram.View'
],
function(
CDSweepstakesSweepstakesView, CDSweepstakesModel,CDSweepstakesinstagramView
) {
'use strict';
return Backbone.Router.extend({
routes: {
'sweepstakes/:id': 'sweepstakes',
'instagram': 'instagramview'
}
,
initialize: function(application) {
this.application = application;
},
sweepstakes: function(id) {
var application = this.application;
var list_id = JSON.stringify(id)
var model = new CDSweepstakesModel();
model.fetch({ data: { listid: list_id } }).done(function(result) {
var view = new CDSweepstakesSweepstakesView({ application: application, list: result, listid: list_id })
view.showContent();
});
},
instagramview: function() {
var application = this.application;
var instagram = true;
var model = new CDSweepstakesModel();
model.fetch({ data: { instagram: instagram } }).done(function(result) {
console.log('result',result)
var view = new CDSweepstakesinstagramView({ application: application, list: result })
view.showContent();
});
}
});
});
Instagramview__________// @module CD.Sweepstakes.Sweepstakes
define('CD.Sweepstakes.instagram.View', [
'cd_sweepstakes_instagram.tpl'
, 'CD.Sweepstakes.Sweepstakes.Model', 'GlobalViews.Message.View', 'Utils', 'Backbone', 'jQuery', 'underscore'
], function(
cd_sweepstakes_instagram_tpl
, CDSweepstakesSweepstakesModel, GlobalViewsMessageView, Utils, Backbone, jQuery, _
) {
'use strict';
// @class CD.Sweepstakes.Sweepstakes.View @extends Backbone.View
return Backbone.View.extend({
template: cd_sweepstakes_instagram_tpl
,
initialize: function(options) {
console.log('options', options)
this.list = options.list
}
,
getContext: function getContext() {
var environment = this.options.application.getComponent('Environment');
var array = []
var message = environment.getConfig('sweepstakes.data')
var list = this.list
_.each(list, function(line) {
array.push({ "title": line.title, "url": "sweepstakes/" + line.urlfrag, })
})
_.each(message, function(line) {
array.push({ "title": line.button, "url": line.link, })
})
console.log('array', array)
//@class CD.Sweepstakes.Sweepstakes.View.Context
return { array: array };
}
});
});
View__________
// @module CD.Sweepstakes.Sweepstakes
define('CD.Sweepstakes.Sweepstakes.View', [
'cd_sweepstakes_sweepstakes.tpl'
, 'CD.Sweepstakes.Sweepstakes.SS2Model'
, 'CD.Sweepstakes.Sweepstakes.Model', 'GlobalViews.Message.View', 'Utils', 'Backbone', 'Backbone.CompositeView', 'Backbone.CollectionView', 'Backbone.FormView', 'jQuery', 'underscore'
], function(
cd_sweepstakes_sweepstakes_tpl
, SweepstakesSS2Model
, CDSweepstakesSweepstakesModel, GlobalViewsMessageView, Utils, Backbone, BackboneCompositeView, BackboneCollectionView, BackboneFormView, jQuery, _
) {
'use strict';
// @class CD.Sweepstakes.Sweepstakes.View @extends Backbone.View
return Backbone.View.extend({
template: cd_sweepstakes_sweepstakes_tpl
,
initialize: function(options) {
this.sweepstakes = options.list[0]
BackboneCompositeView.add(this);
this.application = options.application;
this.model = new CDSweepstakesSweepstakesModel();
BackboneFormView.add(this);
this.sweepsid = options.listid
$(".sweeptakes_landingpages_submitted_container").hide()
}
,
events: {
'submit form': 'SubmitForm'
}
,
bindings: {
'[name="firstname"]': 'firstname',
'[name="lastname"]': 'lastname',
'[name="company"]': 'company',
'[name="email"]': 'email',
'[name="phone"]': 'phone'
}
,
childViews: {},
SubmitForm: function(e) {
var promise = BackboneFormView.saveForm.apply(this, arguments),
self = this;
console.log('promise', promise)
return promise && promise.then(
function(success) {
if (success.successMessage) {
console.log('inside if success')
$(".sweeptakes_landingpages_form").hide()
$(".sweeptakes_landingpages_submitted_container").show()
} else {
var message = "An error occured, please try again"
var global_view_message = new GlobalViewsMessageView({
message: message,
type: 'error',
closable: false
});
var msgContainerParent = jQuery('.warningmessage');
msgContainerParent.html(global_view_message.render().$el.html());
window.location.reload()
}
},
function(fail) {
console.log('fail')
var message = "An error occured, please try again"
var global_view_message = new GlobalViewsMessageView({
message: message,
type: 'error',
closable: false
});
var msgContainerParent = jQuery('.warningmessage');
msgContainerParent.html(global_view_message.render().$el.html());
window.location.reload()
}
);
}
//@method getContext @return CD.Sweepstakes.Sweepstakes.View.Context
,
getContext: function getContext() {
//@class CD.Sweepstakes.Sweepstakes.View.Context
var maindesc = this.sweepstakes.main_desc
var bottomdesc = this.sweepstakes.bott_desc
var rightdesc = this.sweepstakes.right_desc
var title = this.sweepstakes.title
var freecatalog = this.sweepstakes.cateques
var emailsub = this.sweepstakes.emailsub
var reg_msg = this.sweepstakes.reg_msg
_.each(this.sweepstakes.ques, function(line) {
var options = line.option
var myArr = options.split(",");
var obj = [];
_.each(myArr, function(el) {
var objel = { "value": el, "type": line.q_type, "ques": line.question, "quesid": line.questionid }
obj.push(objel)
})
line.option = obj
})
return {
maindesc: maindesc,
bottomdesc: bottomdesc,
rightdesc: rightdesc,
title: title,
freecatalog: freecatalog,
emailsub: emailsub,
sweepsid: this.sweepstakes.internalid,
addquestions: this.sweepstakes.ques,
reg_msg: reg_msg
};
}
});
});
SS Entry Point __________
// CD.Sweepstakes.Sweepstakes.js
// Load all your starter dependencies in backend for your extension here
// ----------------
define('CD.Sweepstakes.Sweepstakes', [
'CD.Sweepstakes.Sweepstakes.ServiceController', 'SC.Model', 'Utils', 'underscore'
], function(
SweepstakesServiceController, SCModel, Utils, _
) {
'use strict';
return SCModel.extend({
getdetail: function(details) {
try {
var list_id = details.listid;
console.log('details.listid', list_id)
console.log('1', details.listid)
var sweepstakes = nlapiSearchRecord("customrecord_sweepstakes_landing_page", null,
[
["custrecord_sweep_url", "is", JSON.parse(list_id)],
"AND",
["custrecord_sweepstakes_end_date", "notbefore", "today"],
"AND",
["custrecord_sweepstakes_start_date", "onorbefore", "today"]
],
[
new nlobjSearchColumn("custrecord_sweepstakes_title"),
new nlobjSearchColumn("custrecord_sweepstakes_start_date"),
new nlobjSearchColumn("custrecord_sweepstakes_end_date"),
new nlobjSearchColumn("custrecord_sweepstakes_cat_ques"),
new nlobjSearchColumn("custrecord_sweepstakes_email_subs"),
new nlobjSearchColumn("custrecord_sweepstakes_main_desc"),
new nlobjSearchColumn("custrecord_sweepstakes_bot_desc"),
new nlobjSearchColumn("custrecord_sweepstakes_right_desc"),
new nlobjSearchColumn("internalid"),
new nlobjSearchColumn("custrecord_sweep_reg_msg")
]
);
var additional_ques = nlapiSearchRecord("customrecord_sweepstakes_landing_page", null,
[
["custrecord_sweep_url", "is", JSON.parse(list_id)]
],
[new nlobjSearchColumn("custrecord20", "CUSTRECORD_SWEEP_LINK", null),
new nlobjSearchColumn("custrecord21", "CUSTRECORD_SWEEP_LINK", null),
new nlobjSearchColumn("custrecord_sweep_additional_options", "CUSTRECORD_SWEEP_LINK", null)
]
);
var additional_queslist = []
if (additional_ques) {
for (var i = 0; i < additional_ques.length; i++) {
var result = additional_ques[i];
additional_queslist.push({
question: result.getText("custrecord20", "CUSTRECORD_SWEEP_LINK", null),
q_type: result.getText("custrecord21", "CUSTRECORD_SWEEP_LINK", null),
option: result.getValue("custrecord_sweep_additional_options", "CUSTRECORD_SWEEP_LINK", null),
questionid: result.getValue("custrecord20", "CUSTRECORD_SWEEP_LINK", null),
});
}
}
var sweepstakesdetails = []
if (sweepstakes) {
for (var i = 0; i < sweepstakes.length; i++) {
var result = sweepstakes[i];
sweepstakesdetails.push({
internalid: result.getValue("internalid"),
title: result.getValue("custrecord_sweepstakes_title"),
startdate: result.getValue("custrecord_sweepstakes_start_date"),
enddate: result.getValue("custrecord_sweepstakes_end_date"),
cateques: result.getValue("custrecord_sweepstakes_cat_ques"),
emailsub: result.getValue("custrecord_sweepstakes_email_subs"),
main_desc: result.getValue("custrecord_sweepstakes_main_desc"),
bott_desc: result.getValue("custrecord_sweepstakes_bot_desc"),
right_desc: result.getValue("custrecord_sweepstakes_right_desc"),
reg_msg: result.getValue("custrecord_sweep_reg_msg"),
ques: additional_queslist || null,
});
}
}
return sweepstakesdetails
} catch (e) {
// statements
console.log(e);
}
},
CreateLead: function(data) {
console.error('In@Model: Forms', JSON.stringify(data))
var CONTENT = '';
var customerSearch = nlapiSearchRecord("customer", null,
[
["email", "is", Utils.sanitizeString(data.email)]
],
[
new nlobjSearchColumn("internalid")
]
);
if (!!customerSearch) {
if (customerSearch.length > 0) {
// console.log('insideif')
try {
var listid = customerSearch[0].getValue("internalid");
var entry = nlapiCreateRecord('customrecord_sweepstakes_entries');
entry.setFieldValue('custrecord_sweepstakes_customer', listid)
console.log('data.sweepid', Utils.sanitizeString(data.sweepid))
entry.setFieldValue('custrecord_sweep_name', Utils.sanitizeString(data.sweepid))
entry.setFieldValue('custrecord_sweep_age', Utils.sanitizeString(data.sweepstakesage))
if (data.vv_freecatalogsEquine) {
entry.setFieldValue('custrecordsweep_equine', "T")
}
if (data.vv_freecatalogsFarm) {
entry.setFieldValue('custrecordsweep_farm', "T")
}
if (data.vv_freecatalogsPet) {
entry.setFieldValue('custrecordsweep_pet', "T")
}
console.log('data.question', data.question)
var sublist = nlapiSubmitRecord(entry);
try {
var answr_arr = []
_.each(data.question, function(line) {
console.log('line', line)
var each_ans = line.split(" :");
console.log("each_ans", each_ans)
answr_arr.push(each_ans)
});
console.log('answr_arr', answr_arr)
for (i = 0; i < answr_arr.length; i++) {
console.log('answr_arr[i][0]', answr_arr[i][0])
console.log('answr_arr[i][0]', answr_arr[i][1])
var entry = nlapiCreateRecord('customrecord_sweep_additional_answer');
entry.setFieldValue('custrecord_entry_question', JSON.parse(answr_arr[i][0]))
entry.setFieldValue('custrecord_addi_answer', answr_arr[i][1])
entry.setFieldValue('custrecord22', sublist)
nlapiSubmitRecord(entry);
}
} catch (e) {
console.log("error", e);
}
return {
successMessage: 'Your request has been submitted'
}
} catch (e) {
// statements
console.error('err@contactus', e);
return {
status: 500,
code: 'ERR_FORM',
message: 'There was an error submitting the form, please try again later'
}
}
}
} else {
try {
var firstname, lastname, company, email, comments;
var customerRecord = nlapiCreateRecord('lead', { recordmode: 'dynamic' });
customerRecord.setFieldValue('isperson', 'T');
customerRecord.setFieldValue('entitystatus', 6); //LEAD-Unqualified
if (data.firstname) {
firstname = Utils.sanitizeString(data.firstname);
customerRecord.setFieldValue('firstname', firstname);
}
if (data.lastname) {
lastname = Utils.sanitizeString(data.lastname);
customerRecord.setFieldValue('lastname', lastname);
}
if (data.company) {
company = Utils.sanitizeString(data.company);
customerRecord.setFieldValue('companyname', company);
}
if (data.email) {
email = Utils.sanitizeString(data.email);
customerRecord.setFieldValue('email', email);
}
if (data.phone) {
phone = Utils.sanitizeString(data.phone);
customerRecord.setFieldValue('phone', phone);
}
if (data.altphone) {
altphone = Utils.sanitizeString(data.altphone);
customerRecord.setFieldValue('altphone', altphone);
}
customerRecord.setFieldValue('subsidiary', 2);
console.log('custid', custid)
var address = customerRecord.createCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
// set subrecord fields
address.setFieldValue('country', "US"); // Country must be set before setting the other address fields
address.setFieldValue('addressee', data.firstname);
address.setFieldValue('addrphone', data.phone);
address.setFieldValue('addr1', data.address1);
address.setFieldValue('addr2', data.address2);
address.setFieldValue('city', data.city);
address.setFieldValue('state', data.state);
address.setFieldValue('zip', data.zipcode);
address.commit();
customerRecord.commitLineItem('addressbook');
var custid = nlapiSubmitRecord(customerRecord);
var entry = nlapiCreateRecord('customrecord_sweepstakes_entries');
entry.setFieldValue('custrecord_sweepstakes_customer', custid)
console.log('data.sweepid', Utils.sanitizeString(data.sweepid))
entry.setFieldValue('custrecord_sweep_name', Utils.sanitizeString(data.sweepid))
entry.setFieldValue('custrecord_sweep_age', Utils.sanitizeString(data.sweepstakesage))
if (data.vv_freecatalogsEquine) {
entry.setFieldValue('custrecordsweep_equine', "T")
}
if (data.vv_freecatalogsFarm) {
entry.setFieldValue('custrecordsweep_farm', "T")
}
if (data.vv_freecatalogsPet) {
entry.setFieldValue('custrecordsweep_pet', "T")
}
console.log('data.question', data.question)
var sublist = nlapiSubmitRecord(entry);
try {
var answr_arr = []
_.each(data.question, function(line) {
console.log('line', line)
var each_ans = line.split(" :");
console.log("each_ans", each_ans)
answr_arr.push(each_ans)
});
console.log('answr_arr', answr_arr)
for (i = 0; i < answr_arr.length; i++) {
var entry = nlapiCreateRecord('customrecord_sweep_additional_answer');
entry.setFieldValue('custrecord_entry_question', JSON.parse(answr_arr[i][0]))
entry.setFieldValue('custrecord_addi_answer', answr_arr[i][1])
entry.setFieldValue('custrecord22', sublist)
nlapiSubmitRecord(entry);
}
} catch (e) {
console.log("error", e);
}
return {
successMessage: 'Your request has been submitted.'
}
} catch (e) {
// statements
console.error('err@contactus', e);
return {
status: 500,
code: 'ERR_FORM',
message: 'There was an error submitting the form, please try again later'
}
}
}
},
getlist: function() {
try {
var instalist = nlapiSearchRecord("customrecord_sweepstakes_landing_page", null,
[
["custrecord_exclude_insta", "is", "F"]
],
[
new nlobjSearchColumn("custrecord_sweepstakes_title"),
new nlobjSearchColumn("custrecord_sweep_url")
]
);
var list = []
if (instalist) {
for (var i = 0; i < instalist.length; i++) {
var result = instalist[i];
list.push({
title: result.getValue("custrecord_sweepstakes_title"),
urlfrag: result.getValue("custrecord_sweep_url"),
});
}
}
console.log('list',list)
return list
} catch (e) {
// statements
console.log(e);
}
},
});
});
ServiceController_______
define("CD.Sweepstakes.Sweepstakes.ServiceController", ["ServiceController", 'CD.Sweepstakes.Sweepstakes'], function(
ServiceController, CDSweepstakesSweepstakes
) {
"use strict";
return ServiceController.extend({
name: "CD.Sweepstakes.Sweepstakes.ServiceController",
// The values in this object are the validation needed for the current service.
options: {
common: {}
},
get: function get() {
try {
var name = this.request.getParameter('name');
var listid = this.request.getParameter('listid');
var instagram = this.request.getParameter('instagram') || false
var result
console.log('listid',listid)
console.log('instagram',instagram)
if (listid) {
result = CDSweepstakesSweepstakes.getdetail({ listid: listid })
}
if (instagram) {
result = CDSweepstakesSweepstakes.getlist()
}
return JSON.stringify(result)
} catch (e) {
console.warn('Service.ss::' + e.name, e);
this.sendError(e);
}
},
post: function post() {
console.log('Services: Forms', JSON.stringify(this.data))
console.log('this: Forms', JSON.stringify(this))
var listid = this.request.getParameter('listid');
console.log('listid: Forms', listid)
this.sendContent(CDSweepstakesSweepstakes.CreateLead(this.data), { 'status': 201 });
},
put: function put() {
// not implemented
},
delete: function() {
// not implemented
}
});
});
Template_______
<style>
.vv_catalogrequest_frame {
width: 100%;
height: 1200px;
}
@media screen and (max-width: 534px) {
.vv_catalogrequest_frame {
height: 1590px;
}
}
</style>
<div class="container sweeptakes_landingpages_container">
<div class="sweeptakes_landingpages vv_landingpages_iv">
<div><small class="warningmessage"></small></div>
<div class="vv_titlebox">
<h1>{{title}}</h1>
</div>
<div class="row">
{{{maindesc}}}
</div>
<div class="row">
<section class="vv_row col-sm-8">
<div class="vv_catreq_form">
<div class="row">
<form role="form" id="vv_catreq_form_quine" class="sweeptakes_landingpages_form" action="POST">
<div class="col-md-12">
<div class="row">
<div class="col-md-12">
<div class="float-box">
<div class="half-width">
<div><input type="text" name="sweepid" id="sweepid" value="{{sweepsid}}" style="display:none;"></div>
<div data-validation="control-group" data-input="firstname" class="control-group">
<div data-validation="control">
<label class="control-label" for="firstname">First name</label>
<input type="text" size="25" name="firstname" id="firstname" value="{{firstname}}">
</div>
</div>
</div>
<div class="half-width">
<div data-validation="control-group" data-input="lastname" class="control-group">
<div data-validation="control">
<label class="control-label" for="lastname">Last name</label>
<input type="text" size="25" aria-labelledby="lastname_fs_lbl" name="lastname" id="lastname" class="inputreq">
</div>
</div>
</div>
</div>
<div class="float-box">
<div class="half-width">
<div class="control-group">
<label class="control-label" for="companyname">Company</label>
<input type="text" size="25" aria-labelledby="companyname_fs_lbl" name="company" style="" id="company" class="input">
</div>
</div>
</div>
<div class="float-box">
<div class="half-width">
<div class="control-group">
<label class="control-label" for="address1">Address Line</label>
<input type="text" size="25" aria-labelledby="address1_fs_lbl" name="address1" style="" id="address1" class="inputreq">
</div>
</div>
<div class="half-width">
<div class="control-group">
<label class="control-label" for="address2">Apt, Ste, Etc</label>
<input type="text" size="25" aria-labelledby="address2_fs_lbl" name="address2" style="" id="address2" class="input">
</div>
</div>
</div>
<div class="float-box">
<div class="half-width">
<div class="control-group">
<label class="control-label" for="city">City</label>
<input type="text" size="25" aria-labelledby="city_fs_lbl" name="city" style="" id="city" class="input">
</div>
</div>
<div class="half-width widthInners">
<div class="innerbig">
<div class="control-group">
<label for="state" class="control-label">State</label>
<select name="state" id="state" class="input">
<option value="" selected=""></option>
<option value="0">Alabama</option>
<option value="1">Alaska</option>
<option value="101">Alberta</option>
<option value="30000">American Samoa</option>
<option value="2">Arizona</option>
<option value="3">Arkansas</option>
<option value="53">Armed Forces Americas</option>
<option value="52">Armed Forces Europe</option>
<option value="54">Armed Forces Pacific</option>
<option value="102">British Columbia</option>
<option value="4">California</option>
<option value="5">Colorado</option>
<option value="6">Connecticut</option>
<option value="7">Delaware</option>
<option value="8">District of Columbia</option>
<option value="30001">Federated States of Micronesia</option>
<option value="9">Florida</option>
<option value="10">Georgia</option>
<option value="30002">Guam</option>
<option value="11">Hawaii</option>
<option value="12">Idaho</option>
<option value="13">Illinois</option>
<option value="14">Indiana</option>
<option value="15">Iowa</option>
<option value="16">Kansas</option>
<option value="17">Kentucky</option>
<option value="18">Louisiana</option>
<option value="19">Maine</option>
<option value="103">Manitoba</option>
<option value="30003">Marshall Islands</option>
<option value="20">Maryland</option>
<option value="21">Massachusetts</option>
<option value="22">Michigan</option>
<option value="23">Minnesota</option>
<option value="24">Mississippi</option>
<option value="25">Missouri</option>
<option value="26">Montana</option>
<option value="27">Nebraska</option>
<option value="28">Nevada</option>
<option value="104">New Brunswick</option>
<option value="29">New Hampshire</option>
<option value="30">New Jersey</option>
<option value="31">New Mexico</option>
<option value="32">New York</option>
<option value="105">Newfoundland</option>
<option value="33">North Carolina</option>
<option value="34">North Dakota</option>
<option value="30004">Northern Marianas</option>
<option value="107">Northwest Territories</option>
<option value="106">Nova Scotia</option>
<option value="108">Nunavut</option>
<option value="35">Ohio</option>
<option value="36">Oklahoma</option>
<option value="109">Ontario</option>
<option value="37">Oregon</option>
<option value="30005">Palau</option>
<option value="38">Pennsylvania</option>
<option value="110">Prince Edward Island</option>
<option value="39">Puerto Rico</option>
<option value="111">Quebec</option>
<option value="40">Rhode Island</option>
<option value="112">Saskatchewan</option>
<option value="41">South Carolina</option>
<option value="42">South Dakota</option>
<option value="43">Tennessee</option>
<option value="44">Texas</option>
<option value="45">Utah</option>
<option value="46">Vermont</option>
<option value="30006">Virgin Islands</option>
<option value="47">Virginia</option>
<option value="48">Washington</option>
<option value="49">West Virginia</option>
<option value="50">Wisconsin</option>
<option value="51">Wyoming</option>
<option value="113">Yukon</option>
</select>
</div>
</div>
<div class="innersmall">
<div class="control-group">
<label class="control-label" for="zipcode">Zip Code</label>
<input type="text" size="25" aria-labelledby="zipcode_fs_lbl" name="zipcode" style="" id="zipcode" class="inputreq">
</div>
</div>
</div>
</div>
<div class="float-box">
<div class="half-width">
<div class="control-group" data-validation="control-group">
<div data-validation="control">
<label class="control-label" for="email">Daytime Phone</label>
<input type="text" size="-1" aria-labelledby="phone_fs_lbl" name="phone" id="phone" class="inputreq">
</div>
</div>
</div>
<div class="half-width">
<div class="control-group">
<label class="control-label" for="retypeEmail">Alternate Phone</label>
<input type="text" size="-1" aria-labelledby="altphone_fs_lbl" name="altphone" id="altphone" class="input">
</div>
</div>
</div>
<div class="float-box">
<div class="half-width">
<div class="control-group" data-validation="control-group">
<div data-validation="control">
<label class="control-label" for="email">Email</label>
<input type="email" id="email" name="email" />
</div>
</div>
</div>
</div>
</div>
</div>
{{#if emailsub}}
<div class="row vv_checkboxes bottomSpacer">
<div class="col-md-12">
<div class="full-width">
<label class="control-label vv_c_box">
<div class="globalsubscriptionstatus-checkbox">
</div>
<input aria-labelledby="custentity_vv_opt_emailoffers_fs_lbl" name="custentity_vv_opt_emailoffers" id="custentity_vv_opt_emailoffers_fs_inp" type="checkbox" value="T" class="checkbox" checked>
<input type="hidden" name="custentity_vv_opt_emailoffers_send">
<img class="checkboximage" src="/images/nav/ns_x.gif" alt="">
<span>Opt-in for email offers</span>
</label>
</div>
<legend>Specify Preference(s):</legend>
<div class="flex-box">
<div class="qtr-width">
<div class="control-group">
<label class="control-label" for="custentity_vv_equineoffers_fs_inp">
<input name="custentity_vv_equineoffers" id="custentity_vv_equineoffers_fs_inp" type="checkbox" value="T" class="checkbox">
<input type="hidden" name="custentity_vv_equineoffers_send"><img class="checkboximage" src="/images/nav/ns_x.gif" alt=""></span>
<span>Equine Offers</span>
</label>
</div>
</div>
<div class="qtr-width">
<div class="control-group">
<label class="control-label" for="custentity_vv_petoffers_fs_inp">
<input name="custentity_vv_petoffers" id="custentity_vv_petoffers_fs_inp" type="checkbox" value="T" class="checkbox">
<input type="hidden" name="custentity_vv_petoffers_send">
<img class="checkboximage" src="/images/nav/ns_x.gif" alt="">
<span>Pet Offers</span>
</label>
</div>
</div>
<div class="qtr-width">
<div class="control-group">
<label class="control-label" for="custentity_vv_ranchlivestockoffers_fs_inp">
<input name="custentity_vv_ranchlivestockoffers" id="custentity_vv_ranchlivestockoffers_fs_inp" type="checkbox" value="T" class="checkbox">
<input type="hidden" name="custentity_vv_ranchlivestockoffers_send">
<img class="checkboximage" src="/images/nav/ns_x.gif" alt="">
<span>Ranch/Livestock Offers</span>
</label>
</div>
</div>
<div class="qtr-width">
<div class="control-group">
<label class="control-label" for="custentity_vv_goatoffers_fs_inp">
<input name="custentity_vv_goatoffers" id="custentity_vv_goatoffers_fs_inp" type="checkbox" value="T" class="checkbox">
<input type="hidden" name="custentity_vv_goatoffers_send">
<img class="checkboximage" src="/images/nav/ns_x.gif" alt="">
<span>Goat Offers</span>
</label>
</div>
</div>
</div>
</div>
</div>
{{/if}}
<div class="row vv_checkboxes woborder bottomSpacer">
<div class="col-md-12">
<div class="control-label" id="custentity_vv_giveawaysage">
<div>
<h4>I am at least 18 years old</h4>
</div>
<div class="">
</div>
<div class="vv_rc_box">
<label><input type="radio" name="sweepstakesage" value="T" required checked />Yes</label>
<label><input type="radio" name="sweepstakesage" value="F" />No</label>
</div>
</div>
</div>
</div>
<div class="row vv_checkboxes woborder bottomSpacer">
<div class="col-md-12">
<div class="control-label" id="custentity_vv_sweeptakes_prizes">
<div>
<h4>I'm interested in prizes for (select all that apply, indicating prize package entries)</h4>
</div>
<div class="hidetis">
<select name="custentity_vv_sweeptakes_prizes" id="custentity_vv_sweeptakes_prizes" class="input" type="select-multiple" aria-labelledby="custentity_vv_sweeptakes_prizes_fs_lbl" size="4">
<option value="1">Horses</option>
<option value="2">Livestock</option>
<option value="3">Pets</option>
<option value="4">Myself</option>
</select>
</div>
<div class="vv_rc_box flexcolumn vv_sweepstakesprizes">
</div>
</div>
</div>
</div>
{{#if freecatalog}}
<div class="row vv_checkboxes woborder bottomSpacer">
<div class="col-md-12">
<div class="control-label" id="custentity_vv_freecatalogs">
<div>
<h4>I WOULD LIKE TO RECEIVE A FREE CATALOG(S):</h4>
</div>
<div class="hidetis">
<select name="custentity_vv_freecatalogs" id="custentity_vv_freecatalogs" class="input" flags="2268816609280" type="select-multiple" aria-labelledby="custentity_vv_freecatalogs_fs_lbl">
<option value="1">Equine</option>
<option value="2">Farm</option>
<option value="3">Pet</option>
</select>
</div>
<div class="vv_rc_box flexcolumn vv_freecatalogs">
</div>
</div>
</div>
</div>
{{/if}}
{{#each addquestions}}
<div class="row vv_checkboxes woborder bottomSpacer">
<div class="col-md-12">
<div class="control-label" id="additional_question">
<div>
<h4>{{question}}</h4>
</div>
<div class="hidetis">
</div>
{{#each option}}
<label><input type="{{type}}" name="question" value="{{quesid}} : {{value}}" class="additional_question_input" />{{value}}</label>
{{/each}}
</div>
</div>
</div>
{{/each}}
<div class="row bottomSpacer">
<div class="col-md-12">
<div class="form-action">
<button type="submit" class="submitbtn" id="submitbtn">Submit</button>
</div>
</div>
</div>
</div>
</form>
</div>
<div class="sweeptakes_landingpages_submitted_container" style="display: none;">
{{#if reg_msg}}
<div>{{{reg_msg}}}</div>
{{else}}
<h1>
Succes your Entry has been received, Thank you
</h1>
<button class="submitbtn" onclick="window.location.href='/'">Continue Shopping</button>
{{/if}}
</div>
</div>
</section>
{{{rightdesc}}}
</div>
<!-- Script -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript">
function confirmEmail() {
var email = document.getElementById('email').value;
// var confemail = document.getElementById('retypeEmail').value;
// if(email != confemail || email.length === 0) {
if (email.length === 0) {
document.getElementById('submitbtn').disabled = true;
} else {
document.getElementById('submitbtn').disabled = false;
}
}
$('#email').change(function() {
confirmEmail();
});
//Radio to Checkbox
$('input[name="custentity_vv_giveawaysage"]').prop('checked', 'checked');
$('#custentity_vv_giveawaysage input[name="sweepstakesage"]').change(function() {
if ($('#custentity_vv_giveawaysage input[name="sweepstakesage"]:checked').val() == "T") {
$('input[name="custentity_vv_giveawaysage"]').prop('checked', 'checked')
} else {
$('input[name="custentity_vv_giveawaysage"]').prop('checked', '')
}
});
//Prizes: MultiSelect to Checkbox
$('select#custentity_vv_sweeptakes_prizes option').each(function() {
var val = $(this).val();
if ($(this).val()) {
$(".vv_sweepstakesprizes").append('<label><input class="vv_sweepstakesprizes_options" type="checkbox" value="' + $(this).val() + '" name="vv_sweepstakesprizes" />' + $(this).text() + '</label>');
}
});
$('.vv_sweepstakesprizes').change(function() {
var tisValues = [];
$('.vv_sweepstakesprizes_options[name="vv_sweepstakesprizes"]:checked').each(function() {
tisValues.push($(this).val());
});
$("select#custentity_vv_sweeptakes_prizes").val(tisValues);
});
//Free Catalogs: MultiSelect to Checkbox
$('select#custentity_vv_freecatalogs option').each(function() {
var val = $(this).val();
var label = $(this).text();
console.log('label', label)
console.log('val', val)
if ($(this).val()) {
$(".vv_freecatalogs").append('<label><input class="vv_sweepstakesprizes_options" type="checkbox" value="' + $(this).val() + '" name="vv_freecatalogs' + label + '" />' + $(this).text() + '</label>');
}
});
$('.vv_freecatalogs').change(function() {
var tisValues = [];
$('.vv_sweepstakesprizes_options[name="vv_freecatalogs"]:checked').each(function() {
tisValues.push($(this).val());
});
console.log('tisValues', tisValues)
$("select#custentity_vv_freecatalogs").val(tisValues);
});
</script>
</div>
<div class="row">
{{{bottomdesc}}}
</div>
<div><small class="warningmessage"></small></div>
</div>
</div>