Wtx ~ Wt Extension Library
WtxLib
Template.h
1 /**************************************************************************
2 ###########################################################################
3 ##
4 ## $SHOWOFFDB_BEGIN_LICENSE$
5 ## Copyright (C) 2011 Lorimark Solutions, LLC and/or its subsidiary(-ies).
6 ## All rights reserved.
7 ## Contact: Lorimark Solutions, LLC (info@showoff-db.org)
8 ##
9 ## This file is part of the Showoff Database Application Framework.
10 ##
11 ## Commercial Usage
12 ## Licensees holding valid ShowoffDB Commercial licenses may use this file in
13 ## accordance with the ShowoffDB Commercial License Agreement provided with the
14 ## Software or, alternatively, in accordance with the terms contained in
15 ## a written agreement between you and Lorimark Solutions, LLC.
16 ##
17 ## GNU Lesser General Public License Usage
18 ## Alternatively, this file may be used under the terms of the GNU Lesser
19 ## General Public License version 2.1 as published by the Free Software
20 ## Foundation and appearing in the file LICENSE.LGPL included in the
21 ## packaging of this file. Please review the following information to
22 ## ensure the GNU Lesser General Public License version 2.1 requirements
23 ## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ##
25 ## In addition, as a special exception, Lorimark Solutions, LLC gives
26 ## you certain additional rights. These rights are described in the
27 ## Lorimark Solutions, LLC ShowoffDB LGPL Exception version 1.0, included in
28 ## the file LGPL_EXCEPTION.txt in this package.
29 ##
30 ## GNU General Public License Usage
31 ## Alternatively, this file may be used under the terms of the GNU
32 ## General Public License version 3.0 as published by the Free Software
33 ## Foundation and appearing in the file LICENSE.GPL included in the
34 ## packaging of this file. Please review the following information to
35 ## ensure the GNU General Public License version 3.0 requirements will be
36 ## met: http://www.gnu.org/copyleft/gpl.html.
37 ##
38 ## If you have questions regarding the use of this file, please contact
39 ## Lorimark Solutions, LLC at info@showoff-db.org.
40 ## $SHOWOFFDB_END_LICENSE$
41 ##
42 #############################################################################
43 ****************************************************************************/
44 
45 
46 #ifndef __WTX_CRM_PERSON_TEMPLATE_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
47 #define __WTX_CRM_PERSON_TEMPLATE_H_234e0174_6b7d_11e8_b503_fb1ef3651ec0__
48 
49 #include <Wtx/Util/Util.h>
50 #include <Wtx/Dbo/PermissionItemTpl.h>
51 
52 #include <Wtx/Addons/Crm/Company/Item.h>
53 
54 #include "Definition.h"
55 
56 namespace Wtx {
57  namespace Crm {
58  namespace Person {
59 
60 template <class C> class Template
62 {
63  public:
64 
65  Template()
67  {
68  }
69 
70  Template( const std::string & keyField )
71  : Wtx::Dbo::PermissionItemTpl<C>( keyField )
72  {
73  isLead ().setValue( false );
74  isClient ().setValue( false );
75  }
76 
77  virtual ~Template()
78  {
79  }
80 
81  static Definition & TableDef()
82  {
83  return C::TableDef();
84  }
85 
86  Wtx::Dbo::Field<std::string> & firstName () { return m_firstName ; }
87  Wtx::Dbo::Field<std::string> & lastName () { return m_lastName ; }
88  Wtx::Dbo::Field<std::string> & middleName () { return m_middleName ; }
89  Wtx::Dbo::Field<std::string> & nickName () { return m_nickName ; }
90  Wtx::Dbo::Field<std::string> & abbreviation () { return m_abbreviation ; }
91  Wtx::Dbo::Field<std::string> & phone () { return m_phone ; }
92  Wtx::Dbo::Field<std::string> & cell () { return m_cell ; }
93  Wtx::Dbo::Field<std::string> & fax () { return m_fax ; }
94  Wtx::Dbo::Field<std::string> & email () { return m_email ; }
95  Wtx::Dbo::Field<std::string> & notes () { return m_notes ; }
96  Wtx::Dbo::Field<bool> & isLead () { return m_isLead ; }
97  Wtx::Dbo::Field<bool> & isClient () { return m_isClient ; }
98 
99  Wtx::Dbo::Field<std::string> & street1 () { return m_street1 ; }
100  Wtx::Dbo::Field<std::string> & street2 () { return m_street2 ; }
101  Wtx::Dbo::Field<std::string> & city () { return m_city ; }
102  Wtx::Dbo::Field<std::string> & state () { return m_state ; }
103  Wtx::Dbo::Field<std::string> & zip () { return m_zip ; }
104  Wtx::Dbo::Field<double> & discount () { return m_discount ; }
105  Wtx::Dbo::Field<std::string> & alert () { return m_alert ; }
106 
107  Wtx::Dbo::FieldBelongsTo< Wtx::Crm::Company::Item::Ptr > & contactForCompany () { return m_contactForCompany; }
108 
109  const Wtx::Dbo::Field<std::string> & firstName () const { return m_firstName ; }
110  const Wtx::Dbo::Field<std::string> & lastName () const { return m_lastName ; }
111  const Wtx::Dbo::Field<std::string> & middleName () const { return m_middleName ; }
112  const Wtx::Dbo::Field<std::string> & nickName () const { return m_nickName ; }
113  const Wtx::Dbo::Field<std::string> & abbreviation () const { return m_abbreviation ; }
114  const Wtx::Dbo::Field<std::string> & phone () const { return m_phone ; }
115  const Wtx::Dbo::Field<std::string> & cell () const { return m_cell ; }
116  const Wtx::Dbo::Field<std::string> & fax () const { return m_fax ; }
117  const Wtx::Dbo::Field<std::string> & email () const { return m_email ; }
118  const Wtx::Dbo::Field<std::string> & notes () const { return m_notes ; }
119  const Wtx::Dbo::Field<bool> & isLead () const { return m_isLead ; }
120  const Wtx::Dbo::Field<bool> & isClient () const { return m_isClient ; }
121 
122  const Wtx::Dbo::Field<std::string> & street1 () const { return m_street1 ; }
123  const Wtx::Dbo::Field<std::string> & street2 () const { return m_street2 ; }
124  const Wtx::Dbo::Field<std::string> & city () const { return m_city ; }
125  const Wtx::Dbo::Field<std::string> & state () const { return m_state ; }
126  const Wtx::Dbo::Field<std::string> & zip () const { return m_zip ; }
127  const Wtx::Dbo::Field<double> & discount () const { return m_discount ; }
128  const Wtx::Dbo::Field<std::string> & alert () const { return m_alert ; }
129 
130  const Wtx::Dbo::FieldBelongsTo< Wtx::Crm::Company::Item::Ptr > & contactForCompany () const { return m_contactForCompany; }
131 
132  std::string csz() const
133  {
134  std::string retVal = city().value();
135 
136  retVal = Wtx::append( retVal, state ().value(), ", " );
137  retVal = Wtx::append( retVal, zip ().value(), " " );
138 
139  return retVal;
140  }
141 
142  template<class Action> void persist( Action &a )
143  {
145  m_firstName .persist( a, &TableDef(). FirstNameFieldDef );
146  m_lastName .persist( a, &TableDef(). LastNameFieldDef );
147  m_middleName .persist( a, &TableDef(). MiddleNameFieldDef );
148  m_nickName .persist( a, &TableDef(). NickNameFieldDef );
149  m_abbreviation .persist( a, &TableDef(). AbbreviationFieldDef );
150  m_phone .persist( a, &TableDef(). PhoneFieldDef );
151  m_cell .persist( a, &TableDef(). CellFieldDef );
152  m_fax .persist( a, &TableDef(). FaxFieldDef );
153  m_email .persist( a, &TableDef(). EmailFieldDef );
154  m_notes .persist( a, &TableDef(). NotesFieldDef );
155  m_isLead .persist( a, &TableDef(). IsLeadFieldDef );
156  m_isClient .persist( a, &TableDef(). IsClientFieldDef );
157 
158  m_street1 .persist( a, &TableDef(). Street1FieldDef );
159  m_street2 .persist( a, &TableDef(). Street2FieldDef );
160  m_city .persist( a, &TableDef(). CityFieldDef );
161  m_state .persist( a, &TableDef(). StateFieldDef );
162  m_zip .persist( a, &TableDef(). ZipFieldDef );
163  m_discount .persist( a, &TableDef(). DiscountFieldDef );
164  m_alert .persist( a, &TableDef(). AlertFieldDef );
165  m_contactForCompany .persist( a, &TableDef(). ContactForCompanyFieldDef );
166 
167  }
168 
169  private:
170 
171  Wtx::Dbo::Field<std::string> m_firstName ;
172  Wtx::Dbo::Field<std::string> m_lastName ;
173  Wtx::Dbo::Field<std::string> m_middleName ;
174  Wtx::Dbo::Field<std::string> m_nickName ;
175  Wtx::Dbo::Field<std::string> m_abbreviation ;
181  Wtx::Dbo::Field<bool> m_isLead ;
182  Wtx::Dbo::Field<bool> m_isClient ;
183 
184  Wtx::Dbo::Field<std::string> m_street1 ;
185  Wtx::Dbo::Field<std::string> m_street2 ;
189  Wtx::Dbo::Field<double> m_discount ;
191 
193 
194 }; // endclass Wtx::Crm::Person::Template
195 
196  } // endnamespace Person
197  } // endnamespace Crm
198 } // endnamespace Wtx
199 
200 #endif // end#ifndef __PERSONTPL_H___
201 
std::string append(const std::string &s, const std::string &append, const std::string &separator)
Append a string to string.
Definition: Util.cpp:404
witty extension library
Definition: Activity.h:51