45 #include <Wtx/Util/Util.h> 46 #include <Wtx/Dbo/TableView.h> 53 Wtx::Crm::Company::Item::MapClass( session );
62 std::string Wtx::Crm::Company::key(
const std::string & lastName,
const std::string & firstName )
65 Wt::WString(
"{1}, {2}")
73 Wt::Dbo::ptr< Wtx::Crm::Company::Item > Wtx::Crm::Company::xfind(
const std::string & xid,
Wtx::Dbo::Session & session )
75 Wt::Dbo::Transaction t( session );
85 Wt::Dbo::ptr< Wtx::Crm::Company::Item > Wtx::Crm::Company::add(
const std::string & name,
Wtx::Dbo::Session & session )
87 Wt::Dbo::Transaction t( session );
94 std::shared_ptr<Wt::WAbstractItemModel> Wtx::Crm::Company::getCompanyModel(
int sid,
int tid,
const std::string & filter,
Wtx::Dbo::Session & session )
97 std::make_shared< Wtx::Dbo::QueryModel< std::tuple<int,std::string> > >();
99 Wt::Dbo::Transaction t(session);
104 w = Wt::WString(
"WHERE id={1}").arg(tid).toUTF8();
120 " AND (UPPER(\"keyField\") LIKE '%{1}%' OR " 121 " UPPER(\"cfyField\") LIKE '%{1}%')" 134 "\"keyField\" || ' ~ ' || " 137 "FROM \"crmPerson\" " 146 std::cout << __FILE__ <<
":" << __LINE__
149 <<
"\n flt:" << filter
157 session.query< std::tuple<int,std::string> >( sql )
160 retVal-> setQuery( query );
161 retVal-> addColumn(
"id" );
162 retVal-> addColumn(
"key" );
168 std::unique_ptr<Wt::WTableView> Wtx::Crm::Company::getCompanyTableView(
int sid,
int tid,
const std::string & filter,
Wtx::Dbo::Session & session )
175 Wt::SelectionMode::Single,
209 {
"id",
"", 50, Wt::AlignmentFlag::Left,
"",
nullptr },
210 {
"keyField",
"", 150, Wt::AlignmentFlag::Left,
"",
nullptr },
211 {
"cfyField",
"", 350, Wt::AlignmentFlag::Left,
"",
nullptr },
223 Wt::Dbo::Transaction t(session);
225 auto retVal = std::make_unique< Wtx::Dbo::TableView< Wtx::Crm::Company::Item > >( viewDef, &session );
227 retVal-> setMaximumSize( Wt::WLength::Auto, 300 );
228 retVal-> setColumnHidden( 0,
true );
229 if( filter.length() > 2 )
234 "(UPPER(\"keyField\") LIKE UPPER('%{1}%')) OR " 235 "(UPPER(\"cfyField\") LIKE UPPER('%{1}%'))" 241 retVal-> setFilter( f );
250 int Wtx::Crm::Company::CompanyProvider::find_id(
const std::string & value )
254 Wt::Dbo::Transaction t( *session() );
256 session()-> find< Wtx::Crm::Person::Item >()
259 " (UPPER( \"keyField\" ) LIKE ?" 260 " OR UPPER( \"cfyField\" ) LIKE ?)" 267 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << __FUNCTION__ <<
"():" 268 <<
" value=" << value
269 <<
" size:" << items.size()
273 if( items.size() != 1 )
276 return items.begin()-> id();
280 std::string Wtx::Crm::Company::CompanyProvider::get_string(
int id )
282 Wt::Dbo::Transaction t( *session() );
284 auto companyItem = session()-> load< Wtx::Crm::Company::Item >( id );
287 Wt::WString(
"{1} ~ {2}")
288 .arg( companyItem-> cfyField().value() )
289 .arg( companyItem-> keyField().value() )
295 std::string Wtx::Crm::Company::CompanyProvider::get_toolTip(
int id )
297 Wt::Dbo::Transaction t( *session() );
298 auto companyItem = session()-> load< Wtx::Crm::Company::Item >( id );
300 auto companyKey = companyItem-> keyField().value();
301 auto companyCfy = companyItem-> cfyField().value();
302 auto companyPhone = companyItem-> phone().value();
303 auto companyEmail = companyItem-> email().value();
305 return "Wtx::Crm::Company::CompanyProvider::get_toolTip";
308 std::string companyInfo;
309 if(
auto companyItem = personItem-> contactForCompany().value() )
314 "\n~~~ COMPANY INFO:" 321 .arg( companyItem-> keyField ().value() )
322 .arg( companyItem-> cfyField ().value() )
323 .arg( companyItem-> mainPhone ().value() )
324 .arg( companyItem-> addr ().value() )
325 .arg( companyItem-> addr2 ().value() )
326 .arg( companyItem-> city ().value() )
327 .arg( companyItem-> zip ().value() )
353 std::shared_ptr< Wt::WAbstractItemModel > Wtx::Crm::Company::CompanyProvider::model(
int sid,
int tid,
const std::string & filter )
356 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << __FUNCTION__ <<
"():" 357 <<
" sid:" << sid <<
"(" << m_sid <<
")" 358 <<
" tid:" << tid <<
"(" << m_tid <<
")" 359 <<
" filter:'" << filter <<
"' (" << filter <<
")" 370 && m_filter == filter )
387 m_model = std::make_shared< Model >();
393 Wt::Dbo::Transaction t( *session() );
398 w = Wt::WString(
"WHERE id={1}").arg(tid).toUTF8();
407 " (UPPER(\"keyField\") LIKE '%{1}%' OR " 408 " UPPER(\"cfyField\") LIKE '%{1}%')" 421 " ORDER BY \"keyField\"" 423 .arg(
"SELECT id,\"keyField\" as key FROM \"crmPerson\"" )
429 session()-> query< std::tuple<int,std::string> >( sql )
432 m_model-> setQuery( query );
433 m_model-> addColumn(
"id" );
434 m_model-> addColumn(
"key" );
437 std::cout << __FILE__ <<
":" << __LINE__
440 <<
"\n flt:" << filter
441 <<
"\n row:" << m_model-> rowCount()
451 std::unique_ptr<Wt::WTableView> Wtx::Crm::Company::CompanyProvider::getTableView(
int sid,
int tid,
const std::string & filter )
453 return std::make_unique< Wt::WTableView >();
456 std::unique_ptr< Wtx::Crm::Company::CompanyProvider > Rtm::Dbo::Person::makeCompanyProvider()
458 return std::make_unique< Wtx::Crm::Company::CompanyProvider >();
std::string ucase(const std::string &value)
Upper Case a string.
static void PostCreateTable(Wt::Dbo::Session &session)
Post Table Create.