Commit fe40fe0b by chenith

Updated Jobs annual payment plan page.

parent 6e3e1062
...@@ -52,6 +52,7 @@ public abstract class BasePaymentPlan extends BaseBusinessClass ...@@ -52,6 +52,7 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
// Static constants corresponding to searches // Static constants corresponding to searches
public static final String SEARCH_All = "All"; public static final String SEARCH_All = "All";
public static final String SEARCH_Max = "Max";
// Static constants corresponding to attribute helpers // Static constants corresponding to attribute helpers
...@@ -2007,6 +2008,109 @@ public abstract class BasePaymentPlan extends BaseBusinessClass ...@@ -2007,6 +2008,109 @@ public abstract class BasePaymentPlan extends BaseBusinessClass
.search (transaction); .search (transaction);
} }
public static SearchMax SearchByMax () { return new SearchMax (); }
public static class SearchMax extends SearchObject<PaymentPlan>
{
public SearchMax andObjectID (QueryFilter<Long> filter)
{
filter.addFilter (context, "tl_payment_plan.object_id", FIELD_ObjectID);
return this;
}
public SearchMax andObjectCreated (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_payment_plan.object_created_date", FIELD_ObjectCreated);
return this;
}
public SearchMax andObjectLastModified (QueryFilter<Date> filter)
{
filter.addFilter (context, "tl_payment_plan.object_last_updated_date", FIELD_ObjectLastModified);
return this;
}
public SearchMax andStripeReference (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.stripe_reference", "StripeReference");
return this;
}
public SearchMax andPlanName (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.plan_name", "PlanName");
return this;
}
public SearchMax andDescription (QueryFilter<String> filter)
{
filter.addFilter (context, "tl_payment_plan.description", "Description");
return this;
}
public SearchMax andCurrencyType (QueryFilter<CurrencyType> filter)
{
filter.addFilter (context, "tl_payment_plan.currency_type", "CurrencyType");
return this;
}
public SearchMax andAmount (QueryFilter<Double> filter)
{
filter.addFilter (context, "tl_payment_plan.amount", "Amount");
return this;
}
public SearchMax andInterval (QueryFilter<Interval> filter)
{
filter.addFilter (context, "tl_payment_plan.interval", "Interval");
return this;
}
public SearchMax andIntervalCount (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.interval_count", "IntervalCount");
return this;
}
public SearchMax andTrialPeriodDays (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.trial_period_days", "TrialPeriodDays");
return this;
}
public SearchMax andActiveJobCount (QueryFilter<Integer> filter)
{
filter.addFilter (context, "tl_payment_plan.active_job_count", "ActiveJobCount");
return this;
}
public PaymentPlan search (ObjectTransaction transaction) throws StorageException
{
BaseBusinessClass[] results = super.search (transaction, REFERENCE_PaymentPlan, SEARCH_Max, criteria);
Set<PaymentPlan> typedResults = new LinkedHashSet <PaymentPlan> ();
for (BaseBusinessClass bbcResult : results)
{
PaymentPlan aResult = (PaymentPlan)bbcResult;
typedResults.add (aResult);
}
return (PaymentPlan)singletonResult(ObjstoreUtils.removeDeleted(transaction, typedResults).toArray(new BaseBusinessClass[0]), "PaymentPlan", "");
}
}
public static PaymentPlan searchMax (ObjectTransaction transaction) throws StorageException
{
return SearchByMax ()
.search (transaction);
}
public Object getAttribute (String attribName) public Object getAttribute (String attribName)
......
package performa.orm; package performa.orm;
import com.stripe.model.Card; import com.stripe.model.Card;
import java.util.Collection;
import java.util.Collections;
import oneit.logging.LoggingArea; import oneit.logging.LoggingArea;
import oneit.objstore.BaseBusinessClass; import oneit.objstore.BaseBusinessClass;
import oneit.objstore.ObjectStatus; import oneit.objstore.ObjectStatus;
...@@ -13,6 +15,7 @@ import oneit.utils.math.NullArith; ...@@ -13,6 +15,7 @@ import oneit.utils.math.NullArith;
import oneit.utils.parsers.FieldException; import oneit.utils.parsers.FieldException;
import performa.orm.types.JobStatus; import performa.orm.types.JobStatus;
import performa.utils.StripeUtils; import performa.utils.StripeUtils;
import performa.utils.Utils;
public class Company extends BaseCompany public class Company extends BaseCompany
...@@ -85,6 +88,13 @@ public class Company extends BaseCompany ...@@ -85,6 +88,13 @@ public class Company extends BaseCompany
{ {
if(getPaymentJobCount() != null) if(getPaymentJobCount() != null)
{ {
PaymentPlan maxPlan = Utils.getMaximumPaymentPlan(getTransaction());
if(maxPlan!=null && getPaymentJobCount()>=maxPlan.getActiveJobCount())
{
return maxPlan;
}
PaymentPlan[] plans = PaymentPlan.SearchByAll() PaymentPlan[] plans = PaymentPlan.SearchByAll()
.andActiveJobCount(new EqualsFilter<>(getPaymentJobCount())) .andActiveJobCount(new EqualsFilter<>(getPaymentJobCount()))
.search(getTransaction()); .search(getTransaction());
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
</TABLE> </TABLE>
<SEARCH type="All" paramFilter="tl_payment_plan.object_id is not null" orderBy="tl_payment_plan.object_id" /> <SEARCH type="All" paramFilter="tl_payment_plan.object_id is not null" orderBy="tl_payment_plan.object_id" />
<SEARCH type="Max" paramFilter="tl_payment_plan.object_id IS NOT NULL AND active_job_count IS NOT NULL" orderBy="tl_payment_plan.active_job_count DESC LIMIT 1" singleton="TRUE" />
</BUSINESSCLASS> </BUSINESSCLASS>
......
...@@ -286,6 +286,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr ...@@ -286,6 +286,10 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
{ {
throw new RuntimeException ("NOT implemented: executeSearchQueryAll"); throw new RuntimeException ("NOT implemented: executeSearchQueryAll");
} }
public ResultSet executeSearchQueryMax (SQLManager sqlMgr) throws SQLException
{
throw new RuntimeException ("NOT implemented: executeSearchQueryMax");
}
...@@ -435,6 +439,44 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr ...@@ -435,6 +439,44 @@ public class PaymentPlanPersistenceMgr extends ObjectPersistenceMgr
return results; return results;
} }
else if (searchType.equals (PaymentPlan.SEARCH_Max))
{
// Local scope for transformed variables
{
}
String orderBy = " ORDER BY tl_payment_plan.active_job_count DESC LIMIT 1";
String tables = " ";
Set<String> joinTableSet = new HashSet<String>();
String filter;
Object[] searchParams; // paramFilter: tl_payment_plan.object_id IS NOT NULL AND active_job_count IS NOT NULL
String preFilter = "(tl_payment_plan.object_id IS NOT NULL AND active_job_count IS NOT NULL)"
+ " ";
preFilter += context.getLoadingAttributes ().getCustomSQL() ;
SearchParamTransform tx = new SearchParamTransform (criteria);
filter = StringUtils.replaceParams (preFilter, tx);
searchParams = tx.getParamsArray();
Integer maxRows = context.getLoadingAttributes ().getMaxRows ();
boolean truncateExtra = !context.getLoadingAttributes ().isFailIfMaxExceeded();
String query = "SELECT " + SELECT_COLUMNS +
"FROM {PREFIX}tl_payment_plan " + tables + tableSetToSQL(joinTableSet) +
"WHERE " + SELECT_JOINS + " " + filter + orderBy;
BaseBusinessClass[] results = loadQuery (allPSets, sqlMgr, context, query, searchParams, maxRows, truncateExtra);
return results;
}
else else
{ {
......
...@@ -527,4 +527,10 @@ public class Utils ...@@ -527,4 +527,10 @@ public class Utils
.andActiveJobCount(new IsNotNullFilter<>()) .andActiveJobCount(new IsNotNullFilter<>())
.search(objTran); .search(objTran);
} }
public static PaymentPlan getMaximumPaymentPlan(ObjectTransaction objTran)
{
return PaymentPlan.SearchByMax().search(objTran);
}
} }
\ No newline at end of file
...@@ -6052,7 +6052,7 @@ input{ ...@@ -6052,7 +6052,7 @@ input{
} }
.payment-job-det { .payment-job-det {
width: 265px; width: 100%;
color: #777777; color: #777777;
font-family: "Usual-Light"; font-family: "Usual-Light";
font-size: 12px; font-size: 12px;
...@@ -6195,4 +6195,9 @@ input{ ...@@ -6195,4 +6195,9 @@ input{
.footer-note a{ .footer-note a{
color: #03A0E7; color: #03A0E7;
text-decoration: underline; text-decoration: underline;
}
.select-plan.disabled button{
background-color: #939393 !important;
border-color: #939393 !important;
} }
\ No newline at end of file
...@@ -38,20 +38,25 @@ ...@@ -38,20 +38,25 @@
{ {
recalcFunction = setupRecalc ($("form"), {'recalcOnError':true}); recalcFunction = setupRecalc ($("form"), {'recalcOnError':true});
addPostRecalcHandler(function ($fieldThatChanged) {
if (! $fieldThatChanged) {
return;
}
var name = $fieldThatChanged.attr('name');
if (typeof name !== typeof undefined && name !== false) {
if ( name.indexOf('PaymentJobCount') >= 0 ) {
validate();
}
}
});
validate(); validate();
$('input').on('change keyup', function() { validate() }); $('input').on('change keyup', function() { validate() });
}); });
function validate() { function validate() {
var empty = false; if ($('.select-plan').hasClass('disabled')) {
$('input').each(function() {
if ($( this ).val() == '') {
empty = true;
}
});
if (empty) {
$('.save-btn').attr('disabled', 'disabled'); $('.save-btn').attr('disabled', 'disabled');
} else { } else {
$('.save-btn').removeAttr('disabled'); $('.save-btn').removeAttr('disabled');
...@@ -100,33 +105,33 @@ ...@@ -100,33 +105,33 @@
</div> </div>
</div> </div>
<div class="a-label-row text-center"> <div class="a-label-row text-center">
<oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green save-btn" <oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'select-plan enabled': 'select-plan disabled'" company="<%= company %>">
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) <oneit:button value="Select Plan" name="saveJob" cssClass="btn btn-primary largeBtn btn-green save-btn"
.mapEntry ("fromPage", fromPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.mapEntry("JobStatus", JobStatus.OPEN) .mapEntry ("fromPage", fromPage)
.mapEntry ("restartProcess", Boolean.TRUE) .mapEntry("JobStatus", JobStatus.OPEN)
.mapEntry ("attribNamesToRestore", Collections.singleton("Job")) .mapEntry ("restartProcess", Boolean.TRUE)
.toMap() %>" /> .mapEntry ("attribNamesToRestore", Collections.singleton("Job"))
.toMap() %>" />
</oneit:recalcClass>
</div> </div>
<div class="a-label-row text-center"> <div class="a-label-row text-center">
<div class="col-md-4 col-sm-4 col-xs-4"> <div class="col-md-12 col-sm-12 col-xs-12 text-center">
</div>
<div class="col-md-6 col-sm-6 col-xs-6 text-center">
<div class="payment-job-det "> <div class="payment-job-det ">
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>"> <oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<oneit:recalc mode="EscapeHTML" script="company.getPaymentPlanAmount()" company="<%= company %>" nullValue=""/> <oneit:recalc mode="Currency" script="company.getPaymentPlanAmount()" company="<%= company %>" nullValue=""/>
Monthly for up to Monthly for up to
<oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/> <oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/>
jobs / month jobs / month
Save <div>
<oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/> Save
per month <oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/>
per month
</div>
</oneit:recalcClass> </oneit:recalcClass>
</div> </div>
</div> </div>
<div class="col-md-2 col-sm-2 col-xs-2">
</div>
</div> </div>
</div> </div>
......
...@@ -163,16 +163,16 @@ ...@@ -163,16 +163,16 @@
<oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>"> <oneit:recalcClass htmlTag="span" classScript="company.getPaymentPlanAmount()!=null ? 'show': 'hide'" company="<%= company %>">
<div class="a-label-row text-center"> <div class="a-label-row text-center">
<div class="col-md-3 col-sm-3 col-xs-3"> <div class="col-md-12 col-sm-12 col-xs-12 payment-job-det text-center">
</div>
<div class="col-md-6 col-sm-6 col-xs-6 payment-job-det text-center">
<oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/> <oneit:toString value="<%= PaymentPlan.PER_PER_JOB_AMOUNT %>" mode="Currency"/>
Monthly for up to Monthly for up to
<oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/> <oneit:recalc mode="EscapeHTML" script="company.getPaymentJobCount()" company="<%= company %>" nullValue=""/>
jobs / month jobs / month
Save <div>
<oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/> Save
per month <oneit:recalc mode="Currency" script="company.getPaymentPlanSaveAmount()" company="<%= company %>" nullValue=""/>
per month
</div>
</div> </div>
<div class="col-md-3 col-sm-3 col-xs-3"> <div class="col-md-3 col-sm-3 col-xs-3">
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment