Skip to content

Instantly share code, notes, and snippets.

@gregmoser
Last active August 29, 2015 13:56
Show Gist options
  • Save gregmoser/8854139 to your computer and use it in GitHub Desktop.
Save gregmoser/8854139 to your computer and use it in GitHub Desktop.
<cffunction name="getFulfillmentsByDate">
<cfargument name="shipDate" default="#now()#" />
<cfset var rs = "" />
<cfset var nextDayDate = dateAdd('d', -1, arguments.shipDate) />
<cfset var twoDayDate = dateAdd('d', -2, arguments.shipDate) />
<cfset var threeDayDate = dateAdd('d', -3, arguments.shipDate) />
<cfset var groundDayDate = dateAdd('d', -5, arguments.shipDate) />
<!--- Firday --->
<cfif dayOfWeek(arguments.shipDate) gte 6>
<cfset var nextDayDate = dateAdd('d', -2, nextDayDate) />
<cfset var twoDayDate = dateAdd('d', -2, twoDayDate) />
<cfset var threeDayDate = dateAdd('d', -2, threeDayDate) />
<cfset var groundDayDate = dateAdd('d', -2, groundDayDate) />
<!--- Thursday --->
<cfelseif dayOfWeek(arguments.shipDate) eq 5>
<cfset var twoDayDate = dateAdd('d', -2, twoDayDate) />
<cfset var threeDayDate = dateAdd('d', -2, threeDayDate) />
<cfset var groundDayDate = dateAdd('d', -2, groundDayDate) />
<!--- Wednesday --->
<cfelseif dayOfWeek(arguments.shipDate) eq 4>
<cfset var threeDayDate = dateAdd('d', -2, threeDayDate) />
<cfset var groundDayDate = dateAdd('d', -2, groundDayDate) />
<!--- Tuesday --->
<cfelseif dayOfWeek(arguments.shipDate) eq 4>
<cfset var groundDayDate = dateAdd('d', -2, groundDayDate) />
</cfif>
<cfquery name="rs">
SELECT
SwOrderFulfillment.orderFulfillmentID,
SwOrder.orderNumber,
SwShippingMethod.shippingMethodName
FROM
SwOrderFulfillment
INNER JOIN
SwShippingMethod on SwOrderFulfillment.shippingMethodID = SwShippingMethod.shippingMethodID
INNER JOIN
SwOrder on SwOrderFulfillment.orderID = SwOrder.orderID
INNER JOIN
SwAccount on SwOrder.accountID = SwAccount.accountID
INNER JOIN
SwAttributeValue as deliveryDateAV on SwOrder.orderID = deliveryDateAV.orderID AND deliveryDateAV.attributeID = 'ff80808143dfcb9b0143f3fa9f8602e8'
WHERE
SwOrder.orderStatusTypeID in ('444df2b5c8f9b37338229d4f7dd84ad1', '444df2b6b8b5d1ccfc14a4ab38aa0a4c')
AND (
(SwShippingMethod.shippingMethodID = 'ff80808143dfcb9b0143f410d7440307' AND deliveryDateAV.attributeValue <= <cfqueryparam cfsqltype="cf_sql_varchar" value="#nextDayDate#" />)
OR
(SwShippingMethod.shippingMethodID = 'ff808081429b7f140142c70c00a905c4' AND deliveryDateAV.attributeValue <= <cfqueryparam cfsqltype="cf_sql_varchar" value="#twoDayDate#" />)
OR
(SwShippingMethod.shippingMethodID = 'ff8080814375dd6601438d8cbf9d02c9' AND deliveryDateAV.attributeValue <= <cfqueryparam cfsqltype="cf_sql_varchar" value="#threeDayDate#" />)
OR
(SwShippingMethod.shippingMethodID = 'ff80808143dfcb9b0143e9a9b81801db' AND deliveryDateAV.attributeValue <= <cfqueryparam cfsqltype="cf_sql_varchar" value="#groundDayDate#" />)
)
</cfquery>
<cfreturn rs />
</cffunction>
<cfset todaysShipments = getFulfillmentsByDate( now() ) />
<cfoutput>
<h1>TODAYS SHIPMENTS (AND OVERDUE)</h1>
<table>
<tr>
<th>Order Number</th>
<th>Shipping Method</th>
<th></th>
</tr>
<cfloop query="todaysShipments">
<tr>
<td>#todaysShipments.orderNumber#</td>
<td>#todaysShipments.shippingMethodName#</td>
<td>
<a title="Fulfill Items" class="adminentitypreprocessorderfulfillment modalload" href="?slatAction=entity.preprocessorderfulfillment&amp;processContext=fulfillItems&amp;orderFulfillmentID=402881c140e4ce650141195b9af70763" data-toggle="modal" data-target="##adminModal">Fulfill Items</a>
</td>
</tr>
</cfloop>
</table>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment