1025 lines
25 KiB
C++
1025 lines
25 KiB
C++
// ArasClientRequests.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "sp.h"
|
|
#include "ArasClientRequests.h"
|
|
#include "WOHeaderDlg.h"
|
|
#include ".\arasclientrequests.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CArasClientRequests dialog
|
|
|
|
|
|
CArasClientRequests::CArasClientRequests(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CArasClientRequests::IDD, pParent)
|
|
, m_bReadOnly(false)
|
|
{
|
|
//{{AFX_DATA_INIT(CArasClientRequests)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_pApp = (CSpApp*)AfxGetApp();
|
|
|
|
rsPrint=m_pApp->rsPool->GetRSPrint("CArasClientRequests rsPrint");
|
|
|
|
|
|
rs=m_pApp->rsPool->GetRS("CArasClientRequests");
|
|
|
|
m_strCriteria="WHERE (((client_requests.workorderid)=0))";
|
|
m_strOrderBy="ORDER BY client_requests.created DESC , client_requests.urgency, clients.company";
|
|
|
|
|
|
}
|
|
|
|
CArasClientRequests::~CArasClientRequests()
|
|
{
|
|
|
|
m_pApp->rsPool->ReleaseRS(&rsPrint->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
|
}
|
|
void CArasClientRequests::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CArasClientRequests)
|
|
DDX_Control(pDX, IDC_LBL_DETAILS, m_lblDetails);
|
|
DDX_Control(pDX, IDC_LBL_BRIEF, m_lblBrief);
|
|
DDX_Control(pDX, IDC_EDDETAILS, m_edDetails);
|
|
DDX_Control(pDX, IDC_EDBRIEF, m_edBrief);
|
|
DDX_Control(pDX, IDOK, m_btnOK);
|
|
DDX_Control(pDX, IDC_REPORT, m_rc);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CArasClientRequests, CDialog)
|
|
//{{AFX_MSG_MAP(CArasClientRequests)
|
|
ON_COMMAND(ID_ARAS_REQUESTS_CLOSE, OnArasRequestsClose)
|
|
ON_NOTIFY(RVN_COLUMNCLICK, IDC_REPORT, OnColumnClick)
|
|
ON_NOTIFY(RVN_ITEMDBCLICK, IDC_REPORT, OnRvnItemDbClick)
|
|
ON_NOTIFY(RVN_ITEMCLICK, IDC_REPORT, OnRvnItemClick)
|
|
ON_COMMAND(ID_ARAS_REQUESTS_MAKE_WORKORDER, OnArasRequestsMakeWorkorder)
|
|
ON_COMMAND(ID_ARAS_REQUESTS_REJECT, OnArasRequestsReject)
|
|
//}}AFX_MSG_MAP
|
|
ON_COMMAND(ID_ARAS_REQUESTS_REFRESH, OnArasRequestsRefresh)
|
|
ON_WM_TIMER()
|
|
ON_WM_INITMENUPOPUP()
|
|
ON_UPDATE_COMMAND_UI(ID_ARAS_REQUESTS_MAKE_WORKORDER, OnUpdateArasRequestsMakeWorkorder)
|
|
ON_UPDATE_COMMAND_UI(ID_ARAS_REQUESTS_REJECT, OnUpdateArasRequestsReject)
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CArasClientRequests message handlers
|
|
|
|
void CArasClientRequests::OnOK()
|
|
{}
|
|
|
|
void CArasClientRequests::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu)
|
|
{
|
|
ASSERT(pPopupMenu != NULL);
|
|
// Check the enabled state of various menu items.
|
|
|
|
CCmdUI state;
|
|
state.m_pMenu = pPopupMenu;
|
|
ASSERT(state.m_pOther == NULL);
|
|
ASSERT(state.m_pParentMenu == NULL);
|
|
|
|
// Determine if menu is popup in top-level menu and set m_pOther to
|
|
// it if so (m_pParentMenu == NULL indicates that it is secondary popup).
|
|
HMENU hParentMenu;
|
|
if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
|
|
state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
|
|
else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
|
|
{
|
|
CWnd* pParent = this;
|
|
// Child windows don't have menus--need to go to the top!
|
|
if (pParent != NULL &&
|
|
(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
|
|
{
|
|
int nIndexMax = ::GetMenuItemCount(hParentMenu);
|
|
for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
|
|
{
|
|
if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
|
|
{
|
|
// When popup is found, m_pParentMenu is containing menu.
|
|
state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
|
|
for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
|
|
state.m_nIndex++)
|
|
{
|
|
state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
|
|
if (state.m_nID == 0)
|
|
continue; // Menu separator or invalid cmd - ignore it.
|
|
|
|
ASSERT(state.m_pOther == NULL);
|
|
ASSERT(state.m_pMenu != NULL);
|
|
if (state.m_nID == (UINT)-1)
|
|
{
|
|
// Possibly a popup menu, route to first item of that popup.
|
|
state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
|
|
if (state.m_pSubMenu == NULL ||
|
|
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
|
|
state.m_nID == (UINT)-1)
|
|
{
|
|
continue; // First item of popup can't be routed to.
|
|
}
|
|
state.DoUpdate(this, TRUE); // Popups are never auto disabled.
|
|
}
|
|
else
|
|
{
|
|
// Normal menu item.
|
|
// Auto enable/disable if frame window has m_bAutoMenuEnable
|
|
// set and command is _not_ a system command.
|
|
state.m_pSubMenu = NULL;
|
|
state.DoUpdate(this, FALSE);
|
|
}
|
|
|
|
// Adjust for menu deletions and additions.
|
|
UINT nCount = pPopupMenu->GetMenuItemCount();
|
|
if (nCount < state.m_nIndexMax)
|
|
{
|
|
state.m_nIndex -= (state.m_nIndexMax - nCount);
|
|
while (state.m_nIndex < nCount &&
|
|
pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
|
|
{
|
|
state.m_nIndex++;
|
|
}
|
|
}
|
|
state.m_nIndexMax = nCount;
|
|
}
|
|
}
|
|
|
|
//DO NOTHING FOR NOW BUT LEFT IN CASE NEEDED IN FUTURE
|
|
void CArasClientRequests::OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
LPNMREPORTVIEW lpnmrv = (LPNMREPORTVIEW)pNMHDR;
|
|
|
|
|
|
|
|
if(lpnmrv->iItem >=0)//-1 if clicked on invalid
|
|
{
|
|
/*
|
|
CLoanersEditDlg d;
|
|
CString item=m_rc.GetItemText(lpnmrv->iItem,6);
|
|
d.SetRentalID(&item);
|
|
if(d.DoModal()==IDOK)
|
|
FillView();
|
|
*/
|
|
|
|
|
|
}
|
|
|
|
*pResult = FALSE;
|
|
}
|
|
|
|
//clicked on an item to view it in fields on this screen
|
|
void CArasClientRequests::OnRvnItemClick(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
|
|
LPNMREPORTVIEW lpnmrv = (LPNMREPORTVIEW)pNMHDR;
|
|
|
|
|
|
|
|
if(lpnmrv->iItem >=0)//-1 if clicked on invalid
|
|
{
|
|
|
|
|
|
m_lCurrentItem=atol(m_rc.GetItemText(lpnmrv->iItem,6));
|
|
FillFields();
|
|
|
|
|
|
}
|
|
|
|
*pResult = FALSE;
|
|
}
|
|
void CArasClientRequests::Security()
|
|
{
|
|
m_bReadOnly=false;
|
|
int x=m_pApp->Allowed(RARASREQUESTS,true);
|
|
|
|
if(x==2)//read only
|
|
{
|
|
m_bReadOnly=true;
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->EnableMenuItem(ID_ARAS_REQUESTS_MAKE_WORKORDER,MF_DISABLED | MF_GRAYED);
|
|
pMenu->EnableMenuItem(ID_ARAS_REQUESTS_REJECT,MF_DISABLED | MF_GRAYED);
|
|
|
|
this->DrawMenuBar();
|
|
|
|
}
|
|
|
|
|
|
if(x==0)
|
|
{
|
|
m_bReadOnly=true;
|
|
m_pApp->SecurityWarning();
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
BOOL CArasClientRequests::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
ShowWindow(SW_HIDE);
|
|
Security();
|
|
CWaitCursor wait;
|
|
//defaults
|
|
|
|
CString profile,q;
|
|
q.Format("SELECT users.aras_req_profile "
|
|
"FROM users WHERE (((users.id)=%u));",m_pApp->m_lusrID);
|
|
rs->Query(q);
|
|
rs->FetchField("aras_req_profile",&profile);
|
|
|
|
|
|
|
|
m_ilReport.Create(IDB_BM2, 16, 1, RGB(255,0,255));
|
|
m_rc.SetImageList(&m_ilReport);
|
|
|
|
//ShowWindow(SW_MAXIMIZE);
|
|
|
|
m_rc.InsertColor(0, 0x00C0D8C0);
|
|
m_rc.InsertColor(1, ::GetSysColor(COLOR_GRAYTEXT));
|
|
m_rc.InsertColor(2, 0x00D0C0C0);
|
|
m_rc.InsertColor(3, 0x00804000);
|
|
|
|
|
|
RVCOLUMN rvc;
|
|
|
|
rvc.nFormat = RVCF_TEXT|RVCF_EX_AUTOWIDTH|RVCF_EX_FIXEDWIDTH|RVCF_SUBITEM_IMAGE;
|
|
rvc.iImage = 1;
|
|
rvc.lpszText = _T("Urgency");
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(0, &rvc);
|
|
|
|
rvc.nFormat = RVCF_TEXT;
|
|
rvc.lpszText = "Date";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(1, &rvc);
|
|
|
|
rvc.lpszText = "Client";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(2, &rvc);
|
|
|
|
rvc.lpszText = "User";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(3, &rvc);
|
|
|
|
rvc.nFormat = RVCF_TEXT;
|
|
rvc.lpszText = "Problem";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(4, &rvc);
|
|
|
|
rvc.lpszText = "Ref#";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(5, &rvc);
|
|
|
|
rvc.nFormat = RVCF_TEXT | RVCF_EX_FIXEDWIDTH;
|
|
rvc.lpszText = "id";
|
|
rvc.iWidth = 0;
|
|
m_rc.DefineColumn(6, &rvc);
|
|
/*
|
|
rvc.nFormat = RVCF_TEXT;
|
|
rvc.lpszText = "Ref";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(7, &rvc);
|
|
|
|
rvc.nFormat = RVCF_TEXT;
|
|
rvc.lpszText = "Desc.";
|
|
rvc.iWidth = 60;
|
|
m_rc.DefineColumn(8, &rvc);
|
|
*/
|
|
|
|
//setup according to users preferences
|
|
if(!profile.IsEmpty())
|
|
m_rc.GetProfile(&profile);
|
|
else
|
|
{
|
|
|
|
//not needed when setting by pref
|
|
//but if there are no preferences then you would need it
|
|
|
|
m_rc.ActivateColumn(0, 0);
|
|
m_rc.ActivateColumn(1, 1);
|
|
m_rc.ActivateColumn(2, 2);
|
|
m_rc.ActivateColumn(3, 3);
|
|
m_rc.ActivateColumn(4, 4);
|
|
m_rc.ActivateColumn(5, 5);
|
|
m_rc.ActivateColumn(6, 6);
|
|
//m_rc.ActivateColumn(7, 7);
|
|
//m_rc.ActivateColumn(8, 8);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
m_rc.ModifyStyle(0, RVS_SINGLESELECT);
|
|
//m_rc.ModifyStyle(0, RVS_SHOWCOLORALTERNATE);
|
|
|
|
|
|
//turn off the grids
|
|
m_rc.ModifyStyle(RVS_SHOWVGRID, 0);
|
|
m_rc.ModifyStyle(RVS_SHOWHGRID, 0);
|
|
|
|
|
|
|
|
//retrieve the loaner items and display them
|
|
FillView();
|
|
//===================================================
|
|
// SET WINDOW SIZE TO MATCH WORK AREA
|
|
ShowWindow(SW_SHOWMAXIMIZED);
|
|
CRect workarea;
|
|
SystemParametersInfo(SPI_GETWORKAREA,0,&workarea,0);
|
|
SetWindowPos(NULL,workarea.left,workarea.top,workarea.Width(),workarea.Height(),SWP_NOZORDER);
|
|
//===================================================
|
|
LayoutControls();
|
|
|
|
|
|
//AUTOREFRESH TIMER
|
|
if(m_pApp->m_lSchedRefreshSecs!=0)
|
|
m_nTimer = SetTimer(2, 1000*m_pApp->m_lSchedRefreshSecs, 0);
|
|
|
|
|
|
//ShowWindow(SW_MAXIMIZE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
|
|
|
|
void CArasClientRequests::FillView()
|
|
{
|
|
CWaitCursor cw;
|
|
CString q;
|
|
COleDateTime dtDefault;
|
|
dtDefault.SetDate(1968,03,12);
|
|
int x=0;
|
|
q.Format("SELECT client_requests.*, clients.company, clients_aras.loginid "
|
|
"FROM (client_requests LEFT JOIN clients ON client_requests.clientlink = clients.id) LEFT JOIN clients_aras ON client_requests.requestor_id = clients_aras.id "
|
|
"%s %s;",m_strCriteria,m_strOrderBy);
|
|
|
|
|
|
|
|
rs->Query(q);
|
|
//m_pApp->ShowStuff(q);
|
|
m_rc.DeleteAllItems();
|
|
m_lCurrentItem=-1;
|
|
|
|
if(rs->IsEmpty())
|
|
return;
|
|
|
|
|
|
|
|
|
|
CString strData;
|
|
COleDateTime dtData;
|
|
long lData;
|
|
rs->MoveFirst();
|
|
|
|
|
|
do
|
|
{
|
|
|
|
|
|
|
|
//Set the look of the row and insert it
|
|
|
|
//urgency
|
|
rs->FetchField("urgency",&lData);
|
|
RVITEM rvi;
|
|
rvi.iItem = x;
|
|
rvi.iSubItem = 0;
|
|
rvi.nMask = RVIM_IMAGE|RVIM_PREVIEW|RVIM_STATE|RVIM_LPARAM;
|
|
rvi.nState = 0;
|
|
rvi.nPreview = 0;//no preview necessary
|
|
|
|
switch(lData)
|
|
{
|
|
case 0:
|
|
rvi.iImage=0;//green
|
|
break;
|
|
case 1://asap
|
|
rvi.iImage=1;//orange light
|
|
break;
|
|
case 2://emergency
|
|
rvi.iImage=2;//redlight
|
|
break;
|
|
}
|
|
|
|
|
|
rvi.lParam = x;
|
|
m_rc.InsertItem(&rvi);
|
|
|
|
|
|
//Date
|
|
rs->FetchField("created",&dtData);
|
|
strData=dtData.Format();
|
|
rvi.iSubItem = 1;
|
|
rvi.nMask = RVIM_TEXT;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
//Client
|
|
rs->FetchField("company",&strData);
|
|
rvi.iSubItem = 2;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
//Requestor
|
|
rs->FetchField("loginid",&strData);
|
|
rvi.iSubItem = 3;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
//problem
|
|
rs->FetchField("request",&strData);
|
|
rvi.iSubItem = 4;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
//refnum
|
|
rs->FetchField("refnum",&strData);
|
|
rvi.iSubItem = 5;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
|
|
//ID
|
|
rs->FetchField("id",&lData);
|
|
strData.Format("%u",lData);
|
|
rvi.iSubItem = 6;
|
|
rvi.lpszText = strData.GetBuffer(strData.GetLength());
|
|
m_rc.SetItem(&rvi);
|
|
|
|
|
|
|
|
x++;
|
|
|
|
}while(rs->MoveForward());
|
|
|
|
|
|
}
|
|
|
|
/*
|
|
//*********************************************
|
|
void CLoanersDlg::OnBtndone()
|
|
{
|
|
CString profile,q;
|
|
//save to user prefs.
|
|
m_rc.WriteProfile(&profile);
|
|
q.Format("UPDATE users SET users.rentalprofile = \"%s\" "
|
|
"WHERE (((users.id)=%u));",profile,m_pApp->m_lusrID);
|
|
rs->Ex(q);
|
|
CDialog::OnOK();
|
|
|
|
}
|
|
|
|
void CLoanersDlg::OnBtnadd()
|
|
{
|
|
|
|
CLoanersEditDlg d;
|
|
if(d.DoModal()==IDOK)
|
|
FillView();
|
|
|
|
}
|
|
|
|
void CLoanersDlg::OnBtndelete()
|
|
{
|
|
int x;
|
|
CString q,strID;
|
|
x=m_rc.GetFirstSelectedItem();
|
|
if(x<0) return;//no selection
|
|
if(AfxMessageBox("Delete the highlighted item? Are you sure?",MB_YESNO)==IDNO)
|
|
return;
|
|
|
|
strID=m_rc.GetItemText(x,6);
|
|
|
|
q.Format("DELETE rentals.* FROM rentals WHERE (((rentals.id)=%s));",strID);
|
|
rs->Ex(q);
|
|
FillView();
|
|
|
|
|
|
}
|
|
|
|
|
|
//SET CRITERIA FOR QUERY:
|
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
|
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
|
void CLoanersDlg::OnCkanydate()
|
|
{
|
|
m_nDateCriteriaX=0;
|
|
ShowDateFields(false);
|
|
Criteria();
|
|
}
|
|
|
|
void CLoanersDlg::OnCksentdate()
|
|
{
|
|
ShowDateFields(true);
|
|
m_nDateCriteriaX=(1);
|
|
Criteria();
|
|
}
|
|
|
|
void CLoanersDlg::OnCkduedate()
|
|
{
|
|
ShowDateFields(true);
|
|
m_nDateCriteriaX=(2);
|
|
Criteria();
|
|
}
|
|
|
|
void CLoanersDlg::OnCkreceiveddate()
|
|
{
|
|
|
|
ShowDateFields(true);
|
|
m_nDateCriteriaX=(3);
|
|
Criteria();
|
|
|
|
}
|
|
|
|
void CLoanersDlg::OnDatetimechangeDtto(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
Criteria();
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
//set date and type criteria and rebuild list
|
|
void CLoanersDlg::Criteria()
|
|
{
|
|
CString strFrom,strTo,strDatePart,strTypePart;
|
|
COleDateTime dtData;
|
|
m_ckAnyDate.SetCheck(FALSE);
|
|
m_ckDueDate.SetCheck(FALSE);
|
|
m_ckSentDate.SetCheck(FALSE);
|
|
m_ckShowAll.SetCheck(FALSE);
|
|
m_ckShowOut.SetCheck(FALSE);
|
|
m_ckShowReturned.SetCheck(FALSE);
|
|
m_ckReceivedDate.SetCheck(FALSE);
|
|
|
|
m_dtFrom.GetTime(dtData);
|
|
strFrom=dtData.Format(_T("%m/%d/%Y"));
|
|
|
|
m_dtTo.GetTime(dtData);
|
|
strTo=dtData.Format(_T("%m/%d/%Y"));
|
|
|
|
m_strCriteria.Empty();
|
|
|
|
switch(m_nDateCriteriaX)
|
|
{
|
|
|
|
case 1://sent date
|
|
m_ckSentDate.SetCheck(TRUE);
|
|
strDatePart.Format("((rentals.dateout) Between #%s# And #%s#)",strFrom,strTo);
|
|
break;
|
|
|
|
case 2://due date
|
|
m_ckDueDate.SetCheck(TRUE);
|
|
strDatePart.Format("((rentals.datedue) Between #%s# And #%s#)",strFrom,strTo);
|
|
break;
|
|
|
|
case 3://received date
|
|
m_ckReceivedDate.SetCheck(TRUE);
|
|
strDatePart.Format("((rentals.datereturn) Between #%s# And #%s#) AND ((rentals.returned)=True)",strFrom,strTo);
|
|
break;
|
|
|
|
default://any date
|
|
strDatePart.Empty();
|
|
m_ckAnyDate.SetCheck(TRUE);
|
|
break;
|
|
}
|
|
|
|
|
|
switch(m_nTypeCriteriaX)
|
|
{
|
|
|
|
case 1://returned
|
|
strTypePart=" ((rentals.returned)=True)";
|
|
|
|
m_ckShowReturned.SetCheck(TRUE);
|
|
break;
|
|
|
|
case 2://out
|
|
|
|
m_ckShowOut.SetCheck(TRUE);
|
|
strTypePart=" ((rentals.returned)=False)";
|
|
break;
|
|
|
|
default://all
|
|
m_ckShowAll.SetCheck(TRUE);
|
|
strTypePart.Empty();
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
//No criteria
|
|
if(strDatePart.IsEmpty() && strTypePart.IsEmpty())
|
|
{
|
|
m_strCriteria.Empty();
|
|
FillView();
|
|
return;
|
|
}
|
|
|
|
//both criteria
|
|
if(!strDatePart.IsEmpty() && !strTypePart.IsEmpty() )
|
|
{
|
|
|
|
m_strCriteria=" WHERE (" + strTypePart + " AND " + strDatePart + ")";
|
|
FillView();
|
|
return;
|
|
}
|
|
|
|
//only one criteria
|
|
if(!strTypePart.IsEmpty())
|
|
{
|
|
m_strCriteria = " WHERE (" + strTypePart+ ")";
|
|
FillView();
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
m_strCriteria=" WHERE (" + strDatePart+ ")";
|
|
FillView();
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void CLoanersDlg::OnBtnprint()
|
|
{
|
|
CString q;
|
|
COleDateTime dtDefault;
|
|
dtDefault.SetDate(1968,03,12);
|
|
q.Format("SELECT rentals.*, IIf(IsNull([sn]),[rentals].[description] & [parts].[description],[company_person] & "
|
|
"\" \" & [unitmodels].[description] & \" \" & [unitmodels].[model]) AS [desc], [rentals]![description] & "
|
|
"IIf(IsNull([parts]![partnumber]),\"\",\"part:\" & [parts]![partnumber]) & "
|
|
"IIf(IsNull([units]![sn]),\"\",\"unit:\" & [units]![sn]) AS item, [loanedto] & "
|
|
"IIf(IsNull([clients]![company]),[clients]![first] & \" \" & [clients]![last],[clients]![company]) "
|
|
"AS rentor, Format([dateout],\"Short Date\") AS outdate, IIf([datedue]=#%s#,\"na\",Format([datedue], "
|
|
"\"Short Date\")) AS duedate, IIf([datereturn]=#%s#,\"Out\",Format([datereturn],\"Short Date\")) "
|
|
"AS retdate, DateDiff(\"d\",Now(),[datedue]) AS duedays "
|
|
"FROM ((((rentals LEFT JOIN clients ON rentals.clientlink = clients.id) LEFT JOIN "
|
|
"units ON rentals.unitlink = units.id) LEFT JOIN parts ON rentals.partlink = parts.id) "
|
|
"LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
|
"%s %s;",dtDefault.Format(_T("%m/%d/%Y")),
|
|
dtDefault.Format(_T("%m/%d/%Y")),m_strCriteria,m_strOrderBy);
|
|
|
|
rsPrint->QueryReadOnly(q);
|
|
if(rsPrint->IsEmpty())
|
|
{
|
|
AfxMessageBox("Nothing to print!");
|
|
return;
|
|
}
|
|
|
|
|
|
//m_pApp->CreateTTX("loaners.ttx",rsPrint->RecordSetPointer());
|
|
m_pApp->PrintCMReport("loaners",rsPrint->RecordSetPointer());
|
|
|
|
|
|
}
|
|
*/
|
|
|
|
|
|
void CArasClientRequests::OnArasRequestsClose()
|
|
{
|
|
KillTimer(2);
|
|
CString profile,q;
|
|
//save to user prefs.
|
|
m_rc.WriteProfile(&profile);
|
|
q.Format("UPDATE users SET users.aras_req_profile = \"%s\" "
|
|
"WHERE (((users.id)=%u));",profile,m_pApp->m_lusrID);
|
|
rs->Ex(q);
|
|
CDialog::OnOK();
|
|
|
|
}
|
|
|
|
|
|
//SET ORDER BY CLAUSE DEPENDING ON CLICK HERE
|
|
void CArasClientRequests::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
int x;
|
|
CString str;
|
|
CFlatHeaderCtrl* header;
|
|
header=m_rc.GetHeaderCtrl();
|
|
|
|
|
|
//FIND CLICKED COLUMN
|
|
|
|
str=header->m_szHotItemText;
|
|
|
|
if(str=="Urgency"){x=0;goto OUTTAHERE;}
|
|
if(str=="Date"){x=1;goto OUTTAHERE;}
|
|
if(str=="Client"){x=2;goto OUTTAHERE;}
|
|
if(str=="User"){x=3;goto OUTTAHERE;}
|
|
if(str=="Problem"){x=4;goto OUTTAHERE;}
|
|
if(str=="Ref#"){x=5;goto OUTTAHERE;}
|
|
|
|
|
|
|
|
OUTTAHERE:
|
|
|
|
|
|
bColumnSortAsc[x]=!bColumnSortAsc[x];
|
|
switch(x)
|
|
{//DESC
|
|
case 0://urgency
|
|
m_strOrderBy="ORDER BY client_requests.urgency";
|
|
break;
|
|
case 1://Date
|
|
m_strOrderBy="ORDER BY client_requests.created";
|
|
break;
|
|
case 2://Client
|
|
m_strOrderBy="ORDER BY clients.company";
|
|
break;
|
|
case 3://User
|
|
m_strOrderBy="ORDER BY clients_aras.loginid";
|
|
break;
|
|
|
|
case 4://Problem
|
|
m_strOrderBy="ORDER BY client_requests.request";
|
|
break;
|
|
|
|
case 5://Ref#
|
|
m_strOrderBy="ORDER BY client_requests.refnum";
|
|
break;
|
|
|
|
//case 6: is id number so not sortable
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!bColumnSortAsc[x])
|
|
m_strOrderBy+=" DESC";
|
|
|
|
|
|
header->SetSortColumn(header->GetHotIndex(),bColumnSortAsc[x]);
|
|
|
|
*pResult = TRUE;//TRUE means we handled it here thanks anyway
|
|
FillView();
|
|
}
|
|
|
|
|
|
//response to a single click on an item
|
|
//fill work request and details boxes
|
|
void CArasClientRequests::FillFields()
|
|
{
|
|
if(m_lCurrentItem<1) return;
|
|
CString q;
|
|
long lUnitID=0;
|
|
|
|
q.Format("SELECT client_requests.request, client_requests.probdetails, client_requests.unitid "
|
|
"FROM client_requests WHERE (((client_requests.id)=%u));",m_lCurrentItem);
|
|
rs->QueryReadOnly(q);
|
|
if(rs->IsEmpty())
|
|
{
|
|
m_edBrief.SetWindowText("?");
|
|
m_edDetails.SetWindowText("?");
|
|
return;
|
|
}
|
|
|
|
rs->FetchField("request",&q);
|
|
m_edBrief.SetWindowText(q);
|
|
|
|
rs->FetchField("probdetails",&q);
|
|
m_edDetails.SetWindowText(q);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void CArasClientRequests::LayoutControls()
|
|
{
|
|
|
|
|
|
int nLeft,nTop,nWidth,nHeight;
|
|
CRect rectCtl1,rectCtl2,rectDlg;
|
|
GetClientRect(rectDlg);//client area needed for movewindow
|
|
//get client screen coordinates
|
|
nLeft=rectDlg.left;
|
|
nTop=rectDlg.top;
|
|
nWidth=rectDlg.Width();
|
|
nHeight=rectDlg.Height();
|
|
|
|
|
|
//MOVE and RESIZE CONTROLS STARTING FROM BOTTOM UP
|
|
|
|
//DETAILS EDIT BOX FIRST AS IS AT BOTTOM OF SCREEN
|
|
m_edDetails.GetWindowRect(rectCtl1);
|
|
m_edDetails.MoveWindow(nLeft,(nHeight-rectCtl1.Height()),nWidth,rectCtl1.Height(),TRUE);
|
|
|
|
//Details Label
|
|
m_edDetails.GetWindowRect(rectCtl1);
|
|
ScreenToClient(rectCtl1);//convert whole screen co-ords to client area
|
|
m_lblDetails.GetWindowRect(rectCtl2);
|
|
ScreenToClient(rectCtl2);//convert whole screen co-ords to client area
|
|
m_lblDetails.MoveWindow(nLeft,(rectCtl1.top-rectCtl2.Height()),rectCtl2.Width(),rectCtl2.Height(),TRUE);
|
|
|
|
//Brief box
|
|
m_lblDetails.GetWindowRect(rectCtl1);
|
|
ScreenToClient(rectCtl1);//convert whole screen co-ords to client area
|
|
m_edBrief.GetWindowRect(rectCtl2);
|
|
ScreenToClient(rectCtl2);//convert whole screen co-ords to client area
|
|
m_edBrief.MoveWindow(nLeft,(rectCtl1.top-rectCtl2.Height())-10,nWidth,rectCtl2.Height(),TRUE);
|
|
|
|
//Brief Label
|
|
m_edBrief.GetWindowRect(rectCtl1);
|
|
ScreenToClient(rectCtl1);//convert whole screen co-ords to client area
|
|
m_lblBrief.GetWindowRect(rectCtl2);
|
|
ScreenToClient(rectCtl2);//convert whole screen co-ords to client area
|
|
m_lblBrief.MoveWindow(nLeft,(rectCtl1.top-rectCtl2.Height()),rectCtl2.Width(),rectCtl2.Height(),TRUE);
|
|
|
|
//REPORT CONTROL
|
|
m_rc.GetWindowRect(rectCtl1);//windowrect is based on whole screen
|
|
m_lblBrief.GetWindowRect(rectCtl2);//based on upper left corner of screen not client area
|
|
ScreenToClient(rectCtl2);//convert whole screen co-ords to client area
|
|
nHeight=(rectDlg.top+rectCtl2.top)-10;//calculate height
|
|
m_rc.MoveWindow(rectDlg.left,rectDlg.top+10,rectDlg.Width(),nHeight-10,TRUE);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
void CArasClientRequests::OnArasRequestsMakeWorkorder()
|
|
{
|
|
CString q;
|
|
long lWOID;
|
|
long lRequestedTech;
|
|
long lClient;
|
|
long lUnitID=0;
|
|
CString strBrief;
|
|
CString strDetails;
|
|
CString strRefNum;
|
|
|
|
|
|
COleDateTime dtNow;
|
|
dtNow=COleDateTime::GetCurrentTime();
|
|
|
|
//m_pApp->m_lDefNewWOStatus;
|
|
|
|
if(m_lCurrentItem >=0)//-1 if clicked on invalid
|
|
{
|
|
|
|
if(AfxMessageBox("Are you sure you want to accept this request\r\nand make a new workorder?",MB_YESNO)==IDNO)
|
|
return;
|
|
//Get data
|
|
q.Format("SELECT client_requests.* FROM client_requests WHERE (((client_requests.id)=%u));",m_lCurrentItem);
|
|
rs->QueryReadOnly(q);
|
|
if(rs->IsEmpty())
|
|
{
|
|
AfxMessageBox("No can do...problem finding request record");
|
|
return;
|
|
|
|
}
|
|
|
|
rs->FetchField("clientlink",&lClient);
|
|
rs->FetchField("request",&strBrief);
|
|
rs->FetchField("probdetails",&strDetails);
|
|
rs->FetchField("prefertech",&lRequestedTech);
|
|
rs->FetchField("refnum",&strRefNum);
|
|
rs->FetchField("unitid",&lUnitID);
|
|
|
|
|
|
//1.9.3.0
|
|
if(strBrief.IsEmpty()) strBrief="Not provided by client";
|
|
if(strDetails.IsEmpty()) strDetails="No details provided";
|
|
if(strRefNum.IsEmpty()) strRefNum="na";
|
|
|
|
//Insert wo header
|
|
q.Format("INSERT INTO wo ( client, onsite, notes, assigntech, starttime, stoptime, creator, "
|
|
"created, ourref, status, clientrefnum ) "
|
|
"SELECT %u, %s, \"%s\",%i, #%s#, #%s#, %u, #%s#, \"%s\", %u, \"%s\";",
|
|
lClient, m_pApp->m_bDefOnsite ? "True" : "False", strBrief,lRequestedTech,
|
|
dtNow.Format(_T("%m/%d/%Y %H:%M:%S")),dtNow.Format(_T("%m/%d/%Y %H:%M:%S")),
|
|
m_pApp->m_lusrID,dtNow.Format(_T("%m/%d/%Y %H:%M:%S")),"Via ARAS",m_pApp->m_lDefNewWOStatus, strRefNum);
|
|
|
|
if(!rs->Ex(q,&lWOID))
|
|
{
|
|
AfxMessageBox("Problem inserting workorder header");
|
|
return;
|
|
}
|
|
|
|
|
|
//insert wo problem
|
|
q.Format("INSERT INTO probs ( wolink, brief, notes, unit, creator, created ) "
|
|
"SELECT %u, \"%s\", \"%s\", %u, %u, #%s#;",
|
|
lWOID,strBrief,strDetails, lUnitID,m_pApp->m_lusrID,dtNow.Format(_T("%m/%d/%Y %H:%M:%S")));
|
|
|
|
if(!rs->Ex(q))
|
|
{
|
|
AfxMessageBox("Problem inserting wo problem record");
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//update wo id number of request
|
|
q.Format("UPDATE client_requests SET client_requests.workorderid = %u "
|
|
"WHERE (((client_requests.id)=%u));",lWOID,m_lCurrentItem);
|
|
|
|
if(!rs->Ex(q))
|
|
{
|
|
AfxMessageBox("Problem updating request record with workorder ID number");
|
|
|
|
}
|
|
|
|
|
|
|
|
//Show Workorder
|
|
rs->Close();
|
|
m_pApp->m_bRefreshStatScreen=true;//bug bug, doesn't cause a refresh when return to STAT
|
|
CWOHeaderDlg wo;
|
|
q.Format("%u",lWOID);
|
|
wo.SetWorkorderID(q);
|
|
wo.DoModal();
|
|
|
|
|
|
FillView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CArasClientRequests::OnArasRequestsReject()
|
|
{
|
|
CString q;
|
|
if(m_lCurrentItem >=0)//-1 if clicked on invalid
|
|
{
|
|
|
|
if(AfxMessageBox("Are you sure you want to reject this request?",MB_YESNO)==IDNO)
|
|
return;
|
|
|
|
//They're sure..delete it. Well not actually, just set woid to -1 to exclude from view
|
|
q.Format("UPDATE client_requests SET client_requests.workorderid = -1 "
|
|
"WHERE (((client_requests.id)=%u));",m_lCurrentItem);
|
|
rs->Ex(q);
|
|
FillView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CArasClientRequests::OnArasRequestsRefresh()
|
|
{
|
|
|
|
KillTimer(2);
|
|
FillView();
|
|
if(m_pApp->m_lSchedRefreshSecs!=0)
|
|
m_nTimer = SetTimer(2, 1000*m_pApp->m_lSchedRefreshSecs, 0);
|
|
}
|
|
|
|
void CArasClientRequests::OnTimer(UINT nIDEvent)
|
|
{
|
|
if(nIDEvent==2)
|
|
{
|
|
CWaitCursor cw;
|
|
KillTimer(2);
|
|
FillView();
|
|
if(m_pApp->m_lSchedRefreshSecs!=0)
|
|
m_nTimer = SetTimer(2, 1000*m_pApp->m_lSchedRefreshSecs, 0);
|
|
|
|
}
|
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CArasClientRequests::OnUpdateArasRequestsMakeWorkorder(CCmdUI *pCmdUI)
|
|
{
|
|
//pCmdUI->Enable(m_bReadOnly?FALSE:TRUE);
|
|
}
|
|
|
|
void CArasClientRequests::OnUpdateArasRequestsReject(CCmdUI *pCmdUI)
|
|
{
|
|
//pCmdUI->Enable(m_bReadOnly?FALSE:TRUE);
|
|
}
|
|
|