diff --git a/utils/AyaImport/Form1.cs b/utils/AyaImport/Form1.cs index fae9a51..cbc0574 100644 --- a/utils/AyaImport/Form1.cs +++ b/utils/AyaImport/Form1.cs @@ -413,10 +413,13 @@ namespace AyaImport } else { +#if(DEBUG) #if(ATTEMPT_UPGRADE_FROM_142) //cmd.CommandText = ("update blah set blah = blah"); //cmd.ExecuteNonQuery(); - nVersion = 171; + UpdateCEDatabaseSchema.go(conn, nVersion); + nVersion = 171;//if this update works then the version is now 171 +#endif #endif if (nVersion > 170) @@ -4586,1306 +4589,1307 @@ namespace AyaImport private static class UpdateCEDatabaseSchema { - -//FUTURE READER keywords to find this method -//update database schema 171 1.9 scdata.sc ayanova ce -//etc etc etc - private static OleDbCommand cmd=null; - private static void executeQuery(string q){ + //FUTURE READER keywords to find this method + //update database schema 171 1.9 scdata.sc ayanova ce + //etc etc etc + private static OleDbCommand cmd = null; + + private static void executeQuery(string q) + { cmd.CommandText = q; cmd.ExecuteNonQuery(); } -private static void go(System.Data.OleDb.OleDbConnection conn, int nVersion) -{ - cmd = new OleDbCommand(); - cmd.Connection=conn; + public static void go(System.Data.OleDb.OleDbConnection conn, int nVersion) + { + cmd = new OleDbCommand(); + cmd.Connection = conn; - - //string msg,strTemp,strData; - - string q,q2; - DateTime dtDefault=new DateTime(1968,03,12); - bool buptodate=false; - bool bUpdateRanOK; - - //do whatever updates are necessary. - while (!buptodate) - { - switch (nVersion) - { -#region older versions I didn't need to migrate (yet) - // //================================================== - //case 126://changed to 127 on 8/22/00 - // { - // //Added a record to the rptsmaster table for the - // //workorder dispatch report - // //Not a schema update only an added record - - - // //see if the record is here already so it's not done twice: - // rs->Query("SELECT rptsmaster.virtualname " - // "FROM rptsmaster WHERE (((rptsmaster.virtualname)=\"Workorder dispatch\"));"); - // if(rs->IsEmpty()) - // { - // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - // "SELECT \"Workorder dispatch\", \"wodispst.rpt\", \"wodispatch\", False, 32767, 21;"); - - - - // } - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"127\";"); - // nVersion=127; - - - // } - - // break; - // //====================================================== - //case 127://changed to 128 on 8/24/00 - // { - // //Added a record to the rptsmaster table for the - // //QUICK workorder dispatch report - // //Not a schema update only an added record - - - // //see if the record is here already so it's not done twice: - // rs->Query("SELECT rptsmaster.virtualname " - // "FROM rptsmaster WHERE (((rptsmaster.virtualname)=\"Workorder dispatch (Quick)\"));"); - // if(rs->IsEmpty()) - // { - // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - // "SELECT \"Workorder dispatch (Quick)\", \"wodispqu.rpt\", \"wodispatch\", False, 32767, 22;"); - - - - // } - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"128\";"); - // nVersion=128; - - // } - - // break; - - // //===================================================== - //case 128://changed to 129 on 8/28/00 - // { - // //Dropped contacts table fields: wolink, problink - // //added fields: clientlink - - - // executeQuery("ALTER TABLE contacts DROP COLUMN wolink;"); - // executeQuery("ALTER TABLE contacts DROP COLUMN problink;"); - // executeQuery("ALTER TABLE contacts ADD COLUMN clientlink LONG;"); - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"129\";"); - - // nVersion=129; - // } - - // break; - //case 129://changed to 130 on 8/29/00 - 8/31/00 - // { - // //contacts table added field:indexed - // //units table added field:indexed - - // executeQuery("ALTER TABLE contacts ADD COLUMN indexed YESNO;"); - // executeQuery("UPDATE contacts SET contacts.indexed = False;"); - - // executeQuery("ALTER TABLE units ADD COLUMN indexed YESNO;"); - // executeQuery("UPDATE units SET units.indexed = False;"); - - // //add the unit history to reports screen - // q2="SELECT \"user\" AS zCurrentUser, probs.id, Format([start],\"Short Date\") AS " - // "servdate, labor.details, IIf(IsNull([company]),[clients]![last] & \", \" & [clients]![first],[company]) " - // "AS clientcompany, units.sn, unitmodels.model, users.initials, probs.meter, ztotalparts.totalparts, " - // "ztotallabor.totallabor " - // "FROM [SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor, " - // "probs.id FROM probs INNER JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON " - // "travrates.id = labor.rate) ON rates.id = labor.rate) ON probs.id = labor.link GROUP BY probs.id]. AS " - // "ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)),0, " - // "Sum(woparts.quantity*woparts.price)) AS totalparts, probs.id FROM probs LEFT JOIN woparts " - // "ON probs.id = woparts.link GROUP BY probs.id]. AS ztotalparts RIGHT JOIN (users RIGHT JOIN " - // "((labor RIGHT JOIN (((wo RIGHT JOIN probs ON wo.id = probs.wolink) LEFT JOIN units ON " - // "probs.unit = units.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) ON labor.link = " - // "probs.id) LEFT JOIN clients ON wo.client = clients.id) ON users.id = labor.tech) ON ztotalparts.id " - // "= probs.id) ON ztotallabor.id = probs.id " - // "WHERE (((probs.unit)~UNIT) AND ((units.sn) Is Not Null) AND ((labor.start) Between #~STRT# And #~END_#)) " - // "ORDER BY labor.start DESC;"; - - // q=string.Format("UPDATE rptsmaster SET rptsmaster.x = True, rptsmaster.criteriafields = 400, rptsmaster.query = '%s' " - // "WHERE (((rptsmaster.id)=7));",q2); - - // executeQuery(q); - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"130\";"); - // nVersion=130; - - - // } - - // break; - // //===================================================== - //case 130://changed to 131 on 9/12/00 - // { - // //PM module additions - - // executeQuery("ALTER TABLE pmschedules ADD COLUMN autoworkorder YESNO;"); - // executeQuery("UPDATE pmschedules SET pmschedules.autoworkorder = False;"); - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"131\";"); - - // nVersion=131; - - - // } - - // break; - // //*************************************************************************** - //case 131://changed to 132 on 9/22/00 and now 133 on 10/02/00 - // { //since it's unreleased, decided to bump up one more. - // //PM module additions - - - // //Add a last meter reading column to the units table - // //this is updated when someone enters a workorder unit count. - // //to make pm easier to deal with. - - // executeQuery("ALTER TABLE units ADD COLUMN lastmeter INTEGER;"); - // //NOTE: CANT SET TO DEFAULT OF ZERO WITHOUT IT CRASHING OUT - - - - // //Delete the pmschedules, superseded by pmhead table below - // executeQuery("DROP TABLE pmschedules;"); - - - // //new pm header table - // q=string.Format("CREATE TABLE pmhead (" - // "id COUNTER CONSTRAINT PK_pmhead PRIMARY KEY, " - // "description TEXT(50), " - // "notes MEMO, " - // "link INTEGER DEFAULT 0, "//link to client or unit id number - // "type INTEGER DEFAULT 0, " //0-timebased,1-meter,2-agebased - // "isclient YESNO DEFAULT False, " //true = client false=unitbased - // "ismodel YESNO DEFAULT False, " //true = MODEL false=units or clients - // "autowo YESNO DEFAULT False, " - // "autorpt YESNO DEFAULT False, " - // "dow INTEGER DEFAULT 0," //autoschedule day of week 0any 1-monday 2-tuesd etc - // "tech INTEGER DEFAULT 0, " //HEREpreferred technician - // "woconvert INTEGER DEFAULT 0, " //convert to workorder days / meter counts in advance - // "nextsrvdate DATETIME DEFAULT #%s#, " - // "nextsrvmeter INTEGER DEFAULT 0, "//next meter count to service on - // "repeatevery INTEGER DEFAULT 0, "//repeat every meter / months - // "agemonths INTEGER DEFAULT 0, "//Age based: months old to schedule - // "ageyears INTEGER DEFAULT 0, "//Age based: years old to schedule - // "active YESNO DEFAULT True, "//on hold or active? - // "series INTEGER DEFAULT 0, "//schedule this many series at a time - // "creator INTEGER DEFAULT 0, "//user who created record - // "created DATETIME DEFAULT #%s#, " //date created - // "modifier INTEGER DEFAULT 0, "//date modified who cares?? probably no one - // "modified DATETIME DEFAULT #%s#, " - // "wotype INTEGER DEFAULT 0, " - // "woquick YESNO DEFAULT False, " - // "woproject INTEGER DEFAULT 0, " - // "woonsite YESNO DEFAULT False);" - // ,dtDefault.Format(_T("%m/%d/%Y")),dtDefault.Format(_T("%m/%d/%Y")),dtDefault.Format(_T("%m/%d/%Y"))); - - // executeQuery(q); - - - - // //new table to hold preventative maintenance items - // //in schedule viewer - // q=string.Format("CREATE TABLE pmitems (" - // "id COUNTER CONSTRAINT PK_pmitem PRIMARY KEY, " - // "pmschedlink INTEGER DEFAULT 0, " - // "clientlink INTEGER DEFAULT 0, " - // "schedate DATETIME DEFAULT #%s#, " - // "schedmeter INTEGER DEFAULT 0, " - // "autowo YESNO DEFAULT True, " - // "hold YESNO DEFAULT False, " - // "schedtech INTEGER DEFAULT 0, " - // "link INTEGER DEFAULT 0, "//link to client or unit id number - // "isclient YESNO DEFAULT False);",dtDefault.Format(_T("%m/%d/%Y"))); //true = client false=unitbased - - // executeQuery(q); - - - // //clear out the pmparts table - // executeQuery("DELETE pmparts.* FROM pmparts;"); - - // //set correct report control profile for PM check screen now 8 columns was 7 - // executeQuery("UPDATE users SET users.pmprofile = \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); - - // //Add the lastmaintdate column to the defaults table - // //this is used for maintenance to ensure that only one station - // //tries to do it at a time: When SC is run, it checks to see if - // //this date is older than the current date, if so, it "locks" it by - // //updating to today's date, thereby effectively locking out any latecomers - // //then runs any required maintenance. - // executeQuery("ALTER TABLE defaults ADD COLUMN lastmaintdate DATETIME;"); - // q=string.Format("UPDATE defaults SET defaults.lastmaintdate = #%s#;",dtDefault.Format(_T("%m/%d/%Y"))); - // executeQuery(q); - - - // //Add the woestimate column to the defaults table, this is to - // //flag whether to use estimates on dispatch workorders or not. - // //this is in response to TCCSI client that needs this and it - // //will now be available to all users. This flag is settable under the - // //defaults screen, program, not users - // executeQuery("ALTER TABLE defaults ADD COLUMN woestimate YESNO;"); - // executeQuery("UPDATE defaults SET defaults.woestimate = False;"); - - // //Customer reference number and contact - // //as suggested by Rob MacKay in Australia - // executeQuery("ALTER TABLE wo ADD COLUMN clientrefnum TEXT(50);"); - // executeQuery("ALTER TABLE wo ADD COLUMN clientcontact TEXT(50);"); - - - // //Add a first boot field to detect new evaluation versions - // //this will be used to show a friendly welcome to message and - // //to fixup the dates in the demo data. - - // //set to false because if this field isn't in the table already, - // //it means user has older version so it just needs to be there - // //not actually used - // executeQuery("ALTER TABLE defaults ADD COLUMN firstboot YESNO;"); - // executeQuery("UPDATE defaults SET defaults.firstboot = False;"); - - // //refdate is used in an eval to fixup all the dates - // //in the evaluation database. - // //so that the evaluator sees the demo data as current - // executeQuery("ALTER TABLE defaults ADD COLUMN refdate DATETIME;"); - - - // //DROP the pm columns no longer required in the units table - // executeQuery("ALTER TABLE units DROP COLUMN lastpmmetric;"); - // executeQuery("ALTER TABLE units DROP COLUMN lastpmdate;"); - // executeQuery("ALTER TABLE units DROP COLUMN nextpmmetric;"); - // executeQuery("ALTER TABLE units DROP COLUMN nextpmdate;"); - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"133\";"); - - // nVersion=133; - - - // } - - // break; - // //===================================================== - //case 133://changed to 134 for schedule view - // { - // CString strID,strName,strRights,strHash; - // long lData; - // GZK k; - - - // //Add new right: - // //loop through all the group records - // rs->Query("SELECT groups.* FROM groups;"); - // do{ - // rs->FetchField("id",&lData); - // rs->FetchField("a",&strName); - // rs->FetchField("b",&strRights); - - // //decrypt the original rights string - // k.GZDecrypt(&strRights,false); - // strRights=strRights+"1";//add on the extra right for schedule view - - // //re-'crypt' - // k.GZEncrypt(&strRights,false); - - // //HASH - // strHash.Format("%u%s%s",lData,strName,strRights); - // k.GZHash(&strHash); - - // //save the rights - // rs->UpdateField("b",&strRights); - - // //save the hash - // rs->UpdateField("c",&strHash); - - // //save the record - // if(!rs->SaveRecord()) - // AfxMessageBox("Error trying to save record"); - - - - - - - - // }while(rs->MoveForward()); - - - - - - // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - // "SELECT \"Parts\", \"parts.rpt\", \".\", False, 32767, 23;"); - - - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"134\";"); - - // nVersion=134; - - - - // } - - // break; - // //*************************************************************************** - - // //===================================================== - //case 134://changed to 135 on 12/19/00 - // { - - // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - // "SELECT \"Search results\", \"srch.rpt\", \".\", False, 32767, 24;"); - - // executeQuery("ALTER TABLE users ADD COLUMN rpttext1 MEMO;"); - - // //fix the version number up - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"135\";"); - - // nVersion=135; - - // } - - // break; - - // //===================================================== - //case 135://changed to 136 on Jan 15 2001 - // { - // bUpdateRanOK=true; - - // //USER RECORD CHANGES - // executeQuery("ALTER TABLE users ADD COLUMN defschedstarthour INTEGER;"); - // executeQuery("ALTER TABLE users ADD COLUMN defschedstophour INTEGER;"); - // executeQuery("ALTER TABLE users ALTER defschedstarthour SET DEFAULT '0';"); - // executeQuery("ALTER TABLE users ALTER defschedstophour SET DEFAULT '0';"); - // if(!executeQuery("UPDATE users SET users.defschedstarthour = 0, users.defschedstophour = 0;")) bUpdateRanOK=false; - - // //WORKORDER COLUMN CHANGES - // executeQuery("ALTER TABLE wo ADD COLUMN status INTEGER;"); - // executeQuery("ALTER TABLE wo ALTER status SET DEFAULT '0';"); - // executeQuery("UPDATE wo SET wo.status = 0;"); - - // executeQuery("ALTER TABLE wo ADD COLUMN ourref TEXT(80);"); - - // executeQuery("ALTER TABLE wo ADD COLUMN esthours REAL;"); - // executeQuery("ALTER TABLE wo ADD COLUMN estrate INTEGER;"); - - // executeQuery("ALTER TABLE wo ALTER notes TEXT(110)"); - - // //STATUS VIEW SCREEN CHANGE - // executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(17,17) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\";"); - - // //fix the version number up as long as updates seem ok - // if(bUpdateRanOK) - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"136\";"); - - // AfxMessageBox("Part of this update modifies the main workorder list view screen.\r\n\r\n" - // "You will need to re-order the columns in the main view to your preferences and re-save the views.\r\n\r\n" - // "This update affects the column order only, not the underlying restriction settings."); - // nVersion=136; - - // } - - // break; - - // //===================================================== - //case 136://changed to 137 on Jan 18 2001 - // { - - - // //NEW FIELDS TO ADD TO STATUS VIEW TABLE - // executeQuery("ALTER TABLE statusviews ADD COLUMN ourref INTEGER;"); - // executeQuery("ALTER TABLE statusviews ADD COLUMN status INTEGER;"); - // executeQuery("ALTER TABLE statusviews ALTER ourref SET DEFAULT '0';"); - // executeQuery("ALTER TABLE statusviews ALTER status SET DEFAULT '0';"); - - // executeQuery("UPDATE statusviews SET statusviews.status = 1;"); - // executeQuery("UPDATE statusviews SET statusviews.ourref = 1;"); - - // executeQuery("ALTER TABLE woparts ADD COLUMN sn TEXT(255);"); - - // //client account number - // executeQuery("ALTER TABLE clients ADD COLUMN acctnumber TEXT(40);"); - - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"137\";"); - // nVersion=137; - // } - - // break; - //case 137://changed to 138 on Jan 29 2001 -bug in tech billing summary - // { - - // q2="SELECT [users].[last] & \", \" & [users].[first] AS name, Sum(techsubq.hours) AS SumOfhours, Sum(techsubq.nchours) AS SumOfnchours, Sum(techsubq.travhours) AS SumOftravhours, Sum(techsubq.wototal) AS SumOfwototal " - // "FROM [SELECT labor.tech, labor.hours, labor.nchours, labor.travhours, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS wototal " - // "FROM rates AS travelrates RIGHT JOIN (((labor LEFT JOIN (probs LEFT JOIN wo ON probs.wolink = wo.id) ON labor.link = probs.id) LEFT JOIN rates ON labor.rate = rates.id) LEFT JOIN clients ON wo.client = clients.id) ON travelrates.id = labor.travrate " - // "WHERE (((labor.tech)<>-1) AND ((labor.stop) Between #~STRT# And #~END_#) AND ((clients.czone)<>-1) AND ((wo.type)<>-1) AND ((wo.project)<>-1) AND ((wo.client)<>-1))]. AS techsubq INNER JOIN users ON techsubq.tech = users.id " - // "GROUP BY techsubq.tech, [users].[last] & \", \" & [users].[first] " - // "ORDER BY [users].[last] & \", \" & [users].[first];"; - - // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - // "WHERE (((rptsmaster.id)=17));",q2); - - // executeQuery(q); - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"138\";"); - // nVersion=138; - - // } - - // break; - //case 138://changed to 139 on Jan 29 2001 -bug in tech billing summary and didn't fix it the first time - // { - - // q2="SELECT [users].[last] & \", \" & [users].[first] AS name, Sum(techsubq.hours) AS SumOfhours, Sum(techsubq.nchours) AS SumOfnchours, Sum(techsubq.travhours) AS SumOftravhours, Sum(techsubq.wototal) AS SumOfwototal " - // "FROM [SELECT labor.tech, labor.hours, labor.nchours, labor.travhours, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS wototal " - // "FROM rates AS travelrates RIGHT JOIN (((labor LEFT JOIN (probs LEFT JOIN wo ON probs.wolink = wo.id) ON labor.link = probs.id) LEFT JOIN rates ON labor.rate = rates.id) LEFT JOIN clients ON wo.client = clients.id) ON travelrates.id = labor.travrate " - // "WHERE (((labor.tech)~TECH) AND ((labor.stop) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ) AND ((wo.client)~CUST))]. AS techsubq INNER JOIN users ON techsubq.tech = users.id " - // "GROUP BY techsubq.tech, [users].[last] & \", \" & [users].[first] " - // "ORDER BY [users].[last] & \", \" & [users].[first];"; - - // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - // "WHERE (((rptsmaster.id)=17));",q2); - - // executeQuery(q); - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"139\";"); - // nVersion=139; - - // } - - // break; - //case 139://changed to 140 on Feb 15 2001 Added color to status items - // { - - // executeQuery("ALTER TABLE probstat ADD COLUMN red INTEGER;"); - // executeQuery("ALTER TABLE probstat ADD COLUMN green INTEGER;"); - // executeQuery("ALTER TABLE probstat ADD COLUMN blue INTEGER;"); - - // executeQuery("ALTER TABLE probstat ALTER red SET DEFAULT '0';"); - // executeQuery("ALTER TABLE probstat ALTER green SET DEFAULT '0';"); - // executeQuery("ALTER TABLE probstat ALTER blue SET DEFAULT '0';"); - - - // //set all to black initially - // executeQuery("UPDATE probstat SET probstat.red = 0;"); - // executeQuery("UPDATE probstat SET probstat.green = 0;"); - // executeQuery("UPDATE probstat SET probstat.blue = 0;"); - - - - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"140\";"); - // nVersion=140; - - - // } - - // break; - - - //case 140://changed to 141 on March 7th 2001 bug in report: Billing summary - hours/parts/3rd party - // { - - // q2="SELECT IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS company, Choose([typeUNIONsub].[type],\"Service\",\"3rd party\",\"Parts\") AS chargesfrom, Sum(typeUNIONsub.total) AS total " - // "FROM ([SELECT probs.wolink AS link, \"1\" AS type, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS total " - // "FROM (rates INNER JOIN (rates AS travelrates INNER JOIN labor ON travelrates.id = labor.travrate) ON rates.id = labor.rate) INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON labor.link = probs.id " - // "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ)) " - // "UNION ALL (SELECT probs.wolink AS link, \"2\" AS type, subrepair.charge AS total " - // "FROM subrepair INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON subrepair.link = probs.id " - // "WHERE (((subrepair.charge)<>0) AND ((wo.created) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ)) " - // "UNION ALL (SELECT probs.wolink, \"3\" AS type, woparts.quantity*woparts.price AS total " - // "FROM woparts INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON woparts.link = probs.id " - // "WHERE (((clients.czone)~ZONE) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ))) " - // " )]. AS typeUNIONsub INNER JOIN wo ON typeUNIONsub.link = wo.id) INNER JOIN clients ON wo.client = clients.id " - // "GROUP BY IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]), Choose([typeUNIONsub].[type],\"Service\",\"3rd party\",\"Parts\");"; - - // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - // "WHERE (((rptsmaster.id)=4));",q2); - - // executeQuery(q); - - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"141\";"); - // nVersion=141; - - - // } - - // break; - - - //case 141://changed to 142 on March 26th 2001 various updates - // { - - - // //Add zone field to users - // executeQuery("ALTER TABLE users ADD COLUMN defzone INTEGER;"); - // executeQuery("ALTER TABLE users ALTER defzone SET DEFAULT '0';"); - - // //set all zones to 0 initially - // executeQuery("UPDATE users SET users.defzone = 0;"); - - // //Add default wo status fields to defaults - // executeQuery("ALTER TABLE defaults ADD COLUMN wonewstat INTEGER;"); - // executeQuery("ALTER TABLE defaults ADD COLUMN woclosestat INTEGER;"); - // executeQuery("ALTER TABLE defaults ADD COLUMN woreopenstat INTEGER;"); - - // //add default schedule screen refresh time period - // executeQuery("ALTER TABLE defaults ADD COLUMN schedrfrshsecs INTEGER;"); - - // //set all 0 initially - // executeQuery("UPDATE defaults SET defaults.wonewstat = 0, defaults.woclosestat = 0, defaults.woreopenstat = 0, defaults.schedrfrshsecs = 60;"); - - - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"142\";"); - // nVersion=142; - - // } - - // break; - - - - //case 142://changed to 143 on April 6th 2001 various updates - // { - - // //Add default wo status fields to defaults - // executeQuery("ALTER TABLE defaults ADD COLUMN schedwindow INTEGER;"); - - - - // //set to 30 day window by default - // executeQuery("UPDATE defaults SET defaults.schedwindow = 30;"); - - - - // //fix the version number up as long as updates seem ok - // executeQuery("UPDATE defaults SET defaults.versioninfo = \"143\";"); - // nVersion=143; - - // } - - // break; -#endregion older versions I didn't need to migrate yet - - case 143://changed to 144 on May 8th 2001 various updates - { - - //Add xfertempl table and set values. This is for import export - - q=("CREATE TABLE xfertempl (" - +"name TEXT(80) CONSTRAINT PK_name PRIMARY KEY, " - +"import YESNO DEFAULT False, " - +"delimiter TEXT(1), " - +"fields MEMO, " - +"builtin YESNO DEFAULT False, " - +"fieldnames YESNO DEFAULT False, " - +"path MEMO, " - +"[sql] MEMO, " - +"[table] TEXT(50));"); - - executeQuery(q); - // executeQuery(q); - - ////rs->Close(); - - - q2="\"+first\",\"+last\",\"+company\",\"+mailaddress\",\"+streetaddress\",\"+city\",\"+stateprov\",\"+postal\",\"+country\",\"+bizphone\",\"+extension\",\"+fax\",\"+email\",\"+technotes\",\"+alert\",\"+generalnotes\",\"-acctnumber\""; - q=string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " - +"SELECT \"Clients\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT * FROM clients;\",\"clients\";",q2); - - cmd.CommandText=q; - cmd.ExecuteNonQuery(); - - - q2="\"+partnumber\",\"+description\",\"+avgcost\",\"+retail\",\"+notes\",\"+supplierpart\",\"-upc\""; - q=string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " - +"SELECT \"Parts\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT * FROM parts;\",\"parts\";",q2); - executeQuery(q); - - - q2="\"+Customer\",\"+Contact\",\"+Phone\",\"+Fax\",\"+Address\",\"+Notes\",\"+Account\""; - q=string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " - +"SELECT \"Quick Books - Clients\" , True, \"T\",'%s', True, False, \"c:\\\", \"\",\"QBCLIENTS\";",q2); - executeQuery(q); - - q2="\"+id\",\"+sn\",\"+id1\",\"+id2\",\"+id3\",\"+company\",\"+first\",\"+last\",\"+receipt\",\"+purchasedate\",\"+model\",\"+manufacturer\",\"+name\",\"+loaner\",\"+lastmeter\""; - q=string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " - +"SELECT \"Units\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT units.id, units.sn, units.id1, units.id2, units.id3, clients.company, clients.first, clients.last, units.receipt, units.purchasedate, unitmodels.model, nonclients.company_person AS manufacturer, unitmodelcats.name, units.loaner, units.lastmeter " - +"FROM ((units LEFT JOIN (unitmodels LEFT JOIN unitmodelcats ON unitmodels.category = unitmodelcats.id) ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN clients ON units.client = clients.id;\",\"sql\";",q2); - executeQuery(q); - - - executeQuery("ALTER TABLE wo ADD COLUMN indexed YESNO;"); - executeQuery("UPDATE wo SET wo.indexed = False;"); - - //new account number field for non-clients - executeQuery("ALTER TABLE nonclients ADD COLUMN account TEXT(40);"); - - //new custref column stuff here: - executeQuery("ALTER TABLE statusviews ADD COLUMN custref INTEGER;"); - executeQuery("ALTER TABLE statusviews ALTER custref SET DEFAULT '0';"); - executeQuery("UPDATE statusviews SET statusviews.custref = 1;"); - executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(18,18) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17\";"); - - - //fix of pmprofile bug where it defaults to 7 columns for new users rather - //then the actual value of 8 - //set correct report control profile for PM check screen now 8 columns was 7 - executeQuery("UPDATE users SET users.pmprofile = \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); - executeQuery("ALTER TABLE users ALTER pmprofile SET DEFAULT \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); - - - - - //Add new parts used on workorder reports to rptsmaster - //DETAILED - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Parts on workorders\", \"partwo.rpt\", \"mgr\", True, 397, 25;"); - //SUMMARY - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Parts on workorder - summarized\", \"prtwosum.rpt\", \"mgr\", True, 397, 26;"); - - - //DETAILED - q2="SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, wo.starttime AS SCHEDULED, IIf(IsNull([partnumber]),\"misc.\",[partnumber]) AS PART, IIf(IsNull([partnumber]),[misc],[description]) AS [DESC], woparts.quantity, woparts.sn, users.last AS TECH, wo.closed, woparts.price AS WOPRICE, parts.retail, clients.id AS CLIENTID, wo.created AS WOCREATED, wo.project, wo.type " - +"FROM (((woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum = parts.id) LEFT JOIN users ON wo.assigntech = users.id) LEFT JOIN clients ON wo.client = clients.id " - +"WHERE (((clients.id)~CUST) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((woparts.id) Is Not Null)) " - +"ORDER BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]);"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=25));",q2); - executeQuery(q); - - - //SUMMARY - q2="SELECT IIf(IsNull([partnumber]),\"misc.\",[partnumber]) AS PART, IIf(IsNull([partnumber]),[misc],[description]) AS [DESC], #~STRT# AS STARTDATE, #~END_# AS ENDDATE, Sum(woparts.quantity) AS [TOTAL USED] " - +"FROM (((woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum = parts.id) LEFT JOIN users ON wo.assigntech = users.id) LEFT JOIN clients ON wo.client = clients.id " - +"WHERE (((clients.id)~CUST) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((woparts.id) Is Not Null)) " - +"GROUP BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]), IIf(IsNull([partnumber]),[misc],[description]) " - +"ORDER BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]);"; - - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=26));",q2); - executeQuery(q); - - - //Add SUBREPAIR REPORTS AND QUERIES - //OUTSTANDING - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Subrepair status - outstanding\", \"subrepair.rpt\", \"mgr\", True, 401, 27;"); - //ALL - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Subrepair status - all\", \"subrepairall.rpt\", \"mgr\", True, 401, 28;"); - - - //OUTSTANDING - q2="SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, nonclients.company_person AS SENTTO, nonclients_1.company_person AS SENTVIA, subrepair.sent AS DATESENT, subrepair.eta AS RECEIVEETA, subrepair.received AS DATERECEIVED, [nonclients_2].[company_person] & \" \" & [unitmodels].[model] & \" \" & [unitmodels].[description] & \" sn: \" & [units].[sn] AS ITEM, units.sn, nonclients_2.company_person AS MANUFACTURER, unitmodels.model, unitmodels.description, subrepair.waybill, subrepair.rma, subrepair.isback " - +"FROM nonclients AS nonclients_2 RIGHT JOIN (((units RIGHT JOIN ((clients RIGHT JOIN (subrepair RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON subrepair.link = probs.id) ON clients.id = wo.client) LEFT JOIN nonclients ON subrepair.where = nonclients.id) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS nonclients_1 ON subrepair.sentvia = nonclients_1.id) ON nonclients_2.id = unitmodels.manufacturer " - +"WHERE (((subrepair.sent) Between #~STRT# And #~END_#) AND ((subrepair.id) Is Not Null) AND ((subrepair.isback)=False) AND ((wo.client)~CUST) AND ((units.id)~UNIT)) " - +"ORDER BY subrepair.sent;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=27));",q2); - executeQuery(q); - - - //ALL - q2="SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, nonclients.company_person AS SENTTO, nonclients_1.company_person AS SENTVIA, subrepair.sent AS DATESENT, subrepair.eta AS RECEIVEETA, subrepair.received AS DATERECEIVED, [nonclients_2].[company_person] & \" \" & [unitmodels].[model] & \" \" & [unitmodels].[description] & \" sn: \" & [units].[sn] AS ITEM, units.sn, nonclients_2.company_person AS MANUFACTURER, unitmodels.model, unitmodels.description, subrepair.waybill, subrepair.rma, subrepair.isback " - +"FROM nonclients AS nonclients_2 RIGHT JOIN (((units RIGHT JOIN ((clients RIGHT JOIN (subrepair RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON subrepair.link = probs.id) ON clients.id = wo.client) LEFT JOIN nonclients ON subrepair.where = nonclients.id) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS nonclients_1 ON subrepair.sentvia = nonclients_1.id) ON nonclients_2.id = unitmodels.manufacturer " - +"WHERE (((subrepair.sent) Between #~STRT# And #~END_#) AND ((subrepair.id) Is Not Null) AND ((wo.client)~CUST) AND ((units.id)~UNIT)) " - +"ORDER BY subrepair.sent;"; - - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=28));",q2); - executeQuery(q); - - - - - ////WARNING MESSAGE ABOUT COLUMN FORMATS IN MAIN WORKORDER VIEW BEING MESSED UP - //AfxMessageBox("Part of this update modifies the main workorder list view screen to add the \r\nCUSTOMER REFERENCE NUMBER column.\r\n\r\n" - // "You will need to re-order the columns in the main view to your preferences and re-save the views.\r\n\r\n" - // "This update affects the column order only, not the underlying restriction settings."); - - - - - - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"144\";"); - nVersion=144; - - - } - - break; - case 144://changed to 145 on May 23rd 2001 various updates - { - - - - - //Add securenet's fields to wo header - executeQuery("ALTER TABLE wo ADD COLUMN prob_reported TEXT(255);"); - executeQuery("ALTER TABLE wo ADD COLUMN prob_found TEXT(255);"); - executeQuery("ALTER TABLE wo ADD COLUMN action_taken TEXT(255);"); - - //Add corresponding entry to defaults to flag whether to show - //those new fields or not - executeQuery("ALTER TABLE defaults ADD COLUMN showprobaction YESNO;"); - //rs->Close(); - - //Default to no for everyone for now - executeQuery("UPDATE defaults SET showprobaction = False;"); - - - - - - - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"145\";"); - nVersion=145; - - - } - - break; - case 145://changed to 146 on May 27th 2001 various updates - { - - - //Add weeks and days fields to pm header - executeQuery("ALTER TABLE pmhead ADD COLUMN rptweeks INTEGER;"); - executeQuery("ALTER TABLE pmhead ADD COLUMN rptdays INTEGER;"); - - executeQuery("ALTER TABLE pmhead ALTER rptweeks SET DEFAULT '0';"); - executeQuery("ALTER TABLE pmhead ALTER rptdays SET DEFAULT '0';"); - - //rs->Close(); - - //set all to 0 initially - executeQuery("UPDATE pmhead SET rptweeks = 0;"); - executeQuery("UPDATE pmhead SET rptdays = 0;"); - - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"146\";"); - nVersion=146; - - - } - - break; - - case 146://changed to 147 on june 21th 2001 various updates - { - - - - //set all blank company fields to last, first names - OleDbCommand cmdr = new OleDbCommand("SELECT clients.last, clients.first, clients.bizphone FROM clients " - +"WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) " - +"ORDER BY clients.last;", conn); + //string msg,strTemp,strData; - OleDbDataReader rdr; - rdr = cmdr.ExecuteReader(); + string q, q2; + DateTime dtDefault = new DateTime(1968, 03, 12); + bool buptodate = false; + bool bUpdateRanOK; + + //do whatever updates are necessary. + while (!buptodate) + { + switch (nVersion) + { + #region older versions I didn't need to migrate (yet) + // //================================================== + //case 126://changed to 127 on 8/22/00 + // { + // //Added a record to the rptsmaster table for the + // //workorder dispatch report + // //Not a schema update only an added record + + + // //see if the record is here already so it's not done twice: + // rs->Query("SELECT rptsmaster.virtualname " + // "FROM rptsmaster WHERE (((rptsmaster.virtualname)=\"Workorder dispatch\"));"); + // if(rs->IsEmpty()) + // { + // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + // "SELECT \"Workorder dispatch\", \"wodispst.rpt\", \"wodispatch\", False, 32767, 21;"); + + + + // } + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"127\";"); + // nVersion=127; + + + // } + + // break; + // //====================================================== + //case 127://changed to 128 on 8/24/00 + // { + // //Added a record to the rptsmaster table for the + // //QUICK workorder dispatch report + // //Not a schema update only an added record + + + // //see if the record is here already so it's not done twice: + // rs->Query("SELECT rptsmaster.virtualname " + // "FROM rptsmaster WHERE (((rptsmaster.virtualname)=\"Workorder dispatch (Quick)\"));"); + // if(rs->IsEmpty()) + // { + // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + // "SELECT \"Workorder dispatch (Quick)\", \"wodispqu.rpt\", \"wodispatch\", False, 32767, 22;"); + + + + // } + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"128\";"); + // nVersion=128; + + // } + + // break; + + // //===================================================== + //case 128://changed to 129 on 8/28/00 + // { + // //Dropped contacts table fields: wolink, problink + // //added fields: clientlink + + + // executeQuery("ALTER TABLE contacts DROP COLUMN wolink;"); + // executeQuery("ALTER TABLE contacts DROP COLUMN problink;"); + // executeQuery("ALTER TABLE contacts ADD COLUMN clientlink LONG;"); + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"129\";"); + + // nVersion=129; + // } + + // break; + //case 129://changed to 130 on 8/29/00 - 8/31/00 + // { + // //contacts table added field:indexed + // //units table added field:indexed + + // executeQuery("ALTER TABLE contacts ADD COLUMN indexed YESNO;"); + // executeQuery("UPDATE contacts SET contacts.indexed = False;"); + + // executeQuery("ALTER TABLE units ADD COLUMN indexed YESNO;"); + // executeQuery("UPDATE units SET units.indexed = False;"); + + // //add the unit history to reports screen + // q2="SELECT \"user\" AS zCurrentUser, probs.id, Format([start],\"Short Date\") AS " + // "servdate, labor.details, IIf(IsNull([company]),[clients]![last] & \", \" & [clients]![first],[company]) " + // "AS clientcompany, units.sn, unitmodels.model, users.initials, probs.meter, ztotalparts.totalparts, " + // "ztotallabor.totallabor " + // "FROM [SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor, " + // "probs.id FROM probs INNER JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON " + // "travrates.id = labor.rate) ON rates.id = labor.rate) ON probs.id = labor.link GROUP BY probs.id]. AS " + // "ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)),0, " + // "Sum(woparts.quantity*woparts.price)) AS totalparts, probs.id FROM probs LEFT JOIN woparts " + // "ON probs.id = woparts.link GROUP BY probs.id]. AS ztotalparts RIGHT JOIN (users RIGHT JOIN " + // "((labor RIGHT JOIN (((wo RIGHT JOIN probs ON wo.id = probs.wolink) LEFT JOIN units ON " + // "probs.unit = units.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) ON labor.link = " + // "probs.id) LEFT JOIN clients ON wo.client = clients.id) ON users.id = labor.tech) ON ztotalparts.id " + // "= probs.id) ON ztotallabor.id = probs.id " + // "WHERE (((probs.unit)~UNIT) AND ((units.sn) Is Not Null) AND ((labor.start) Between #~STRT# And #~END_#)) " + // "ORDER BY labor.start DESC;"; + + // q=string.Format("UPDATE rptsmaster SET rptsmaster.x = True, rptsmaster.criteriafields = 400, rptsmaster.query = '%s' " + // "WHERE (((rptsmaster.id)=7));",q2); + + // executeQuery(q); + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"130\";"); + // nVersion=130; + + + // } + + // break; + // //===================================================== + //case 130://changed to 131 on 9/12/00 + // { + // //PM module additions + + // executeQuery("ALTER TABLE pmschedules ADD COLUMN autoworkorder YESNO;"); + // executeQuery("UPDATE pmschedules SET pmschedules.autoworkorder = False;"); + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"131\";"); + + // nVersion=131; + + + // } + + // break; + // //*************************************************************************** + //case 131://changed to 132 on 9/22/00 and now 133 on 10/02/00 + // { //since it's unreleased, decided to bump up one more. + // //PM module additions + + + // //Add a last meter reading column to the units table + // //this is updated when someone enters a workorder unit count. + // //to make pm easier to deal with. + + // executeQuery("ALTER TABLE units ADD COLUMN lastmeter INTEGER;"); + // //NOTE: CANT SET TO DEFAULT OF ZERO WITHOUT IT CRASHING OUT + + + + // //Delete the pmschedules, superseded by pmhead table below + // executeQuery("DROP TABLE pmschedules;"); + + + // //new pm header table + // q=string.Format("CREATE TABLE pmhead (" + // "id COUNTER CONSTRAINT PK_pmhead PRIMARY KEY, " + // "description TEXT(50), " + // "notes MEMO, " + // "link INTEGER DEFAULT 0, "//link to client or unit id number + // "type INTEGER DEFAULT 0, " //0-timebased,1-meter,2-agebased + // "isclient YESNO DEFAULT False, " //true = client false=unitbased + // "ismodel YESNO DEFAULT False, " //true = MODEL false=units or clients + // "autowo YESNO DEFAULT False, " + // "autorpt YESNO DEFAULT False, " + // "dow INTEGER DEFAULT 0," //autoschedule day of week 0any 1-monday 2-tuesd etc + // "tech INTEGER DEFAULT 0, " //HEREpreferred technician + // "woconvert INTEGER DEFAULT 0, " //convert to workorder days / meter counts in advance + // "nextsrvdate DATETIME DEFAULT #%s#, " + // "nextsrvmeter INTEGER DEFAULT 0, "//next meter count to service on + // "repeatevery INTEGER DEFAULT 0, "//repeat every meter / months + // "agemonths INTEGER DEFAULT 0, "//Age based: months old to schedule + // "ageyears INTEGER DEFAULT 0, "//Age based: years old to schedule + // "active YESNO DEFAULT True, "//on hold or active? + // "series INTEGER DEFAULT 0, "//schedule this many series at a time + // "creator INTEGER DEFAULT 0, "//user who created record + // "created DATETIME DEFAULT #%s#, " //date created + // "modifier INTEGER DEFAULT 0, "//date modified who cares?? probably no one + // "modified DATETIME DEFAULT #%s#, " + // "wotype INTEGER DEFAULT 0, " + // "woquick YESNO DEFAULT False, " + // "woproject INTEGER DEFAULT 0, " + // "woonsite YESNO DEFAULT False);" + // ,dtDefault.Format(_T("%m/%d/%Y")),dtDefault.Format(_T("%m/%d/%Y")),dtDefault.Format(_T("%m/%d/%Y"))); + + // executeQuery(q); + + + + // //new table to hold preventative maintenance items + // //in schedule viewer + // q=string.Format("CREATE TABLE pmitems (" + // "id COUNTER CONSTRAINT PK_pmitem PRIMARY KEY, " + // "pmschedlink INTEGER DEFAULT 0, " + // "clientlink INTEGER DEFAULT 0, " + // "schedate DATETIME DEFAULT #%s#, " + // "schedmeter INTEGER DEFAULT 0, " + // "autowo YESNO DEFAULT True, " + // "hold YESNO DEFAULT False, " + // "schedtech INTEGER DEFAULT 0, " + // "link INTEGER DEFAULT 0, "//link to client or unit id number + // "isclient YESNO DEFAULT False);",dtDefault.Format(_T("%m/%d/%Y"))); //true = client false=unitbased + + // executeQuery(q); + + + // //clear out the pmparts table + // executeQuery("DELETE pmparts.* FROM pmparts;"); + + // //set correct report control profile for PM check screen now 8 columns was 7 + // executeQuery("UPDATE users SET users.pmprofile = \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); + + // //Add the lastmaintdate column to the defaults table + // //this is used for maintenance to ensure that only one station + // //tries to do it at a time: When SC is run, it checks to see if + // //this date is older than the current date, if so, it "locks" it by + // //updating to today's date, thereby effectively locking out any latecomers + // //then runs any required maintenance. + // executeQuery("ALTER TABLE defaults ADD COLUMN lastmaintdate DATETIME;"); + // q=string.Format("UPDATE defaults SET defaults.lastmaintdate = #%s#;",dtDefault.Format(_T("%m/%d/%Y"))); + // executeQuery(q); + + + // //Add the woestimate column to the defaults table, this is to + // //flag whether to use estimates on dispatch workorders or not. + // //this is in response to TCCSI client that needs this and it + // //will now be available to all users. This flag is settable under the + // //defaults screen, program, not users + // executeQuery("ALTER TABLE defaults ADD COLUMN woestimate YESNO;"); + // executeQuery("UPDATE defaults SET defaults.woestimate = False;"); + + // //Customer reference number and contact + // //as suggested by Rob MacKay in Australia + // executeQuery("ALTER TABLE wo ADD COLUMN clientrefnum TEXT(50);"); + // executeQuery("ALTER TABLE wo ADD COLUMN clientcontact TEXT(50);"); + + + // //Add a first boot field to detect new evaluation versions + // //this will be used to show a friendly welcome to message and + // //to fixup the dates in the demo data. + + // //set to false because if this field isn't in the table already, + // //it means user has older version so it just needs to be there + // //not actually used + // executeQuery("ALTER TABLE defaults ADD COLUMN firstboot YESNO;"); + // executeQuery("UPDATE defaults SET defaults.firstboot = False;"); + + // //refdate is used in an eval to fixup all the dates + // //in the evaluation database. + // //so that the evaluator sees the demo data as current + // executeQuery("ALTER TABLE defaults ADD COLUMN refdate DATETIME;"); + + + // //DROP the pm columns no longer required in the units table + // executeQuery("ALTER TABLE units DROP COLUMN lastpmmetric;"); + // executeQuery("ALTER TABLE units DROP COLUMN lastpmdate;"); + // executeQuery("ALTER TABLE units DROP COLUMN nextpmmetric;"); + // executeQuery("ALTER TABLE units DROP COLUMN nextpmdate;"); + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"133\";"); + + // nVersion=133; + + + // } + + // break; + // //===================================================== + //case 133://changed to 134 for schedule view + // { + // CString strID,strName,strRights,strHash; + // long lData; + // GZK k; + + + // //Add new right: + // //loop through all the group records + // rs->Query("SELECT groups.* FROM groups;"); + // do{ + // rs->FetchField("id",&lData); + // rs->FetchField("a",&strName); + // rs->FetchField("b",&strRights); + + // //decrypt the original rights string + // k.GZDecrypt(&strRights,false); + // strRights=strRights+"1";//add on the extra right for schedule view + + // //re-'crypt' + // k.GZEncrypt(&strRights,false); + + // //HASH + // strHash.Format("%u%s%s",lData,strName,strRights); + // k.GZHash(&strHash); + + // //save the rights + // rs->UpdateField("b",&strRights); + + // //save the hash + // rs->UpdateField("c",&strHash); + + // //save the record + // if(!rs->SaveRecord()) + // AfxMessageBox("Error trying to save record"); + + + + + + + + // }while(rs->MoveForward()); + + + + + + // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + // "SELECT \"Parts\", \"parts.rpt\", \".\", False, 32767, 23;"); + + + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"134\";"); + + // nVersion=134; + + + + // } + + // break; + // //*************************************************************************** + + // //===================================================== + //case 134://changed to 135 on 12/19/00 + // { + + // executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + // "SELECT \"Search results\", \"srch.rpt\", \".\", False, 32767, 24;"); + + // executeQuery("ALTER TABLE users ADD COLUMN rpttext1 MEMO;"); + + // //fix the version number up + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"135\";"); + + // nVersion=135; + + // } + + // break; + + // //===================================================== + //case 135://changed to 136 on Jan 15 2001 + // { + // bUpdateRanOK=true; + + // //USER RECORD CHANGES + // executeQuery("ALTER TABLE users ADD COLUMN defschedstarthour INTEGER;"); + // executeQuery("ALTER TABLE users ADD COLUMN defschedstophour INTEGER;"); + // executeQuery("ALTER TABLE users ALTER defschedstarthour SET DEFAULT '0';"); + // executeQuery("ALTER TABLE users ALTER defschedstophour SET DEFAULT '0';"); + // if(!executeQuery("UPDATE users SET users.defschedstarthour = 0, users.defschedstophour = 0;")) bUpdateRanOK=false; + + // //WORKORDER COLUMN CHANGES + // executeQuery("ALTER TABLE wo ADD COLUMN status INTEGER;"); + // executeQuery("ALTER TABLE wo ALTER status SET DEFAULT '0';"); + // executeQuery("UPDATE wo SET wo.status = 0;"); + + // executeQuery("ALTER TABLE wo ADD COLUMN ourref TEXT(80);"); + + // executeQuery("ALTER TABLE wo ADD COLUMN esthours REAL;"); + // executeQuery("ALTER TABLE wo ADD COLUMN estrate INTEGER;"); + + // executeQuery("ALTER TABLE wo ALTER notes TEXT(110)"); + + // //STATUS VIEW SCREEN CHANGE + // executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(17,17) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\";"); + + // //fix the version number up as long as updates seem ok + // if(bUpdateRanOK) + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"136\";"); + + // AfxMessageBox("Part of this update modifies the main workorder list view screen.\r\n\r\n" + // "You will need to re-order the columns in the main view to your preferences and re-save the views.\r\n\r\n" + // "This update affects the column order only, not the underlying restriction settings."); + // nVersion=136; + + // } + + // break; + + // //===================================================== + //case 136://changed to 137 on Jan 18 2001 + // { + + + // //NEW FIELDS TO ADD TO STATUS VIEW TABLE + // executeQuery("ALTER TABLE statusviews ADD COLUMN ourref INTEGER;"); + // executeQuery("ALTER TABLE statusviews ADD COLUMN status INTEGER;"); + // executeQuery("ALTER TABLE statusviews ALTER ourref SET DEFAULT '0';"); + // executeQuery("ALTER TABLE statusviews ALTER status SET DEFAULT '0';"); + + // executeQuery("UPDATE statusviews SET statusviews.status = 1;"); + // executeQuery("UPDATE statusviews SET statusviews.ourref = 1;"); + + // executeQuery("ALTER TABLE woparts ADD COLUMN sn TEXT(255);"); + + // //client account number + // executeQuery("ALTER TABLE clients ADD COLUMN acctnumber TEXT(40);"); + + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"137\";"); + // nVersion=137; + // } + + // break; + //case 137://changed to 138 on Jan 29 2001 -bug in tech billing summary + // { + + // q2="SELECT [users].[last] & \", \" & [users].[first] AS name, Sum(techsubq.hours) AS SumOfhours, Sum(techsubq.nchours) AS SumOfnchours, Sum(techsubq.travhours) AS SumOftravhours, Sum(techsubq.wototal) AS SumOfwototal " + // "FROM [SELECT labor.tech, labor.hours, labor.nchours, labor.travhours, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS wototal " + // "FROM rates AS travelrates RIGHT JOIN (((labor LEFT JOIN (probs LEFT JOIN wo ON probs.wolink = wo.id) ON labor.link = probs.id) LEFT JOIN rates ON labor.rate = rates.id) LEFT JOIN clients ON wo.client = clients.id) ON travelrates.id = labor.travrate " + // "WHERE (((labor.tech)<>-1) AND ((labor.stop) Between #~STRT# And #~END_#) AND ((clients.czone)<>-1) AND ((wo.type)<>-1) AND ((wo.project)<>-1) AND ((wo.client)<>-1))]. AS techsubq INNER JOIN users ON techsubq.tech = users.id " + // "GROUP BY techsubq.tech, [users].[last] & \", \" & [users].[first] " + // "ORDER BY [users].[last] & \", \" & [users].[first];"; + + // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + // "WHERE (((rptsmaster.id)=17));",q2); + + // executeQuery(q); + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"138\";"); + // nVersion=138; + + // } + + // break; + //case 138://changed to 139 on Jan 29 2001 -bug in tech billing summary and didn't fix it the first time + // { + + // q2="SELECT [users].[last] & \", \" & [users].[first] AS name, Sum(techsubq.hours) AS SumOfhours, Sum(techsubq.nchours) AS SumOfnchours, Sum(techsubq.travhours) AS SumOftravhours, Sum(techsubq.wototal) AS SumOfwototal " + // "FROM [SELECT labor.tech, labor.hours, labor.nchours, labor.travhours, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS wototal " + // "FROM rates AS travelrates RIGHT JOIN (((labor LEFT JOIN (probs LEFT JOIN wo ON probs.wolink = wo.id) ON labor.link = probs.id) LEFT JOIN rates ON labor.rate = rates.id) LEFT JOIN clients ON wo.client = clients.id) ON travelrates.id = labor.travrate " + // "WHERE (((labor.tech)~TECH) AND ((labor.stop) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ) AND ((wo.client)~CUST))]. AS techsubq INNER JOIN users ON techsubq.tech = users.id " + // "GROUP BY techsubq.tech, [users].[last] & \", \" & [users].[first] " + // "ORDER BY [users].[last] & \", \" & [users].[first];"; + + // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + // "WHERE (((rptsmaster.id)=17));",q2); + + // executeQuery(q); + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"139\";"); + // nVersion=139; + + // } + + // break; + //case 139://changed to 140 on Feb 15 2001 Added color to status items + // { + + // executeQuery("ALTER TABLE probstat ADD COLUMN red INTEGER;"); + // executeQuery("ALTER TABLE probstat ADD COLUMN green INTEGER;"); + // executeQuery("ALTER TABLE probstat ADD COLUMN blue INTEGER;"); + + // executeQuery("ALTER TABLE probstat ALTER red SET DEFAULT '0';"); + // executeQuery("ALTER TABLE probstat ALTER green SET DEFAULT '0';"); + // executeQuery("ALTER TABLE probstat ALTER blue SET DEFAULT '0';"); + + + // //set all to black initially + // executeQuery("UPDATE probstat SET probstat.red = 0;"); + // executeQuery("UPDATE probstat SET probstat.green = 0;"); + // executeQuery("UPDATE probstat SET probstat.blue = 0;"); + + + + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"140\";"); + // nVersion=140; + + + // } + + // break; + + + //case 140://changed to 141 on March 7th 2001 bug in report: Billing summary - hours/parts/3rd party + // { + + // q2="SELECT IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS company, Choose([typeUNIONsub].[type],\"Service\",\"3rd party\",\"Parts\") AS chargesfrom, Sum(typeUNIONsub.total) AS total " + // "FROM ([SELECT probs.wolink AS link, \"1\" AS type, (rates.rate*labor.hours)+(travelrates.rate*labor.travhours) AS total " + // "FROM (rates INNER JOIN (rates AS travelrates INNER JOIN labor ON travelrates.id = labor.travrate) ON rates.id = labor.rate) INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON labor.link = probs.id " + // "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ)) " + // "UNION ALL (SELECT probs.wolink AS link, \"2\" AS type, subrepair.charge AS total " + // "FROM subrepair INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON subrepair.link = probs.id " + // "WHERE (((subrepair.charge)<>0) AND ((wo.created) Between #~STRT# And #~END_#) AND ((clients.czone)~ZONE) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ)) " + // "UNION ALL (SELECT probs.wolink, \"3\" AS type, woparts.quantity*woparts.price AS total " + // "FROM woparts INNER JOIN (clients INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON clients.id = wo.client) ON woparts.link = probs.id " + // "WHERE (((clients.czone)~ZONE) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((wo.project)~PROJ))) " + // " )]. AS typeUNIONsub INNER JOIN wo ON typeUNIONsub.link = wo.id) INNER JOIN clients ON wo.client = clients.id " + // "GROUP BY IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]), Choose([typeUNIONsub].[type],\"Service\",\"3rd party\",\"Parts\");"; + + // q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + // "WHERE (((rptsmaster.id)=4));",q2); + + // executeQuery(q); + + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"141\";"); + // nVersion=141; + + + // } + + // break; + + + //case 141://changed to 142 on March 26th 2001 various updates + // { + + + // //Add zone field to users + // executeQuery("ALTER TABLE users ADD COLUMN defzone INTEGER;"); + // executeQuery("ALTER TABLE users ALTER defzone SET DEFAULT '0';"); + + // //set all zones to 0 initially + // executeQuery("UPDATE users SET users.defzone = 0;"); + + // //Add default wo status fields to defaults + // executeQuery("ALTER TABLE defaults ADD COLUMN wonewstat INTEGER;"); + // executeQuery("ALTER TABLE defaults ADD COLUMN woclosestat INTEGER;"); + // executeQuery("ALTER TABLE defaults ADD COLUMN woreopenstat INTEGER;"); + + // //add default schedule screen refresh time period + // executeQuery("ALTER TABLE defaults ADD COLUMN schedrfrshsecs INTEGER;"); + + // //set all 0 initially + // executeQuery("UPDATE defaults SET defaults.wonewstat = 0, defaults.woclosestat = 0, defaults.woreopenstat = 0, defaults.schedrfrshsecs = 60;"); + + + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"142\";"); + // nVersion=142; + + // } + + // break; + + + + //case 142://changed to 143 on April 6th 2001 various updates + // { + + // //Add default wo status fields to defaults + // executeQuery("ALTER TABLE defaults ADD COLUMN schedwindow INTEGER;"); + + + + // //set to 30 day window by default + // executeQuery("UPDATE defaults SET defaults.schedwindow = 30;"); + + + + // //fix the version number up as long as updates seem ok + // executeQuery("UPDATE defaults SET defaults.versioninfo = \"143\";"); + // nVersion=143; + + // } + + // break; + #endregion older versions I didn't need to migrate yet + + case 143://changed to 144 on May 8th 2001 various updates + { + + //Add xfertempl table and set values. This is for import export + + q = ("CREATE TABLE xfertempl (" + + "name TEXT(80) CONSTRAINT PK_name PRIMARY KEY, " + + "import YESNO DEFAULT False, " + + "delimiter TEXT(1), " + + "fields MEMO, " + + "builtin YESNO DEFAULT False, " + + "fieldnames YESNO DEFAULT False, " + + "path MEMO, " + + "[sql] MEMO, " + + "[table] TEXT(50));"); + + executeQuery(q); + // executeQuery(q); + + ////rs->Close(); + + + q2 = "\"+first\",\"+last\",\"+company\",\"+mailaddress\",\"+streetaddress\",\"+city\",\"+stateprov\",\"+postal\",\"+country\",\"+bizphone\",\"+extension\",\"+fax\",\"+email\",\"+technotes\",\"+alert\",\"+generalnotes\",\"-acctnumber\""; + q = string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " + + "SELECT \"Clients\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT * FROM clients;\",\"clients\";", q2); + + cmd.CommandText = q; + cmd.ExecuteNonQuery(); + + + q2 = "\"+partnumber\",\"+description\",\"+avgcost\",\"+retail\",\"+notes\",\"+supplierpart\",\"-upc\""; + q = string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " + + "SELECT \"Parts\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT * FROM parts;\",\"parts\";", q2); + executeQuery(q); + + + q2 = "\"+Customer\",\"+Contact\",\"+Phone\",\"+Fax\",\"+Address\",\"+Notes\",\"+Account\""; + q = string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " + + "SELECT \"Quick Books - Clients\" , True, \"T\",'%s', True, False, \"c:\\\", \"\",\"QBCLIENTS\";", q2); + executeQuery(q); + + q2 = "\"+id\",\"+sn\",\"+id1\",\"+id2\",\"+id3\",\"+company\",\"+first\",\"+last\",\"+receipt\",\"+purchasedate\",\"+model\",\"+manufacturer\",\"+name\",\"+loaner\",\"+lastmeter\""; + q = string.Format("INSERT INTO xfertempl ( name, import, delimiter, fields, builtin, fieldnames, path, [sql], [table] ) " + + "SELECT \"Units\" , False, \",\",'%s', True, True, \"c:\\\", \"SELECT units.id, units.sn, units.id1, units.id2, units.id3, clients.company, clients.first, clients.last, units.receipt, units.purchasedate, unitmodels.model, nonclients.company_person AS manufacturer, unitmodelcats.name, units.loaner, units.lastmeter " + + "FROM ((units LEFT JOIN (unitmodels LEFT JOIN unitmodelcats ON unitmodels.category = unitmodelcats.id) ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN clients ON units.client = clients.id;\",\"sql\";", q2); + executeQuery(q); + + + executeQuery("ALTER TABLE wo ADD COLUMN indexed YESNO;"); + executeQuery("UPDATE wo SET wo.indexed = False;"); + + //new account number field for non-clients + executeQuery("ALTER TABLE nonclients ADD COLUMN account TEXT(40);"); + + //new custref column stuff here: + executeQuery("ALTER TABLE statusviews ADD COLUMN custref INTEGER;"); + executeQuery("ALTER TABLE statusviews ALTER custref SET DEFAULT '0';"); + executeQuery("UPDATE statusviews SET statusviews.custref = 1;"); + executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(18,18) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17\";"); + + + //fix of pmprofile bug where it defaults to 7 columns for new users rather + //then the actual value of 8 + //set correct report control profile for PM check screen now 8 columns was 7 + executeQuery("UPDATE users SET users.pmprofile = \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); + executeQuery("ALTER TABLE users ALTER pmprofile SET DEFAULT \"(8,8) 111 70 91 93 67 67 258 0 0 1 2 3 4 5 6 7\";"); + + + + + //Add new parts used on workorder reports to rptsmaster + //DETAILED + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Parts on workorders\", \"partwo.rpt\", \"mgr\", True, 397, 25;"); + //SUMMARY + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Parts on workorder - summarized\", \"prtwosum.rpt\", \"mgr\", True, 397, 26;"); + + + //DETAILED + q2 = "SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, wo.starttime AS SCHEDULED, IIf(IsNull([partnumber]),\"misc.\",[partnumber]) AS PART, IIf(IsNull([partnumber]),[misc],[description]) AS [DESC], woparts.quantity, woparts.sn, users.last AS TECH, wo.closed, woparts.price AS WOPRICE, parts.retail, clients.id AS CLIENTID, wo.created AS WOCREATED, wo.project, wo.type " + + "FROM (((woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum = parts.id) LEFT JOIN users ON wo.assigntech = users.id) LEFT JOIN clients ON wo.client = clients.id " + + "WHERE (((clients.id)~CUST) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((woparts.id) Is Not Null)) " + + "ORDER BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]);"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=25));", q2); + executeQuery(q); + + + //SUMMARY + q2 = "SELECT IIf(IsNull([partnumber]),\"misc.\",[partnumber]) AS PART, IIf(IsNull([partnumber]),[misc],[description]) AS [DESC], #~STRT# AS STARTDATE, #~END_# AS ENDDATE, Sum(woparts.quantity) AS [TOTAL USED] " + + "FROM (((woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum = parts.id) LEFT JOIN users ON wo.assigntech = users.id) LEFT JOIN clients ON wo.client = clients.id " + + "WHERE (((clients.id)~CUST) AND ((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((woparts.id) Is Not Null)) " + + "GROUP BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]), IIf(IsNull([partnumber]),[misc],[description]) " + + "ORDER BY IIf(IsNull([partnumber]),\"misc.\",[partnumber]);"; + + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=26));", q2); + executeQuery(q); + + + //Add SUBREPAIR REPORTS AND QUERIES + //OUTSTANDING + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Subrepair status - outstanding\", \"subrepair.rpt\", \"mgr\", True, 401, 27;"); + //ALL + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Subrepair status - all\", \"subrepairall.rpt\", \"mgr\", True, 401, 28;"); + + + //OUTSTANDING + q2 = "SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, nonclients.company_person AS SENTTO, nonclients_1.company_person AS SENTVIA, subrepair.sent AS DATESENT, subrepair.eta AS RECEIVEETA, subrepair.received AS DATERECEIVED, [nonclients_2].[company_person] & \" \" & [unitmodels].[model] & \" \" & [unitmodels].[description] & \" sn: \" & [units].[sn] AS ITEM, units.sn, nonclients_2.company_person AS MANUFACTURER, unitmodels.model, unitmodels.description, subrepair.waybill, subrepair.rma, subrepair.isback " + + "FROM nonclients AS nonclients_2 RIGHT JOIN (((units RIGHT JOIN ((clients RIGHT JOIN (subrepair RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON subrepair.link = probs.id) ON clients.id = wo.client) LEFT JOIN nonclients ON subrepair.where = nonclients.id) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS nonclients_1 ON subrepair.sentvia = nonclients_1.id) ON nonclients_2.id = unitmodels.manufacturer " + + "WHERE (((subrepair.sent) Between #~STRT# And #~END_#) AND ((subrepair.id) Is Not Null) AND ((subrepair.isback)=False) AND ((wo.client)~CUST) AND ((units.id)~UNIT)) " + + "ORDER BY subrepair.sent;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=27));", q2); + executeQuery(q); + + + //ALL + q2 = "SELECT IIf(IsNull([company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS CLIENT, wo.id AS WORKORDER, #~STRT# AS STARTDATE, #~END_# AS ENDDATE, nonclients.company_person AS SENTTO, nonclients_1.company_person AS SENTVIA, subrepair.sent AS DATESENT, subrepair.eta AS RECEIVEETA, subrepair.received AS DATERECEIVED, [nonclients_2].[company_person] & \" \" & [unitmodels].[model] & \" \" & [unitmodels].[description] & \" sn: \" & [units].[sn] AS ITEM, units.sn, nonclients_2.company_person AS MANUFACTURER, unitmodels.model, unitmodels.description, subrepair.waybill, subrepair.rma, subrepair.isback " + + "FROM nonclients AS nonclients_2 RIGHT JOIN (((units RIGHT JOIN ((clients RIGHT JOIN (subrepair RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON subrepair.link = probs.id) ON clients.id = wo.client) LEFT JOIN nonclients ON subrepair.where = nonclients.id) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS nonclients_1 ON subrepair.sentvia = nonclients_1.id) ON nonclients_2.id = unitmodels.manufacturer " + + "WHERE (((subrepair.sent) Between #~STRT# And #~END_#) AND ((subrepair.id) Is Not Null) AND ((wo.client)~CUST) AND ((units.id)~UNIT)) " + + "ORDER BY subrepair.sent;"; + + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=28));", q2); + executeQuery(q); + + + + + ////WARNING MESSAGE ABOUT COLUMN FORMATS IN MAIN WORKORDER VIEW BEING MESSED UP + //AfxMessageBox("Part of this update modifies the main workorder list view screen to add the \r\nCUSTOMER REFERENCE NUMBER column.\r\n\r\n" + // "You will need to re-order the columns in the main view to your preferences and re-save the views.\r\n\r\n" + // "This update affects the column order only, not the underlying restriction settings."); + + + + + + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"144\";"); + nVersion = 144; + + + } + + break; + case 144://changed to 145 on May 23rd 2001 various updates + { + + + + + //Add securenet's fields to wo header + executeQuery("ALTER TABLE wo ADD COLUMN prob_reported TEXT(255);"); + executeQuery("ALTER TABLE wo ADD COLUMN prob_found TEXT(255);"); + executeQuery("ALTER TABLE wo ADD COLUMN action_taken TEXT(255);"); + + //Add corresponding entry to defaults to flag whether to show + //those new fields or not + executeQuery("ALTER TABLE defaults ADD COLUMN showprobaction YESNO;"); + //rs->Close(); + + //Default to no for everyone for now + executeQuery("UPDATE defaults SET showprobaction = False;"); + + + + + + + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"145\";"); + nVersion = 145; + + + } + + break; + case 145://changed to 146 on May 27th 2001 various updates + { + + + //Add weeks and days fields to pm header + executeQuery("ALTER TABLE pmhead ADD COLUMN rptweeks INTEGER;"); + executeQuery("ALTER TABLE pmhead ADD COLUMN rptdays INTEGER;"); + + executeQuery("ALTER TABLE pmhead ALTER rptweeks SET DEFAULT '0';"); + executeQuery("ALTER TABLE pmhead ALTER rptdays SET DEFAULT '0';"); + + //rs->Close(); + + //set all to 0 initially + executeQuery("UPDATE pmhead SET rptweeks = 0;"); + executeQuery("UPDATE pmhead SET rptdays = 0;"); + + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"146\";"); + nVersion = 146; + + + } + + break; + + case 146://changed to 147 on june 21th 2001 various updates + { + + + + //set all blank company fields to last, first names + + OleDbCommand cmdr = new OleDbCommand("SELECT clients.last, clients.first, clients.bizphone FROM clients " + + "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) " + + "ORDER BY clients.last;", conn); + + OleDbDataReader rdr; + rdr = cmdr.ExecuteReader(); + + //rs->QueryReadOnly("SELECT clients.last, clients.first, clients.bizphone FROM clients " + // "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) " + // "ORDER BY clients.last;"); + //if(rs->IsEmpty()) + if (!rdr.Read())//meaning none + { + executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] " + + "WHERE (((clients.company) Is Null));"); + + //rs->Close(); + + } + else + { + + throw new Exception( + "Warning: Due to a change in the clients table in the database\r\n" + + "this update needs to move the contact first and last names to the former \r\n" + + "\"Company\" field which is now the single client field.\r\n\r\n" + + + "Your help is required to correct a problem before the update can finish:\r\n" + + "You have duplicate non-company clients and need to change them in the clients screen.\r\n\r\n" + + + "When this update completes and returns you to AyaNova, \r\n" + + "go directly to the client screen (Options->Edit->Clients) where you will be given\r\n" + + "more instructions on fixing the duplicate client names."); + + + //m_pApp->ShowStuff(strData); + //stop from doing anything further + //buptodate=true; + //break; + + } + + //---------------------------------------------------------------------------- + //Performance boost - new indexes + + executeQuery("CREATE INDEX idxanytime ON wo (anytime);"); + executeQuery("CREATE INDEX idxquick ON wo (quick);"); + executeQuery("CREATE INDEX idxassigntech ON wo (assigntech);"); + executeQuery("CREATE INDEX idxstarttime ON wo (starttime);"); + System.Diagnostics.Debug.WriteLine("This update contains speed improvements to the database.\r\n\r\n" + + "This will not take effect until *after* you COMPACT the database after updating.\r\n" + + "The COMPACT option is on the database utilities menu.\r\n" + + "(Re-indexing is not necessary, only COMPACT)"); + + //----------------------------------------------------------------------------- + + + //---------------------------------------------------------------------------- + //Add new schedule groups tables + + q = string.Format( + "CREATE TABLE schdgrps (" + + "id COUNTER CONSTRAINT PK_pmitem PRIMARY KEY, " + + "name TEXT(80));"); + executeQuery(q); + + q = string.Format("CREATE TABLE schdets (" + + "grpid INTEGER DEFAULT 0, " + + "techid INTEGER DEFAULT 0);"); + executeQuery(q); + + //rs->Close(); + + //group get's indexed because it's the searched and linked field + executeQuery("CREATE INDEX idxgrpid ON schdets (grpid);"); + //techid's don't get indexed because they are simply retrieved + + + //----------------------------------------------------------------------------- + + + //create subunits table + q = string.Format("CREATE TABLE subunits (" + + "masterunitid INTEGER DEFAULT 0, " + + "unitid INTEGER DEFAULT 0, " + + "creator INTEGER DEFAULT 0, "//user who created record + + "created DATETIME, " //date created + + "modifier INTEGER DEFAULT 0, "//date modified who cares?? probably no one + + "modified DATETIME);"); + executeQuery(q); + + executeQuery("CREATE INDEX idxmstrunit " + + "ON subunits (masterunitid);"); + + //----------------------------------------------------------------------------- + //add the master/sub unit report to reports screen + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Master and sub units (kits)\", \"unitkits.rpt\", \"mgr\", True, 3217, 29;"); + + q2 = "SELECT units.sn AS mastersn, units.id, units.client, unitmodels.manufacturer, units.model, unitmodels.description AS mastermodel, nonclients.company_person AS mastermake, unitmodelcats.name AS mastertype, units_1.sn AS subsn, unitmodels_1.description AS submodel, nonclients_1.company_person AS submake, unitmodelcats_1.name AS subtype " + + "FROM ((((subunits RIGHT JOIN (((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN unitmodelcats ON unitmodels.category = unitmodelcats.id) ON subunits.masterunitid = units.id) LEFT JOIN units AS units_1 ON subunits.unitid = units_1.id) LEFT JOIN unitmodels AS unitmodels_1 ON units_1.model = unitmodels_1.id) LEFT JOIN unitmodelcats AS unitmodelcats_1 ON unitmodels_1.category = unitmodelcats_1.id) LEFT JOIN nonclients AS nonclients_1 ON unitmodels_1.manufacturer = nonclients_1.id " + + "WHERE (((units.id)~UNIT) AND ((units.client)~CUST) AND ((unitmodels.manufacturer)~MANU) AND ((units.model)~MODL)) " + + "ORDER BY units.sn, units.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=29));", q2); + + executeQuery(q); + //----------------------------------------------------------------------------- + + //----------------------------------------------------------------------------- + //add the rate billing summary report to reports screen + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Billing summary by rate\", \"ratesums.rpt\", \"mgr\", True, 463, 30;"); + + q2 = "SELECT rates.name, Sum(labor.hours) AS SumOfhours, Sum(labor.nchours) AS SumOfnchours, Sum(labor.travhours) AS SumOftravhours, rates.rate, rates.travelrate " + + "FROM ((wo RIGHT JOIN probs ON wo.id = probs.wolink) RIGHT JOIN labor ON probs.id = labor.link) LEFT JOIN rates ON labor.rate = rates.id " + + "WHERE (((labor.start) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((labor.tech)~TECH) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((rates.id)~RATE) AND ((rates.active)=True)) " + + "GROUP BY rates.name, rates.rate, rates.travelrate, rates.id UNION (SELECT rates.name, Sum(labor.hours) AS SumOfhours, Sum(labor.nchours) AS SumOfnchours, Sum(labor.travhours) AS SumOftravhours, rates.rate, rates.travelrate " + + "FROM ((wo RIGHT JOIN probs ON wo.id = probs.wolink) RIGHT JOIN labor ON probs.id = labor.link) LEFT JOIN rates ON labor.travrate = rates.id " + + "WHERE (((labor.start) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((labor.tech)~TECH) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((rates.id)~RATE) AND ((rates.active)=True)) " + + "GROUP BY rates.name, rates.rate, rates.travelrate, rates.id) " + + "ORDER BY rates.name;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=30));", q2); + + executeQuery(q); + + + + + + + //----------------------------------------------------------------------------- + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"147\";"); + + nVersion = 147; + //----------------------------------------------------------------------------- + + + + } + + break; + + case 147://changed to 148 on july 6th 2001 for version 1.7.1.7 + { + + //---------------------------------------------------------------------------- + //increase size of srchdict.word from 30 characters to 50 + executeQuery("ALTER TABLE srchdict ALTER COLUMN word TEXT(50);"); + + //increase size of srch.client from 50 characters to 80 + executeQuery("ALTER TABLE srch ALTER COLUMN client TEXT(80);"); + + //----------------------------------------------------------------------------- + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"148\";"); + + //----------------------------------------------------------------------------- + nVersion = 148; + + } + + break; + case 148: + { + + //---------------------------------------------------------------------------- + //Add a program version number field to the database + executeQuery("ALTER TABLE defaults ADD COLUMN min_exe TEXT(25);"); + + + + //----------------------------------------------------------- + //Add schedule markers table and indices + + executeQuery("CREATE TABLE schedmarkers (" + + "id COUNTER CONSTRAINT PK_schedmrk PRIMARY KEY, " + + "link INTEGER DEFAULT 0," + + "startdate DATETIME, " + + "enddate DATETIME, " + + "notes TEXT(15), " + + "red INTEGER DEFAULT 128, " + + "green INTEGER DEFAULT 128, " + + "blue INTEGER DEFAULT 128" + + ");"); + executeQuery("CREATE INDEX idxsmlink " + + "ON schedmarkers (link);"); + + executeQuery("CREATE INDEX idxsmstdate " + + "ON schedmarkers (startdate);"); + + executeQuery("CREATE INDEX idxsmendate " + + "ON schedmarkers (enddate);"); + //---------------------------------------------------------- + + + //---------------------------------------------- + executeQuery("ALTER TABLE wo ADD COLUMN starttime2 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN stoptime2 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN assigntech2 INTEGER;"); + + executeQuery("ALTER TABLE wo ADD COLUMN starttime3 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN stoptime3 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN assigntech3 INTEGER;"); + + executeQuery("ALTER TABLE wo ADD COLUMN starttime4 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN stoptime4 DATETIME;"); + executeQuery("ALTER TABLE wo ADD COLUMN assigntech4 INTEGER;"); + + executeQuery("ALTER TABLE wo ALTER assigntech SET DEFAULT '-1';"); + executeQuery("ALTER TABLE wo ALTER assigntech2 SET DEFAULT '-1';"); + executeQuery("ALTER TABLE wo ALTER assigntech3 SET DEFAULT '-1';"); + executeQuery("ALTER TABLE wo ALTER assigntech4 SET DEFAULT '-1';"); + //---------------------------------------------- + executeQuery("CREATE INDEX idxassigntech2 ON wo (assigntech2);"); + executeQuery("CREATE INDEX idxstarttime2 ON wo (starttime2);"); + + executeQuery("CREATE INDEX idxassigntech3 ON wo (assigntech3);"); + executeQuery("CREATE INDEX idxstarttime3 ON wo (starttime3);"); + + executeQuery("CREATE INDEX idxassigntech4 ON wo (assigntech4);"); + executeQuery("CREATE INDEX idxstarttime4 ON wo (starttime4);"); + + //set extra techs to -1 meaning not assigned yet + executeQuery("UPDATE wo SET wo.assigntech2 = -1, wo.assigntech3 = -1, wo.assigntech4 = -1;"); + + //set non-scheduled workorders first tech to non assigned -1 + executeQuery("UPDATE wo SET wo.assigntech = -1 WHERE (((wo.anytime)=True));"); + + + //----------------------------------------------------------------------------- + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"149\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + + //----------------------------------------------------------------------------- + + nVersion = 149; + + } + + break; + + case 149: + { + //Last modified 07/30/2001 - added category/type column + //COLUMNMOD + //new CATEGORY column stuff here: + executeQuery("ALTER TABLE statusviews ADD COLUMN category INTEGER;"); + executeQuery("ALTER TABLE statusviews ALTER category SET DEFAULT '0';"); + executeQuery("UPDATE statusviews SET statusviews.category = -1;"); + + //new project column here + executeQuery("ALTER TABLE statusviews ADD COLUMN project INTEGER;"); + executeQuery("ALTER TABLE statusviews ALTER project SET DEFAULT '0';"); + executeQuery("UPDATE statusviews SET statusviews.category = -1;"); + + + //update all views to handle extra columns + executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(20,20) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\";"); + + + + //fix the version number up as long as updates seem ok + executeQuery("UPDATE defaults SET defaults.versioninfo = \"150\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + + ////WARNING MESSAGE ABOUT COLUMN FORMATS IN MAIN WORKORDER VIEW BEING MESSED UP + //System.Diagnostics.Debug.WriteLine("Part of this update modifies the main workorder list view screen to add the \r\n" + // "WORKORDER CATEGORY and PROJECT columns.\r\n\r\n" + // "This change will affect *all* the views you have configured in AyaNova.\r\n" + // "You will need to re-order the columns in the main view to your preferences and re-save each view separately.\r\n\r\n" + // "This update affects the column order only, not the underlying restriction settings.\r\n" + // "\r\nDo not attempt to edit your views until after you have restarted AyaNova when this update completes."); + + //----------------------------------------------------------------------------- + + nVersion = 150; + + + } + + break; + + case 150: + { + //ADD AYANOTIFY TABLES + //--------------------------------------- + executeQuery( + "CREATE TABLE notify_cfg (freq_mm INTEGER, [dow] INTEGER, stop_hour DATETIME, start_hour DATETIME, " + + "[attempts] INTEGER, [mapi] YESNO, keeplogdays INTEGER, [verboseLog] YESNO, login_name TEXT(50), " + + "login_pw TEXT(50), [connection] TEXT(120), from_address TEXT(80), [server] TEXT(120), " + + "next_xmit DATETIME, [dialup] YESNO, last_xmit DATETIME, dayspast INTEGER , " + + "daysfuture INTEGER);"); + + executeQuery("ALTER TABLE notify_cfg ALTER freq_mm SET DEFAULT '0';"); + executeQuery("ALTER TABLE notify_cfg ALTER dow SET DEFAULT '0';"); + executeQuery("ALTER TABLE notify_cfg ALTER attempts SET DEFAULT '0';"); + executeQuery("ALTER TABLE notify_cfg ALTER keeplogdays SET DEFAULT '30';"); + executeQuery("ALTER TABLE notify_cfg ALTER dayspast SET DEFAULT '0';"); + executeQuery("ALTER TABLE notify_cfg ALTER daysfuture SET DEFAULT '14';"); + + + + + + + + executeQuery( + "INSERT INTO notify_cfg ( freq_mm, dow, stop_hour, start_hour, attempts, mapi, " + + "keeplogdays, verboseLog, login_name, login_pw, [connection], from_address, server, " + + "next_xmit, dialup, last_xmit, dayspast, daysfuture ) " + + "SELECT 60 , 0, #12/30/1899 19:0:0#, #12/30/1899 7:0:0#, 0, False, 30, False, " + + "\"login\", \"password\", \"My ISP\", \"from_me@my_isp.com\", \"smtp.mail.my_isp.com\", " + + "#1/1/2000#, False, #1/1/2000#, 1, 14;"); + + + //log table + executeQuery("CREATE TABLE notify_log (" + + "id INTEGER DEFAULT 0, " + + "nwhen DATETIME, " + + "nwho INTEGER DEFAULT 0, " + + "nwhat TEXT(255), " + + "ntype INTEGER DEFAULT 0, " + + "nresult TEXT(255) " + + ");"); + + //temp table for building notifications + executeQuery("CREATE TABLE notify_temp (" + + "woid INTEGER DEFAULT 0, " + + "scheddate DATETIME, " + + "schedstop DATETIME, " + + "schedtech INTEGER DEFAULT 0 " + + ");"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"151\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + nVersion = 151; + + + } + + break; + + + case 151: + { + + //--------------------------------------- + //add the WORKORDERS report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Workorders\", \"allwo.rpt\", \"mgr\", True, 397, 31;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " + + "FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " + + " LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " + + "ORDER BY wo.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=31));", q2); + executeQuery(q); + //------------------------------------------------ + //--------------------------------------- + //add the WORKORDERS BRIEF report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Workorders - brief\", \"allwobrief.rpt\", \"mgr\", True, 397, 32;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " + + "FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(woparts.misc= \"\",parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " + + "LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " + + "ORDER BY wo.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=32));", q2); + executeQuery(q); + //------------------------------------------------ + + //--------------------------------------- + //add the Units by P.M. report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Units by P.M.\", \"pmunits.rpt\", \"mgr\", True, 2193, 33;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person AS MAKE, unitmodels.model, units.sn, unitmodels.description AS UNITDESC, units.id1, units.id2, units.id3, clients.company, nonclients.phone, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.nextsrvmeter, units.lastmeter, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, units.purchasedate, pmhead.ageyears, pmhead.agemonths, users.initials, users.first, users.last, pmhead.isclient " + + "FROM ((pmhead LEFT JOIN ((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) ON pmhead.link = units.id) LEFT JOIN clients ON units.client = clients.id) LEFT JOIN users ON pmhead.tech = users.id " + + "WHERE (((pmhead.isclient)=False) AND ((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " + + "ORDER BY nonclients.company_person, unitmodels.model, units.sn, clients.company;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=33));", q2); + executeQuery(q); + //------------------------------------------------ + + //--------------------------------------- + //add the P.M. by Units report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"P.M. by Units\", \"unitspm.rpt\", \"mgr\", True, 2193, 34;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person AS MAKE, unitmodels.model, units.sn, unitmodels.description AS UNITDESC, units.id1, units.id2, units.id3, clients.company, nonclients.phone, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.nextsrvmeter, units.lastmeter, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, units.purchasedate, pmhead.ageyears, pmhead.agemonths, users.initials, users.first, users.last, pmhead.isclient " + + "FROM ((pmhead LEFT JOIN ((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) ON pmhead.link = units.id) LEFT JOIN clients ON units.client = clients.id) LEFT JOIN users ON pmhead.tech = users.id " + + "WHERE (((pmhead.isclient)=False) AND ((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " + + "ORDER BY nonclients.company_person, unitmodels.model, units.sn, clients.company;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=34));", q2); + executeQuery(q); + //------------------------------------------------ + + //--------------------------------------- + //add the P.M. by Client report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"P.M. by Client\", \"clientpm.rpt\", \"mgr\", True, 385, 35;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, clients.company, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.link AS CLIENTID, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, pmhead.ageyears, pmhead.agemonths, users.initials, users.first AS TECH_FIRST, users.last AS TECH_LAST " + + "FROM clients RIGHT JOIN (pmhead LEFT JOIN users ON pmhead.tech = users.id) ON clients.id = pmhead.link " + + "WHERE (((pmhead.nextsrvdate) Between #~STRT# And #~END_#) AND ((pmhead.link)~CUST) AND ((pmhead.isclient)=True)) " + + "ORDER BY clients.company;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=35));", q2); + executeQuery(q); + //------------------------------------------------ + + + //--------------------------------------- + //add the Workorders not invoiced report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Workorders not invoiced\", \"notbilled.rpt\", \"mgr\", True, 385, 36;"); + + q2 = strData = "SELECT ~CRITERIA AS CRITERIA, wo.id, clients.company, wo.modified, wo.ourref, wo.clientrefnum, wo.clientcontact, wo.closed, wo.invoice, wo.notes " + + "FROM probstat RIGHT JOIN (wo LEFT JOIN clients ON wo.client = clients.id) ON probstat.id = wo.status " + + "WHERE (((wo.modified) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.invoice) Is Null)) " + + "ORDER BY wo.modified DESC;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=36));", q2); + executeQuery(q); + //------------------------------------------------ + + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"152\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + nVersion = 152; + + + } + + break; + + + + case 152: //update for v1720 added extra security rights items + { - //rs->QueryReadOnly("SELECT clients.last, clients.first, clients.bizphone FROM clients " - // "WHERE (((clients.first) In (SELECT [first] FROM [clients] As Tmp GROUP BY [first],[last] HAVING Count(*)>1 And [last] = [clients].[last])) AND ((clients.company) Is Null)) " - // "ORDER BY clients.last;"); - //if(rs->IsEmpty()) - if(!rdr.Read())//meaning none - { - executeQuery("UPDATE clients SET clients.company = [last] & \", \" & [first] " - +"WHERE (((clients.company) Is Null));"); - - //rs->Close(); - - } - else - { - - throw new Exception( - "Warning: Due to a change in the clients table in the database\r\n" - +"this update needs to move the contact first and last names to the former \r\n" - +"\"Company\" field which is now the single client field.\r\n\r\n" - - + "Your help is required to correct a problem before the update can finish:\r\n" - + "You have duplicate non-company clients and need to change them in the clients screen.\r\n\r\n" - - + "When this update completes and returns you to AyaNova, \r\n" - + "go directly to the client screen (Options->Edit->Clients) where you will be given\r\n" - + "more instructions on fixing the duplicate client names."); - - - //m_pApp->ShowStuff(strData); - //stop from doing anything further - //buptodate=true; - //break; - - } - - //---------------------------------------------------------------------------- - //Performance boost - new indexes - - executeQuery("CREATE INDEX idxanytime ON wo (anytime);"); - executeQuery("CREATE INDEX idxquick ON wo (quick);"); - executeQuery("CREATE INDEX idxassigntech ON wo (assigntech);"); - executeQuery("CREATE INDEX idxstarttime ON wo (starttime);"); - System.Diagnostics.Debug.WriteLine("This update contains speed improvements to the database.\r\n\r\n" - +"This will not take effect until *after* you COMPACT the database after updating.\r\n" - +"The COMPACT option is on the database utilities menu.\r\n" - +"(Re-indexing is not necessary, only COMPACT)"); - - //----------------------------------------------------------------------------- - - - //---------------------------------------------------------------------------- - //Add new schedule groups tables - - q=string.Format( - "CREATE TABLE schdgrps (" - +"id COUNTER CONSTRAINT PK_pmitem PRIMARY KEY, " - +"name TEXT(80));"); - executeQuery(q); - - q=string.Format("CREATE TABLE schdets (" - +"grpid INTEGER DEFAULT 0, " - +"techid INTEGER DEFAULT 0);"); - executeQuery(q); - - //rs->Close(); - - //group get's indexed because it's the searched and linked field - executeQuery("CREATE INDEX idxgrpid ON schdets (grpid);"); - //techid's don't get indexed because they are simply retrieved - - - //----------------------------------------------------------------------------- - - - //create subunits table - q=string.Format("CREATE TABLE subunits (" - +"masterunitid INTEGER DEFAULT 0, " - +"unitid INTEGER DEFAULT 0, " - +"creator INTEGER DEFAULT 0, "//user who created record - +"created DATETIME, " //date created - +"modifier INTEGER DEFAULT 0, "//date modified who cares?? probably no one - +"modified DATETIME);"); - executeQuery(q); - - executeQuery("CREATE INDEX idxmstrunit " - +"ON subunits (masterunitid);"); - - //----------------------------------------------------------------------------- - //add the master/sub unit report to reports screen - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Master and sub units (kits)\", \"unitkits.rpt\", \"mgr\", True, 3217, 29;"); - - q2="SELECT units.sn AS mastersn, units.id, units.client, unitmodels.manufacturer, units.model, unitmodels.description AS mastermodel, nonclients.company_person AS mastermake, unitmodelcats.name AS mastertype, units_1.sn AS subsn, unitmodels_1.description AS submodel, nonclients_1.company_person AS submake, unitmodelcats_1.name AS subtype " - +"FROM ((((subunits RIGHT JOIN (((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN unitmodelcats ON unitmodels.category = unitmodelcats.id) ON subunits.masterunitid = units.id) LEFT JOIN units AS units_1 ON subunits.unitid = units_1.id) LEFT JOIN unitmodels AS unitmodels_1 ON units_1.model = unitmodels_1.id) LEFT JOIN unitmodelcats AS unitmodelcats_1 ON unitmodels_1.category = unitmodelcats_1.id) LEFT JOIN nonclients AS nonclients_1 ON unitmodels_1.manufacturer = nonclients_1.id " - +"WHERE (((units.id)~UNIT) AND ((units.client)~CUST) AND ((unitmodels.manufacturer)~MANU) AND ((units.model)~MODL)) " - +"ORDER BY units.sn, units.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=29));",q2); - - executeQuery(q); - //----------------------------------------------------------------------------- - - //----------------------------------------------------------------------------- - //add the rate billing summary report to reports screen - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Billing summary by rate\", \"ratesums.rpt\", \"mgr\", True, 463, 30;"); - - q2="SELECT rates.name, Sum(labor.hours) AS SumOfhours, Sum(labor.nchours) AS SumOfnchours, Sum(labor.travhours) AS SumOftravhours, rates.rate, rates.travelrate " - +"FROM ((wo RIGHT JOIN probs ON wo.id = probs.wolink) RIGHT JOIN labor ON probs.id = labor.link) LEFT JOIN rates ON labor.rate = rates.id " - +"WHERE (((labor.start) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((labor.tech)~TECH) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((rates.id)~RATE) AND ((rates.active)=True)) " - +"GROUP BY rates.name, rates.rate, rates.travelrate, rates.id UNION (SELECT rates.name, Sum(labor.hours) AS SumOfhours, Sum(labor.nchours) AS SumOfnchours, Sum(labor.travhours) AS SumOftravhours, rates.rate, rates.travelrate " - +"FROM ((wo RIGHT JOIN probs ON wo.id = probs.wolink) RIGHT JOIN labor ON probs.id = labor.link) LEFT JOIN rates ON labor.travrate = rates.id " - +"WHERE (((labor.start) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((labor.tech)~TECH) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_) AND ((rates.id)~RATE) AND ((rates.active)=True)) " - +"GROUP BY rates.name, rates.rate, rates.travelrate, rates.id) " - +"ORDER BY rates.name;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=30));",q2); - - executeQuery(q); - - - - - - - //----------------------------------------------------------------------------- - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"147\";"); - - nVersion=147; - //----------------------------------------------------------------------------- - - - - } - - break; - - case 147://changed to 148 on july 6th 2001 for version 1.7.1.7 - { - - //---------------------------------------------------------------------------- - //increase size of srchdict.word from 30 characters to 50 - executeQuery("ALTER TABLE srchdict ALTER COLUMN word TEXT(50);"); - - //increase size of srch.client from 50 characters to 80 - executeQuery("ALTER TABLE srch ALTER COLUMN client TEXT(80);"); - - //----------------------------------------------------------------------------- - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"148\";"); - - //----------------------------------------------------------------------------- - nVersion=148; - - } - - break; - case 148: - { - - //---------------------------------------------------------------------------- - //Add a program version number field to the database - executeQuery("ALTER TABLE defaults ADD COLUMN min_exe TEXT(25);"); - - - - //----------------------------------------------------------- - //Add schedule markers table and indices - - executeQuery( "CREATE TABLE schedmarkers (" - +"id COUNTER CONSTRAINT PK_schedmrk PRIMARY KEY, " - +"link INTEGER DEFAULT 0," - +"startdate DATETIME, " - +"enddate DATETIME, " - +"notes TEXT(15), " - +"red INTEGER DEFAULT 128, " - +"green INTEGER DEFAULT 128, " - +"blue INTEGER DEFAULT 128" - +");"); - executeQuery("CREATE INDEX idxsmlink " - +"ON schedmarkers (link);"); - - executeQuery("CREATE INDEX idxsmstdate " - +"ON schedmarkers (startdate);"); - - executeQuery("CREATE INDEX idxsmendate " - +"ON schedmarkers (enddate);"); - //---------------------------------------------------------- - - - //---------------------------------------------- - executeQuery("ALTER TABLE wo ADD COLUMN starttime2 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN stoptime2 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN assigntech2 INTEGER;"); - - executeQuery("ALTER TABLE wo ADD COLUMN starttime3 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN stoptime3 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN assigntech3 INTEGER;"); - - executeQuery("ALTER TABLE wo ADD COLUMN starttime4 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN stoptime4 DATETIME;"); - executeQuery("ALTER TABLE wo ADD COLUMN assigntech4 INTEGER;"); - - executeQuery("ALTER TABLE wo ALTER assigntech SET DEFAULT '-1';"); - executeQuery("ALTER TABLE wo ALTER assigntech2 SET DEFAULT '-1';"); - executeQuery("ALTER TABLE wo ALTER assigntech3 SET DEFAULT '-1';"); - executeQuery("ALTER TABLE wo ALTER assigntech4 SET DEFAULT '-1';"); - //---------------------------------------------- - executeQuery("CREATE INDEX idxassigntech2 ON wo (assigntech2);"); - executeQuery("CREATE INDEX idxstarttime2 ON wo (starttime2);"); - - executeQuery("CREATE INDEX idxassigntech3 ON wo (assigntech3);"); - executeQuery("CREATE INDEX idxstarttime3 ON wo (starttime3);"); - - executeQuery("CREATE INDEX idxassigntech4 ON wo (assigntech4);"); - executeQuery("CREATE INDEX idxstarttime4 ON wo (starttime4);"); - - //set extra techs to -1 meaning not assigned yet - executeQuery("UPDATE wo SET wo.assigntech2 = -1, wo.assigntech3 = -1, wo.assigntech4 = -1;"); - - //set non-scheduled workorders first tech to non assigned -1 - executeQuery("UPDATE wo SET wo.assigntech = -1 WHERE (((wo.anytime)=True));"); - - - //----------------------------------------------------------------------------- - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"149\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - - //----------------------------------------------------------------------------- - - nVersion=149; - - } - - break; - - case 149: - { - //Last modified 07/30/2001 - added category/type column - //COLUMNMOD - //new CATEGORY column stuff here: - executeQuery("ALTER TABLE statusviews ADD COLUMN category INTEGER;"); - executeQuery("ALTER TABLE statusviews ALTER category SET DEFAULT '0';"); - executeQuery("UPDATE statusviews SET statusviews.category = -1;"); - - //new project column here - executeQuery("ALTER TABLE statusviews ADD COLUMN project INTEGER;"); - executeQuery("ALTER TABLE statusviews ALTER project SET DEFAULT '0';"); - executeQuery("UPDATE statusviews SET statusviews.category = -1;"); - - - //update all views to handle extra columns - executeQuery("UPDATE statusviews SET statusviews.viewprofile = \"(20,20) 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\";"); - - - - //fix the version number up as long as updates seem ok - executeQuery("UPDATE defaults SET defaults.versioninfo = \"150\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - - ////WARNING MESSAGE ABOUT COLUMN FORMATS IN MAIN WORKORDER VIEW BEING MESSED UP - //System.Diagnostics.Debug.WriteLine("Part of this update modifies the main workorder list view screen to add the \r\n" - // "WORKORDER CATEGORY and PROJECT columns.\r\n\r\n" - // "This change will affect *all* the views you have configured in AyaNova.\r\n" - // "You will need to re-order the columns in the main view to your preferences and re-save each view separately.\r\n\r\n" - // "This update affects the column order only, not the underlying restriction settings.\r\n" - // "\r\nDo not attempt to edit your views until after you have restarted AyaNova when this update completes."); - - //----------------------------------------------------------------------------- - - nVersion=150; - - - } - - break; - - case 150: - { - //ADD AYANOTIFY TABLES - //--------------------------------------- - executeQuery( - "CREATE TABLE notify_cfg (freq_mm INTEGER, [dow] INTEGER, stop_hour DATETIME, start_hour DATETIME, " - +"[attempts] INTEGER, [mapi] YESNO, keeplogdays INTEGER, [verboseLog] YESNO, login_name TEXT(50), " - +"login_pw TEXT(50), [connection] TEXT(120), from_address TEXT(80), [server] TEXT(120), " - +"next_xmit DATETIME, [dialup] YESNO, last_xmit DATETIME, dayspast INTEGER , " - +"daysfuture INTEGER);"); - - executeQuery("ALTER TABLE notify_cfg ALTER freq_mm SET DEFAULT '0';"); - executeQuery("ALTER TABLE notify_cfg ALTER dow SET DEFAULT '0';"); - executeQuery("ALTER TABLE notify_cfg ALTER attempts SET DEFAULT '0';"); - executeQuery("ALTER TABLE notify_cfg ALTER keeplogdays SET DEFAULT '30';"); - executeQuery("ALTER TABLE notify_cfg ALTER dayspast SET DEFAULT '0';"); - executeQuery("ALTER TABLE notify_cfg ALTER daysfuture SET DEFAULT '14';"); - - - - - - - - executeQuery( - "INSERT INTO notify_cfg ( freq_mm, dow, stop_hour, start_hour, attempts, mapi, " - +"keeplogdays, verboseLog, login_name, login_pw, [connection], from_address, server, " - +"next_xmit, dialup, last_xmit, dayspast, daysfuture ) " - +"SELECT 60 , 0, #12/30/1899 19:0:0#, #12/30/1899 7:0:0#, 0, False, 30, False, " - +"\"login\", \"password\", \"My ISP\", \"from_me@my_isp.com\", \"smtp.mail.my_isp.com\", " - +"#1/1/2000#, False, #1/1/2000#, 1, 14;"); - - - //log table - executeQuery( "CREATE TABLE notify_log (" - +"id INTEGER DEFAULT 0, " - +"nwhen DATETIME, " - +"nwho INTEGER DEFAULT 0, " - +"nwhat TEXT(255), " - +"ntype INTEGER DEFAULT 0, " - +"nresult TEXT(255) " - +");"); - - //temp table for building notifications - executeQuery( "CREATE TABLE notify_temp (" - +"woid INTEGER DEFAULT 0, " - +"scheddate DATETIME, " - +"schedstop DATETIME, " - +"schedtech INTEGER DEFAULT 0 " - +");"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"151\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - nVersion=151; - - - } - - break; - - - case 151: - { - - //--------------------------------------- - //add the WORKORDERS report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Workorders\", \"allwo.rpt\", \"mgr\", True, 397, 31;"); - - q2="SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " - +"FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " - +" LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " - +"ORDER BY wo.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=31));",q2); - executeQuery(q); - //------------------------------------------------ - //--------------------------------------- - //add the WORKORDERS BRIEF report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Workorders - brief\", \"allwobrief.rpt\", \"mgr\", True, 397, 32;"); - - q2="SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " - +"FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(woparts.misc= \"\",parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " - +"LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " - +"ORDER BY wo.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=32));",q2); - executeQuery(q); - //------------------------------------------------ - - //--------------------------------------- - //add the Units by P.M. report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Units by P.M.\", \"pmunits.rpt\", \"mgr\", True, 2193, 33;"); - - q2="SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person AS MAKE, unitmodels.model, units.sn, unitmodels.description AS UNITDESC, units.id1, units.id2, units.id3, clients.company, nonclients.phone, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.nextsrvmeter, units.lastmeter, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, units.purchasedate, pmhead.ageyears, pmhead.agemonths, users.initials, users.first, users.last, pmhead.isclient " - +"FROM ((pmhead LEFT JOIN ((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) ON pmhead.link = units.id) LEFT JOIN clients ON units.client = clients.id) LEFT JOIN users ON pmhead.tech = users.id " - +"WHERE (((pmhead.isclient)=False) AND ((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " - +"ORDER BY nonclients.company_person, unitmodels.model, units.sn, clients.company;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=33));",q2); - executeQuery(q); - //------------------------------------------------ - - //--------------------------------------- - //add the P.M. by Units report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"P.M. by Units\", \"unitspm.rpt\", \"mgr\", True, 2193, 34;"); - - q2="SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person AS MAKE, unitmodels.model, units.sn, unitmodels.description AS UNITDESC, units.id1, units.id2, units.id3, clients.company, nonclients.phone, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.nextsrvmeter, units.lastmeter, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, units.purchasedate, pmhead.ageyears, pmhead.agemonths, users.initials, users.first, users.last, pmhead.isclient " - +"FROM ((pmhead LEFT JOIN ((units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) ON pmhead.link = units.id) LEFT JOIN clients ON units.client = clients.id) LEFT JOIN users ON pmhead.tech = users.id " - +"WHERE (((pmhead.isclient)=False) AND ((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " - +"ORDER BY nonclients.company_person, unitmodels.model, units.sn, clients.company;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=34));",q2); - executeQuery(q); - //------------------------------------------------ - - //--------------------------------------- - //add the P.M. by Client report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"P.M. by Client\", \"clientpm.rpt\", \"mgr\", True, 385, 35;"); - - q2="SELECT ~CRITERIA AS CRITERIA, clients.company, pmhead.description, pmhead.notes, pmhead.nextsrvdate, pmhead.link AS CLIENTID, pmhead.woconvert, pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, pmhead.rptdays, pmhead.ageyears, pmhead.agemonths, users.initials, users.first AS TECH_FIRST, users.last AS TECH_LAST " - +"FROM clients RIGHT JOIN (pmhead LEFT JOIN users ON pmhead.tech = users.id) ON clients.id = pmhead.link " - +"WHERE (((pmhead.nextsrvdate) Between #~STRT# And #~END_#) AND ((pmhead.link)~CUST) AND ((pmhead.isclient)=True)) " - +"ORDER BY clients.company;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=35));",q2); - executeQuery(q); - //------------------------------------------------ - - - //--------------------------------------- - //add the Workorders not invoiced report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Workorders not invoiced\", \"notbilled.rpt\", \"mgr\", True, 385, 36;"); - - q2=strData="SELECT ~CRITERIA AS CRITERIA, wo.id, clients.company, wo.modified, wo.ourref, wo.clientrefnum, wo.clientcontact, wo.closed, wo.invoice, wo.notes " - +"FROM probstat RIGHT JOIN (wo LEFT JOIN clients ON wo.client = clients.id) ON probstat.id = wo.status " - +"WHERE (((wo.modified) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.invoice) Is Null)) " - +"ORDER BY wo.modified DESC;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=36));",q2); - executeQuery(q); - //------------------------------------------------ - - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"152\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - nVersion=152; - - - } - - break; - - - - case 152: //update for v1720 added extra security rights items - { - //2023-07-14 - I'm going to ignore this for now hopefully not necessary //CString strID,strName,strRights,strHash; //long lData; //GZK k; - - + + ////Add new right: ////loop through all the group records //rs->Query("SELECT groups.* FROM groups;"); @@ -5893,1505 +5897,1504 @@ private static void go(System.Data.OleDb.OleDbConnection conn, int nVersion) // rs->FetchField("id",&lData); // rs->FetchField("a",&strName); // rs->FetchField("b",&strRights); - + // //decrypt the original rights string // k.GZDecrypt(&strRights,false); // strRights=strRights+"111";//add on the extra right for schedule view - + // //re-'crypt' // k.GZEncrypt(&strRights,false); - + // //HASH // strHash.Format("%u%s%s",lData,strName,strRights); // k.GZHash(&strHash); - + // //save the rights // rs->UpdateField("b",&strRights); - + // //save the hash // rs->UpdateField("c",&strHash); - + // //save the record // if(!rs->SaveRecord()) // AfxMessageBox("Error trying to save rights record"); - - - - - - - + + + + + + + //}while(rs->MoveForward()); - - - - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"153\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - nVersion=153; - - - } - - break; - - case 153: //update for v1720 modified client equipment report query - //and added eval field for web server - { - - //"KJB3BoICxnQM9KvUO+1mzQ==" Evaluate 8 chars - executeQuery("ALTER TABLE defaults ADD COLUMN mango TEXT(80);"); - executeQuery("UPDATE defaults SET defaults.mango = \"KJB3BoICxnQM9KvUO+1mzQ\";"); - - /* - How web server mango column works: - if = Evaluate then means ready to be evaluated - first time webserver runs sets mango to expiry date - when expires sets column to Expired and web server stops working - */ - - - //ADD EMAIL NOTIFICATION FIELDS TO USERS TABLE (oops forgot to do it earlier) - executeQuery("ALTER TABLE users ADD COLUMN email TEXT(120);"); - executeQuery("ALTER TABLE users ADD COLUMN emailnotify YESNO;"); - executeQuery("ALTER TABLE users ALTER emailnotify SET DEFAULT '0';"); - executeQuery("UPDATE users SET users.emailnotify = False;"); - - - - //UPDATE CLIENT EQUIPMENT REPORT QUERY - - q2="SELECT clients.id, IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS client, [clients].[first] & \" \" & [clients].[last] AS clientcontact, clients.bizphone, [manufacturers].[company_person] & \" \" & [unitmodels].[model] AS item, units.sn, IIf([units].[boughthere],\"us\",[nonclients].[company_person]) AS vendor, units.purchasedate, units.receipt AS invoice, units.notes, units.description " - +"FROM (((units LEFT JOIN clients ON units.client = clients.id) LEFT JOIN nonclients ON units.purchasedfrom = nonclients.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS manufacturers ON unitmodels.manufacturer = manufacturers.id " - +"WHERE (((clients.id)~CUST) AND ((units.purchasedate) Between #~STRT# And #~END_#) AND ((units.loaner)=False)) " - +"ORDER BY IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]);"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=20));",q2); - executeQuery(q); - - //UPDATE UNIT HISTORY REPORT QUERY - - q2="SELECT ~USERNAME AS zCurrentUser, probs.id, probs.wolink AS WORKORDERID, probs.brief AS PROBBRIEF, probs.notes " - +"AS PROBNOTES, Format([start],\"Short Date\") AS servdate, labor.details, clients.company AS clientcompany, " - +"units.sn, unitmodels.model, users.initials, probs.meter, ztotalparts.totalparts, ztotallabor.totallabor FROM " - +"[SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor, probs.id FROM probs INNER " - +"JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON travrates.id = labor.rate) ON rates.id = labor.rate) " - +"ON probs.id = labor.link GROUP BY probs.id]. AS ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)), 0,Sum(woparts.quantity*woparts.price)) AS totalparts, " - +"probs.id FROM probs LEFT JOIN woparts ON probs.id = woparts.link GROUP BY probs.id]. AS ztotalparts RIGHT " - +"JOIN (users RIGHT JOIN ((labor RIGHT JOIN (((wo RIGHT JOIN probs ON wo.id = probs.wolink) LEFT JOIN units " - +"ON probs.unit = units.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) ON labor.link = probs.id) LEFT " - +"JOIN clients ON wo.client = clients.id) ON users.id = labor.tech) ON ztotalparts.id = probs.id) ON " - +"ztotallabor.id = probs.id WHERE (((probs.unit)~UNIT) AND ((units.sn) Is Not Null) AND ((labor.start) " - +"Between #~STRT# And #~END_#)) ORDER BY labor.start DESC;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=7));",q2); - executeQuery(q); - - //UPDATE CALLBACKS BY DATE - - q="UPDATE rptsmaster SET rptsmaster.x = True " - +"WHERE (((rptsmaster.id)=2));"; - executeQuery(q); - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"154\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); - nVersion=154; - - } - - break; - - - case 154: //update for v1721 - - { - executeQuery("ALTER TABLE users ADD COLUMN schedrnd YESNO;"); - executeQuery("UPDATE users SET users.schedrnd = True;"); - - executeQuery("ALTER TABLE users ADD COLUMN schedoneday YESNO;"); - executeQuery("UPDATE users SET users.schedoneday = False;"); - - executeQuery("ALTER TABLE rentals ADD COLUMN ref TEXT(80);"); - - executeQuery("ALTER TABLE users ALTER COLUMN rentalprofile TEXT(80);"); - executeQuery("ALTER TABLE users ALTER rentalprofile SET DEFAULT \"(9,9) 42 169 195 103 88 129 0 105 109 0 1 8 7 2 3 4 5 6\";"); - executeQuery("UPDATE users SET users.rentalprofile = '(9,9) 42 169 195 103 88 129 0 105 109 0 1 8 7 2 3 4 5 6';"); - - - - //--------------------------------------- - //add the LOANERS report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"loaners\", \"loaners.rpt\", \"mgr\", False, 32767, 37;"); - - //------------------------------------------------ - - //--------------------------------------- - //add the RESPONSE TIME BY PROBLEM report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Response time by problem item (first response)\", \"respprob.rpt\", \"mgr\", True, 399, 38;"); - - q2="SELECT ~CRITERIA AS CRITERIA, probs.created AS prob_entered, probs.wolink, Min(labor.start) AS First_response, wo.id AS Workorder, wotypes.category AS CategoryName, projects.name AS ProjectName, clients.company AS ClientName, probs.brief " - +"FROM (((labor LEFT JOIN (wo RIGHT JOIN probs ON wo.id = probs.wolink) ON labor.link = probs.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN projects ON wo.project = projects.id) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((labor.tech)~TECH) AND ((wo.quick)=False)) " - +"GROUP BY probs.created, probs.wolink, wo.id, wotypes.category, projects.name, clients.company, probs.brief, wo.created " - +"HAVING (((Min(labor.start)) Is Not Null)) " - +"ORDER BY wo.created DESC , probs.wolink;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=38));",q2); - executeQuery(q); - //------------------------------------------------ - //--------------------------------------- - //add the RESPONSE TIME BY WORKORDER report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Response time for standard WO (first response)\", \"respwo.rpt\", \"mgr\", True, 399, 39;"); - - q2="SELECT ~CRITERIA AS CRITERIA, wo.created AS wo_entered, probs.wolink, Min(labor.start) AS First_response, wo.id AS Workorder, wotypes.category AS CategoryName, projects.name AS ProjectName, clients.company AS ClientName " - +"FROM (((labor LEFT JOIN (wo RIGHT JOIN probs ON wo.id = probs.wolink) ON labor.link = probs.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN projects ON wo.project = projects.id) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((labor.tech)~TECH) AND ((wo.quick)=False)) " - +"GROUP BY wo.created, probs.wolink, wo.id, wotypes.category, projects.name, clients.company " - +"HAVING (((Min(labor.start)) Is Not Null)) " - +"ORDER BY wo.created DESC , probs.wolink;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=39));",q2); - executeQuery(q); - //------------------------------------------------ - - - //ADD the tables for ARAS clients - //------------------------------------------------ - //clients_aras - executeQuery( "CREATE TABLE clients_aras (" - +"id COUNTER CONSTRAINT PK_clntaras PRIMARY KEY, " - +"clientlink INTEGER DEFAULT 0," - +"loginid TEXT(50), " - +"loginpw TEXT(50), " - +"view_wo_status YESNO DEFAULT False, " - +"search_history YESNO DEFAULT False, " - +"wo_view YESNO DEFAULT False, " - +"wo_report YESNO DEFAULT False, " - +"request_service YESNO DEFAULT False, " - +"view_request_list YESNO DEFAULT False, " - +"private_notes MEMO, " - +"last_login_date DATETIME, " - +"creator INTEGER DEFAULT 0, "//user who created record - +"created DATETIME, " //date created - +"modifier INTEGER DEFAULT 0, "//date modified - +"modified DATETIME " - +");"); - //------------------------------------------------ - - //client_requests - executeQuery( "CREATE TABLE client_requests (" - +"id COUNTER CONSTRAINT PK_clntrqsts PRIMARY KEY, " - +"clientlink INTEGER DEFAULT 0," - +"requestor_id INTEGER DEFAULT 0," - +"workorderid INTEGER DEFAULT 0," - +"request TEXT(110), " - +"probdetails MEMO, " - +"prefertech INTEGER DEFAULT -1," - +"refnum TEXT(80), " - +"ournotes MEMO, " - +"created DATETIME, " //date created - +"urgency INTEGER DEFAULT 0"//0=not 2=extreme - - +");"); - //------------------------------------------------ - - //ADD new profile key to user table for ARAS request view screen - - - executeQuery("ALTER TABLE users ADD COLUMN aras_req_profile TEXT(80);"); - executeQuery("ALTER TABLE users ALTER aras_req_profile SET DEFAULT \"(7,7) 52 76 128 73 217 162 0 0 1 2 3 4 5 6\";"); - executeQuery("UPDATE users SET users.aras_req_profile = '(7,7) 52 76 128 73 217 162 0 0 1 2 3 4 5 6';"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"155\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.1\";"); - nVersion=155; - - - } - - break; - - - case 155://changed to 156 on Sept 30th 2002 for version 1.9 - { - //Added field to turn on or off transaction support - //true=database execute queries are wrapped in transactions - //false=old style pre 1.9 not wrapped in transactions - //made it an option in case users have problems - //should improve data currency on a busy network - executeQuery("ALTER TABLE defaults ADD COLUMN transact YESNO;"); - executeQuery("UPDATE defaults SET defaults.transact = True;"); - - - //client alternate phone number - executeQuery("ALTER TABLE clients ADD COLUMN phone2 TEXT(40);"); - executeQuery("ALTER TABLE clients ADD COLUMN phone3 TEXT(40);"); - - - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"156\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=156; - - } - - break; - - case 156://changed to 157 on Oct 4th 2002 for version 1.9 - { - - //Horizontal grid on main work order list screen - //user preference field. Default to true so they - //know it's there and we can get all those emails - //bitching about it because they don't read the docs and know that - //they can turn it off - executeQuery("ALTER TABLE users ADD COLUMN hgrid YESNO;"); - executeQuery("UPDATE users SET users.hgrid = True;"); - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"157\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=157; - - - break; - - } - - - case 157://changed to 158 on Oct 8th 2002 for version 1.9 - { - - //drop location field in wo which is not used and - //add a pmid field - executeQuery("ALTER TABLE wo ADD COLUMN pmid INTEGER;"); - executeQuery("ALTER TABLE wo ALTER pmid SET DEFAULT '0';"); - executeQuery("UPDATE wo SET wo.pmid = 0;"); - executeQuery("ALTER TABLE wo DROP COLUMN location;"); - - - //update pmhead table to include the two new time fields - executeQuery("ALTER TABLE pmhead ADD COLUMN starttime DATETIME;"); - executeQuery("ALTER TABLE pmhead ADD COLUMN endtime DATETIME;"); - executeQuery("UPDATE pmhead SET pmhead.starttime = #10/8/2002 8:0:0#;"); - executeQuery("UPDATE pmhead SET pmhead.endtime = #10/8/2002 9:0:0#;"); - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"158\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=158; - break; - } - case 158://changed to 159 on Oct 9th 2002 for version 1.9 - { + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"153\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + nVersion = 153; - //-2 now means don't show scheduled tech column in workorder list - //where it used to be 0 for that so change all 0's to -2's - executeQuery("UPDATE statusviews SET statusviews.schedtech = -2 " - +"WHERE (((statusviews.schedtech)=0));"); + } - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"159\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=159; - break; + break; - } + case 153: //update for v1720 modified client equipment report query + //and added eval field for web server + { + //"KJB3BoICxnQM9KvUO+1mzQ==" Evaluate 8 chars + executeQuery("ALTER TABLE defaults ADD COLUMN mango TEXT(80);"); + executeQuery("UPDATE defaults SET defaults.mango = \"KJB3BoICxnQM9KvUO+1mzQ\";"); - case 159://changed to 160 on Oct 11th 2002 for version 1.9 - { + /* + How web server mango column works: + if = Evaluate then means ready to be evaluated + first time webserver runs sets mango to expiry date + when expires sets column to Expired and web server stops working + */ - //add created days column to status views table - executeQuery("ALTER TABLE statusviews ADD COLUMN createddays INTEGER;"); - executeQuery("ALTER TABLE statusviews ALTER createddays SET DEFAULT '0';"); - executeQuery("UPDATE statusviews SET statusviews.createddays = 0;"); - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"160\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=160; - break; - } + //ADD EMAIL NOTIFICATION FIELDS TO USERS TABLE (oops forgot to do it earlier) + executeQuery("ALTER TABLE users ADD COLUMN email TEXT(120);"); + executeQuery("ALTER TABLE users ADD COLUMN emailnotify YESNO;"); + executeQuery("ALTER TABLE users ALTER emailnotify SET DEFAULT '0';"); + executeQuery("UPDATE users SET users.emailnotify = False;"); - case 160://changed to 161 on Oct 12th 2002 for version 1.9 - { + //UPDATE CLIENT EQUIPMENT REPORT QUERY - //Add distance column to labor table - executeQuery("ALTER TABLE labor ADD COLUMN distance REAL;"); - executeQuery("ALTER TABLE labor ALTER distance SET DEFAULT '0';"); - executeQuery("UPDATE labor SET labor.distance = 0;"); + q2 = "SELECT clients.id, IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS client, [clients].[first] & \" \" & [clients].[last] AS clientcontact, clients.bizphone, [manufacturers].[company_person] & \" \" & [unitmodels].[model] AS item, units.sn, IIf([units].[boughthere],\"us\",[nonclients].[company_person]) AS vendor, units.purchasedate, units.receipt AS invoice, units.notes, units.description " + + "FROM (((units LEFT JOIN clients ON units.client = clients.id) LEFT JOIN nonclients ON units.purchasedfrom = nonclients.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients AS manufacturers ON unitmodels.manufacturer = manufacturers.id " + + "WHERE (((clients.id)~CUST) AND ((units.purchasedate) Between #~STRT# And #~END_#) AND ((units.loaner)=False)) " + + "ORDER BY IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]);"; + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=20));", q2); + executeQuery(q); - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"161\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=161; - break; + //UPDATE UNIT HISTORY REPORT QUERY - } + q2 = "SELECT ~USERNAME AS zCurrentUser, probs.id, probs.wolink AS WORKORDERID, probs.brief AS PROBBRIEF, probs.notes " + + "AS PROBNOTES, Format([start],\"Short Date\") AS servdate, labor.details, clients.company AS clientcompany, " + + "units.sn, unitmodels.model, users.initials, probs.meter, ztotalparts.totalparts, ztotallabor.totallabor FROM " + + "[SELECT Sum((labor.hours*rates.rate)+(labor.travhours*travrates.rate)) AS totallabor, probs.id FROM probs INNER " + + "JOIN (rates INNER JOIN (rates AS travrates INNER JOIN labor ON travrates.id = labor.rate) ON rates.id = labor.rate) " + + "ON probs.id = labor.link GROUP BY probs.id]. AS ztotallabor RIGHT JOIN ([SELECT IIf(IsNull(Sum(woparts.quantity*woparts.price)), 0,Sum(woparts.quantity*woparts.price)) AS totalparts, " + + "probs.id FROM probs LEFT JOIN woparts ON probs.id = woparts.link GROUP BY probs.id]. AS ztotalparts RIGHT " + + "JOIN (users RIGHT JOIN ((labor RIGHT JOIN (((wo RIGHT JOIN probs ON wo.id = probs.wolink) LEFT JOIN units " + + "ON probs.unit = units.id) LEFT JOIN unitmodels ON units.model = unitmodels.id) ON labor.link = probs.id) LEFT " + + "JOIN clients ON wo.client = clients.id) ON users.id = labor.tech) ON ztotalparts.id = probs.id) ON " + + "ztotallabor.id = probs.id WHERE (((probs.unit)~UNIT) AND ((units.sn) Is Not Null) AND ((labor.start) " + + "Between #~STRT# And #~END_#)) ORDER BY labor.start DESC;"; + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=7));", q2); + executeQuery(q); + //UPDATE CALLBACKS BY DATE - case 161://changed to 162 on Oct 12th 2002 for version 1.9 - { + q = "UPDATE rptsmaster SET rptsmaster.x = True " + + "WHERE (((rptsmaster.id)=2));"; + executeQuery(q); - //Add distance column to labor table - executeQuery("ALTER TABLE clients ADD COLUMN inactive YESNO;"); - executeQuery("ALTER TABLE clients ALTER inactive SET DEFAULT '0';"); - executeQuery("UPDATE clients SET clients.inactive = False;"); + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"154\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.0\";"); + nVersion = 154; + + } + break; - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"162\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=162; - - break; - - } - - - - case 162://changed to 163 on Oct 12th 2002 for version 1.9 - { - - //Set all woparts.misc to NULL as some may be empty - //other changes will ensure it is never set to empty in future - //this is just to catch any existing ones. - executeQuery("UPDATE woparts SET woparts.misc = Null WHERE (((woparts.misc)=\"\"));"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"163\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=163; - - break; - - } - - - - case 163://changed to 164 on Oct 13th 2002 for version 1.9 - { - - //Add subquery field to rptsmaster - //required for parts printing on dispatch standard workorder - executeQuery("ALTER TABLE rptsmaster ADD COLUMN subreportquery MEMO;"); - - - //REMOVE ANY OLD RPTS MASTER ENTRIES FOR WORKORDER REPORTS - - //STANDARD DISPATCH - q2="SELECT \"~ESTRATE\" AS estrate, \"~SCHEDTECH\" AS scheduledtech, " -+"~ESTHOURS AS esthours, IIf(IsNull([clients].[company]),[clients].[last] " -+"& \", \" & [clients].[first],[clients].[company]) " -+"AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " - +"& IIf(IsNull([clients].[city]),\"\",Chr(13) " -+"& [clients].[city]) & IIf(IsNull([clients].[stateprov]),\"\",\", " -+"\" & [clients].[stateprov] " -+"& IIf(IsNull([clients].[postal]),\"\",\" " -+"\" & [clients].[postal])) AS address, \"Work required: " -+"\" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " -+"& \") SN: \" & [units].[sn],\"\") AS probheader, " -+"\"~REGTO\" AS compname, wo.notes AS wonotes, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, " -+"wo.prob_reported, wo.prob_found, wo.action_taken, " -+"wo.id AS wonumber, wo.created, labor.details, probs.notes, " -+"IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " -+"AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " -+"\" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & \" (\" " -+"& [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS Equipment, wo.starttime AS [Booked for], wo.stoptime " -+"AS [Booked for END], wo.closed, probs.brief, " -+"clients.mailaddress, clients.streetaddress, clients.city, " -+"clients.stateprov, clients.postal, clients.country, " -+"clients.bizphone, clients.extension, " -+"clients.technotes, clients.first, clients.last, probstat.notes " -+"AS STATUS, probstat_1.notes AS ITEMSTATUS, " -+"projects.name AS PROJNAME, projects.notes AS " -+"PROJNOTES FROM projects RIGHT JOIN ((((((labor RIGHT " -+"JOIN (((units RIGHT JOIN probs ON units.id = " -+"probs.unit) LEFT JOIN unitmodels ON units.model = " -+"unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer " -+"= nonclients.id) ON labor.link = probs.id) " -+"RIGHT JOIN ((wo LEFT JOIN clients ON wo.client " -+"= clients.id) LEFT JOIN clients AS headoffices " -+"ON clients.headoffice = headoffices.id) ON probs.wolink " -+"= wo.id) LEFT JOIN contracts ON clients.contract " -+"= contracts.id) LEFT JOIN contracts AS contracts_1 " -+"ON headoffices.contract = contracts_1.id) LEFT " -+"JOIN probstat ON wo.status = probstat.id) LEFT " -+"JOIN probstat AS probstat_1 ON probs.status = probstat_1.id) " -+"ON projects.id = wo.project WHERE (((wo.id)=~WOID)); "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=21));",q2); - executeQuery(q); - - - //***** SUBREPORT ****************** - q2="SELECT probs.id, woparts.quantity, woparts.sn, parts.partnumber, " -+"woparts.misc, parts.description, parts.retail, " -+"IIf(IsNull(woparts.misc),[parts].[partnumber] " -+"& \" \" & [parts].[description] & \": \" & [woparts].[quantity] " -+"& \" @ \" & Format([woparts].[price],\"Currency\") " -+"& \" ea.\" & IIf(IsNull([woparts].[sn]),\"\",\" sn:\" & [woparts].[sn]) " -+", [woparts].[misc] " -+"& \": \" & [woparts].[quantity] & \" @ \" & Format([woparts].[price],\"Currency\") " -+"& \" ea.sn:\" & [woparts].[sn] " -+") AS item, [woparts].[quantity]*[woparts].[price] " -+"AS linetotal FROM (woparts RIGHT JOIN " -+"(probs RIGHT JOIN wo ON probs.wolink = wo.id) ON " -+"woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum " -+"= parts.id WHERE (((woparts.quantity) " -+"Is Not Null) AND ((wo.id)=~WOID));"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.subreportquery = '%s' " - +"WHERE (((rptsmaster.id)=21));",q2); - executeQuery(q); - //------------------------------------------------ - - //STANDARD BRIEF - q2="SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] " -+"& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS probheader, \"~REGTO\" AS compname, wom.probnum, " -+"wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " -+"wom.PROBBRIEF, wom.item, wom.linetotal, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " -+"AS wodate, wo.id AS wonumber, wo.invoice, " -+"wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " -+"clients.billheadoffice, clients.first, clients.last, " -+"clients.mailaddress, clients.streetaddress, " -+"clients.city, clients.stateprov, clients.postal, " -+"clients.country, clients.bizphone, clients.extension, " -+"clients.fax, clients.email, [clients].[company] " -+"AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " -+"& \", \" & [headoffices].[first],[headoffices].[company]) " -+"AS headname, wom.details, " -+"wom.STARTDATE, wom.STOPDATE, projects.name " -+"AS PROJNAME, projects.notes AS PROJNOTES FROM " -+"(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " -+"\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " -+"AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " -+"AS PROBBRIEF, probs.id AS probnum, probs.wolink " -+"AS wonum, \"Service: \" & users.first & \" \" & " -+"users.last & \" - \" & IIf(labor.hours>0,labor.hours " -+"& \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" " -+"(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " -+"(\" & labor.nchours & \" hrs. no charge)\",\"\") " -+"& IIf(labor.travhours>0,\", \" & labor.travhours & \" " -+"hrs. travel @ \" & Format(travelrates.rate,\"Currency\") " -+"& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " -+"& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " -+"AS linetotal,labor.details, labor.start AS STARTDATE, " -+"labor.stop as STOPDATE FROM users INNER JOIN " -+"(rates AS travelrates INNER JOIN (rates INNER JOIN " -+"(labor INNER JOIN probs ON labor.link = probs.id) " -+"ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " -+"ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " -+"UNION ALL (SELECT \"2\" AS ctype, " -+"\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " -+"probs.brief AS PROBBRIEF, probs.id AS probnum, " -+" probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " -+"& \" \" & parts.description " -+"& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " -+"& \" ea.(sn:\" & woparts.sn " -+"& \")\",woparts.misc & \": \" & woparts.quantity " -+"& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " -+"& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " -+"AS linetotal,\"\" AS details, #03/12/1968# " -+"AS STARTDATE, #03/12/1968# AS STOPDATE FROM " -+"(probs INNER JOIN woparts ON probs.id = woparts.link) " -+"LEFT JOIN parts ON woparts.partnum = parts.id " -+"WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " -+" \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " -+"AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " -+"AS probnum, probs.wolink as wonum, \"Third party " -+"service: \" AS item, subrepair.charge AS linettotal, " -+"\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " -+"AS STOPDATE FROM probs INNER JOIN subrepair " -+"ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " -+"AND ((subrepair.charge)<>0))))]. AS " -+"wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " -+"clients ON wo.client = clients.id) LEFT JOIN clients " -+"AS headoffices ON clients.headoffice = headoffices.id) " -+"ON probs.id = wom.probnum) ON units.id = probs.unit) " -+"LEFT JOIN unitmodels ON units.model = unitmodels.id) " -+"LEFT JOIN nonclients ON unitmodels.manufacturer " -+"= nonclients.id) LEFT JOIN projects ON " -+"wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=1));",q2); - executeQuery(q); - //------------------------------------------------ - - //STANDARD COMPLETED - q2="SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] " -+"& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS probheader, \"~REGTO\" AS compname, wom.probnum, " -+"wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " -+"wom.PROBBRIEF, wom.item, wom.linetotal, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " -+"AS wodate, wo.id AS wonumber, wo.invoice, " -+"wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " -+"clients.billheadoffice, clients.first, clients.last, " -+"clients.mailaddress, clients.streetaddress, " -+"clients.city, clients.stateprov, clients.postal, " -+"clients.country, clients.bizphone, clients.extension, " -+"clients.fax, clients.email, [clients].[company] " -+"AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " -+"& \", \" & [headoffices].[first],[headoffices].[company]) " -+"AS headname, wom.details, " -+"wom.STARTDATE, wom.STOPDATE, projects.name " -+"AS PROJNAME, projects.notes AS PROJNOTES FROM " -+"(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " -+"\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " -+"AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " -+"AS PROBBRIEF, probs.id AS probnum, probs.wolink " -+"AS wonum, \"Service: \" & users.first & \" \" & " -+"users.last & \" - \" & IIf(labor.hours>0,labor.hours " -+"& \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" " -+"(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " -+"(\" & labor.nchours & \" hrs. no charge)\",\"\") " -+"& IIf(labor.travhours>0,\", \" & labor.travhours & \" " -+"hrs. travel @ \" & Format(travelrates.rate,\"Currency\") " -+"& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " -+"& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " -+"AS linetotal,labor.details, labor.start AS STARTDATE, " -+"labor.stop as STOPDATE FROM users INNER JOIN " -+"(rates AS travelrates INNER JOIN (rates INNER JOIN " -+"(labor INNER JOIN probs ON labor.link = probs.id) " -+"ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " -+"ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " -+"UNION ALL (SELECT \"2\" AS ctype, " -+"\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " -+"probs.brief AS PROBBRIEF, probs.id AS probnum, " -+" probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " -+"& \" \" & parts.description " -+"& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " -+"& \" ea.(sn:\" & woparts.sn " -+"& \")\",woparts.misc & \": \" & woparts.quantity " -+"& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " -+"& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " -+"AS linetotal,\"\" AS details, #03/12/1968# " -+"AS STARTDATE, #03/12/1968# AS STOPDATE FROM " -+"(probs INNER JOIN woparts ON probs.id = woparts.link) " -+"LEFT JOIN parts ON woparts.partnum = parts.id " -+"WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " -+" \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " -+"AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " -+"AS probnum, probs.wolink as wonum, \"Third party " -+"service: \" AS item, subrepair.charge AS linettotal, " -+"\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " -+"AS STOPDATE FROM probs INNER JOIN subrepair " -+"ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " -+"AND ((subrepair.charge)<>0))))]. AS " -+"wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " -+"clients ON wo.client = clients.id) LEFT JOIN clients " -+"AS headoffices ON clients.headoffice = headoffices.id) " -+"ON probs.id = wom.probnum) ON units.id = probs.unit) " -+"LEFT JOIN unitmodels ON units.model = unitmodels.id) " -+"LEFT JOIN nonclients ON unitmodels.manufacturer " -+"= nonclients.id) LEFT JOIN projects ON " -+"wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=19));",q2); - executeQuery(q); - //------------------------------------------------ - - - - - //QUICK DISPATCH WORKORDER - q2="SELECT IIf(IsNull([clients].[company]),[clients].[last] " -+"& \", \" & [clients].[first],[clients].[company]) " -+"AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " - +"& IIf(IsNull([clients].[city]),\"\",[clients].[city]) " -+"& IIf(IsNull([clients].[stateprov]),\"\",\", " -+"\" & [clients].[stateprov] & IIf(IsNull([clients].[postal]),\"\",\" " -+"\" & [clients].[postal])) AS address, " -+"\"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & " -+"\" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS probheader, \"~REGTO\" AS compname, wo.id " -+"AS wonumber, wo.created, labor.details, probs.notes, " -+"IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " -+"AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " -+"\" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " -+"& \") SN: \" & [units].[sn],\"\") AS " -+"Equipment, wo.starttime AS [Booked for], probs.brief, " -+"clients.mailaddress, clients.streetaddress, " -+"clients.city, clients.stateprov, clients.postal, clients.country, " -+"clients.bizphone, clients.extension, " -+"clients.technotes, clients.first, clients.last, " -+"wo.clientrefnum, wo.ourref, wo.clientcontact FROM " -+"(((labor RIGHT JOIN (((units RIGHT JOIN probs ON " -+"units.id = probs.unit) LEFT JOIN unitmodels ON units.model " -+"= unitmodels.id) LEFT JOIN nonclients ON " -+"unitmodels.manufacturer = nonclients.id) ON labor.link " -+"= probs.id) RIGHT JOIN ((wo LEFT JOIN clients " -+"ON wo.client = clients.id) LEFT JOIN clients AS headoffices " -+"ON clients.headoffice = headoffices.id) " -+"ON probs.wolink = wo.id) LEFT JOIN contracts ON clients.contract " -+"= contracts.id) LEFT JOIN contracts " -+"AS contracts_1 ON headoffices.contract = contracts_1.id " -+"WHERE (((wo.id)=~WOID));"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=22));",q2); - executeQuery(q); - //------------------------------------------------ - - - //QUICK COMPLETED FORMAT WORKORDER REPORT - q2="SELECT \"~REGTO\" AS zCompName, wo.id, wo.clientrefnum, " -+"wo.clientcontact, clients.company AS clientcompany, " -+"Format(wo.closed,\"Short Date\") AS wodate, " -+"[users]![first] & \" \" & [users]![last] AS wotech, " -+"labor.hours, labor.travhours, labor.nchours, rates_1.name " -+"AS workrate, rates.name AS travrate, labor.start " -+"AS starttime, labor.stop AS stoptime, wo.invoice, " -+"labor.details, wo.onsite FROM (((users " -+"RIGHT JOIN (labor RIGHT JOIN (wo LEFT JOIN probs ON " -+"wo.id = probs.wolink) ON labor.link = probs.id) " -+"ON users.id = labor.tech) LEFT JOIN clients ON wo.client " -+"= clients.id) LEFT JOIN rates ON labor.travrate " -+"= rates.id) LEFT JOIN rates AS rates_1 ON " -+"labor.rate = rates_1.id WHERE (((wo.id)=~WOID)); "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=0));",q2); - executeQuery(q); - //------------------------------------------------ - - //fixup the dispatch report recordset fields - executeQuery("UPDATE rptsmaster SET rptsmaster.recordset = \"wostandard\" " - +"WHERE (((rptsmaster.id)=21));"); - - - executeQuery("UPDATE rptsmaster SET rptsmaster.recordset = \"woquick\" " - +"WHERE (((rptsmaster.id)=22));"); - - //Fix the workorder virtual names so they are - //the same as the original menu commands that called them - executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Dispatch format work order\" " - +"WHERE (((rptsmaster.id)=22));"); - - executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Completed work order\" " - +"WHERE (((rptsmaster.id)=0));"); - - executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Dispatch work order\" " - +"WHERE (((rptsmaster.id)=21));"); - - executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Brief completed work order\" " - +"WHERE (((rptsmaster.id)=1));"); - executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"D&etailed completed work order\" " - +"WHERE (((rptsmaster.id)=19));"); - - - //Add the subreport filename field - executeQuery("ALTER TABLE rptsmaster ADD COLUMN subfilename TEXT(255);"); - - executeQuery("UPDATE rptsmaster SET rptsmaster.subfilename = \"wodispstpartssub.rpt\" " - +"WHERE (((rptsmaster.id)=21));"); - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"164\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=164; - - - break; - - } - - - case 164://changed to 165 on Oct 14th 2002 for version 1.9 - { - - //Add cost of parts to woparts - //this is used to record cost at time of use - executeQuery("ALTER TABLE woparts ADD COLUMN cost CURRENCY;"); - executeQuery("ALTER TABLE woparts ALTER cost SET DEFAULT '0';"); - executeQuery("UPDATE woparts SET woparts.cost = 0;"); - - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"165\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=165; - break; - - } - - - - case 165://changed to 166 on Oct 14th 2002 for version 1.9 - { - - /* - Add new fields for rptsusers - long m_lPaperOrientation; - long m_lPaperSize; - long m_lPaperSource; - long m_lDuplexType; - */ - - executeQuery("ALTER TABLE rptsusers ADD COLUMN porient INTEGER;"); - executeQuery("ALTER TABLE rptsusers ALTER porient SET DEFAULT '0';"); - executeQuery("UPDATE rptsusers SET rptsusers.porient = 0;"); - - executeQuery("ALTER TABLE rptsusers ADD COLUMN psize INTEGER;"); - executeQuery("ALTER TABLE rptsusers ALTER psize SET DEFAULT '0';"); - executeQuery("UPDATE rptsusers SET rptsusers.psize = 0;"); - - executeQuery("ALTER TABLE rptsusers ADD COLUMN psource INTEGER;"); - executeQuery("ALTER TABLE rptsusers ALTER psource SET DEFAULT '0';"); - executeQuery("UPDATE rptsusers SET rptsusers.psource = 0;"); - - executeQuery("ALTER TABLE rptsusers ADD COLUMN pduplex INTEGER;"); - executeQuery("ALTER TABLE rptsusers ALTER pduplex SET DEFAULT '0';"); - executeQuery("UPDATE rptsusers SET rptsusers.pduplex = 0;"); - - executeQuery("ALTER TABLE rptsusers DROP COLUMN devmode;"); - executeQuery("ALTER TABLE rptsusers DROP COLUMN devmodesize;"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"166\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=166; - break; - - } - - case 166://changed to 167 on Oct 16th 2002 for version 1.9 - { - - - - - //--------------------------------------- - /* - Add new wodispst2.rpt - Dispatch work order (with labor) - */ - executeQuery("INSERT INTO rptsmaster ( virtualname, filename,subfilename, recordset, x, criteriafields, id ) " - +"SELECT \"Dispatch work order (with &labor)\", \"wodispst2.rpt\", \"wodispstpartssub.rpt\", \"wostandard\", False, 32767, 40;"); - - q2="SELECT \"~ESTRATE\" AS estrate, \"~SCHEDTECH\" AS scheduledtech, " -+"~ESTHOURS AS esthours, IIf(IsNull([clients].[company]),[clients].[last] " -+"& \", \" & [clients].[first],[clients].[company]) " -+"AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " -+"& IIf(IsNull([clients].[city]),\"\",Chr(13) " -+"& [clients].[city]) & IIf(IsNull([clients].[stateprov]),\"\",\", " -+"\" & [clients].[stateprov] " -+"& IIf(IsNull([clients].[postal]),\"\",\" " -+"\" & [clients].[postal])) AS address, \"Work required: " -+"\" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " -+"& \") SN: \" & [units].[sn],\"\") AS probheader, " -+"\"~REGTO\" AS compname, wo.notes AS wonotes, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, " -+"wo.prob_reported, wo.prob_found, wo.action_taken, " -+"wo.id AS wonumber, wo.created, labor.details, probs.notes, " -+"IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " -+"AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " -+"\" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] & \" (\" " -+"& [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS Equipment, wo.starttime AS [Booked for], wo.stoptime " -+"AS [Booked for END], wo.closed, probs.brief, " -+"clients.mailaddress, clients.streetaddress, clients.city, " -+"clients.stateprov, clients.postal, clients.country, " -+"clients.bizphone, clients.extension, " -+"clients.technotes, clients.first, clients.last, probstat.notes " -+"AS STATUS, probstat_1.notes AS ITEMSTATUS, " -+"projects.name AS PROJNAME, projects.notes AS " -+"PROJNOTES, users.first, users.last, users.initials, " -+"labor.hours, labor.nchours, labor.travhours, labor.start, " -+"labor.stop, labor.distance FROM (projects " -+"RIGHT JOIN ((((((labor RIGHT JOIN (((units RIGHT " -+"JOIN probs ON units.id = probs.unit) LEFT JOIN " -+"unitmodels ON units.model = unitmodels.id) LEFT JOIN " -+"nonclients ON unitmodels.manufacturer = nonclients.id) " -+"ON labor.link = probs.id) RIGHT JOIN ((wo " -+"LEFT JOIN clients ON wo.client = clients.id) LEFT " -+"JOIN clients AS headoffices ON clients.headoffice " -+"= headoffices.id) ON probs.wolink = wo.id) LEFT JOIN " -+"contracts ON clients.contract = contracts.id) LEFT " -+"JOIN contracts AS contracts_1 ON headoffices.contract " -+"= contracts_1.id) LEFT JOIN probstat ON wo.status " -+"= probstat.id) LEFT JOIN probstat AS probstat_1 " -+"ON probs.status = probstat_1.id) ON projects.id " -+"= wo.project) LEFT JOIN users ON labor.tech = " + + case 154: //update for v1721 + { + executeQuery("ALTER TABLE users ADD COLUMN schedrnd YESNO;"); + executeQuery("UPDATE users SET users.schedrnd = True;"); + + executeQuery("ALTER TABLE users ADD COLUMN schedoneday YESNO;"); + executeQuery("UPDATE users SET users.schedoneday = False;"); + + executeQuery("ALTER TABLE rentals ADD COLUMN ref TEXT(80);"); + + executeQuery("ALTER TABLE users ALTER COLUMN rentalprofile TEXT(80);"); + executeQuery("ALTER TABLE users ALTER rentalprofile SET DEFAULT \"(9,9) 42 169 195 103 88 129 0 105 109 0 1 8 7 2 3 4 5 6\";"); + executeQuery("UPDATE users SET users.rentalprofile = '(9,9) 42 169 195 103 88 129 0 105 109 0 1 8 7 2 3 4 5 6';"); + + + + //--------------------------------------- + //add the LOANERS report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"loaners\", \"loaners.rpt\", \"mgr\", False, 32767, 37;"); + + //------------------------------------------------ + + //--------------------------------------- + //add the RESPONSE TIME BY PROBLEM report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Response time by problem item (first response)\", \"respprob.rpt\", \"mgr\", True, 399, 38;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, probs.created AS prob_entered, probs.wolink, Min(labor.start) AS First_response, wo.id AS Workorder, wotypes.category AS CategoryName, projects.name AS ProjectName, clients.company AS ClientName, probs.brief " + + "FROM (((labor LEFT JOIN (wo RIGHT JOIN probs ON wo.id = probs.wolink) ON labor.link = probs.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN projects ON wo.project = projects.id) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((labor.tech)~TECH) AND ((wo.quick)=False)) " + + "GROUP BY probs.created, probs.wolink, wo.id, wotypes.category, projects.name, clients.company, probs.brief, wo.created " + + "HAVING (((Min(labor.start)) Is Not Null)) " + + "ORDER BY wo.created DESC , probs.wolink;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=38));", q2); + executeQuery(q); + //------------------------------------------------ + //--------------------------------------- + //add the RESPONSE TIME BY WORKORDER report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Response time for standard WO (first response)\", \"respwo.rpt\", \"mgr\", True, 399, 39;"); + + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.created AS wo_entered, probs.wolink, Min(labor.start) AS First_response, wo.id AS Workorder, wotypes.category AS CategoryName, projects.name AS ProjectName, clients.company AS ClientName " + + "FROM (((labor LEFT JOIN (wo RIGHT JOIN probs ON wo.id = probs.wolink) ON labor.link = probs.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN projects ON wo.project = projects.id) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.project)~PROJ) AND ((wo.client)~CUST) AND ((wo.type)~CAT_) AND ((labor.tech)~TECH) AND ((wo.quick)=False)) " + + "GROUP BY wo.created, probs.wolink, wo.id, wotypes.category, projects.name, clients.company " + + "HAVING (((Min(labor.start)) Is Not Null)) " + + "ORDER BY wo.created DESC , probs.wolink;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=39));", q2); + executeQuery(q); + //------------------------------------------------ + + + //ADD the tables for ARAS clients + //------------------------------------------------ + //clients_aras + executeQuery("CREATE TABLE clients_aras (" + + "id COUNTER CONSTRAINT PK_clntaras PRIMARY KEY, " + + "clientlink INTEGER DEFAULT 0," + + "loginid TEXT(50), " + + "loginpw TEXT(50), " + + "view_wo_status YESNO DEFAULT False, " + + "search_history YESNO DEFAULT False, " + + "wo_view YESNO DEFAULT False, " + + "wo_report YESNO DEFAULT False, " + + "request_service YESNO DEFAULT False, " + + "view_request_list YESNO DEFAULT False, " + + "private_notes MEMO, " + + "last_login_date DATETIME, " + + "creator INTEGER DEFAULT 0, "//user who created record + + "created DATETIME, " //date created + + "modifier INTEGER DEFAULT 0, "//date modified + + "modified DATETIME " + + ");"); + //------------------------------------------------ + + //client_requests + executeQuery("CREATE TABLE client_requests (" + + "id COUNTER CONSTRAINT PK_clntrqsts PRIMARY KEY, " + + "clientlink INTEGER DEFAULT 0," + + "requestor_id INTEGER DEFAULT 0," + + "workorderid INTEGER DEFAULT 0," + + "request TEXT(110), " + + "probdetails MEMO, " + + "prefertech INTEGER DEFAULT -1," + + "refnum TEXT(80), " + + "ournotes MEMO, " + + "created DATETIME, " //date created + + "urgency INTEGER DEFAULT 0"//0=not 2=extreme + + + ");"); + //------------------------------------------------ + + //ADD new profile key to user table for ARAS request view screen + + + executeQuery("ALTER TABLE users ADD COLUMN aras_req_profile TEXT(80);"); + executeQuery("ALTER TABLE users ALTER aras_req_profile SET DEFAULT \"(7,7) 52 76 128 73 217 162 0 0 1 2 3 4 5 6\";"); + executeQuery("UPDATE users SET users.aras_req_profile = '(7,7) 52 76 128 73 217 162 0 0 1 2 3 4 5 6';"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"155\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.7.2.1\";"); + nVersion = 155; + + + } + + break; + + + case 155://changed to 156 on Sept 30th 2002 for version 1.9 + { + //Added field to turn on or off transaction support + //true=database execute queries are wrapped in transactions + //false=old style pre 1.9 not wrapped in transactions + //made it an option in case users have problems + //should improve data currency on a busy network + executeQuery("ALTER TABLE defaults ADD COLUMN transact YESNO;"); + executeQuery("UPDATE defaults SET defaults.transact = True;"); + + + //client alternate phone number + executeQuery("ALTER TABLE clients ADD COLUMN phone2 TEXT(40);"); + executeQuery("ALTER TABLE clients ADD COLUMN phone3 TEXT(40);"); + + + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"156\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 156; + + } + + break; + + case 156://changed to 157 on Oct 4th 2002 for version 1.9 + { + + //Horizontal grid on main work order list screen + //user preference field. Default to true so they + //know it's there and we can get all those emails + //bitching about it because they don't read the docs and know that + //they can turn it off + executeQuery("ALTER TABLE users ADD COLUMN hgrid YESNO;"); + executeQuery("UPDATE users SET users.hgrid = True;"); + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"157\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 157; + + + break; + + } + + + case 157://changed to 158 on Oct 8th 2002 for version 1.9 + { + + //drop location field in wo which is not used and + //add a pmid field + executeQuery("ALTER TABLE wo ADD COLUMN pmid INTEGER;"); + executeQuery("ALTER TABLE wo ALTER pmid SET DEFAULT '0';"); + executeQuery("UPDATE wo SET wo.pmid = 0;"); + executeQuery("ALTER TABLE wo DROP COLUMN location;"); + + + //update pmhead table to include the two new time fields + executeQuery("ALTER TABLE pmhead ADD COLUMN starttime DATETIME;"); + executeQuery("ALTER TABLE pmhead ADD COLUMN endtime DATETIME;"); + executeQuery("UPDATE pmhead SET pmhead.starttime = #10/8/2002 8:0:0#;"); + executeQuery("UPDATE pmhead SET pmhead.endtime = #10/8/2002 9:0:0#;"); + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"158\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 158; + break; + + } + + + + case 158://changed to 159 on Oct 9th 2002 for version 1.9 + { + + //-2 now means don't show scheduled tech column in workorder list + //where it used to be 0 for that so change all 0's to -2's + executeQuery("UPDATE statusviews SET statusviews.schedtech = -2 " + + "WHERE (((statusviews.schedtech)=0));"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"159\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 159; + break; + + } + + + case 159://changed to 160 on Oct 11th 2002 for version 1.9 + { + + //add created days column to status views table + executeQuery("ALTER TABLE statusviews ADD COLUMN createddays INTEGER;"); + executeQuery("ALTER TABLE statusviews ALTER createddays SET DEFAULT '0';"); + executeQuery("UPDATE statusviews SET statusviews.createddays = 0;"); + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"160\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 160; + break; + } + + + + case 160://changed to 161 on Oct 12th 2002 for version 1.9 + { + + //Add distance column to labor table + executeQuery("ALTER TABLE labor ADD COLUMN distance REAL;"); + executeQuery("ALTER TABLE labor ALTER distance SET DEFAULT '0';"); + executeQuery("UPDATE labor SET labor.distance = 0;"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"161\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 161; + break; + + } + + + + case 161://changed to 162 on Oct 12th 2002 for version 1.9 + { + + //Add distance column to labor table + executeQuery("ALTER TABLE clients ADD COLUMN inactive YESNO;"); + executeQuery("ALTER TABLE clients ALTER inactive SET DEFAULT '0';"); + executeQuery("UPDATE clients SET clients.inactive = False;"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"162\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 162; + + break; + + } + + + + case 162://changed to 163 on Oct 12th 2002 for version 1.9 + { + + //Set all woparts.misc to NULL as some may be empty + //other changes will ensure it is never set to empty in future + //this is just to catch any existing ones. + executeQuery("UPDATE woparts SET woparts.misc = Null WHERE (((woparts.misc)=\"\"));"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"163\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 163; + + break; + + } + + + + case 163://changed to 164 on Oct 13th 2002 for version 1.9 + { + + //Add subquery field to rptsmaster + //required for parts printing on dispatch standard workorder + executeQuery("ALTER TABLE rptsmaster ADD COLUMN subreportquery MEMO;"); + + + //REMOVE ANY OLD RPTS MASTER ENTRIES FOR WORKORDER REPORTS + + //STANDARD DISPATCH + q2 = "SELECT \"~ESTRATE\" AS estrate, \"~SCHEDTECH\" AS scheduledtech, " ++ "~ESTHOURS AS esthours, IIf(IsNull([clients].[company]),[clients].[last] " ++ "& \", \" & [clients].[first],[clients].[company]) " ++ "AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " + + "& IIf(IsNull([clients].[city]),\"\",Chr(13) " ++ "& [clients].[city]) & IIf(IsNull([clients].[stateprov]),\"\",\", " ++ "\" & [clients].[stateprov] " ++ "& IIf(IsNull([clients].[postal]),\"\",\" " ++ "\" & [clients].[postal])) AS address, \"Work required: " ++ "\" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " ++ "& \") SN: \" & [units].[sn],\"\") AS probheader, " ++ "\"~REGTO\" AS compname, wo.notes AS wonotes, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, " ++ "wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "wo.id AS wonumber, wo.created, labor.details, probs.notes, " ++ "IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " ++ "AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " ++ "\" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & \" (\" " ++ "& [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS Equipment, wo.starttime AS [Booked for], wo.stoptime " ++ "AS [Booked for END], wo.closed, probs.brief, " ++ "clients.mailaddress, clients.streetaddress, clients.city, " ++ "clients.stateprov, clients.postal, clients.country, " ++ "clients.bizphone, clients.extension, " ++ "clients.technotes, clients.first, clients.last, probstat.notes " ++ "AS STATUS, probstat_1.notes AS ITEMSTATUS, " ++ "projects.name AS PROJNAME, projects.notes AS " ++ "PROJNOTES FROM projects RIGHT JOIN ((((((labor RIGHT " ++ "JOIN (((units RIGHT JOIN probs ON units.id = " ++ "probs.unit) LEFT JOIN unitmodels ON units.model = " ++ "unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer " ++ "= nonclients.id) ON labor.link = probs.id) " ++ "RIGHT JOIN ((wo LEFT JOIN clients ON wo.client " ++ "= clients.id) LEFT JOIN clients AS headoffices " ++ "ON clients.headoffice = headoffices.id) ON probs.wolink " ++ "= wo.id) LEFT JOIN contracts ON clients.contract " ++ "= contracts.id) LEFT JOIN contracts AS contracts_1 " ++ "ON headoffices.contract = contracts_1.id) LEFT " ++ "JOIN probstat ON wo.status = probstat.id) LEFT " ++ "JOIN probstat AS probstat_1 ON probs.status = probstat_1.id) " ++ "ON projects.id = wo.project WHERE (((wo.id)=~WOID)); "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=21));", q2); + executeQuery(q); + + + //***** SUBREPORT ****************** + q2 = "SELECT probs.id, woparts.quantity, woparts.sn, parts.partnumber, " ++ "woparts.misc, parts.description, parts.retail, " ++ "IIf(IsNull(woparts.misc),[parts].[partnumber] " ++ "& \" \" & [parts].[description] & \": \" & [woparts].[quantity] " ++ "& \" @ \" & Format([woparts].[price],\"Currency\") " ++ "& \" ea.\" & IIf(IsNull([woparts].[sn]),\"\",\" sn:\" & [woparts].[sn]) " ++ ", [woparts].[misc] " ++ "& \": \" & [woparts].[quantity] & \" @ \" & Format([woparts].[price],\"Currency\") " ++ "& \" ea.sn:\" & [woparts].[sn] " ++ ") AS item, [woparts].[quantity]*[woparts].[price] " ++ "AS linetotal FROM (woparts RIGHT JOIN " ++ "(probs RIGHT JOIN wo ON probs.wolink = wo.id) ON " ++ "woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum " ++ "= parts.id WHERE (((woparts.quantity) " ++ "Is Not Null) AND ((wo.id)=~WOID));"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.subreportquery = '%s' " + + "WHERE (((rptsmaster.id)=21));", q2); + executeQuery(q); + //------------------------------------------------ + + //STANDARD BRIEF + q2 = "SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] " ++ "& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS probheader, \"~REGTO\" AS compname, wom.probnum, " ++ "wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " ++ "wom.PROBBRIEF, wom.item, wom.linetotal, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " ++ "AS wodate, wo.id AS wonumber, wo.invoice, " ++ "wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "clients.billheadoffice, clients.first, clients.last, " ++ "clients.mailaddress, clients.streetaddress, " ++ "clients.city, clients.stateprov, clients.postal, " ++ "clients.country, clients.bizphone, clients.extension, " ++ "clients.fax, clients.email, [clients].[company] " ++ "AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " ++ "& \", \" & [headoffices].[first],[headoffices].[company]) " ++ "AS headname, wom.details, " ++ "wom.STARTDATE, wom.STOPDATE, projects.name " ++ "AS PROJNAME, projects.notes AS PROJNOTES FROM " ++ "(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " ++ "\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " ++ "AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " ++ "AS PROBBRIEF, probs.id AS probnum, probs.wolink " ++ "AS wonum, \"Service: \" & users.first & \" \" & " ++ "users.last & \" - \" & IIf(labor.hours>0,labor.hours " ++ "& \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" " ++ "(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " ++ "(\" & labor.nchours & \" hrs. no charge)\",\"\") " ++ "& IIf(labor.travhours>0,\", \" & labor.travhours & \" " ++ "hrs. travel @ \" & Format(travelrates.rate,\"Currency\") " ++ "& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " ++ "& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " ++ "AS linetotal,labor.details, labor.start AS STARTDATE, " ++ "labor.stop as STOPDATE FROM users INNER JOIN " ++ "(rates AS travelrates INNER JOIN (rates INNER JOIN " ++ "(labor INNER JOIN probs ON labor.link = probs.id) " ++ "ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " ++ "ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " ++ "UNION ALL (SELECT \"2\" AS ctype, " ++ "\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " ++ "probs.brief AS PROBBRIEF, probs.id AS probnum, " ++ " probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " ++ "& \" \" & parts.description " ++ "& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " ++ "& \" ea.(sn:\" & woparts.sn " ++ "& \")\",woparts.misc & \": \" & woparts.quantity " ++ "& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " ++ "& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " ++ "AS linetotal,\"\" AS details, #03/12/1968# " ++ "AS STARTDATE, #03/12/1968# AS STOPDATE FROM " ++ "(probs INNER JOIN woparts ON probs.id = woparts.link) " ++ "LEFT JOIN parts ON woparts.partnum = parts.id " ++ "WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " ++ " \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " ++ "AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " ++ "AS probnum, probs.wolink as wonum, \"Third party " ++ "service: \" AS item, subrepair.charge AS linettotal, " ++ "\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " ++ "AS STOPDATE FROM probs INNER JOIN subrepair " ++ "ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " ++ "AND ((subrepair.charge)<>0))))]. AS " ++ "wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " ++ "clients ON wo.client = clients.id) LEFT JOIN clients " ++ "AS headoffices ON clients.headoffice = headoffices.id) " ++ "ON probs.id = wom.probnum) ON units.id = probs.unit) " ++ "LEFT JOIN unitmodels ON units.model = unitmodels.id) " ++ "LEFT JOIN nonclients ON unitmodels.manufacturer " ++ "= nonclients.id) LEFT JOIN projects ON " ++ "wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=1));", q2); + executeQuery(q); + //------------------------------------------------ + + //STANDARD COMPLETED + q2 = "SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] " ++ "& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS probheader, \"~REGTO\" AS compname, wom.probnum, " ++ "wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " ++ "wom.PROBBRIEF, wom.item, wom.linetotal, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " ++ "AS wodate, wo.id AS wonumber, wo.invoice, " ++ "wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "clients.billheadoffice, clients.first, clients.last, " ++ "clients.mailaddress, clients.streetaddress, " ++ "clients.city, clients.stateprov, clients.postal, " ++ "clients.country, clients.bizphone, clients.extension, " ++ "clients.fax, clients.email, [clients].[company] " ++ "AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " ++ "& \", \" & [headoffices].[first],[headoffices].[company]) " ++ "AS headname, wom.details, " ++ "wom.STARTDATE, wom.STOPDATE, projects.name " ++ "AS PROJNAME, projects.notes AS PROJNOTES FROM " ++ "(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " ++ "\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " ++ "AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " ++ "AS PROBBRIEF, probs.id AS probnum, probs.wolink " ++ "AS wonum, \"Service: \" & users.first & \" \" & " ++ "users.last & \" - \" & IIf(labor.hours>0,labor.hours " ++ "& \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" " ++ "(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " ++ "(\" & labor.nchours & \" hrs. no charge)\",\"\") " ++ "& IIf(labor.travhours>0,\", \" & labor.travhours & \" " ++ "hrs. travel @ \" & Format(travelrates.rate,\"Currency\") " ++ "& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " ++ "& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " ++ "AS linetotal,labor.details, labor.start AS STARTDATE, " ++ "labor.stop as STOPDATE FROM users INNER JOIN " ++ "(rates AS travelrates INNER JOIN (rates INNER JOIN " ++ "(labor INNER JOIN probs ON labor.link = probs.id) " ++ "ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " ++ "ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " ++ "UNION ALL (SELECT \"2\" AS ctype, " ++ "\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " ++ "probs.brief AS PROBBRIEF, probs.id AS probnum, " ++ " probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " ++ "& \" \" & parts.description " ++ "& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " ++ "& \" ea.(sn:\" & woparts.sn " ++ "& \")\",woparts.misc & \": \" & woparts.quantity " ++ "& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " ++ "& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " ++ "AS linetotal,\"\" AS details, #03/12/1968# " ++ "AS STARTDATE, #03/12/1968# AS STOPDATE FROM " ++ "(probs INNER JOIN woparts ON probs.id = woparts.link) " ++ "LEFT JOIN parts ON woparts.partnum = parts.id " ++ "WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " ++ " \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " ++ "AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " ++ "AS probnum, probs.wolink as wonum, \"Third party " ++ "service: \" AS item, subrepair.charge AS linettotal, " ++ "\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " ++ "AS STOPDATE FROM probs INNER JOIN subrepair " ++ "ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " ++ "AND ((subrepair.charge)<>0))))]. AS " ++ "wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " ++ "clients ON wo.client = clients.id) LEFT JOIN clients " ++ "AS headoffices ON clients.headoffice = headoffices.id) " ++ "ON probs.id = wom.probnum) ON units.id = probs.unit) " ++ "LEFT JOIN unitmodels ON units.model = unitmodels.id) " ++ "LEFT JOIN nonclients ON unitmodels.manufacturer " ++ "= nonclients.id) LEFT JOIN projects ON " ++ "wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=19));", q2); + executeQuery(q); + //------------------------------------------------ + + + + + //QUICK DISPATCH WORKORDER + q2 = "SELECT IIf(IsNull([clients].[company]),[clients].[last] " ++ "& \", \" & [clients].[first],[clients].[company]) " ++ "AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " + + "& IIf(IsNull([clients].[city]),\"\",[clients].[city]) " ++ "& IIf(IsNull([clients].[stateprov]),\"\",\", " ++ "\" & [clients].[stateprov] & IIf(IsNull([clients].[postal]),\"\",\" " ++ "\" & [clients].[postal])) AS address, " ++ "\"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & " ++ "\" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS probheader, \"~REGTO\" AS compname, wo.id " ++ "AS wonumber, wo.created, labor.details, probs.notes, " ++ "IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " ++ "AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " ++ "\" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " ++ "& \") SN: \" & [units].[sn],\"\") AS " ++ "Equipment, wo.starttime AS [Booked for], probs.brief, " ++ "clients.mailaddress, clients.streetaddress, " ++ "clients.city, clients.stateprov, clients.postal, clients.country, " ++ "clients.bizphone, clients.extension, " ++ "clients.technotes, clients.first, clients.last, " ++ "wo.clientrefnum, wo.ourref, wo.clientcontact FROM " ++ "(((labor RIGHT JOIN (((units RIGHT JOIN probs ON " ++ "units.id = probs.unit) LEFT JOIN unitmodels ON units.model " ++ "= unitmodels.id) LEFT JOIN nonclients ON " ++ "unitmodels.manufacturer = nonclients.id) ON labor.link " ++ "= probs.id) RIGHT JOIN ((wo LEFT JOIN clients " ++ "ON wo.client = clients.id) LEFT JOIN clients AS headoffices " ++ "ON clients.headoffice = headoffices.id) " ++ "ON probs.wolink = wo.id) LEFT JOIN contracts ON clients.contract " ++ "= contracts.id) LEFT JOIN contracts " ++ "AS contracts_1 ON headoffices.contract = contracts_1.id " ++ "WHERE (((wo.id)=~WOID));"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=22));", q2); + executeQuery(q); + //------------------------------------------------ + + + //QUICK COMPLETED FORMAT WORKORDER REPORT + q2 = "SELECT \"~REGTO\" AS zCompName, wo.id, wo.clientrefnum, " ++ "wo.clientcontact, clients.company AS clientcompany, " ++ "Format(wo.closed,\"Short Date\") AS wodate, " ++ "[users]![first] & \" \" & [users]![last] AS wotech, " ++ "labor.hours, labor.travhours, labor.nchours, rates_1.name " ++ "AS workrate, rates.name AS travrate, labor.start " ++ "AS starttime, labor.stop AS stoptime, wo.invoice, " ++ "labor.details, wo.onsite FROM (((users " ++ "RIGHT JOIN (labor RIGHT JOIN (wo LEFT JOIN probs ON " ++ "wo.id = probs.wolink) ON labor.link = probs.id) " ++ "ON users.id = labor.tech) LEFT JOIN clients ON wo.client " ++ "= clients.id) LEFT JOIN rates ON labor.travrate " ++ "= rates.id) LEFT JOIN rates AS rates_1 ON " ++ "labor.rate = rates_1.id WHERE (((wo.id)=~WOID)); "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=0));", q2); + executeQuery(q); + //------------------------------------------------ + + //fixup the dispatch report recordset fields + executeQuery("UPDATE rptsmaster SET rptsmaster.recordset = \"wostandard\" " + + "WHERE (((rptsmaster.id)=21));"); + + + executeQuery("UPDATE rptsmaster SET rptsmaster.recordset = \"woquick\" " + + "WHERE (((rptsmaster.id)=22));"); + + //Fix the workorder virtual names so they are + //the same as the original menu commands that called them + executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Dispatch format work order\" " + + "WHERE (((rptsmaster.id)=22));"); + + executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Completed work order\" " + + "WHERE (((rptsmaster.id)=0));"); + + executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Dispatch work order\" " + + "WHERE (((rptsmaster.id)=21));"); + + executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"&Brief completed work order\" " + + "WHERE (((rptsmaster.id)=1));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.virtualname = \"D&etailed completed work order\" " + + "WHERE (((rptsmaster.id)=19));"); + + + //Add the subreport filename field + executeQuery("ALTER TABLE rptsmaster ADD COLUMN subfilename TEXT(255);"); + + executeQuery("UPDATE rptsmaster SET rptsmaster.subfilename = \"wodispstpartssub.rpt\" " + + "WHERE (((rptsmaster.id)=21));"); + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"164\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 164; + + + break; + + } + + + case 164://changed to 165 on Oct 14th 2002 for version 1.9 + { + + //Add cost of parts to woparts + //this is used to record cost at time of use + executeQuery("ALTER TABLE woparts ADD COLUMN cost CURRENCY;"); + executeQuery("ALTER TABLE woparts ALTER cost SET DEFAULT '0';"); + executeQuery("UPDATE woparts SET woparts.cost = 0;"); + + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"165\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 165; + break; + + } + + + + case 165://changed to 166 on Oct 14th 2002 for version 1.9 + { + + /* + Add new fields for rptsusers + long m_lPaperOrientation; + long m_lPaperSize; + long m_lPaperSource; + long m_lDuplexType; + */ + + executeQuery("ALTER TABLE rptsusers ADD COLUMN porient INTEGER;"); + executeQuery("ALTER TABLE rptsusers ALTER porient SET DEFAULT '0';"); + executeQuery("UPDATE rptsusers SET rptsusers.porient = 0;"); + + executeQuery("ALTER TABLE rptsusers ADD COLUMN psize INTEGER;"); + executeQuery("ALTER TABLE rptsusers ALTER psize SET DEFAULT '0';"); + executeQuery("UPDATE rptsusers SET rptsusers.psize = 0;"); + + executeQuery("ALTER TABLE rptsusers ADD COLUMN psource INTEGER;"); + executeQuery("ALTER TABLE rptsusers ALTER psource SET DEFAULT '0';"); + executeQuery("UPDATE rptsusers SET rptsusers.psource = 0;"); + + executeQuery("ALTER TABLE rptsusers ADD COLUMN pduplex INTEGER;"); + executeQuery("ALTER TABLE rptsusers ALTER pduplex SET DEFAULT '0';"); + executeQuery("UPDATE rptsusers SET rptsusers.pduplex = 0;"); + + executeQuery("ALTER TABLE rptsusers DROP COLUMN devmode;"); + executeQuery("ALTER TABLE rptsusers DROP COLUMN devmodesize;"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"166\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 166; + break; + + } + + case 166://changed to 167 on Oct 16th 2002 for version 1.9 + { + + + + + //--------------------------------------- + /* + Add new wodispst2.rpt + Dispatch work order (with labor) + */ + executeQuery("INSERT INTO rptsmaster ( virtualname, filename,subfilename, recordset, x, criteriafields, id ) " + + "SELECT \"Dispatch work order (with &labor)\", \"wodispst2.rpt\", \"wodispstpartssub.rpt\", \"wostandard\", False, 32767, 40;"); + + q2 = "SELECT \"~ESTRATE\" AS estrate, \"~SCHEDTECH\" AS scheduledtech, " ++ "~ESTHOURS AS esthours, IIf(IsNull([clients].[company]),[clients].[last] " ++ "& \", \" & [clients].[first],[clients].[company]) " ++ "AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) " ++ "& IIf(IsNull([clients].[city]),\"\",Chr(13) " ++ "& [clients].[city]) & IIf(IsNull([clients].[stateprov]),\"\",\", " ++ "\" & [clients].[stateprov] " ++ "& IIf(IsNull([clients].[postal]),\"\",\" " ++ "\" & [clients].[postal])) AS address, \"Work required: " ++ "\" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] " ++ "& \") SN: \" & [units].[sn],\"\") AS probheader, " ++ "\"~REGTO\" AS compname, wo.notes AS wonotes, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, " ++ "wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "wo.id AS wonumber, wo.created, labor.details, probs.notes, " ++ "IIf(IsNull(contracts_1.name),[contracts].[name],contracts_1.name) " ++ "AS contractinfo, IIf([probs].[unit]<>0,\"Unit: " ++ "\" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] & \" (\" " ++ "& [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS Equipment, wo.starttime AS [Booked for], wo.stoptime " ++ "AS [Booked for END], wo.closed, probs.brief, " ++ "clients.mailaddress, clients.streetaddress, clients.city, " ++ "clients.stateprov, clients.postal, clients.country, " ++ "clients.bizphone, clients.extension, " ++ "clients.technotes, clients.first, clients.last, probstat.notes " ++ "AS STATUS, probstat_1.notes AS ITEMSTATUS, " ++ "projects.name AS PROJNAME, projects.notes AS " ++ "PROJNOTES, users.first, users.last, users.initials, " ++ "labor.hours, labor.nchours, labor.travhours, labor.start, " ++ "labor.stop, labor.distance FROM (projects " ++ "RIGHT JOIN ((((((labor RIGHT JOIN (((units RIGHT " ++ "JOIN probs ON units.id = probs.unit) LEFT JOIN " ++ "unitmodels ON units.model = unitmodels.id) LEFT JOIN " ++ "nonclients ON unitmodels.manufacturer = nonclients.id) " ++ "ON labor.link = probs.id) RIGHT JOIN ((wo " ++ "LEFT JOIN clients ON wo.client = clients.id) LEFT " ++ "JOIN clients AS headoffices ON clients.headoffice " ++ "= headoffices.id) ON probs.wolink = wo.id) LEFT JOIN " ++ "contracts ON clients.contract = contracts.id) LEFT " ++ "JOIN contracts AS contracts_1 ON headoffices.contract " ++ "= contracts_1.id) LEFT JOIN probstat ON wo.status " ++ "= probstat.id) LEFT JOIN probstat AS probstat_1 " ++ "ON probs.status = probstat_1.id) ON projects.id " ++ "= wo.project) LEFT JOIN users ON labor.tech = " + "users.id WHERE (((wo.id)=~WOID));"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=40));",q2); - executeQuery(q); + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=40));", q2); + executeQuery(q); - //subreport query - q2="SELECT probs.id, woparts.quantity, woparts.sn, parts.partnumber, " -+"woparts.misc, parts.description, parts.retail, " -+"IIf(IsNull(woparts.misc),[parts].[partnumber] " -+"& \" \" & [parts].[description] & \": \" & [woparts].[quantity] " -+"& \" @ \" & Format([woparts].[price],\"Currency\") " -+"& \" ea.\" & IIf(IsNull([woparts].[sn]),\"\",\" " -+"sn:\" & [woparts].[sn]) , [woparts].[misc] " -+"& \": \" & [woparts].[quantity] & \" @ \" & Format([woparts].[price],\"Currency\") " -+"& \" ea.sn:\" & [woparts].[sn] " -+") AS item, [woparts].[quantity]*[woparts].[price] " -+"AS linetotal FROM (woparts RIGHT JOIN (probs " -+"RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link " -+"= probs.id) LEFT JOIN parts ON woparts.partnum " -+"= parts.id WHERE (((woparts.quantity) Is Not Null) " -+"AND ((wo.id)=~WOID));"; - q=string.Format("UPDATE rptsmaster SET rptsmaster.subreportquery = '%s' " - +"WHERE (((rptsmaster.id)=40));",q2); - executeQuery(q); - //------------------------------------------------ + //subreport query + q2 = "SELECT probs.id, woparts.quantity, woparts.sn, parts.partnumber, " ++ "woparts.misc, parts.description, parts.retail, " ++ "IIf(IsNull(woparts.misc),[parts].[partnumber] " ++ "& \" \" & [parts].[description] & \": \" & [woparts].[quantity] " ++ "& \" @ \" & Format([woparts].[price],\"Currency\") " ++ "& \" ea.\" & IIf(IsNull([woparts].[sn]),\"\",\" " ++ "sn:\" & [woparts].[sn]) , [woparts].[misc] " ++ "& \": \" & [woparts].[quantity] & \" @ \" & Format([woparts].[price],\"Currency\") " ++ "& \" ea.sn:\" & [woparts].[sn] " ++ ") AS item, [woparts].[quantity]*[woparts].[price] " ++ "AS linetotal FROM (woparts RIGHT JOIN (probs " ++ "RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link " ++ "= probs.id) LEFT JOIN parts ON woparts.partnum " ++ "= parts.id WHERE (((woparts.quantity) Is Not Null) " ++ "AND ((wo.id)=~WOID));"; + q = string.Format("UPDATE rptsmaster SET rptsmaster.subreportquery = '%s' " + + "WHERE (((rptsmaster.id)=40));", q2); + executeQuery(q); + //------------------------------------------------ - //---------- ADD DISPLAY ORDER FIELD TO RPTS MASTER - executeQuery("ALTER TABLE rptsmaster ADD COLUMN wodisplayorder INTEGER;"); - - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 1 " - +"WHERE (((rptsmaster.virtualname)=\"&Dispatch format work order\"));"); + //---------- ADD DISPLAY ORDER FIELD TO RPTS MASTER + executeQuery("ALTER TABLE rptsmaster ADD COLUMN wodisplayorder INTEGER;"); - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 2 " - +"WHERE (((rptsmaster.virtualname)=\"&Completed work order\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 1 " + + "WHERE (((rptsmaster.virtualname)=\"&Dispatch format work order\"));"); - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 3 " - +"WHERE (((rptsmaster.virtualname)=\"&Dispatch work order\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 2 " + + "WHERE (((rptsmaster.virtualname)=\"&Completed work order\"));"); - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 4 " - +"WHERE (((rptsmaster.virtualname)=\"Dispatch work order (with &labor)\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 3 " + + "WHERE (((rptsmaster.virtualname)=\"&Dispatch work order\"));"); - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 5 " - +"WHERE (((rptsmaster.virtualname)=\"&Brief completed work order\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 4 " + + "WHERE (((rptsmaster.virtualname)=\"Dispatch work order (with &labor)\"));"); - executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 6 " - +"WHERE (((rptsmaster.virtualname)=\"D&etailed completed work order\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 5 " + + "WHERE (((rptsmaster.virtualname)=\"&Brief completed work order\"));"); + executeQuery("UPDATE rptsmaster SET rptsmaster.wodisplayorder = 6 " + + "WHERE (((rptsmaster.virtualname)=\"D&etailed completed work order\"));"); + + + + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"167\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 167; + + break; + + } + + + + case 167: + { + + //Addition of client address book Report + executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " + + "SELECT \"Client address book\", \"clntadd.rpt\", \"mgr\", True, 32767, 41;"); + + q2 = "SELECT clients.*, HEADS.* FROM clients LEFT JOIN clients " + + "AS HEADS ON clients.headoffice = HEADS.id WHERE " + + "(((clients.id)~CUST)) ORDER BY clients.company; "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=41));", q2); + executeQuery(q); + + + //Set STATUS column in statusviews to -1 if it was previously 1 as -1 + //now means any status where 1 used to mean any status + q = string.Format("UPDATE statusviews SET statusviews.status = -1 WHERE (((statusviews.status)=1));"); + executeQuery(q); + + + //10/26/2002 + //set assigntech to correct value on old quick work orders + q = "UPDATE labor RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) " + + "ON labor.link = probs.id SET wo.assigntech = [labor].[tech] " + + "WHERE (((wo.quick)=True) AND ((wo.assigntech)=-1));"; + executeQuery(q); + + //Add aras_client field to rptsmaster + executeQuery("ALTER TABLE rptsmaster ADD COLUMN client_aras YESNO;"); + executeQuery("ALTER TABLE rptsmaster ALTER client_aras SET DEFAULT '-1';"); + executeQuery("UPDATE rptsmaster SET rptsmaster.client_aras = True;"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"168\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); + nVersion = 168; + //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only + break; + + } + + case 168: + { + + //Changed ....... + executeQuery("ALTER TABLE probs ALTER COLUMN meter INTEGER;"); + + + //Update report 31 to fix bug in query causing part descriptions to be blank + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " + + "FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" hrs. no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" hrs. travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " + + " UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc), parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " + + " LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " + + "ORDER BY wo.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=31));", q2); + executeQuery(q); + + + //2023-07-14 going to skip this stuff hopefully don't need it + // //************* change any client aras logins that match ayanova user logins ********** + // CString strReportDupes,str; + // CString sLoginARAS,sLoginARASHash,sCompany,sNewLogin; + // GZK k; + // long l=0; + // long lARASID=0; + // //check for and zap any aras client login names that match AyaNova login names + // //loop through all aras login names + // //for each that hashes out to same as ayanova login name, change login name to prepend unique string + // q="SELECT clients.company AS COMP1, clients_aras.loginid, " + // "clients_aras.id AS ARASID FROM clients_aras LEFT " + // "JOIN clients ON clients_aras.clientlink = clients.id " + // "ORDER BY clients.company, clients_aras.loginid;"; + // rs2->QueryReadOnly(q); + // if(!rs2->IsEmpty()) + // { + // do{ + + // rs2->FetchField("loginid",&sLoginARAS); + // sLoginARASHash=sLoginARAS; + // k.GZHash(&sLoginARASHash); + // q=string.Format("SELECT users.login FROM users WHERE (((users.login)=\"%s\"));",sLoginARASHash); + // rs3->QueryReadOnly(q); + // if(!rs3->IsEmpty())//This ARAS client login matches AyaNova login + // { + + // l++; + // sNewLogin.Format("Temporary%u",l); + // rs2->FetchField("COMP1",&sCompany); + // str.Format("Client %s ARAS login account %s changed to %s\r\n",sCompany,sLoginARAS,sNewLogin); + // strReportDupes+=str; + // rs2->FetchField("ARASID",&lARASID); + // q=string.Format("UPDATE clients_aras SET clients_aras.loginid = \"%s\" " + // "WHERE (((clients_aras.id) = %u ));",sNewLogin,lARASID); + // executeQuery(q); + + + + // } + + // }while(rs2->MoveForward()); + + + // } + + + + + // //Check for duplicate ARAS client login names + + // q="SELECT clients_aras.loginid, clients_aras.id AS ARASID, clients.company AS COMP1 " + //"FROM clients_aras LEFT JOIN clients ON " + //"clients_aras.clientlink = clients.id WHERE (((clients_aras.loginid) " + //"In (SELECT [loginid] FROM [clients_aras] " + //"As Tmp GROUP BY [loginid] HAVING Count(*)>1 " + //"))) ORDER BY clients_aras.loginid;"; + // rs2->QueryReadOnly(q); + // if(!rs2->IsEmpty())//there are dupes + // { + // do{ + // l++; + // sNewLogin.Format("Temporary%u",l); + // rs2->FetchField("COMP1",&sCompany); + // str.Format("Client %s ARAS login account %s changed to %s\r\n",sCompany,sLoginARAS,sNewLogin); + // strReportDupes+=str; + // rs2->FetchField("ARASID",&lARASID); + // q=string.Format("UPDATE clients_aras SET clients_aras.loginid = \"%s\" " + // "WHERE (((clients_aras.id) = %u ));",sNewLogin,lARASID); + // executeQuery(q); + + + // }while(rs2->MoveForward()); + + + // } + + // if(!strReportDupes.IsEmpty()) + // { + // strReportDupes= + // "******** READ THIS CAREFULLY ********\r\n" + // "The following client(s) ARAS login ID's we're changed for security reasons.\r\n\r\n" + + // "You should save this information now and change them after the update has\r\n" + // "completed. (otherwise they will not be able to log in)\r\n\r\n" + + // "To save this information click on the copy all text.. button, open a word processor or\r\n" + // "Microsoft Notepad and paste. You can then save / print this list.\r\n" + // "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n"+strReportDupes; + // m_pApp->ShowStuff(strReportDupes); + // strReportDupes.Empty(); + + // } + + + + //****************************************************************************** + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"169\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.3.0\";"); + nVersion = 169; + //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only + break; + + } + case 169: + { + + //------------------------------------------------ + //REMOVE Hrs. FROM WORK ORDER REPORT QUERIES + //STANDARD BRIEF + q2 = "SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] " ++ "& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS probheader, \"~REGTO\" AS compname, wom.probnum, " ++ "wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " ++ "wom.PROBBRIEF, wom.item, wom.linetotal, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " ++ "AS wodate, wo.id AS wonumber, wo.invoice, " ++ "wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "clients.billheadoffice, clients.first, clients.last, " ++ "clients.mailaddress, clients.streetaddress, " ++ "clients.city, clients.stateprov, clients.postal, " ++ "clients.country, clients.bizphone, clients.extension, " ++ "clients.fax, clients.email, [clients].[company] " ++ "AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " ++ "& \", \" & [headoffices].[first],[headoffices].[company]) " ++ "AS headname, wom.details, " ++ "wom.STARTDATE, wom.STOPDATE, projects.name " ++ "AS PROJNAME, projects.notes AS PROJNOTES FROM " ++ "(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " ++ "\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " ++ "AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " ++ "AS PROBBRIEF, probs.id AS probnum, probs.wolink " ++ "AS wonum, \"Service: \" & users.first & \" \" & " ++ "users.last & \" - \" & IIf(labor.hours>0,labor.hours " ++ "& \" @ \" & Format(rates.rate,\"Currency\") & \" " ++ "(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " ++ "(\" & labor.nchours & \" no charge)\",\"\") " ++ "& IIf(labor.travhours>0,\", \" & labor.travhours & \" " ++ "travel @ \" & Format(travelrates.rate,\"Currency\") " ++ "& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " ++ "& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " ++ "AS linetotal,labor.details, labor.start AS STARTDATE, " ++ "labor.stop as STOPDATE FROM users INNER JOIN " ++ "(rates AS travelrates INNER JOIN (rates INNER JOIN " ++ "(labor INNER JOIN probs ON labor.link = probs.id) " ++ "ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " ++ "ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " ++ "UNION ALL (SELECT \"2\" AS ctype, " ++ "\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " ++ "probs.brief AS PROBBRIEF, probs.id AS probnum, " ++ " probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " ++ "& \" \" & parts.description " ++ "& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " ++ "& \" ea.(sn:\" & woparts.sn " ++ "& \")\",woparts.misc & \": \" & woparts.quantity " ++ "& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " ++ "& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " ++ "AS linetotal,\"\" AS details, #03/12/1968# " ++ "AS STARTDATE, #03/12/1968# AS STOPDATE FROM " ++ "(probs INNER JOIN woparts ON probs.id = woparts.link) " ++ "LEFT JOIN parts ON woparts.partnum = parts.id " ++ "WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " ++ " \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " ++ "AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " ++ "AS probnum, probs.wolink as wonum, \"Third party " ++ "service: \" AS item, subrepair.charge AS linettotal, " ++ "\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " ++ "AS STOPDATE FROM probs INNER JOIN subrepair " ++ "ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " ++ "AND ((subrepair.charge)<>0))))]. AS " ++ "wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " ++ "clients ON wo.client = clients.id) LEFT JOIN clients " ++ "AS headoffices ON clients.headoffice = headoffices.id) " ++ "ON probs.id = wom.probnum) ON units.id = probs.unit) " ++ "LEFT JOIN unitmodels ON units.model = unitmodels.id) " ++ "LEFT JOIN nonclients ON unitmodels.manufacturer " ++ "= nonclients.id) LEFT JOIN projects ON " ++ "wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=1));", q2); + executeQuery(q); + + //------------------------------------------------ + + //STANDARD COMPLETED + q2 = "SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " ++ "& \"Unit: \" & [nonclients].[company_person] " ++ "& \" \" & [unitmodels].[description] " ++ "& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " ++ "AS probheader, \"~REGTO\" AS compname, wom.probnum, " ++ "wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " ++ "wom.PROBBRIEF, wom.item, wom.linetotal, " ++ "wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " ++ "AS wodate, wo.id AS wonumber, wo.invoice, " ++ "wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " ++ "clients.billheadoffice, clients.first, clients.last, " ++ "clients.mailaddress, clients.streetaddress, " ++ "clients.city, clients.stateprov, clients.postal, " ++ "clients.country, clients.bizphone, clients.extension, " ++ "clients.fax, clients.email, [clients].[company] " ++ "AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " ++ "& \", \" & [headoffices].[first],[headoffices].[company]) " ++ "AS headname, wom.details, " ++ "wom.STARTDATE, wom.STOPDATE, projects.name " ++ "AS PROJNAME, projects.notes AS PROJNOTES FROM " ++ "(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " ++ "\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " ++ "AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " ++ "AS PROBBRIEF, probs.id AS probnum, probs.wolink " ++ "AS wonum, \"Service: \" & users.first & \" \" & " ++ "users.last & \" - \" & IIf(labor.hours>0,labor.hours " ++ "& \" @ \" & Format(rates.rate,\"Currency\") & \" " ++ "(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " ++ "(\" & labor.nchours & \" no charge)\",\"\") " ++ "& IIf(labor.travhours>0,\", \" & labor.travhours & \" " ++ "travel @ \" & Format(travelrates.rate,\"Currency\") " ++ "& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " ++ "& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " ++ "AS linetotal,labor.details, labor.start AS STARTDATE, " ++ "labor.stop as STOPDATE FROM users INNER JOIN " ++ "(rates AS travelrates INNER JOIN (rates INNER JOIN " ++ "(labor INNER JOIN probs ON labor.link = probs.id) " ++ "ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " ++ "ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " ++ "UNION ALL (SELECT \"2\" AS ctype, " ++ "\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " ++ "probs.brief AS PROBBRIEF, probs.id AS probnum, " ++ " probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " ++ "& \" \" & parts.description " ++ "& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " ++ "& \" ea.(sn:\" & woparts.sn " ++ "& \")\",woparts.misc & \": \" & woparts.quantity " ++ "& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " ++ "& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " ++ "AS linetotal,\"\" AS details, #03/12/1968# " ++ "AS STARTDATE, #03/12/1968# AS STOPDATE FROM " ++ "(probs INNER JOIN woparts ON probs.id = woparts.link) " ++ "LEFT JOIN parts ON woparts.partnum = parts.id " ++ "WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " ++ " \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " ++ "AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " ++ "AS probnum, probs.wolink as wonum, \"Third party " ++ "service: \" AS item, subrepair.charge AS linettotal, " ++ "\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " ++ "AS STOPDATE FROM probs INNER JOIN subrepair " ++ "ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " ++ "AND ((subrepair.charge)<>0))))]. AS " ++ "wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " ++ "clients ON wo.client = clients.id) LEFT JOIN clients " ++ "AS headoffices ON clients.headoffice = headoffices.id) " ++ "ON probs.id = wom.probnum) ON units.id = probs.unit) " ++ "LEFT JOIN unitmodels ON units.model = unitmodels.id) " ++ "LEFT JOIN nonclients ON unitmodels.manufacturer " ++ "= nonclients.id) LEFT JOIN projects ON " ++ "wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=19));", q2); + executeQuery(q); + //------------------------------------------------ + + //WORKORDERS BRIEF + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " + + "FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(woparts.misc= \"\",parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " + + "LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " + + "ORDER BY wo.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=32));", q2); + executeQuery(q); + + //WORKORDERS DETAILED + + + q2 = "SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " + + "FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " + + " UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc), parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " + + " LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " + + "UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " + + "WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " + + "ORDER BY wo.id;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=31));", q2); + executeQuery(q); + + + //=-=-=-=- PM by UNIT bug fix + q2 = "SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person " ++ "AS MAKE, unitmodels.model, units.sn, " ++ "unitmodels.description AS UNITDESC, units.id1, " ++ "units.id2, units.id3, clients.company, nonclients.phone, " ++ "pmhead.description, pmhead.notes, Min(pmitems.schedate) " ++ "AS nextsrvdate, Min(pmitems.schedmeter) " ++ "AS nextsrvmeter, units.lastmeter, pmhead.woconvert, " ++ "pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, " ++ "pmhead.rptdays, units.purchasedate, pmhead.ageyears, " ++ "pmhead.agemonths, users.initials, users.first, " ++ "users.last, pmhead.isclient FROM pmitems " ++ "RIGHT JOIN (((pmhead LEFT JOIN ((units LEFT JOIN " ++ "unitmodels ON units.model = unitmodels.id) LEFT JOIN " ++ "nonclients ON unitmodels.manufacturer = nonclients.id) " ++ "ON pmhead.link = units.id) LEFT JOIN clients " ++ "ON units.client = clients.id) LEFT JOIN users " ++ "ON pmhead.tech = users.id) ON pmitems.pmschedlink " ++ "= pmhead.id GROUP BY ~CRITERIA , pmhead.id, nonclients.company_person, " ++ "unitmodels.model, units.sn, unitmodels.description, " ++ "units.id1, units.id2, units.id3, " ++ "clients.company, nonclients.phone, pmhead.description, " ++ "pmhead.notes, units.lastmeter, pmhead.woconvert, " ++ "pmhead.repeatevery, pmhead.rptweeks, pmhead.rptdays, " ++ "units.purchasedate, pmhead.ageyears, " ++ "pmhead.agemonths, users.initials, users.first, users.last, " ++ "pmhead.isclient, units.client, units.id, " ++ "units.model HAVING (((pmhead.isclient)=False) AND " ++ "((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " ++ "ORDER BY nonclients.company_person, " ++ "unitmodels.model, units.sn, clients.company;"; + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=34));", q2); + executeQuery(q); + //------------------------------------------------ + + //--------------------------------------- + //P.M. by client bug fix + + q2 = "SELECT ~CRITERIA AS CRITERIA, [clients].[company], " ++ "[pmhead].[description], [pmhead].[notes], Min([pmitems].[schedate]) " ++ "AS nextsrvdate, [pmhead].[link] " ++ "AS CLIENTID, [pmhead].[woconvert], [pmhead].[repeatevery] " ++ "AS rptmonths_count, [pmhead].[rptweeks], [pmhead].[rptdays], " ++ "[pmhead].[ageyears], [pmhead].[agemonths], " ++ "[users].[initials], [users].[first] AS " ++ "TECH_FIRST, [users].[last] AS TECH_LAST FROM pmitems " ++ "RIGHT JOIN (clients RIGHT JOIN (pmhead LEFT JOIN " ++ "users ON [pmhead].[tech]=[users].[id]) ON [clients].[id]=[pmhead].[link]) " ++ "ON [pmitems].[pmschedlink]=[pmhead].[id] " ++ "GROUP BY ~CRITERIA, [clients].[company], " ++ "[pmhead].[description], [pmhead].[notes], " ++ "[pmhead].[link], [pmhead].[woconvert], [pmhead].[repeatevery], " ++ "[pmhead].[rptweeks], [pmhead].[rptdays], " ++ "[pmhead].[ageyears], [pmhead].[agemonths], [users].[initials], " ++ "[users].[first], [users].[last], " ++ "[pmhead].[isclient] HAVING (((Min(pmitems.schedate)) " ++ "Between #~STRT# And #~END_#) AND ((pmhead.link)~CUST) " ++ "AND ((pmhead.isclient)=True)) ORDER BY [clients].[company]; "; + + + q = string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + + "WHERE (((rptsmaster.id)=35));", q2); + executeQuery(q); + //------------------------------------------------ + + + //2023-07-14 skipping this hopefully unneeded block + + // CString strID,strName,strRights,strHash; + // long lData; + // GZK k; + + + // //Add new ARAS REQUEST right: + // //loop through all the group records + // rs->Query("SELECT groups.* FROM groups;"); + // do{ + // rs->FetchField("id",&lData); + // rs->FetchField("a",&strName); + // rs->FetchField("b",&strRights); + + // //decrypt the original rights string + // k.GZDecrypt(&strRights,false); + // strRights=strRights+"1";//add on the extra right for schedule view + + // //re-'crypt' + // k.GZEncrypt(&strRights,false); + + // //HASH + // strHash.Format("%u%s%s",lData,strName,strRights); + // k.GZHash(&strHash); + + // //save the rights + // rs->UpdateField("b",&strRights); + + // //save the hash + // rs->UpdateField("c",&strHash); + + // //save the record + // if(!rs->SaveRecord()) + // AfxMessageBox("Error trying to save rights record"); + // }while(rs->MoveForward()); + + + // //Remove any bogus sub-repair records that were created by ARAS with a "where" set to zero + // //change has already been made in ARAS 2.9.3 that will prevent them from being created in future + // executeQuery("DELETE subrepair.*, subrepair.where FROM subrepair WHERE (((subrepair.where)=0));"); + + // //remove any blank customer service requests + // executeQuery("DELETE client_requests.workorderid, client_requests.request, " + //"client_requests.probdetails, client_requests.refnum, " + //"client_requests.requestor_id, client_requests.* " + //"FROM client_requests WHERE (((client_requests.workorderid)=0) " + //"AND ((client_requests.request) " + //"Is Null) AND ((client_requests.probdetails) Is " + //"Null) AND ((client_requests.refnum) Is Null)); "); + + + // //Add the UNIT id to the ARAS requests table + // //Add aras_client field to rptsmaster + // executeQuery("ALTER TABLE client_requests ADD COLUMN unitid INTEGER;"); + // executeQuery("ALTER TABLE client_requests ALTER unitid SET DEFAULT '0';"); + // executeQuery("UPDATE client_requests SET client_requests.unitid = 0;"); + + + // //add a field to defaults to control what client sees in ARAS workorder screen + // executeQuery("ALTER TABLE defaults ADD COLUMN limit_client_aras YESNO;"); + // executeQuery("UPDATE defaults SET defaults.limit_client_aras = False;"); + + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"170\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.4.0\";"); + nVersion = 170; + //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only + break; + + } + case 170: + { //v1.9.4.4 changes + + //Fix client address book report criteria fields + executeQuery("UPDATE rptsmaster SET rptsmaster.criteriafields = 129 " + + "WHERE (((rptsmaster.id)=41));"); + + //Fix technician billing summary report criteria fields + executeQuery("UPDATE rptsmaster SET rptsmaster.criteriafields = 911 " + + "WHERE (((rptsmaster.id)=17));"); + + executeQuery("UPDATE wo SET wo.modified = [wo].[created], wo.modifier " + + "= [wo].[creator] WHERE (((wo.modified) Is Null)); "); + /* + q2="SELECT clients.*, HEADS.* FROM clients LEFT JOIN clients " + "AS HEADS ON clients.headoffice = HEADS.id WHERE " + "(((clients.id)~CUST)) ORDER BY clients.company; "; + + q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " + "WHERE (((rptsmaster.id)=41));",q2); + executeQuery(q); + + + //Set STATUS column in statusviews to -1 if it was previously 1 as -1 + //now means any status where 1 used to mean any status + q=string.Format("UPDATE statusviews SET statusviews.status = -1 WHERE (((statusviews.status)=1));"); + executeQuery(q); + + + //10/26/2002 + //set assigntech to correct value on old quick work orders + q="UPDATE labor RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) " + "ON labor.link = probs.id SET wo.assigntech = [labor].[tech] " + "WHERE (((wo.quick)=True) AND ((wo.assigntech)=-1));"; + executeQuery(q); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"167\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=167; - - break; - - } - - - - case 167: - { - - //Addition of client address book Report - executeQuery("INSERT INTO rptsmaster ( virtualname, filename, recordset, x, criteriafields, id ) " - +"SELECT \"Client address book\", \"clntadd.rpt\", \"mgr\", True, 32767, 41;"); - - q2="SELECT clients.*, HEADS.* FROM clients LEFT JOIN clients " - +"AS HEADS ON clients.headoffice = HEADS.id WHERE " - +"(((clients.id)~CUST)) ORDER BY clients.company; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=41));",q2); - executeQuery(q); - - - //Set STATUS column in statusviews to -1 if it was previously 1 as -1 - //now means any status where 1 used to mean any status - q=string.Format("UPDATE statusviews SET statusviews.status = -1 WHERE (((statusviews.status)=1));"); - executeQuery(q); - - - //10/26/2002 - //set assigntech to correct value on old quick work orders - q="UPDATE labor RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) " - +"ON labor.link = probs.id SET wo.assigntech = [labor].[tech] " - +"WHERE (((wo.quick)=True) AND ((wo.assigntech)=-1));"; - executeQuery(q); - - //Add aras_client field to rptsmaster - executeQuery("ALTER TABLE rptsmaster ADD COLUMN client_aras YESNO;"); - executeQuery("ALTER TABLE rptsmaster ALTER client_aras SET DEFAULT '-1';"); - executeQuery("UPDATE rptsmaster SET rptsmaster.client_aras = True;"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"168\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.0.0\";"); - nVersion=168; - //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only - break; - - } - - case 168: - { - - //Changed ....... - executeQuery("ALTER TABLE probs ALTER COLUMN meter INTEGER;"); - - - //Update report 31 to fix bug in query causing part descriptions to be blank - q2="SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " - +"FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" hrs. @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" hrs. no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" hrs. travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " - +" UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc), parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " - +" LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " - +"ORDER BY wo.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=31));",q2); - executeQuery(q); - - - //2023-07-14 going to skip this stuff hopefully don't need it -// //************* change any client aras logins that match ayanova user logins ********** -// CString strReportDupes,str; -// CString sLoginARAS,sLoginARASHash,sCompany,sNewLogin; -// GZK k; -// long l=0; -// long lARASID=0; -// //check for and zap any aras client login names that match AyaNova login names -// //loop through all aras login names -// //for each that hashes out to same as ayanova login name, change login name to prepend unique string -// q="SELECT clients.company AS COMP1, clients_aras.loginid, " -// "clients_aras.id AS ARASID FROM clients_aras LEFT " -// "JOIN clients ON clients_aras.clientlink = clients.id " -// "ORDER BY clients.company, clients_aras.loginid;"; -// rs2->QueryReadOnly(q); -// if(!rs2->IsEmpty()) -// { -// do{ - -// rs2->FetchField("loginid",&sLoginARAS); -// sLoginARASHash=sLoginARAS; -// k.GZHash(&sLoginARASHash); -// q=string.Format("SELECT users.login FROM users WHERE (((users.login)=\"%s\"));",sLoginARASHash); -// rs3->QueryReadOnly(q); -// if(!rs3->IsEmpty())//This ARAS client login matches AyaNova login -// { - -// l++; -// sNewLogin.Format("Temporary%u",l); -// rs2->FetchField("COMP1",&sCompany); -// str.Format("Client %s ARAS login account %s changed to %s\r\n",sCompany,sLoginARAS,sNewLogin); -// strReportDupes+=str; -// rs2->FetchField("ARASID",&lARASID); -// q=string.Format("UPDATE clients_aras SET clients_aras.loginid = \"%s\" " -// "WHERE (((clients_aras.id) = %u ));",sNewLogin,lARASID); -// executeQuery(q); - - - -// } - -// }while(rs2->MoveForward()); - - -// } - - - - -// //Check for duplicate ARAS client login names - -// q="SELECT clients_aras.loginid, clients_aras.id AS ARASID, clients.company AS COMP1 " -//"FROM clients_aras LEFT JOIN clients ON " -//"clients_aras.clientlink = clients.id WHERE (((clients_aras.loginid) " -//"In (SELECT [loginid] FROM [clients_aras] " -//"As Tmp GROUP BY [loginid] HAVING Count(*)>1 " -//"))) ORDER BY clients_aras.loginid;"; -// rs2->QueryReadOnly(q); -// if(!rs2->IsEmpty())//there are dupes -// { -// do{ -// l++; -// sNewLogin.Format("Temporary%u",l); -// rs2->FetchField("COMP1",&sCompany); -// str.Format("Client %s ARAS login account %s changed to %s\r\n",sCompany,sLoginARAS,sNewLogin); -// strReportDupes+=str; -// rs2->FetchField("ARASID",&lARASID); -// q=string.Format("UPDATE clients_aras SET clients_aras.loginid = \"%s\" " -// "WHERE (((clients_aras.id) = %u ));",sNewLogin,lARASID); -// executeQuery(q); - - -// }while(rs2->MoveForward()); - - -// } - -// if(!strReportDupes.IsEmpty()) -// { -// strReportDupes= -// "******** READ THIS CAREFULLY ********\r\n" -// "The following client(s) ARAS login ID's we're changed for security reasons.\r\n\r\n" - -// "You should save this information now and change them after the update has\r\n" -// "completed. (otherwise they will not be able to log in)\r\n\r\n" - -// "To save this information click on the copy all text.. button, open a word processor or\r\n" -// "Microsoft Notepad and paste. You can then save / print this list.\r\n" -// "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\r\n"+strReportDupes; -// m_pApp->ShowStuff(strReportDupes); -// strReportDupes.Empty(); - -// } - - - -//****************************************************************************** - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"169\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.3.0\";"); - nVersion=169; - //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only - break; - - } - case 169: - { - - //------------------------------------------------ - //REMOVE Hrs. FROM WORK ORDER REPORT QUERIES - //STANDARD BRIEF - q2="SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] " -+"& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS probheader, \"~REGTO\" AS compname, wom.probnum, " -+"wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " -+"wom.PROBBRIEF, wom.item, wom.linetotal, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " -+"AS wodate, wo.id AS wonumber, wo.invoice, " -+"wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " -+"clients.billheadoffice, clients.first, clients.last, " -+"clients.mailaddress, clients.streetaddress, " -+"clients.city, clients.stateprov, clients.postal, " -+"clients.country, clients.bizphone, clients.extension, " -+"clients.fax, clients.email, [clients].[company] " -+"AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " -+"& \", \" & [headoffices].[first],[headoffices].[company]) " -+"AS headname, wom.details, " -+"wom.STARTDATE, wom.STOPDATE, projects.name " -+"AS PROJNAME, projects.notes AS PROJNOTES FROM " -+"(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " -+"\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " -+"AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " -+"AS PROBBRIEF, probs.id AS probnum, probs.wolink " -+"AS wonum, \"Service: \" & users.first & \" \" & " -+"users.last & \" - \" & IIf(labor.hours>0,labor.hours " -+"& \" @ \" & Format(rates.rate,\"Currency\") & \" " -+"(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " -+"(\" & labor.nchours & \" no charge)\",\"\") " -+"& IIf(labor.travhours>0,\", \" & labor.travhours & \" " -+"travel @ \" & Format(travelrates.rate,\"Currency\") " -+"& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " -+"& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " -+"AS linetotal,labor.details, labor.start AS STARTDATE, " -+"labor.stop as STOPDATE FROM users INNER JOIN " -+"(rates AS travelrates INNER JOIN (rates INNER JOIN " -+"(labor INNER JOIN probs ON labor.link = probs.id) " -+"ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " -+"ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " -+"UNION ALL (SELECT \"2\" AS ctype, " -+"\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " -+"probs.brief AS PROBBRIEF, probs.id AS probnum, " -+" probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " -+"& \" \" & parts.description " -+"& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " -+"& \" ea.(sn:\" & woparts.sn " -+"& \")\",woparts.misc & \": \" & woparts.quantity " -+"& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " -+"& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " -+"AS linetotal,\"\" AS details, #03/12/1968# " -+"AS STARTDATE, #03/12/1968# AS STOPDATE FROM " -+"(probs INNER JOIN woparts ON probs.id = woparts.link) " -+"LEFT JOIN parts ON woparts.partnum = parts.id " -+"WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " -+" \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " -+"AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " -+"AS probnum, probs.wolink as wonum, \"Third party " -+"service: \" AS item, subrepair.charge AS linettotal, " -+"\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " -+"AS STOPDATE FROM probs INNER JOIN subrepair " -+"ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " -+"AND ((subrepair.charge)<>0))))]. AS " -+"wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " -+"clients ON wo.client = clients.id) LEFT JOIN clients " -+"AS headoffices ON clients.headoffice = headoffices.id) " -+"ON probs.id = wom.probnum) ON units.id = probs.unit) " -+"LEFT JOIN unitmodels ON units.model = unitmodels.id) " -+"LEFT JOIN nonclients ON unitmodels.manufacturer " -+"= nonclients.id) LEFT JOIN projects ON " -+"wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=1));",q2); - executeQuery(q); - - //------------------------------------------------ - - //STANDARD COMPLETED - q2="SELECT \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) " -+"& \"Unit: \" & [nonclients].[company_person] " -+"& \" \" & [unitmodels].[description] " -+"& \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") " -+"AS probheader, \"~REGTO\" AS compname, wom.probnum, " -+"wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, " -+"wom.PROBBRIEF, wom.item, wom.linetotal, " -+"wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created " -+"AS wodate, wo.id AS wonumber, wo.invoice, " -+"wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, " -+"clients.billheadoffice, clients.first, clients.last, " -+"clients.mailaddress, clients.streetaddress, " -+"clients.city, clients.stateprov, clients.postal, " -+"clients.country, clients.bizphone, clients.extension, " -+"clients.fax, clients.email, [clients].[company] " -+"AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] " -+"& \", \" & [headoffices].[first],[headoffices].[company]) " -+"AS headname, wom.details, " -+"wom.STARTDATE, wom.STOPDATE, projects.name " -+"AS PROJNAME, projects.notes AS PROJNOTES FROM " -+"(((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT " -+"\"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum " -+"AS TRAVPN, probs.notes AS PROBNOTES, probs.brief " -+"AS PROBBRIEF, probs.id AS probnum, probs.wolink " -+"AS wonum, \"Service: \" & users.first & \" \" & " -+"users.last & \" - \" & IIf(labor.hours>0,labor.hours " -+"& \" @ \" & Format(rates.rate,\"Currency\") & \" " -+"(pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" " -+"(\" & labor.nchours & \" no charge)\",\"\") " -+"& IIf(labor.travhours>0,\", \" & labor.travhours & \" " -+"travel @ \" & Format(travelrates.rate,\"Currency\") " -+"& IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" " -+"& travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) " -+"AS linetotal,labor.details, labor.start AS STARTDATE, " -+"labor.stop as STOPDATE FROM users INNER JOIN " -+"(rates AS travelrates INNER JOIN (rates INNER JOIN " -+"(labor INNER JOIN probs ON labor.link = probs.id) " -+"ON rates.id = labor.rate) ON travelrates.id = labor.travrate) " -+"ON users.id = labor.tech WHERE (((probs.wolink)=~WOID)) " -+"UNION ALL (SELECT \"2\" AS ctype, " -+"\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, " -+"probs.brief AS PROBBRIEF, probs.id AS probnum, " -+" probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc),parts.partnumber " -+"& \" \" & parts.description " -+"& \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") " -+"& \" ea.(sn:\" & woparts.sn " -+"& \")\",woparts.misc & \": \" & woparts.quantity " -+"& \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" " -+"& woparts.sn & \")\") AS item, woparts.quantity*woparts.price " -+"AS linetotal,\"\" AS details, #03/12/1968# " -+"AS STARTDATE, #03/12/1968# AS STOPDATE FROM " -+"(probs INNER JOIN woparts ON probs.id = woparts.link) " -+"LEFT JOIN parts ON woparts.partnum = parts.id " -+"WHERE (((probs.wolink)=~WOID)) UNION ALL (SELECT " -+" \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes " -+"AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id " -+"AS probnum, probs.wolink as wonum, \"Third party " -+"service: \" AS item, subrepair.charge AS linettotal, " -+"\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# " -+"AS STOPDATE FROM probs INNER JOIN subrepair " -+"ON probs.id = subrepair.link WHERE (((probs.wolink)=~WOID) " -+"AND ((subrepair.charge)<>0))))]. AS " -+"wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN " -+"clients ON wo.client = clients.id) LEFT JOIN clients " -+"AS headoffices ON clients.headoffice = headoffices.id) " -+"ON probs.id = wom.probnum) ON units.id = probs.unit) " -+"LEFT JOIN unitmodels ON units.model = unitmodels.id) " -+"LEFT JOIN nonclients ON unitmodels.manufacturer " -+"= nonclients.id) LEFT JOIN projects ON " -+"wo.project = projects.id ORDER BY wom.STARTDATE DESC; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=19));",q2); - executeQuery(q); - //------------------------------------------------ - - //WORKORDERS BRIEF - q2="SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " - +"FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(woparts.misc= \"\",parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " - +"LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " - +"ORDER BY wo.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=32));",q2); - executeQuery(q); - - //WORKORDERS DETAILED - - - q2="SELECT ~CRITERIA AS CRITERIA, wo.id AS wonumber, \"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, \"test\" AS compname, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.bizphone, clients.extension, clients.fax, clients.email, clients.company AS clientname, wom.details, wom.START, wom.STOP,wom.REGHOURS, wom.TRAVHOURS, wom.NCHOURS, projects.name AS PROJNAME, projects.notes AS PROJNOTES, wo.client, wo.project, wo.type, wotypes.category AS CATEGORY " - +"FROM ((((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours & \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal, labor.details , labor.start AS START, labor.stop AS STOP, labor.hours AS REGHOURS, labor.travhours AS TRAVHOURS, labor.nchours as NCHOURS FROM users INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE (((probs.wolink)<>0)) " - +" UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & IIf(IsNull(woparts.misc), parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM (probs INNER JOIN woparts ON probs.id = woparts.link) " - +" LEFT JOIN parts ON woparts.partnum = parts.id WHERE (((probs.wolink)<>0)) " - +"UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS START, #03/12/1968# AS STOP, 0 AS REGHOURS, 0 AS TRAVHOURS, 0 as NCHOURS FROM probs INNER JOIN subrepair ON probs.id = subrepair.link WHERE (((probs.wolink)<>0) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ) LEFT JOIN wotypes ON wo.type = wotypes.id " - +"WHERE (((wo.created) Between #~STRT# And #~END_#) AND ((wo.client)~CUST) AND ((wo.project)~PROJ) AND ((wo.type)~CAT_)) " - +"ORDER BY wo.id;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=31));",q2); - executeQuery(q); - - - //=-=-=-=- PM by UNIT bug fix - q2="SELECT ~CRITERIA AS CRITERIA, pmhead.id, nonclients.company_person " -+"AS MAKE, unitmodels.model, units.sn, " -+"unitmodels.description AS UNITDESC, units.id1, " -+"units.id2, units.id3, clients.company, nonclients.phone, " -+"pmhead.description, pmhead.notes, Min(pmitems.schedate) " -+"AS nextsrvdate, Min(pmitems.schedmeter) " -+"AS nextsrvmeter, units.lastmeter, pmhead.woconvert, " -+"pmhead.repeatevery AS rptmonths_count, pmhead.rptweeks, " -+"pmhead.rptdays, units.purchasedate, pmhead.ageyears, " -+"pmhead.agemonths, users.initials, users.first, " -+"users.last, pmhead.isclient FROM pmitems " -+"RIGHT JOIN (((pmhead LEFT JOIN ((units LEFT JOIN " -+"unitmodels ON units.model = unitmodels.id) LEFT JOIN " -+"nonclients ON unitmodels.manufacturer = nonclients.id) " -+"ON pmhead.link = units.id) LEFT JOIN clients " -+"ON units.client = clients.id) LEFT JOIN users " -+"ON pmhead.tech = users.id) ON pmitems.pmschedlink " -+"= pmhead.id GROUP BY ~CRITERIA , pmhead.id, nonclients.company_person, " -+"unitmodels.model, units.sn, unitmodels.description, " -+"units.id1, units.id2, units.id3, " -+"clients.company, nonclients.phone, pmhead.description, " -+"pmhead.notes, units.lastmeter, pmhead.woconvert, " -+"pmhead.repeatevery, pmhead.rptweeks, pmhead.rptdays, " -+"units.purchasedate, pmhead.ageyears, " -+"pmhead.agemonths, users.initials, users.first, users.last, " -+"pmhead.isclient, units.client, units.id, " -+"units.model HAVING (((pmhead.isclient)=False) AND " -+"((units.client)~CUST) AND ((units.id)~UNIT) AND ((units.model)~MODL)) " -+"ORDER BY nonclients.company_person, " -+"unitmodels.model, units.sn, clients.company;"; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=34));",q2); - executeQuery(q); - //------------------------------------------------ - - //--------------------------------------- - //P.M. by client bug fix - - q2="SELECT ~CRITERIA AS CRITERIA, [clients].[company], " -+"[pmhead].[description], [pmhead].[notes], Min([pmitems].[schedate]) " -+"AS nextsrvdate, [pmhead].[link] " -+"AS CLIENTID, [pmhead].[woconvert], [pmhead].[repeatevery] " -+"AS rptmonths_count, [pmhead].[rptweeks], [pmhead].[rptdays], " -+"[pmhead].[ageyears], [pmhead].[agemonths], " -+"[users].[initials], [users].[first] AS " -+"TECH_FIRST, [users].[last] AS TECH_LAST FROM pmitems " -+"RIGHT JOIN (clients RIGHT JOIN (pmhead LEFT JOIN " -+"users ON [pmhead].[tech]=[users].[id]) ON [clients].[id]=[pmhead].[link]) " -+"ON [pmitems].[pmschedlink]=[pmhead].[id] " -+"GROUP BY ~CRITERIA, [clients].[company], " -+"[pmhead].[description], [pmhead].[notes], " -+"[pmhead].[link], [pmhead].[woconvert], [pmhead].[repeatevery], " -+"[pmhead].[rptweeks], [pmhead].[rptdays], " -+"[pmhead].[ageyears], [pmhead].[agemonths], [users].[initials], " -+"[users].[first], [users].[last], " -+"[pmhead].[isclient] HAVING (((Min(pmitems.schedate)) " -+"Between #~STRT# And #~END_#) AND ((pmhead.link)~CUST) " -+"AND ((pmhead.isclient)=True)) ORDER BY [clients].[company]; "; - - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - +"WHERE (((rptsmaster.id)=35));",q2); - executeQuery(q); - //------------------------------------------------ - - - //2023-07-14 skipping this hopefully unneeded block - -// CString strID,strName,strRights,strHash; -// long lData; -// GZK k; - - -// //Add new ARAS REQUEST right: -// //loop through all the group records -// rs->Query("SELECT groups.* FROM groups;"); -// do{ -// rs->FetchField("id",&lData); -// rs->FetchField("a",&strName); -// rs->FetchField("b",&strRights); - -// //decrypt the original rights string -// k.GZDecrypt(&strRights,false); -// strRights=strRights+"1";//add on the extra right for schedule view - -// //re-'crypt' -// k.GZEncrypt(&strRights,false); - -// //HASH -// strHash.Format("%u%s%s",lData,strName,strRights); -// k.GZHash(&strHash); - -// //save the rights -// rs->UpdateField("b",&strRights); - -// //save the hash -// rs->UpdateField("c",&strHash); - -// //save the record -// if(!rs->SaveRecord()) -// AfxMessageBox("Error trying to save rights record"); -// }while(rs->MoveForward()); - - -// //Remove any bogus sub-repair records that were created by ARAS with a "where" set to zero -// //change has already been made in ARAS 2.9.3 that will prevent them from being created in future -// executeQuery("DELETE subrepair.*, subrepair.where FROM subrepair WHERE (((subrepair.where)=0));"); - -// //remove any blank customer service requests -// executeQuery("DELETE client_requests.workorderid, client_requests.request, " -//"client_requests.probdetails, client_requests.refnum, " -//"client_requests.requestor_id, client_requests.* " -//"FROM client_requests WHERE (((client_requests.workorderid)=0) " -//"AND ((client_requests.request) " -//"Is Null) AND ((client_requests.probdetails) Is " -//"Null) AND ((client_requests.refnum) Is Null)); "); - - -// //Add the UNIT id to the ARAS requests table -// //Add aras_client field to rptsmaster -// executeQuery("ALTER TABLE client_requests ADD COLUMN unitid INTEGER;"); -// executeQuery("ALTER TABLE client_requests ALTER unitid SET DEFAULT '0';"); -// executeQuery("UPDATE client_requests SET client_requests.unitid = 0;"); - - -// //add a field to defaults to control what client sees in ARAS workorder screen -// executeQuery("ALTER TABLE defaults ADD COLUMN limit_client_aras YESNO;"); -// executeQuery("UPDATE defaults SET defaults.limit_client_aras = False;"); - - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"170\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.4.0\";"); - nVersion=170; - //buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only - break; - - } - case 170: - { //v1.9.4.4 changes - - //Fix client address book report criteria fields - executeQuery("UPDATE rptsmaster SET rptsmaster.criteriafields = 129 " - +"WHERE (((rptsmaster.id)=41));"); - - //Fix technician billing summary report criteria fields - executeQuery("UPDATE rptsmaster SET rptsmaster.criteriafields = 911 " - +"WHERE (((rptsmaster.id)=17));"); - - executeQuery("UPDATE wo SET wo.modified = [wo].[created], wo.modifier " - +"= [wo].[creator] WHERE (((wo.modified) Is Null)); "); -/* - q2="SELECT clients.*, HEADS.* FROM clients LEFT JOIN clients " - "AS HEADS ON clients.headoffice = HEADS.id WHERE " - "(((clients.id)~CUST)) ORDER BY clients.company; "; - - q=string.Format("UPDATE rptsmaster SET rptsmaster.query = '%s' " - "WHERE (((rptsmaster.id)=41));",q2); - executeQuery(q); - - - //Set STATUS column in statusviews to -1 if it was previously 1 as -1 - //now means any status where 1 used to mean any status - q=string.Format("UPDATE statusviews SET statusviews.status = -1 WHERE (((statusviews.status)=1));"); - executeQuery(q); - - - //10/26/2002 - //set assigntech to correct value on old quick work orders - q="UPDATE labor RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) " - "ON labor.link = probs.id SET wo.assigntech = [labor].[tech] " - "WHERE (((wo.quick)=True) AND ((wo.assigntech)=-1));"; - executeQuery(q); - - -*/ - - //fix the version number up - executeQuery("UPDATE defaults SET defaults.versioninfo = \"171\";"); - executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.4.0\";"); - nVersion=171; - buptodate=true;//<<==========CRITICAL!!!!!, should be at end of last case statement only - break; - - } - //<--------Insert new version before here -------------------- - - - default: - { - throw new Exception( - "Your database version was not recognized and can not be updated automatically\r\n" - +"Please email support@ayanova.com immediately with this version number: %i\r\n"+nVersion); - //AfxMessageBox(msg); - return; - } - break; - } - -}//while not buptodate -////rs->Close(); -//AfxMessageBox("You should close and re-start AyaNova now\r\n\r\n OR \r\n\r\n" -// "follow any instructions given during the update\r\n" -// "as directed before restarting"); -} + */ + + //fix the version number up + executeQuery("UPDATE defaults SET defaults.versioninfo = \"171\";"); + executeQuery("UPDATE defaults SET defaults.min_exe = \"1.9.4.0\";"); + nVersion = 171; + buptodate = true;//<<==========CRITICAL!!!!!, should be at end of last case statement only + break; + + } + //<--------Insert new version before here -------------------- + + + default: + { + throw new Exception( + "Your database version was not recognized and can not be updated automatically\r\n" + + "Please email support@ayanova.com immediately with this version number: %i\r\n" + nVersion); + //AfxMessageBox(msg); + return; + } + break; + } + + }//while not buptodate + ////rs->Close(); + //AfxMessageBox("You should close and re-start AyaNova now\r\n\r\n OR \r\n\r\n" + // "follow any instructions given during the update\r\n" + // "as directed before restarting"); + } }