⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findpayment.bsh

📁 国外的一套开源CRM
💻 BSH
字号:
/*
 *  Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a 
 *  copy of this software and associated documentation files (the "Software"), 
 *  to deal in the Software without restriction, including without limitation 
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
 *  and/or sell copies of the Software, and to permit persons to whom the 
 *  Software is furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included 
 *  in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 *  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
 *  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 
 *  OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
 *  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 *@author     Andy Zeneski (jaz@ofbiz.org)
 *@version    $Revision: 1.3 $
 *@since      3.0
*/

import java.util.*;
import java.sql.Timestamp;
import org.ofbiz.entity.*;
import org.ofbiz.entity.condition.*;
import org.ofbiz.base.util.*;

delegator = request.getAttribute("delegator");

// get the payment types
paymentTypes = delegator.findAll("PaymentType", UtilMisc.toList("description"));
context.put("paymentTypes", paymentTypes);

// get the payment statuses
paymentStatuses = delegator.findByAnd("StatusItem", UtilMisc.toMap("statusTypeId", "PMNT_STATUS"), UtilMisc.toList("sequenceId", "description"));
context.put("paymentStatuses", paymentStatuses);

// get the payment method types
paymentMethodTypes = delegator.findAll("PaymentMethodType", UtilMisc.toList("description"));
context.put("paymentMethodTypes", paymentMethodTypes);

// current selected status
currentStatusId = request.getParameter("paymentStatusId");
if (currentStatusId != null && currentStatusId.length() > 0) {
    currentStatus = delegator.findByPrimaryKey("StatusItem", UtilMisc.toMap("statusId", currentStatusId));
    context.put("currentStatus", currentStatus);
}

// current selected payment method
currentMethodId = request.getParameter("paymentMethodTypeId");
if (currentMethodId != null && currentMethodId.length() > 0) {
    currentMethod = delegator.findByPrimaryKey("PaymentMethodType", UtilMisc.toMap("paymentMethodTypeId", currentMethodId));
    context.put("currentMethod", currentMethod);
}


// create the fromDate for calendar
fromCal = Calendar.getInstance();
fromCal.setTime(new java.util.Date());
//fromCal.set(Calendar.DAY_OF_WEEK, fromCal.getActualMinimum(Calendar.DAY_OF_WEEK));
fromCal.set(Calendar.HOUR_OF_DAY, fromCal.getActualMinimum(Calendar.HOUR_OF_DAY));
fromCal.set(Calendar.MINUTE, fromCal.getActualMinimum(Calendar.MINUTE));
fromCal.set(Calendar.SECOND, fromCal.getActualMinimum(Calendar.SECOND));
fromCal.set(Calendar.MILLISECOND, fromCal.getActualMinimum(Calendar.MILLISECOND));
fromTs = new Timestamp(fromCal.getTimeInMillis());
fromStr = fromTs.toString();
fromStr = fromStr.substring(0, fromStr.indexOf('.'));
context.put("fromDateStr", fromStr);

// create the thruDate for calendar
toCal = Calendar.getInstance();
toCal.setTime(new java.util.Date());
//toCal.set(Calendar.DAY_OF_WEEK, toCal.getActualMaximum(Calendar.DAY_OF_WEEK));
toCal.set(Calendar.HOUR_OF_DAY, toCal.getActualMaximum(Calendar.HOUR_OF_DAY));
toCal.set(Calendar.MINUTE, toCal.getActualMaximum(Calendar.MINUTE));
toCal.set(Calendar.SECOND, toCal.getActualMaximum(Calendar.SECOND));
toCal.set(Calendar.MILLISECOND, toCal.getActualMaximum(Calendar.MILLISECOND));
toTs = new Timestamp(toCal.getTimeInMillis());
toStr = toTs.toString();
context.put("thruDateStr", toStr);

// get the lookup flag
lookupFlag = request.getParameter("lookupFlag");

// blank param list
paramList = "";

paymentList = null;
if (lookupFlag != null) {
    paramList = paramList + "&lookupFlag=" + lookupFlag;
    lookupErrorMessage = null;   
    andExprs = new ArrayList();
    entityName = "Payment"; 
           
    // define the main condition
    mainCond = null;
    
    // now do the filtering
    if (lookupErrorMessage == null) {               
        paymentType = request.getParameter("paymentType");
        paymentStatus = request.getParameter("paymentStatusId");
        paymentMethodType = request.getParameter("paymentMethodTypeId");
        fromPartyId = request.getParameter("fromPartyId");
        toPartyId = request.getParameter("toPartyId");
        minDate = request.getParameter("minDate");
        maxDate = request.getParameter("maxDate");
                
        if (paymentType == null) paymentType = "ANY";
        if (paymentStatus == null) paymentStatus = "ANY";
        if (paymentMethodType == null) paymentMethodType = "ANY";
                
        paramList = paramList + "&paymentTypeId=" + paymentType;        
        if (!"ANY".equals(paymentType)) {            
            andExprs.add(new EntityExpr("paymentTypeId", EntityOperator.EQUALS, paymentType));
        }
        paramList = paramList + "&paymentStatusId=" + paymentStatus;
        if (!"ANY".equals(paymentStatus)) {            
            andExprs.add(new EntityExpr("statusId", EntityOperator.EQUALS, paymentStatus));
        }
        paramList = paramList + "&paymentMethodTypeId=" + paymentMethodType;
        if (!"ANY".equals(paymentMethodType)) {            
            andExprs.add(new EntityExpr("paymentMethodTypeId", EntityOperator.EQUALS, paymentMethodType));
        }
        
        if (UtilValidate.isNotEmpty(fromPartyId)) {
            paramList = paramList + "&fromPartyId=" + fromPartyId;
            andExprs.add(new EntityExpr("partyIdFrom", EntityOperator.EQUALS, fromPartyId));
            context.put("fromPartyId", fromPartyId);
        }
        
        if (UtilValidate.isNotEmpty(toPartyId)) {
            paramList = paramList + "&toPartyId=" + toPartyId;
            andExprs.add(new EntityExpr("partyIdTo", EntityOperator.EQUALS, toPartyId));
            context.put("toPartyId", toPartyId);
        }
       
        if (minDate != null && minDate.length() > 8) {            
            minDate = minDate.trim();
            if (minDate.length() < 14) minDate = minDate + " " + "00:00:00.000";
            paramList = paramList + "&minDate=" + minDate;
            andExprs.add(new EntityExpr("effectiveDate", EntityOperator.GREATER_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(minDate, "Timestamp", null, null)));        
        }
        if (maxDate != null && maxDate.length() > 8) {
            maxDate = maxDate.trim();
            if (maxDate.length() < 14) maxDate = maxDate + " " + "23:59:59.999";
            paramList = paramList + "&maxDate=" + maxDate;
            andExprs.add(new EntityExpr("effectiveDate", EntityOperator.LESS_THAN_EQUAL_TO, ObjectType.simpleTypeConvert(maxDate, "Timestamp", null, null)));
        }
                
        mainCond = new EntityConditionList(andExprs, EntityOperator.AND);        
                                                       
    }
    
    if (lookupErrorMessage == null && mainCond != null) {
        // do the lookup
        paymentList = delegator.findByCondition(entityName, mainCond, null, UtilMisc.toList("-effectiveDate"));
        Debug.log("" + paymentList);         
    }
    
    context.put("paymentList", paymentList);
    
    if (lookupErrorMessage != null) {
        context.put("lookupErrorMessage", lookupErrorMessage);
    }
}

context.put("paramList", paramList);

// set the page parameters
viewIndex = 0;
try {
    viewIndex = Integer.valueOf((String) request.getParameter("VIEW_INDEX")).intValue();
} catch (Exception e) {
    viewIndex = 0;
}

viewSize = 20;
try {
    viewSize = Integer.valueOf((String) request.getParameter("VIEW_SIZE")).intValue();
} catch (Exception e) {
    viewSize = 20;
}

listSize = 0;
if (paymentList != null) {
    listSize = paymentList.size();
}

lowIndex = viewIndex * viewSize;
highIndex = (viewIndex + 1) * viewSize;
if (listSize < highIndex) {
    highIndex = listSize;
}
context.put("viewIndex", viewIndex);
context.put("listSize", listSize);
context.put("highIndex", highIndex);
context.put("lowIndex", lowIndex);
context.put("viewSize", viewSize);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -