Changeset 485
- Timestamp:
- 04/07/09 11:44:18 (3 years ago)
- Location:
- trunk/phpbms
- Files:
-
- 11 removed
- 88 modified
- 16 copied
-
ChangeLog (modified) (4 diffs)
-
common/javascript/fields.js (modified) (8 diffs)
-
common/stylesheet/mozilla/menu.css (modified) (1 diff)
-
common/stylesheet/mozilla/pages/base/snapshot.css (copied) (copied from branches/nathan/common/stylesheet/mozilla/pages/base/snapshot.css)
-
common/stylesheet/mozilla/pages/bms/incoming_cashflow.css (copied) (copied from branches/nathan/common/stylesheet/mozilla/pages/bms/incoming_cashflow.css)
-
common/stylesheet/mozilla/pages/info.css (modified) (1 diff)
-
common/stylesheet/mozilla/pages/login.css (modified) (1 diff)
-
common/stylesheet/mozilla/pages/requirements.css (modified) (1 diff)
-
common/stylesheet/mozilla/pages/snapshot.css (deleted)
-
defaultsettings.php (modified) (1 diff)
-
help/index.php (modified) (2 diffs)
-
include/common_functions.php (modified) (24 diffs)
-
include/db.php (modified) (15 diffs)
-
include/fields.php (modified) (1 diff)
-
include/imports.php (modified) (16 diffs)
-
include/jstransport.php (modified) (4 diffs)
-
include/login_include.php (modified) (1 diff)
-
include/session.php (modified) (9 diffs)
-
include/tables.php (modified) (1 diff)
-
index.php (modified) (3 diffs)
-
info.php (modified) (2 diffs)
-
install/createtables.sql (modified) (10 diffs)
-
install/fail.gif (copied) (copied from branches/nathan/install/fail.gif)
-
install/index.php (copied) (copied from branches/nathan/install/index.php)
-
install/install.css (modified) (1 diff)
-
install/install.js (modified) (1 diff)
-
install/install.php (deleted)
-
install/installajax.php (copied) (copied from branches/nathan/install/installajax.php)
-
install/installxml.php (deleted)
-
install/install_include.php (modified) (1 diff)
-
install/menu.sql (modified) (1 diff)
-
install/notes.sql (modified) (1 diff)
-
install/scheduler.sql (modified) (1 diff)
-
install/success.gif (copied) (copied from branches/nathan/install/success.gif)
-
install/tablecolumns.sql (modified) (1 diff)
-
install/tabledefs.sql (modified) (1 diff)
-
install/tablefindoptions.sql (modified) (1 diff)
-
install/tablegroupings.sql (modified) (1 diff)
-
install/tableoptions.sql (modified) (1 diff)
-
install/tablesearchablefields.sql (modified) (1 diff)
-
install/update.js (modified) (1 diff)
-
install/update.php (modified) (3 diffs)
-
install/updateajax.php (copied) (copied from branches/nathan/install/updateajax.php)
-
install/updatev0.98.sql (modified) (3 diffs)
-
install/updatexml.php (deleted)
-
install/update_include.php (modified) (1 diff)
-
install/version.php (deleted)
-
install/warning.gif (copied) (copied from branches/nathan/install/warning.gif)
-
modules/base/adminsettings.php (modified) (2 diffs)
-
modules/base/cron.php (modified) (19 diffs)
-
modules/base/general_import.php (modified) (10 diffs)
-
modules/base/include/adminsettings_include.php (modified) (9 diffs)
-
modules/base/include/files.php (modified) (3 diffs)
-
modules/base/include/menu.php (modified) (4 diffs)
-
modules/base/include/notes.php (modified) (36 diffs)
-
modules/base/include/relationships.php (modified) (1 diff)
-
modules/base/include/reports.php (modified) (2 diffs)
-
modules/base/include/roles.php (modified) (1 diff)
-
modules/base/include/scheduler.php (modified) (4 diffs)
-
modules/base/include/snapshot_include.php (modified) (6 diffs)
-
modules/base/include/tabledefs.php (modified) (4 diffs)
-
modules/base/include/users.php (modified) (5 diffs)
-
modules/base/include/usersearches.php (modified) (2 diffs)
-
modules/base/notes_addedit.php (modified) (22 diffs)
-
modules/base/scheduler_addedit.php (modified) (10 diffs)
-
modules/base/scheduler_delete_logs.php (copied) (copied from branches/nathan/modules/base/scheduler_delete_logs.php)
-
modules/base/scheduler_delete_tempimport.php (modified) (1 diff)
-
modules/base/snapshot.php (modified) (2 diffs)
-
modules/base/tabs_addedit.php (modified) (8 diffs)
-
modules/base/users_addedit.php (modified) (9 diffs)
-
modules/base/users_import.php (deleted)
-
modules/bms/clients_addedit.php (modified) (21 diffs)
-
modules/bms/clients_import.php (modified) (12 diffs)
-
modules/bms/include/addresses.php (modified) (6 diffs)
-
modules/bms/include/addresstorecord.php (modified) (14 diffs)
-
modules/bms/include/clients.php (modified) (27 diffs)
-
modules/bms/include/discounts.php (modified) (1 diff)
-
modules/bms/include/invoices.php (modified) (5 diffs)
-
modules/bms/include/invoicestatuses.php (modified) (2 diffs)
-
modules/bms/include/products.php (modified) (5 diffs)
-
modules/bms/include/receipts.php (modified) (29 diffs)
-
modules/bms/install/install.php (modified) (1 diff)
-
modules/bms/install/reports.sql (modified) (1 diff)
-
modules/bms/install/tablecolumns.sql (modified) (1 diff)
-
modules/bms/install/tabledefs.sql (modified) (2 diffs)
-
modules/bms/install/tablegroupings.sql (modified) (1 diff)
-
modules/bms/install/tableoptions.sql (modified) (1 diff)
-
modules/bms/install/tablesearchablefields.sql (modified) (1 diff)
-
modules/bms/install/update.php (modified) (9 diffs)
-
modules/bms/install/updatev0.9.sql (copied) (copied from branches/nathan/modules/bms/install/updatev0.9.sql)
-
modules/bms/install/updatev0.90.sql (deleted)
-
modules/bms/install/updatev0.98.sql (modified) (3 diffs)
-
modules/bms/install/version.php (deleted)
-
modules/bms/invoices_attachments.php (modified) (4 diffs)
-
modules/bms/invoices_notes.php (modified) (3 diffs)
-
modules/bms/javascript/aritem_aging.js (modified) (2 diffs)
-
modules/bms/javascript/incoming_cashflow.js (copied) (copied from branches/nathan/modules/bms/javascript/incoming_cashflow.js)
-
modules/bms/javascript/totalreports.js (modified) (4 diffs)
-
modules/bms/products_import.php (deleted)
-
modules/bms/report/incoming_cashflow.php (copied) (copied from branches/nathan/modules/bms/report/incoming_cashflow.php)
-
modules/bms/version.php (copied) (copied from branches/nathan/modules/bms/version.php)
-
modules/recurringinvoices/install/install.php (modified) (1 diff)
-
modules/recurringinvoices/install/update.php (modified) (1 diff)
-
modules/recurringinvoices/install/version.php (deleted)
-
modules/recurringinvoices/scheduler_recurr.php (modified) (20 diffs)
-
modules/recurringinvoices/version.php (copied) (copied from branches/nathan/modules/recurringinvoices/version.php)
-
modules/sample/install/install.php (modified) (1 diff)
-
modules/sample/install/update.php (modified) (1 diff)
-
modules/sample/install/version.php (deleted)
-
modules/sample/sampletable_addedit.php (modified) (9 diffs)
-
modules/sample/snapshot.php (modified) (1 diff)
-
modules/sample/version.php (copied) (copied from branches/nathan/modules/sample/version.php)
-
phpbmsversion.php (copied) (copied from branches/nathan/phpbmsversion.php)
-
requirements.php (modified) (2 diffs)
-
THANKS.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/ChangeLog
r392 r485 1 phpBMS v0.98 2 http://phpbms.org/browser/tags/phpbms-0.98 3 * Support for importing records directly from within phpBMS 4 * New install and update procedures 5 6 The complete list of closed tickets can be found here: http://phpbms.org/query?status=closed&milestone=0.98 7 1 8 phpBMS v0.96 9 http://phpbms.org/browser/tags/phpbms-0.96 2 10 * Support For Multiple Client Addresses 3 11 * Separate Bill To and Ship To Addresses on Sales Orders 4 * Automatic removal of old CC/Bank routing information on Invoices 12 * Automatic removal of old CC/Bank routing information on Invoices 5 13 6 14 The complete list of closed tickets can be found here: http://phpbms.org/query?status=closed&milestone=0.96 … … 51 59 phpBMS v0.7 52 60 http://phpbms.org/browser/tags/phpbms-0.7 53 61 54 62 * Support for multiple phone formats 55 63 * Support for multiple currency formats 56 64 * Support for multiple date/time formats 57 65 * New client order defaults 58 * New scheduler system 66 * New scheduler system 59 67 * New logging system 60 68 * Support for type JPG on logo … … 65 73 * Longer state fields 66 74 * Order status now modifiable 67 * Track order status history 75 * Track order status history 68 76 * Users can edit their information 69 77 * New user access level system … … 223 231 * Fixed issue with invoice line items not able to enter/fill correctly 224 232 * addressed global variable problem in multiple areas 225 * Removed parameter "response" from passed variables to UPS shipping lookup. 233 * Removed parameter "response" from passed variables to UPS shipping lookup. 226 234 * Including parameter breaks the CGI lookup (returned blank response) for UPS shipping lookup 227 235 * Included amount due on invoice report -
trunk/phpbms/common/javascript/fields.js
r285 r485 41 41 var thereturn=true; 42 42 var errorMessage=""; 43 43 44 44 //skip validation if cancel 45 45 if (theform["cancelclick"]){ … … 56 56 break; 57 57 } 58 } 59 58 } 59 60 60 //validate required fields first 61 61 for(i=0;i<requiredArray.length;i++){ … … 101 101 } 102 102 } 103 103 104 104 //next phone numbers 105 105 for(i=0;i<phoneArray.length;i++){ … … 133 133 } 134 134 return thereturn; 135 135 136 136 } 137 137 … … 209 209 function validateCurrency(theitem){ 210 210 theitem.value=numberToCurrency(currencyToNumber(theitem.value)); 211 211 212 212 //in case the field has an additional onchange code to be run 213 213 if (theitem.thechange) theitem.thechange(); … … 227 227 if (thenumber.charAt(i)!="%" && thenumber.charAt(i)!="+" && thenumber.charAt(i)!=",") markupnumber+=thenumber.charAt(i); 228 228 } 229 229 230 230 //get rid of trailing zeros and possibly "." 231 231 while(markupnumber.charAt(markupnumber.length-1)=="0" && markupnumber.indexOf(".")!=-1) markupnumber=markupnumber.substring(0,markupnumber.length-1); … … 238 238 239 239 function checkUnique(tabledefid,column,checkvalue,excludeid){ 240 240 241 241 var theurl=APP_PATH+"checkunique.php?tdid="+parseInt(tabledefid); 242 242 theurl=theurl+"&c="+encodeURIComponent(column); … … 246 246 247 247 loadXMLDoc(theurl,null,false); 248 248 249 249 response = req.responseXML.documentElement; 250 250 thevalue = response.getElementsByTagName('isunique')[0].firstChild.data; 251 251 252 252 if(thevalue==1) return true; else return false; 253 253 } -
trunk/phpbms/common/stylesheet/mozilla/menu.css
r442 r485 124 124 125 125 /* ------ Help Page ---- */ 126 #helpBox{height:420px; overflow:auto; background:white} 127 #helpBox h1{margin-top:20px;} 128 #helpClose{width:70px} 126 #helpBox{background:white} 127 #helpClose{ 128 padding-left: 15px; 129 padding-right: 15px; 130 } -
trunk/phpbms/common/stylesheet/mozilla/pages/info.css
r204 r485 1 1 /* $Rev$ | $LastChangedBy$ */ 2 2 /* $LastChangedDate$ */ 3 #container{width:740px; margin:10px auto} 3 #container{ 4 width:740px; margin:10px auto 5 } 6 4 7 #phpBMSLogo{ 5 float:right; 6 background:white url(../../../image/logo-large.png) 10px 10px no-repeat; 7 padding:77px 10px 10px 10px; 8 margin-right:20px; 9 width:250px; 10 text-align:right; 8 float: right; 9 background: white url("../../../image/logo-large.png") 10px 10px no-repeat; 10 padding: 77px 10px 10px 10px; 11 width: 250px; 12 text-align: right; 11 13 } 12 #companyInfo{margin-right:190px;} 13 #loginButton{width:100px;} 14 15 #companyInfo{ 16 margin-right:260px; 17 } 18 19 #loginButton{ 20 padding-right: 15px; 21 padding-left: 15px; 22 } -
trunk/phpbms/common/stylesheet/mozilla/pages/login.css
r285 r485 2 2 /* $LastChangedDate$ */ 3 3 4 .bodyline{display:block;padding:5px;width:300px; margin: 0 auto;} 4 .bodyline{ 5 display: block; 6 padding: 5px; 7 width: 22em; 8 margin: 0 auto; 9 } 10 11 label{ 12 line-height: 1.5em; 13 } 14 5 15 #loginbox{ 6 16 margin:100px auto 50px; 7 17 } 8 18 9 #loginbox h1{font-size:21px;font-weight:bold;background-position:6px 6px;padding-left:28px;color:#455372;} 19 #loginbox h1{ 20 font-size: 21px; 21 font-weight: bold; 22 background-position: 6px 6px; 23 padding-left: 28px; 24 color:#455372; 25 } 10 26 11 #moreinfoButtonP{text-align:left;padding-bottom:5px;} 27 #loginbox .box{ 28 margin:10px 8px 10px; 29 border-style: none; 30 background-color: white; 31 text-align: center; 32 } 12 33 13 #moreinfo{padding:0;} 14 #moreingo p{padding:2px;} 15 #moreinfo h2{margin:0;padding:5px;background:none;height:22px;} 16 #moreinfo h2 a{display:block;width:85px;height:22px;background:url(../../../image/logo.png);} 17 #moreinfo h3{text-align:left;padding:2px 5px 10px;margin:0;border:0;font-weight:normal;font-size:9px; border:0;} 34 #loginbox form{ 35 padding:10px 5px 0; 36 margin:0; 37 } 18 38 19 #buttonP{padding-right:18px;text-align:right;} 20 #buttonP button{padding-left:15px;padding-right:15px;} 21 22 #loginbox .box{ 23 margin:10px 8px 10px; 24 border-style:none; 25 background-color:white; 26 text-align:center; 39 #moreinfoButtonP{ 40 float: left; 41 text-align:left; 42 padding-top: 6px; 27 43 } 28 44 29 #loginbox form{padding:10px 5px 0;margin:0;} 45 #moreinfo{ 46 padding:0; 47 } 30 48 31 #username,#password{width:98%;} 32 #command{width:75px;} 49 #moreinfo p{ 50 padding:2px; 51 } 33 52 34 #failed{text-align:center;margin-top:5px;} 53 #moreinfo h2{ 54 margin: 0; 55 padding: 5px; 56 background: none; 57 height: 22px; 58 } 59 60 #moreinfo h2 a{ 61 display: block; 62 width: 85px; 63 height: 22px; 64 background: url("../../../image/logo.png"); 65 } 66 67 #moreinfo h3{ 68 text-align: left; 69 padding: 2px 5px 10px; 70 margin: 0; 71 border: 0; 72 font-weight: normal; 73 font-size: 9px; 74 border: 0; 75 } 76 77 #buttonP{ 78 text-align:right; 79 } 80 81 #buttonP button{ 82 padding-left: 15px; 83 padding-right: 15px; 84 font-size: 13px; 85 } 35 86 36 87 37 88 38 #demobox{ margin:0 auto;} 39 #demobox h2{margin-top:0;} 40 #demobox dt{font-weight:bold; padding:2px 10px;} 41 #demobox dd{padding-bottom:10px;} 89 #username, #password{ 90 width:99%; 91 font-size: 15px; 92 } 93 94 #command{ 95 width:75px; 96 } 97 98 #failed{ 99 text-align: center; 100 margin-top: 5px; 101 } 102 103 104 #demobox{ 105 margin: 0 auto; 106 } 107 108 #demobox h2{ 109 margin-top:0; 110 } 111 112 #demobox dt{ 113 font-weight:bold; 114 padding:2px 10px; 115 } 116 117 #demobox dd{ 118 padding-bottom: 10px; 119 } -
trunk/phpbms/common/stylesheet/mozilla/pages/requirements.css
r204 r485 1 1 /* $Rev$ | $LastChangedBy$ */ 2 2 /* $LastChangedDate$ */ 3 #container{width:740px; margin:10px auto;} 4 #cba{margin-top:45px;} 5 #logo{ 6 float:right;background:white url(../../../image/logo-large.png) 8px 12px no-repeat; 7 width:260px;height:67px; 3 #container{ 4 width:740px; 5 margin:10px auto; 8 6 } 9 #logo span{display:none;} 10 #browserTable{margin:20px;} 11 #loginButton{width:100px;} 7 8 #browserTable{ 9 width: 100% 10 } 11 12 #loginButton{ 13 padding-left: 10px; 14 padding-right: 10px; 15 } -
trunk/phpbms/defaultsettings.php
r180 r485 1 <?php /* ]1 <?php /* [ 2 2 mysql_server = "localhost" 3 3 mysql_database = "phpbms" 4 mysql_user = "bms"4 mysql_user = "bms" 5 5 mysql_userpass = "bmspass" 6 6 mysql_pconnect = "true" 7 end] */ ?>7 ] */ ?> -
trunk/phpbms/help/index.php
r308 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 require("../include/session.php"); 40 41 $querystatement="SELECT displayname,version from modules ORDER BY id"; 42 $queryresult=$db->query($querystatement); 39 require("../include/session.php"); 43 40 44 function displayVersions($db,$queryresult){ 45 if($queryresult){ 46 while($therecord=$db->fetchArray($queryresult)){ 47 if($therecord["displayname"]!="Base"){ 48 echo $therecord["displayname"].": "; 49 echo "v".$therecord["version"]."<br />"; 50 } else 51 echo "<span class=\"important\">phpBMS version: ".$therecord["version"]."</span><br />"; 52 } 53 } 54 } 55 41 class versions{ 42 43 var $db; 44 var $queryresult; 45 46 function versions($db){ 47 48 $this->db = $db; 49 50 }//end function init 51 52 function get(){ 53 54 $querystatement = " 55 SELECT 56 `name`, 57 `displayname`, 58 `version` 59 FROM 60 `modules` 61 ORDER BY 62 `id`"; 63 64 $this->queryresult = $this->db->query($querystatement); 65 66 }//end function get 67 68 69 function show(){ 70 71 if(!$this->queryresult) 72 return false; 73 74 while($therecord = $this->db->fetchArray($this->queryresult)){ 75 76 if($therecord["name"] != "base") 77 echo formatVariable($therecord["displayname"]).": v".$therecord["version"]."<br />"; 78 else 79 echo '<strong>v'.$therecord["version"].'</strong><br /><br />'; 80 81 }//endwhile 82 83 return true; 84 85 }//end function show 86 87 }//end class 88 89 $versions = new versions($db); 90 $versions->get(); 91 56 92 ?> 57 93 <div class="box" id="helpBox"> 58 94 59 <h1>About This Program</h3> 60 <blockquote> 61 <p align="right" style="float:right;"><img src="<?php echo APP_PATH?>common/image/logo.png" alt="phpBMS Logo" width="85" height="22"/></p> 62 63 <h3>phpBMS - Commercial Open Source Business Management Web Application</h3> 64 65 <p class="small"><?php displayVersions($db,$queryresult)?></p> 66 67 <p>Copyright ® 2004-2007 Kreotek, LLC. All Rights Reserved. phpBMS, and the phpBMS logo are trademarks of Kreotek, LLC.</p> 68 69 <p> 70 <strong>Kreotek, LLC</strong><br /> 71 610 Quantum<br /> 72 Rio Rancho, NM 87124<br /> 73 <a href="http://www.kreotek.com" target="_blank">http://www.kreotek.com</a><br /> 74 1-800-731-8026<br /> 75 </p> 76 </blockquote> 95 <p align="right" style="float:right; text-align:right; padding-left: 10px;" class="small"> 96 <img src="<?php echo APP_PATH?>common/image/logo.png" alt="phpBMS Logo" width="85" height="22"/><br /> 97 <?php $versions->show()?> 98 </p> 77 99 78 <h1>Keyboard Shortcuts</h1> 79 <blockquote> 80 <p> 81 phpBMS takes advanage of HTML's accesskey property to allow 82 you to use your keyboard to navigate pages. Some browsers and OS's 83 might have different modifier keys, so check your 84 browser documentation. In windows, when using Internet Explorer and Firefox < 2.0, hold 85 down the Alt key followed by the shortcut. When using Firefox > 2.0 in windows hold down Alt-Shift buttons 86 followed by the shortcut. In opera hold down Shift-Esc then 87 the shortut. On a Mac, use the ctrl key in both Firefox < 2.0 and Safari. 88 </p> 89 90 <h2>Search/List Screens</h2> 91 <div class="fauxP"> 92 <table border="0" cellpadding="0" cellspacing="0" class="querytable" width="300"> 93 <tr> 94 <th valign="bottom" class="queryheader" align="right" width="100%">Command</th> 95 <th valign="bottom" class="queryheader" align="center">Key</th> 96 </tr> 97 <tr class="qr1" > 98 <td align="right">New Record</td> 99 <td align="center">N</td> 100 </tr> 101 <tr class="qr2" > 102 <td align="right">Edit Record</td> 103 <td align="center">E</td> 104 </tr> 105 <tr class="qr1" > 106 <td align="right">Print</td> 107 <td align="center">P</td> 108 </tr> 109 <tr class="qr2" > 110 <td align="right">Delete (where applicable)</td> 111 <td align="center">D</td> 112 </tr> 113 <tr class="qr1" > 114 <td align="right">Select All</td> 115 <td align="center">A</td> 116 </tr> 117 <tr class="qr2" > 118 <td align="right">Select None</td> 119 <td align="center">X</td> 120 </tr> 121 <tr class="qr1" > 122 <td align="right">Keep Highlighted</td> 123 <td align="center">K</td> 124 </tr> 125 <tr class="qr2"> 126 <td align="right">Omit Highlighted</td> 127 <td align="center">O</td> 128 </tr> 129 <tr class="queryfooter"> 130 <td> </td> 131 <td> </td> 132 </tr> 133 </table> 134 </div> 135 136 <h2>Add/Edit Screens</h2> 137 <div class="fauxP"> 138 <table border="0" cellpadding="0" cellspacing="0" class="querytable" width="300"> 139 <tr> 140 <th valign="bottom" class="queryheader" align="right" width="100%">Command</th> 141 <th valign="bottom" class="queryheader" align="center">Key</th> 142 </tr> 143 <tr class="qr1"> 144 <td align="right">Save Record</td> 145 <td align="center">S</td> 146 </tr> 147 <tr class="qr2"> 148 <td align="right">Cancel</td> 149 <td align="center">X</td> 150 </tr> 151 <tr class="queryfooter"> 152 <td> </td> 153 <td> </td> 154 </tr> 155 </table> 156 </div> 157 </blockquote> 100 <h3 style="margin-top:0">phpBMS</h3> 101 <p><strong>Commercial Open Source Business Management Web Application</strong> 102 103 <p class="tiny">Copyright ® <?php echo date("Y") ?> Kreotek, LLC. All Rights Reserved. phpBMS, and the phpBMS logo are trademarks of Kreotek, LLC.</p> 158 104 159 105 160 <h1>Community Support at www.phpbms.org</h1> 161 162 <blockquote> 163 <ul> 164 <li><p><a href="http://www.phpbms.org" target="_blank">phpBMS project Web Site</a> - Main site for phpBMS development, documentation, and user support.</p></li> 165 <li><p><a href="http://phpbms.org/wiki/PhpbmsFaq" target="_blank">phpBMS FAQ</a> - Frequently asked questions </p></li> 166 <li><p><a href="http://www.phpbms.org/forum" target="_blank">phpBMS User Support forum</a> - A place for user and developer discussions.</p></li> 167 <li><p><a href="http://phpbms.org/wiki/PhpbmsGuide" target="_blank">phpBMS Wiki Documentation </a> - Wiki driven user documentation starting point.</p></li> 168 </ul> 169 </blockquote> 106 <p class="tiny" style="clear: right;float: right;"><a href="http://www.kreotek.com" target="_blank">http://www.kreotek.com</a></p> 170 107 171 <h1>Customization and Paid Support Options</h1>172 108 173 <blockquote> 174 <h2>Paid Technical, Development and Installation Support</h2> 175 176 <p> 177 Know that your mission critical business software is backed by 178 toll-free phone and e-mail support provided by the very people 179 who created the software. Choose a paid support contract 180 provided by Kreotek that suits your need and budget. 181 </p> 182 <p> 183 Visit <a href="http://www.kreotek.com" target="_blank">http://www.kreotek.com</a> or call 184 <strong>1-800-731-8026</strong> for more information. 185 </p> 186 <h2>Customizing phpBMS</h2> 187 <p> 188 No two businesses are run the exact same way. Every individual buiness has uniques needs. Don't conform 189 your business processes to your software, make your software work the way your business does. 190 </p> 191 <p> 192 Kreotek can provide for all of your company's customization needs. From custom reports, importing, adding fields, 193 or integrating with legacy systems, let the people who created the software tailor phpBMS to work within your 194 specific business processes. 195 </p> 196 <p> 197 Visit <a href="http://www.kreotek.com" target="_blank">http://www.kreotek.com</a> or call 198 <strong>1-800-731-8026</strong> for more information. 199 </p> 200 </blockquote> 109 <p class="small"> 110 <strong>Kreotek, LLC</strong><br /> 111 610 Quantum<br /> 112 Rio Rancho, NM 87124 USA 113 </p> 114 115 116 <p class="tiny"> 117 U.S. and Canada Toll Free<br /> 118 1-800-731-8026 119 </p> 120 121 <p class="tiny"> 122 Outside US and Canada<br /> 123 +1-505-994-6388 124 </p> 125 126 <h3>Community Support</h3> 127 <ul> 128 <li class="small"><a href="http://www.phpbms.org" target="_blank">phpBMS project Web Site</a></li> 129 <li class="small"><a href="http://www.phpbms.org/forum" target="_blank">phpBMS Community Support forum</a></li> 130 <li class="small"> <a href="http://phpbms.org/wiki/PhpbmsGuide" target="_blank">phpBMS Wiki Documentation </a></li> 131 </ul> 132 133 <h3>Paid Support and Customization</h3> 134 <p class="small"> 135 Receive paid support directly from the creators of phpBMS, Kreotek. 136 We have multiple tiers of support contracts available and can customize 137 phpBMS to suit your specific needs. 138 </p> 139 201 140 </div> 202 141 <p align="right"><button id="helpClose" type="button" class="Buttons" onclick="closeModal()"><span>close</span></button></p> -
trunk/phpbms/include/common_functions.php
r427 r485 40 40 // it should be instanced in session.php 41 41 class phpbms{ 42 42 43 43 var $db; 44 44 var $modules = array();//array of installed modules … … 48 48 var $bottomJS = array(); 49 49 var $onload = array(); 50 50 51 51 var $showFooter = true; 52 52 var $showMenu = true; 53 53 54 54 function phpbms($db){ 55 55 $this->db = $db; 56 56 57 57 $this->modules = $this->getModules(); 58 58 } … … 65 65 } 66 66 } 67 67 68 68 function showJsIncludes(){ 69 69 foreach($this->jsIncludes as $theinclude){ … … 84 84 }//end method 85 85 86 86 87 87 function getModules(){ 88 88 $modules = array(); 89 89 90 90 $querystatement = "SELECT * FROM `modules`"; 91 91 $queryresult = $this->db->query($querystatement); 92 92 while($therecord = $this->db->fetchArray($queryresult)) 93 93 $modules[$therecord["name"]] = $therecord; 94 94 95 95 return $modules; 96 96 } 97 97 98 98 99 99 function displayRights($roleid,$rolename = NULL){ 100 100 switch($roleid){ 101 101 102 102 case 0: 103 103 echo "EVERYONE"; 104 104 break; 105 105 106 106 case -100: 107 107 echo "Administrators"; 108 108 break; 109 109 110 110 default: 111 111 if(!$rolename){ 112 112 $querystatement = "SELECT name FROM roles WHERE id=".((int) $roleid); 113 113 $queryresult = $this->db->query($querystatement); 114 114 115 115 $therecord = $this->db->fetchArray($queryresult); 116 116 $rolename = $therecord["name"]; 117 117 }//end if 118 118 119 119 echo $rolename; 120 120 }//end case … … 123 123 124 124 function showTabs($tabgroup,$currenttabid,$recordid=0){ 125 125 126 126 $querystatement="SELECT id,name,location,enableonnew,notificationsql,tooltip,roleid FROM tabs WHERE tabgroup=\"".$tabgroup."\" ORDER BY displayorder"; 127 127 $queryresult=$this->db->query($querystatement); 128 129 ?><ul class="tabs"><?php 128 129 ?><ul class="tabs"><?php 130 130 while($therecord=$this->db->fetchArray($queryresult)){ 131 131 132 132 if(hasRights($therecord["roleid"])){ 133 133 134 134 ?><li <?php if($therecord["id"]==$currenttabid) echo "class=\"tabsSel\"" ?>><?php 135 135 if($therecord["id"]==$currenttabid || ($recordid==0 && $therecord["enableonnew"]==0)){ … … 143 143 $therecord["notificationsql"]=str_replace("{{id}}",((int) $recordid),$therecord["notificationsql"]); 144 144 $notificationresult=$this->db->query($therecord["notificationsql"]); 145 145 146 146 if($this->db->numRows($notificationresult)!=0){ 147 147 $notificationrecord=$this->db->fetchArray($notificationresult); … … 153 153 } 154 154 } 155 155 156 156 echo $opener.$therecord["name"].$closer; 157 158 ?></li><?php 157 158 ?></li><?php 159 159 }//endif hasRights 160 }//end whilt 160 }//end whilt 161 161 ?> 162 162 </ul><?php … … 165 165 166 166 function getUserName($id=0){ 167 167 168 168 $querystatement="select concat(firstname,\" \",lastname) as name from users where id=".((int) $id); 169 169 $queryresult = $this->db->query($querystatement); 170 170 171 171 $tempinfo = $this->db->fetchArray($queryresult); 172 172 return trim($tempinfo["name"]); 173 173 174 174 }// end method 175 175 … … 222 222 if(count($temparray)==3) 223 223 $thedate=mktime(0,0,0,(int) $temparray[1],(int) $temparray[2],(int) $temparray[0]); 224 else 224 else 225 225 return false; 226 226 break; … … 231 231 if(count($temparray)==4) 232 232 $thedate=mktime(0,0,0,(int) $temparray[1],(int) $temparray[2],(int) $temparray[3]); 233 else 233 else 234 234 return false; 235 235 break; 236 236 237 237 case "English, UK": 238 238 $datestring="/".ereg_replace(",.","/",$datestring); … … 240 240 if(count($temparray)==4) 241 241 $thedate=mktime(0,0,0,(int) $temparray[2],(int) $temparray[1],(int) $temparray[3]); 242 else 242 else 243 243 return false; 244 244 break; 245 245 246 246 case "Dutch, NL": 247 247 $datestring="-".ereg_replace(",.","-",$datestring); … … 249 249 if(count($temparray)==4) 250 250 $thedate=mktime(0,0,0,(int) $temparray[2],(int) $temparray[1],(int) $temparray[3]); 251 else 251 else 252 252 return false; 253 253 break; … … 302 302 $datestring=strftime("%Y-%m-%d",$thedate); 303 303 break; 304 304 305 305 case "English, US": 306 306 $datestring=strftime("%m/%d/%Y",$thedate); 307 307 break; 308 308 309 309 case "English, UK": 310 310 $datestring=strftime("%d/%m/%Y",$thedate); … … 349 349 if($format=="24 Hour") 350 350 $timestring=$sqltime; 351 else 351 else 352 352 $timestring=timeToString(stringToTime($sqltime,"24 Hour"),$format); 353 353 return $timestring; … … 362 362 if(count($tempdatearray)>1 && count($temptimearray)>1) 363 363 $thedatetime=mktime((int) $temptimearray[0],(int) $temptimearray[1],(int) $temptimearray[2],(int) $tempdatearray[1],(int) $tempdatearray[2],(int) $tempdatearray[0]); 364 } 364 } 365 365 return $thedatetime; 366 366 } … … 371 371 if($sqldatetime!=""){ 372 372 $datetimearray=explode(" ",$sqldatetime); 373 373 374 374 $datestring=trim($datetimearray[0]); 375 375 if($dateformat=="SQL") 376 376 $datestring=$datestring; 377 else 377 else 378 378 $datestring=dateToString(stringToDate($datestring,"SQL"),$dateformat); 379 379 if(isset($datetimearray[1])){ … … 381 381 if($timeformat=="24 Hour") 382 382 $timestring=$timestring; 383 else 383 else 384 384 $timestring=timeToString(stringToTime($timestring,"24 Hour"),$timeformat); 385 385 } … … 400 400 settype($datetime, 'string'); 401 401 eregi('(....)(..)(..)(..)(..)(..)',$datetime,$matches); 402 array_shift ($matches); 402 array_shift ($matches); 403 403 foreach (array('year','month','day','hour','minute','second') as $var) { 404 404 $$var = (int) array_shift($matches); 405 405 } 406 407 406 407 408 408 $thedatetime=mktime($hour,$minute,$second,$month,$day,$year); 409 409 410 410 return trim(dateToString($thedatetime,$dateformat)." ".timeToString($thedatetime,$timeformat)); 411 411 } … … 448 448 $number=str_replace(DECIMAL_SYMBOL,".",$number); 449 449 $number=((real) $number); 450 450 451 451 return $number; 452 452 } 453 453 454 454 // Phone/Email functions 455 //===================================================================== 456 function validateEmail($value){ 457 458 $thereturn = false; 459 $atPos = strpos($value, "@"); 460 461 //@ symobol must be after first char 462 if($atPos > 0){ 463 464 $dotPos = strpos($value, ".", $atPos); 465 $length = strlen($value); 466 467 //the dot must be at least 2 chars away from at 468 //it also must not be the last char in the string 469 if( ($dotPos > ($atPos + 1)) && ($length > ($dotPos + 1)) ) 470 $thereturn = true; 471 472 }//end if 473 474 return $thereturn; 475 476 }//end function --validateEmail-- 477 478 479 function validatePhone($number){ 480 481 //need to decide on the phone reg ex based upon settings information 482 switch(PHONE_FORMAT){ 483 484 case "US - Loose": 485 $phoneRegEx = "/^(?:[\+]?(?:[\d]{1,3})?(?:\s*[\(\.-]?(\d{3})[\)\.-])?\s*(\d{3})[\.-](\d{4}))(?:(?:[ ]+(?:[xX]|(?:[eE][xX][tT][\.]?)))[ ]?[\d]{1,5})?$/"; 486 break; 487 488 case "US - Strict": 489 $phoneRegEx = "/^[2-9]\d{2}-\d{3}-\d{4}$/"; 490 break; 491 492 case "UK - Loose": 493 $phoneRegEx = "/^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/"; 494 break; 495 496 case "International": 497 $phoneRegEx = "/^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/"; 498 break; 499 case "No Verification": 500 $phoneRegEx = "/.*/"; 501 break; 502 }//end switch 503 504 return preg_match($phoneRegEx,$number); 505 506 }//end function --validatePhone-- 455 507 456 508 //============================================================================ … … 496 548 497 549 //This function prepares an array for SQL manipulation. 498 550 499 551 if(get_magic_quotes_runtime() || get_magic_quotes_gpc()){ 500 501 foreach ($thearray as $key=>$value) 552 553 foreach ($thearray as $key=>$value) 502 554 if(is_array($value)) 503 555 $thearray[$key]= addSlashesToArray($value); 504 556 else 505 557 $thearray[$key] = mysql_real_escape_string(stripslashes($value)); 506 507 } else 558 559 } else 508 560 foreach ($thearray as $key=>$value) 509 561 if(is_array($value)) 510 $thearray[$key]= addSlashesToArray($value); 562 $thearray[$key]= addSlashesToArray($value); 511 563 else 512 564 $thearray[$key] = mysql_real_escape_string($value); 513 565 514 566 return $thearray; 515 567 516 568 }//end function 517 569 … … 522 574 if(!isset($sqlEncoding)) 523 575 $sqlEncoding = ""; 524 576 525 577 switch ($sqlEncoding){ 526 578 527 579 case "latin1": 528 580 $encoding = "ISO-8859-15"; 529 581 break; 530 582 531 583 case "utf8": 532 584 default: 533 585 $encoding = "UTF-8"; 534 586 break; 535 587 536 588 }//endswitch 537 589 538 590 return htmlspecialchars($string, ENT_COMPAT, $encoding); 539 591 … … 605 657 $value=$value; 606 658 break; 607 608 659 660 609 661 case "bbcode": 610 662 $value=htmlQuotes($value); 611 663 612 664 // This list needs to be expanded 613 665 $bbcodelist["[b]"] = "<strong>"; … … 615 667 $bbcodelist["[br]"] = "<br />"; 616 668 $bbcodelist["[space]"] = " "; 617 669 618 670 foreach($bbcodelist as $bbcode => $translation) 619 671 $value = str_replace($bbcode, $translation, $value); 620 621 break; 622 672 673 break; 674 623 675 default: 624 676 $value=htmlQuotes($value); … … 639 691 640 692 function nl_langinfo($constant){ 641 642 return $constant; 643 693 694 return $constant; 695 644 696 }//end function 645 697 646 698 function nl_setup(){ 647 699 648 700 $date = mktime(0,0,0,10,7,2007); 649 701 650 702 for($i = 1; $i<=7; $i++){ 651 703 652 704 define("ABDAY_".$i, date("D", $date)); 653 705 define("DAY_".$i, date("l"), $date); 654 706 655 707 $date = strtotime("tomorrow", $date); 656 708 }//end for 657 658 709 710 659 711 for($i = 1; $i<=12; $i++){ 660 712 661 713 $date = mktime(0, 0, 0, $i, 1, 2007); 662 714 663 715 define("ABMON_".$i, date("M", $date)); 664 716 define("MON_".$i, date("F"), $date); 665 717 666 718 }//end for 667 719 668 720 }//end function 669 721 670 722 nl_setup(); 671 723 672 724 }//end if 673 725 ?> -
trunk/phpbms/include/db.php
r427 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 249 $ | $LastChangedBy: brieb $ … … 41 41 //we may want to do more than connect via mysql; 42 42 var $type="mysql"; 43 43 44 44 // mysql vars; 45 45 var $db_link; … … 49 49 var $dbpass; 50 50 var $pconnect=true; 51 51 52 52 var $showError=false; 53 53 var $logError=true; 54 54 var $stopOnError=true; 55 55 var $errorFormat="xhtml"; 56 56 57 57 var $error = NULL; 58 58 59 59 function db($connect = true, $hostname = NULL, $schema = NULL, $user = NULL, $pass = NULL, $pconnect = NULL, $type = "mysql"){ 60 60 61 61 if($type!="mysql") 62 62 $this->type=$type; … … 69 69 if($hostname!=NULL) 70 70 $this->hostname = $hostname; 71 71 72 72 if(defined("MYSQL_DATABASE")) 73 73 $this->schema = MYSQL_DATABASE; 74 74 if($schema!=NULL) 75 75 $this->schema = $schema; 76 76 77 77 if(defined("MYSQL_USER")) 78 78 $this->dbuser = MYSQL_USER; 79 79 if($schema!=NULL) 80 80 $this->dbuser = $user; 81 81 82 82 if(defined("MYSQL_USERPASS")) 83 83 $this->dbpass = MYSQL_USERPASS; 84 84 if($schema!=NULL) 85 85 $this->dbpass = $pass; 86 86 87 87 if(defined("MYSQL_PCONNECT")) 88 88 $this->pconnect = MYSQL_PCONNECT; 89 89 if($pconnect!=NULL) 90 90 $this->pconnect = $pconnect; 91 break; 91 break; 92 92 } 93 93 94 94 if($connect){ 95 95 if($this->connect()){ … … 97 97 return $this->db_link; 98 98 else 99 return false; 99 return false; 100 100 } else 101 101 return false; … … 106 106 function connect(){ 107 107 // This functions connects to the database. It uses pconnect if the variable is set; 108 108 109 109 if($this->pconnect) 110 110 $this->db_link = @ mysql_pconnect($this->hostname,$this->dbuser,$this->dbpass); 111 111 else 112 112 $this->db_link = @ mysql_connect($this->hostname,$this->dbuser,$this->dbpass); 113 113 114 if(!$this->db_link){ 115 114 116 $error = new appError(-400,"Could not connect to database server.\n\n".$this->getError(),"",$this->showError,$this->stopOnError,false,$this->errorFormat); 115 117 return false; 116 } else 118 119 } else 117 120 return $this->db_link; 118 } 119 120 121 122 }//end function connect 123 124 121 125 function selectSchema($schema=NULL){ 122 126 if($schema!=NULL) 123 127 $this->schema=$schema; 124 128 125 129 if(! @ mysql_select_db($this->schema,$this->db_link)){ 126 $error = new appError(-410,"Could not open schema ".$this->schema,"",$this->showError,$this->stopOnError,false,$this->errorFormat); 130 $error = new appError(-410,"Could not open schema ".$this->schema,"",$this->showError,$this->stopOnError,false,$this->errorFormat); 127 131 return false; 128 132 } else 129 return true; 133 return true; 130 134 } 131 135 … … 134 138 switch($this->type){ 135 139 case "mysql": 136 if(!isset($this->db_link)) 137 if(!$this->d ataB()) die($this->error);140 if(!isset($this->db_link)) 141 if(!$this->db()) die($this->error); 138 142 $queryresult = @ mysql_query($sqlstatement,$this->db_link); 139 143 if(!$queryresult){ … … 141 145 $error = new appError(-420,$this->getError($this->db_link)."\n\nStatement: ".$sqlstatement,"",$this->showError,$this->stopOnError,$this->logError,$this->errorFormat); 142 146 return false; 143 } 144 break; 145 }//end case 146 147 } 148 break; 149 }//end case 150 147 151 $this->error=NULL; 148 152 return $queryresult; … … 153 157 154 158 switch($this->type){ 155 case "mysql": 159 case "mysql": 156 160 @ mysql_query("SET NAMES ".$encoding, $this->db_link); 157 161 break; 158 162 159 163 }//endswitch 160 164 … … 163 167 164 168 function getError($link = NULL){ 165 166 switch($this->type){ 167 case "mysql": 168 $thereturn = mysql_error($link); 169 170 switch($this->type){ 171 case "mysql": 172 if($link) 173 $thereturn = @ mysql_error($link); 174 else 175 $thereturn = @ mysql_error(); 169 176 break; 170 177 }//end switch --type-- 171 172 return $thereturn; 173 178 179 return $thereturn; 180 174 181 }//end method --getError-- 175 182 176 183 177 184 function numRows($queryresult){ … … 200 207 }//end function 201 208 202 209 203 210 function startTransaction(){ 204 205 switch($this->type){ 206 211 212 switch($this->type){ 213 207 214 case "mysql": 208 215 $this->query("START TRANSACTION;"); 209 216 break; 210 217 211 218 }//end switch 212 219 213 220 }//end method --startTransaction-- 214 215 221 222 216 223 function commitTransaction(){ 217 218 switch($this->type){ 219 224 225 switch($this->type){ 226 220 227 case "mysql": 221 228 $this->query("COMMIT;"); 222 229 break; 223 230 224 231 }//end switch 225 232 226 233 }//end method --startTransaction-- 227 228 234 235 229 236 function rollbackTransaction(){ 230 231 switch($this->type){ 232 237 238 switch($this->type){ 239 233 240 case "mysql": 234 241 $this->query("ROLLBACK;"); 235 242 break; 236 243 237 244 }//end switch 238 245 239 246 }//end method --startTransaction-- 240 247 241 248 242 249 function seek($queryresult,$rownum){ … … 278 285 return $thereturn; 279 286 }//end function 280 281 287 288 282 289 function tableInfo($tablename){ 283 290 //this function returns a multi-dimensional array describing the fields in a given table … … 291 298 $thereturn[$name]["type"] = @ mysql_field_type($queryresult,$offset); 292 299 $thereturn[$name]["length"] = mysql_field_len($queryresult,$offset); 293 $thereturn[$name]["flags"] = mysql_field_flags($queryresult,$offset); 300 $thereturn[$name]["flags"] = mysql_field_flags($queryresult,$offset); 294 301 } 295 302 } … … 305 312 case "mysql": 306 313 $thereturn = @ mysql_insert_id($this->db_link); 307 break; 314 break; 308 315 } 309 316 310 317 return $thereturn; 311 318 } 312 319 313 320 function affectedRows(){ 314 321 $thereturn = false; … … 316 323 case "mysql": 317 324 $thereturn = @ mysql_affected_rows($this->db_link); 318 break; 325 break; 319 326 } 320 327 321 328 return $thereturn; 322 329 } 323 330 324 331 }//end db class 325 332 ?> -
trunk/phpbms/include/fields.php
r447 r485 451 451 ?><option value="0" <?php 452 452 if ($this->value==0 || $this->value==""){ 453 echo " selected=\"selected\" " ?>><none></option><?php453 echo " selected=\"selected\" "; 454 454 }//end if --value-- 455 ?>><none></option><?php 455 456 }//end if --hasblank-- 456 457 -
trunk/phpbms/include/imports.php
r433 r485 1 1 <?php 2 2 class phpbmsImport{ 3 3 4 4 var $table; 5 5 var $error = ""; … … 10 10 var $data; 11 11 var $revertID = 0; 12 12 13 13 // Do not manually override 14 14 var $transactionRecords = array(); 15 15 var $tempFileID = 0; 16 16 var $pageType = "main"; 17 17 18 18 function phpbmsImport($table, $importType = "csv"){ 19 19 20 20 $this->table = $table; 21 21 $this->importType = $importType; … … 25 25 break; 26 26 }//end switch 27 27 28 28 $this->table->db->logError = true; 29 29 //So, that, when there is a db error, it will go all the way through and not just stop 30 30 $this->table->db->stopOnError = false; 31 //Won't display db errors, just log them. 31 //Won't display db errors, just log them. 32 32 $this->table->db->showError = false; 33 33 if(isset($_POST["pageType"])) 34 34 $this->pageType = $_POST["pageType"]; 35 35 36 36 if(isset($_POST["tempFileID"])) 37 37 $this->tempFileID = ((int)$_POST["tempFileID"]); 38 38 39 39 }//end method --imports-- 40 40 41 41 function _parseFromData($data){ 42 42 43 43 switch($this->importType){ 44 44 45 45 case "csv": 46 46 47 47 if(is_readable($data)){ 48 48 $contents = $this->_getFile($data); 49 49 50 50 if(is_readable($contents)){ 51 51 $this->docError = "invalid csv document"; 52 52 return false; 53 53 }//end if 54 54 55 55 }//end if 56 56 57 57 $this->parser->parse($data); 58 58 59 59 if(!count($this->parser->titles) || !count($this->parser->data)){ 60 60 $this->docError = "invalid csv document"; 61 return false; 61 return false; 62 62 }//end if 63 63 64 64 return true; 65 65 break; 66 66 67 67 }//end swtich 68 68 69 69 }//end method --_parseFromFile-- 70 71 70 71 72 72 function _getTransactionData(){ 73 73 //needs to be changed for more complicated tables … … 75 75 foreach($this->transactionIDs as $theid) 76 76 $inStatement .= $theid.","; 77 77 78 78 if($inStatement){ 79 79 80 80 $inStatement = substr($inStatement, 0, -1); 81 81 82 82 $querystatement = " 83 83 SELECT … … 88 88 `id` IN (".$inStatement."); 89 89 "; 90 90 91 91 $queryresult = $this->table->db->query($querystatement); 92 92 93 93 while($therecord = $this->table->db->fetchArray($queryresult)) 94 94 $this->transactionRecords[] = $therecord; 95 96 }//end if 97 95 96 }//end if 97 98 98 }//end method --_getTransactionData-- 99 100 99 100 101 101 function _getFile($fileName){ 102 102 if(function_exists('file_get_contents')){ … … 106 106 $file = addslashes(fread(fopen($fileName, 'r'), filesize($fileName))); 107 107 }//end if 108 108 109 109 return $file; 110 110 }//end method --_getFile-- 111 111 112 112 //DO NOT CALL IN TRANSACTION 113 113 function _storeTempCSV($fileName){ 114 114 115 115 $querystatement = " 116 116 INSERT INTO … … 136 136 '".$_SESSION["userinfo"]["id"]."', 137 137 '".$_SESSION["userinfo"]["id"]."' 138 138 139 139 ) 140 140 "; 141 141 142 142 $this->table->db->query($querystatement); 143 143 144 144 $id = $this->table->db->insertId(); 145 145 146 146 if($id) 147 147 $this->tempFileID = ((int) $id); 148 148 else 149 149 $this->error .= '<li> inserting temporary file failure </li>'; 150 150 151 151 }//end method --_storeTempCSV-- 152 153 152 153 154 154 function _getTempCSV($tempFileID){ 155 155 156 156 if($tempFileID){ 157 157 158 158 $querystatement = " 159 159 SELECT … … 164 164 id = ".((int)$tempFileID)." 165 165 "; 166 166 167 167 $queryresult = $this->table->db->query($querystatement); 168 168 169 169 $therecord = $this->table->db->fetchArray($queryresult); 170 170 171 171 return $therecord["file"]; 172 172 173 173 }//end if 174 174 175 175 return false; 176 176 177 177 }//end method --_getTempCSV-- 178 178 179 179 //DO NOT CALL IN TRANSACTION 180 180 function _removeTempCSV($tempFileID = 0){ 181 181 182 182 $querystatement = " 183 183 DELETE FROM … … 192 192 ); 193 193 "; 194 194 195 195 $queryresult = $this->table->db->query($querystatement); 196 196 197 197 $querystatement = " 198 198 ALTER TABLE … … 200 200 AUTO_INCREMENT = ".((int) $tempFileID)."; 201 201 "; 202 202 203 203 $queryresult = $this->table->db->query($querystatement); 204 204 205 205 }//end method --_removeTempCSV-- 206 206 207 207 //DO NOT USE THIS METHOD INSIDE AN OPEN TRANSACTION. 208 208 //IT WILL AUTOMATICALLY COMMIT THE TRANSACTION 209 209 function _revertAutoIncrement($revertID = 0){ 210 210 211 211 //check to see if there is a revert id (i.e. there was a valid insert) 212 212 if($revertID) 213 213 if(is_numeric($revertID)){ 214 214 215 215 $querystatement = " 216 216 ALTER TABLE … … 218 218 AUTO_INCREMENT = ".((int) $revertID)."; 219 219 "; 220 220 221 221 $this->table->db->query($querystatement); 222 222 223 223 }//end if 224 224 225 225 }//end method --_revertAutoIncrement-- 226 227 226 227 228 228 function importRecords($rows, $titles){ 229 229 230 230 switch($this->importType){ 231 232 case "csv": 231 232 case "csv": 233 233 //count total fieldnames (top row of csv document) 234 234 $fieldNum = count($titles); 235 235 236 236 //the file starts at line number 1, but since line 1 is 237 237 //supposed to be the fieldnames in the table(s), the lines 238 238 //being insereted start @ 2. 239 239 $rowNum = 2; 240 240 241 241 //get the data one row at a time 242 242 foreach($rows as $rowData){ 243 244 $theid = 0; 245 243 244 $theid = 0; // set for when verifification does not pass 245 $verify = array(); //set for when number of field rows does not match number of titles 246 246 247 //trim off leading/trailing spaces 247 248 $trimmedRowData = array(); 249 248 250 foreach($rowData as $name => $data) 249 251 $trimmedRowData[$name] = trim($data); 250 252 251 253 //check to see if number of fieldnames is consistent for each row 252 254 $rowFieldNum = count($trimmedRowData); 253 255 254 256 //if valid, insert, if not, log error and don't insert. 255 if($rowFieldNum == $fieldNum) 256 $theid = $this->table->insertRecord($trimmedRowData); 257 else 257 if($rowFieldNum == $fieldNum){ 258 $verify = $this->table->verifyVariables($trimmedRowData); 259 if(!count($verify)) 260 $theid = $this->table->insertRecord($trimmedRowData); 261 }else 258 262 $this->error .= '<li> incorrect amount of fields for line number '.$rowNum.'.</li>'; 259 263 260 264 if($theid){ 261 265 //keep track of the ids in the transaction to be able to select them 262 266 //for preview purposes 263 267 $this->transactionIDs[] = $theid; 264 268 265 269 //get first id to correct auto increment 266 270 if(!$this->revertID) … … 268 272 }else 269 273 $this->error .= '<li> failed insert for line number '.$rowNum.'.</li>'; 270 274 275 foreach($verify as $error) 276 $this->error .= '<li class="subError">'.$error.'</li>'; 277 271 278 $rowNum++; 272 279 273 280 }//end foreach 274 281 break; 275 282 276 283 }//end switch 277 284 278 285 }//end method --importRecords-- 279 280 286 287 281 288 function displayTransaction($recordsArray, $fieldsArray){ 282 289 //needs to be changed for more complicated tables … … 317 324 <?php 318 325 }//end if 319 326 320 327 }//end method --displayTransaction-- 321 322 328 329 323 330 function processImportPage(){ 324 331 325 332 $this->table->getTableInfo(); 326 333 327 334 if(!isset($_POST["command"])){ 328 335 329 336 //happens upon first coming to page 330 337 331 338 //remove any other temporary csv files in the `files` table 332 339 //present from previous imports 333 340 $this->_removeTempCSV(); 334 341 335 342 //check to see if user has the rights to be here. 336 343 //If not, kick him to the no access page. 337 344 if(!hasRights($this->table->importroleid)) 338 345 goURL(APP_PATH."noaccess.php"); 339 346 340 347 }else{ 341 348 //form has been submitted 342 349 switch($_POST["command"]){ 343 350 344 351 //cancel button pressed. 345 352 case "cancel": … … 354 361 }//end if 355 362 break; 356 363 357 364 case "upload": 358 365 359 366 //check for valid file upload 360 367 if(!$_FILES["import"]["error"] && ($_FILES["import"]["size"] > 0)){ 361 368 362 369 //check and parse the file 363 370 if($this->_parseFromData($_FILES["import"]["tmp_name"])){ 364 371 365 372 //start transaction 366 373 $this->table->db->startTransaction(); 367 374 368 375 $this->importRecords($this->parser->data, $this->parser->titles); 369 376 370 377 //get data for preview purposes 371 378 $this->_getTransactionData(); 372 379 //"undo" any inserts 373 380 $this->table->db->rollbackTransaction(); 374 381 375 382 //DO NOT CALL IN TRANSACTION 376 383 //ALTER TABLES AUTO COMMIT AND THE FILE NEEDS TO CARRY … … 378 385 $this->_revertAutoIncrement($this->revertID); 379 386 $this->_storeTempCSV($_FILES["import"]["tmp_name"]); 380 387 381 388 }//end if 382 389 383 390 }else 384 391 $this->docError .= "failed file upload"; 385 392 386 393 //switch page types 387 394 $this->pageType = "confirm"; 388 395 389 396 if(!$this->error && !$this->docError){ 390 397 $therecord["phpbmsStatus"] = "Confirm Import"; … … 394 401 }else 395 402 $therecord["phpbmsStatus"] = "Import Error"; 396 403 397 404 break; 398 405 399 406 case "import": 400 407 401 408 //get the contents of the stored csv document 402 409 $CSVcontents = $this->_getTempCSV($this->tempFileID); 403 410 404 411 //parser uses newline character to be able to parse the last line 405 412 if(substr($CSVcontents,-1,1) != "\n") 406 413 $CSVcontents .= "\n"; 407 408 414 415 409 416 $this->parser->parse($CSVcontents); 410 417 411 418 $this->importRecords($this->parser->data, $this->parser->titles); 412 419 413 420 $this->table->db->commitTransaction(); 414 421 415 422 //DO NOT CALL IN TRANSACTION 416 423 417 424 //get rid of temporary csv document 418 425 $this->_removeTempCSV($this->tempFileID); 419 426 420 427 $therecord["phpbmsStatus"] = "Record(s) Imported"; 421 428 //change page type 422 429 $this->pageType = "main"; 423 430 break; 424 431 425 432 }//end command switch 426 433 427 434 }// end if 428 435 429 436 //display the title 430 437 $therecord["title"] = $this->table->displayname." Import"; 431 438 return $therecord; 432 439 433 440 }//end method --imports-- 434 441 435 442 }//end class --imports-- 436 437 443 444 438 445 //this class is to have different buttons, and no created/modified. 439 446 if(class_exists("phpbmsForm")){ 440 447 class importForm extends phpbmsForm{ 441 448 442 449 function importForm($action = NULL, $method="post", $name="record", $onsubmit="return validateForm(this);", $dontSubmit = true){ 443 450 444 451 parent::phpbmsForm($action,$method,$name,$onsubmit,$dontSubmit); 445 452 446 453 }//end method --importForm-- 447 448 function startForm($pageTitle, $pageType ){449 450 ?><form action="<?php echo str_replace("&","&",$this->action) ?>" method="<?php echo $this->method?>" name="<?php echo $this->name?>" onsubmit="<?php echo $this->onsubmit?>" <?php 454 455 function startForm($pageTitle, $pageType, $numberOfRecords = 0){ 456 457 ?><form action="<?php echo str_replace("&","&",$this->action) ?>" method="<?php echo $this->method?>" name="<?php echo $this->name?>" onsubmit="<?php echo $this->onsubmit?>" <?php 451 458 if(isset($this->enctype)) echo ' enctype="'.$this->enctype.'" '; 452 459 if(isset($this->id)) echo ' id="'.$this->id.'" '; 453 ?>><?php 460 ?>><?php 454 461 if($this->dontSubmit){ 455 462 ?><div id="dontSubmit"><input type="submit" value=" " onclick="return false;" /></div><?php 456 463 } ?> 457 <div id="topButtons"><?php $this->showButtons(1, $pageType ); ?></div>458 <h1 id="h1Title"><span><?php echo $pageTitle ?></span></h1><?php 459 464 <div id="topButtons"><?php $this->showButtons(1, $pageType, $numberOfRecords); ?></div> 465 <h1 id="h1Title"><span><?php echo $pageTitle ?></span></h1><?php 466 460 467 }//end method --startForm-- 461 462 function showButtons($ids = 1, $pageType = "main" ){468 469 function showButtons($ids = 1, $pageType = "main", $numberOfRecords = 0){ 463 470 ?> 464 471 <div class="importCancels"> 465 472 <?php if($pageType == "main"){ ?> 466 <input <?php if($ids==1) {?>accesskey=" i"<?php }?> title="Upload (alt+u)" id="uploadButton<?php echo $ids?>" name="command" type="submit" value="upload" class="Buttons" />473 <input <?php if($ids==1) {?>accesskey="u"<?php }?> title="Upload (alt+u)" id="uploadButton<?php echo $ids?>" name="command" type="submit" value="upload" class="Buttons" /> 467 474 <input id="cancelButton<?php echo $ids?>" name="command" type="submit" value="cancel" class="Buttons" <?php if($ids==1) {?>accesskey="x" <?php }?> title="(access key+x)" /> 468 475 <?php }else{?> 469 <input type="submit" class="Buttons" value="import" name="command" id="import<?php echo $ids?>" title="commit" />476 <input type="submit" class="Buttons" value="import" name="command" id="import<?php echo $ids?>" title="commit" <?php echo ($numberOfRecords? '':'disabled="disabled"') ?>/> 470 477 <input type="submit" class="Buttons" value="cancel" name="command" id="cancelButton<?php echo $ids?>" title="rollback"/> 471 478 <?php }//end if ?> 472 479 </div><?php 473 480 }//end method --showButtons-- 474 481 475 482 }//end class --importForm-- 476 483 } -
trunk/phpbms/include/jstransport.php
r440 r485 1 <?php 1 <?php 2 2 $loginNoKick=true; 3 3 $loginNoDisplayError=true; 4 require_once("session.php"); 5 4 require_once("session.php"); 5 6 6 //phone formating 7 ?>phoneRegExpression=<?php 7 ?>phoneRegExpression=<?php 8 8 switch(PHONE_FORMAT){ 9 9 case "US - Loose": … … 11 11 break; 12 12 case "US - Strict": 13 ?>/^[2-9]\d{2}-\d{3}-\d{4}$/;<?php 13 ?>/^[2-9]\d{2}-\d{3}-\d{4}$/;<?php 14 14 break; 15 15 case "UK - Loose": 16 16 ?>/^((\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$/;<?php 17 break; 17 break; 18 18 case "International": 19 19 ?>/^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/;<?php 20 break; 21 } 22 20 break; 21 case "No Verification": 22 ?>/.*/;<?php 23 break; 24 } 25 23 26 //date formating 24 27 ?>APP_PATH="<?php echo htmlQuotes(APP_PATH)?>";<?php … … 26 29 //date formating 27 30 ?>DATE_FORMAT="<?php echo htmlQuotes(DATE_FORMAT)?>";<?php 28 31 29 32 //time formating 30 33 ?>TIME_FORMAT="<?php echo htmlQuotes(TIME_FORMAT)?>";<?php … … 40 43 41 44 ?>LOGIN_REFRESH=<?php echo LOGIN_REFRESH?>;<?php 42 45 43 46 if(defined("TERM1_DAYS")){ 44 47 ?>TERM1_DAYS=<?php echo TERM1_DAYS?>;<?php 45 48 }//end if 46 47 ?>MONTH_NAMES_LONG= [ <?php 48 49 50 ?>MONTH_NAMES_LONG= [ <?php 51 49 52 $mNames = ""; 50 53 for($i=0; $i < 11; $i++) 51 54 $mNames .= ', "'.strftime("%B", mktime(0, 0, 0, $i+1, 1, 1974)).'"'; 52 55 $mNames = substr($mNames, 2); 53 56 54 57 echo $mNames; 55 56 ?> ];<?php 58 59 ?> ];<?php 57 60 58 61 if(isset($phpbms->modules["bms"])){ 59 62 60 63 ?>TERM1_DAYS=<?php echo TERM1_DAYS?>;<?php 61 64 62 65 }//end if 63 66 64 67 65 68 ?> -
trunk/phpbms/include/login_include.php
r311 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 function verifyLogin($username,$password,$db){ 40 $thereturn = "Login Failed"; 41 42 $querystatement = "SELECT id, firstname, lastname, email, phone, department, employeenumber, admin 43 FROM users 44 WHERE login=\"".mysql_real_escape_string($username)."\" 45 AND password=ENCODE(\"".mysql_real_escape_string($password)."\",\"".mysql_real_escape_string(ENCRYPTION_SEED)."\") 46 AND revoked=0 AND portalaccess=0"; 47 48 $queryresult = $db->query($querystatement); 49 50 if($db->numRows($queryresult)){ 51 39 class login{ 40 41 var $db; 42 43 function login($db){ 44 45 $this->db = $db; 46 47 }//end function init 48 49 50 function verify($username, $password){ 51 52 $querystatement = " 53 SELECT 54 id, 55 firstname, 56 lastname, 57 email, 58 phone, 59 department, 60 employeenumber, 61 admin 62 FROM 63 users 64 WHERE 65 login = '".mysql_real_escape_string($username)."' 66 AND password = ENCODE('".mysql_real_escape_string($password)."','".mysql_real_escape_string(ENCRYPTION_SEED)."') 67 AND revoked = 0 68 AND portalaccess = 0"; 69 70 $queryresult = $this->db->query($querystatement); 71 72 if($this->db->numRows($queryresult)){ 73 52 74 //We found a record that matches in the database 53 75 // populate the session and go in 54 $_SESSION["userinfo"] =$db->fetchArray($queryresult);55 76 $_SESSION["userinfo"] = $this->db->fetchArray($queryresult); 77 56 78 // Next get the users roles, and populate the session with them 57 $_SESSION["userinfo"]["roles"][]=0; 58 $querystatement = "SELECT roleid FROM rolestousers WHERE userid=".$_SESSION["userinfo"]["id"]; 59 $rolesqueryresult = $db->query($querystatement); 60 61 while($rolerecord=$db->fetchArray($rolesqueryresult)) 79 $_SESSION["userinfo"]["roles"][] = 0; 80 $querystatement = " 81 SELECT 82 roleid 83 FROM 84 rolestousers 85 WHERE userid=".$_SESSION["userinfo"]["id"]; 86 87 $rolesqueryresult = $this->db->query($querystatement); 88 89 while($rolerecord = $this->db->fetchArray($rolesqueryresult)) 62 90 $_SESSION["userinfo"]["roles"][]=$rolerecord["roleid"]; 63 64 65 $querystatement = "UPDATE users SET modifieddate=modifieddate, lastlogin=Now() WHERE id = ".$_SESSION["userinfo"]["id"];66 $updateresult = $db->query($querystatement);67 91 68 $_SESSION["tableparams"]=array(); 92 //update lastlogin 93 $ip = $_SERVER["REMOTE_ADDR"]; 94 95 $updatestatement = " 96 UPDATE 97 users 98 SET 99 modifieddate = modifieddate, 100 lastlogin = Now(), 101 `lastip` = '".$ip."' 102 WHERE 103 id = ".$_SESSION["userinfo"]["id"]; 104 105 $this->db->query($updatestatement); 106 107 $_SESSION["tableparams"] = array(); 69 108 70 109 goURL(DEFAULT_LOAD_PAGE); 71 } else 72 return "Login Failed"; 73 } 110 111 } else { 112 113 //log login attempt 114 $log = new phpbmsLog("Login attempt failed for user '".$username."'", "SECURITY"); 115 116 return "Login Failed"; 117 118 }//endif numrows 74 119 75 120 76 // Start Code 77 //================================================================================================================= 78 79 $failed=""; 80 if (isset($_POST["name"])) { 81 $variables=addSlashesToArray($_POST); 82 $failed=verifyLogin($variables["name"],$variables["password"],$db); 83 } else 84 $_POST["name"]=""; 85 ?> 121 }//end function verify 122 123 }//end class -
trunk/phpbms/include/session.php
r402 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 40 // Turn on/or off debugging 39 41 @ define("APP_DEBUG",true); 40 42 if(APP_DEBUG) 41 43 error_reporting(E_ALL); 42 44 45 46 // Error Class - This class reports errors. It can also log these errors 47 // to the phpBMS log table in some cases. 43 48 class appError{ 49 44 50 var $number=0; 45 51 var $title=""; … … 48 54 var $logerror=true; 49 55 var $format="xhtml"; 50 56 57 //init 51 58 function appError($number=0,$details="",$title="",$display=false,$stop=true,$logerror=true,$format="xhtml"){ 59 52 60 $this->title = $title; 53 54 55 61 $this->details = $details; 56 57 62 $this->stop = $stop; 58 63 59 64 $this->logerror = $logerror; 60 65 $this->format = $format; 61 66 $this->number = $number; 62 67 68 // find a predetermined title; 63 69 if($this->number<0){ 70 64 71 switch($number){ 72 case -300: 73 $this->title = "settings.php file not readable"; 74 $this->details = 75 'If this is the initial installation of the program, 76 you may wan to run the installer. Use your web browser to navigate to:<br /><br /> 77 78 <a href="'.APP_PATH.'install">phpBMS Installation</a><br /><br /> 79 80 If your application already has a settings.php file in the main phpbms directory, you may need to give your web server rights to read the file.'; 81 break; 65 82 case -400: 66 83 case -410: … … 71 88 case -460: 72 89 $this->title="Database Error"; 73 break; 74 } 75 } 76 90 break; 91 }//end case; 92 93 }//endif this->number 94 77 95 if($display || APP_DEBUG) $this->display($format); 78 96 if($logerror) $this->logError(); 79 97 if($this->stop) exit; 80 } 81 82 function display($format=NULL){ 83 84 if($format==NULL) 85 $format=$this->format; 86 98 99 }//eend function init 100 101 102 //This function outputs the error to screen either in 103 // XHTML, plain text, or JSON format 104 function display($format = NULL){ 105 106 if($format == NULL) 107 $format = $this->format; 108 87 109 switch(strtolower($format)){ 110 88 111 case "json": 89 112 90 echo "{\n"; 91 echo "\"error\" : { \"id\" : ".$this->number; 92 if($this->title) 93 echo ", \"title\" : \"".addslashes($this->title)."\""; 94 if($this->details) 95 echo ", \"details\" : \"".addslashes($this->details)."\""; 96 echo "\n}"; 97 98 break; 99 113 $return["id"] = $this->number; 114 $return["title"] = $this->title; 115 $return["details"] = $this->details; 116 117 echo json_encode($return); 118 119 break; 120 100 121 case "xhtml": 101 122 102 $this->details = str_replace("\n","<br />", htmlspecialchars($this->details,ENT_COMPAT,"UTF-8")); 123 // Unsure if this line is needed, as it limits what we can do with detail print out 124 //$this->details = str_replace("\n","<br />", htmlspecialchars($this->details,ENT_COMPAT,"UTF-8")); 103 125 104 126 if(defined("APP_PATH")){ 127 105 128 if(!defined("STYLESHEET")) 106 129 define("STYLESHEET","mozilla"); 107 ?><link href="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/base.css" rel="stylesheet" type="text/css" /><?php 130 131 ?><link href="<?php echo APP_PATH ?>common/stylesheet/<?php echo STYLESHEET ?>/base.css" rel="stylesheet" type="text/css" /><?php 132 108 133 } else { 109 //if the app_path is not defined, we can try including the mozilla stylesheet, relative to 134 135 //if the app_path is not defined, we can try including the mozilla stylesheet, relative to 110 136 // the assumed phpbms root 111 ?><link href="common/stylesheet/mozilla/base.css" rel="stylesheet" type="text/css" /><?php 137 ?><link href="common/stylesheet/mozilla/base.css" rel="stylesheet" type="text/css" /><?php 138 112 139 }//end if 140 113 141 ?><div class="bodyline"> 114 142 <h1><span>phpBMS Error: <?php echo $this->number; if($this->title) echo " ".$this->title?></span></h1> … … 118 146 </div> 119 147 <?php } //end if?> 120 </div><?php 121 122 break;123 148 </div><?php 149 150 break; 151 124 152 default: 125 153 126 154 echo "phpBMS Error: ".$this->number; 127 155 if($this->title) echo ": ".$this->title; 128 156 if($this->details) echo " - ".$this->details; 129 130 break;157 158 break; 131 159 }//end switch 132 160 }// end dispaly function 133 161 162 163 // this function logs the error in the phpBMS log table 134 164 function logError(){ 165 135 166 $message = $_SERVER["REQUEST_URI"]."\n"; 136 167 $message .= $this->number; 168 137 169 if($this->title) 138 170 $message.=": ".$this->title; 171 139 172 if($this->details) 140 173 $message.="\n\n".$this->details; 141 174 142 175 $log = new phpbmsLog($message,"ERROR"); 176 143 177 }//end logError 144 178 145 179 }//end appError class 146 180 181 182 // This is the class for logging items tot the phpBMS 183 // log table; 147 184 class phpbmsLog{ 148 149 var $db =NULL;150 var $type ="ERROR";151 var $value ="";152 var $userid =2;153 185 186 var $db = NULL; 187 var $type = "ERROR"; 188 var $value = ""; 189 var $userid = 2; 190 154 191 function phpbmsLog($value=NULL,$type=NULL,$userid=NULL,$db=NULL,$sendLog=true){ 155 192 … … 158 195 if($db){ 159 196 if(is_object($db)){ 160 $this->db=$db; 161 197 198 $this->db = $db; 199 162 200 $this->db->showError=false; 163 201 $this->db->logError=false; 164 202 $this->db->stopOnError=false; 165 } 166 } 167 else{ 203 204 }//endif object 205 206 } else { 207 168 208 if(class_exists("db")){ 209 169 210 $this->db= new db(false); 170 211 171 212 $this->db->showError=false; 172 213 $this->db->logError=false; 173 214 $this->db->stopOnError=false; 174 215 175 216 $this->db->connect(); 176 217 $this->db->selectSchema(); 177 } else 218 219 } else 178 220 return false; 179 } 180 221 222 }//endif db 223 181 224 if($value) 182 $this->value=$value; 225 $this->value = $value; 226 183 227 if($type) 184 $this->type=$type; 228 $this->type = $type; 229 185 230 if($userid) 186 $this->userid =((int) $userid);187 231 $this->userid = ((int) $userid); 232 188 233 if($sendLog) 189 234 return $this->sendLog(); 190 235 else 191 236 return true; 192 193 }//end function 194 237 238 }//end function init 239 240 241 // inserts record into log table 195 242 function sendLog(){ 196 197 $ip=$_SERVER["REMOTE_ADDR"]; 198 199 $querystatement="INSERT INTO `log` (`type`,`value`,`userid`,`ip`) VALUES ("; 200 $querystatement.="\"".mysql_real_escape_string($this->type)."\", "; 201 $querystatement.="\"".mysql_real_escape_string($this->value)."\", "; 202 $querystatement.=$this->userid.", "; 203 $querystatement.="\"".$ip."\")"; 204 205 $this->db->query($querystatement); 206 207 } 208 }//end phpbmslog 209 210 211 243 244 $ip = $_SERVER["REMOTE_ADDR"]; 245 246 $insertstatement = " 247 INSERT INTO 248 `log` 249 (`type`, `value`, `userid`, `ip`) VALUES ( 250 '".mysql_real_escape_string($this->type)."', 251 '".mysql_real_escape_string($this->value)."', 252 ".$this->userid.", 253 '".$ip."' 254 )"; 255 256 $this->db->query($insertstatement); 257 258 }//end function sendLog 259 260 }//end class phpbmslog 261 262 263 // This class handles the loading of the database, session and application 264 // variables, as well as verifying API level logins 212 265 class phpbmsSession{ 213 266 214 var $db =null;267 var $db = null; 215 268 216 269 function loadDBSettings($reportError = true){ 270 217 271 // This functions looks for the settings.php file, and loads 218 272 // the database variables as constants. As an added benefit 219 273 // it adds the phpBMS root as an included path. 220 221 $path=""; 222 $count=1; 274 223 275 224 276 //need to look for settings file... only go up a total of 10 directories 225 $currdirectory= getcwd(); 226 227 while(!file_exists("settings.php") and ($count<10)){ 277 $currdirectory = getcwd(); 278 279 //Prep the setting of the application path; 280 $currentURL = explode("/",$_SERVER["PHP_SELF"]); 281 array_pop($currentURL); 282 283 $count = 0; 284 $path = ""; 285 286 //We need to find the applications root 287 while(!file_exists("phpbmsversion.php") && $count < 9){ 288 228 289 $path.="../"; 229 290 @ chdir("../"); 230 291 $count++; 231 } 232 292 293 }//end while 294 295 //Now set the Web location (APP_PATH) 296 $appPath = "/"; 297 for($i = 0; $i < count($currentURL) - $count; $i++) 298 if($currentURL[$i]) 299 $appPath .= $currentURL[$i]."/"; 300 301 define("APP_PATH", $appPath); 302 233 303 $settingsfile = @ fopen("settings.php","r"); 304 234 305 if($settingsfile){ 235 //loop through the settings file and load variables into the session 306 307 //loop through the settings file and load variables into the session 236 308 while( !feof($settingsfile)) { 237 $line=NULL; 238 $key=NULL; 239 $value=NULL; 240 $line=fscanf($settingsfile,"%[^=]=%[^[]]",$key,$value); 309 310 $line = NULL; 311 $key = NULL; 312 $value = NULL; 313 $line = @ fscanf($settingsfile,"%[^=]=%[^[]]",$key,$value); 314 241 315 if ($line){ 316 242 317 $key=trim($key); 243 318 $value=trim($value); 244 if($key!="" and !strpos($key,"]")){ 319 320 if($key!="" and !strpos($key,"]")){ 321 245 322 $startpos=strpos($value,"\""); 246 323 $endpos=strrpos($value,"\""); 324 247 325 if($endpos!=false) 248 326 $value=substr($value,$startpos+1,$endpos-$startpos-1); 249 if(strpos($key,"mysql_")===0){ 327 328 if(strpos($key,"mysql_")===0) 250 329 define(strtoupper($key),$value); 251 } 252 } 253 } 254 } 255 330 331 }//endif key 332 333 }//endif line 334 335 }//endwhile 336 256 337 @ fclose($settingsfile); 257 338 … … 261 342 262 343 //this adds the phpbms root to the include path 263 if ( ! defined( "PATH_SEPARATOR" ) ) {264 265 //if we cannot determin the OS, we will assume its unix266 if(!isset($_ENV["OS"]))267 $_ENV["OS"] = "unix";268 269 if ( strpos( $_ENV["OS"], "Win" ) !== false )270 define( "PATH_SEPARATOR", ";" );271 else272 define( "PATH_SEPARATOR", ":" );273 344 if ( !defined( "PATH_SEPARATOR" ) ) { 345 346 //if we cannot determin the OS, we will assume its unix 347 if(!isset($_ENV["OS"])) 348 $_ENV["OS"] = "unix"; 349 350 if ( strpos( $_ENV["OS"], "Win" ) !== false ) 351 define( "PATH_SEPARATOR", ";" ); 352 else 353 define( "PATH_SEPARATOR", ":" ); 354 274 355 }//end if 275 356 276 $pathToAdd=@ getcwd(); 277 ini_set("include_path",ini_get("include_path").PATH_SEPARATOR.$pathToAdd); 278 279 //Now to set the path 280 $pathrev = strrev($_SERVER["PHP_SELF"]); 281 $choppos=0; 282 283 for($x=0;$x<$count;$x++) 284 $choppos = strpos($pathrev,"/",$choppos+1); 285 define("APP_PATH",strrev(substr($pathrev,$choppos))); 286 357 $pathToAdd = @ getcwd(); 358 359 //Now we include the root application path to php's include path 360 if(ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.$pathToAdd) === false && $reportError) 361 $error = new appError(-310, "Your implementation of PHP does not allow changing of the include path. You may need to modify your PHP settings to allow phpBMS to modify this php ini setting. If you are using a web hosting company, you may need to contact them to allow this.", "Cannot add to include path", true, true, false); 362 363 364 //return directory to current directory 287 365 @ chdir ($currdirectory); 366 288 367 return $path; 368 289 369 } else { 370 290 371 if($reportError) 291 $error= new appError(-300,"You may need to run the install process, or set the permission on your settings file correctly.","Settings File Could Not Be Read",true,true,false); 372 $error = new appError(-300,"","",true,true,false); 373 292 374 return false; 293 } 375 376 }//endif settingsfile 377 294 378 }//end function 295 379 380 296 381 function loadSettings($encoding = "utf8"){ 297 // We are going to make sure that we are using utf8 382 383 // We are going to make sure that we are using utf8 298 384 // but it works only in mySQL 5, so we supress errors 299 385 // when trying it. 300 386 if($this->db==NULL) 301 387 $error=new appError(-310,"","Database not loaded"); 302 388 303 389 $this->db->logError = false; 304 390 $this->db->stopOnError = false; 305 391 306 392 $this->db->setEncoding($encoding); 307 393 308 394 $this->db->logError = true; 309 395 310 396 $querystatement = "SELECT name,value FROM settings"; 311 397 … … 313 399 314 400 if(!$queryresult){ 401 315 402 $error= new appError(-310,"If you have not ran the update script for phpBMS, please run it before logging in.","Could Not Retrieve Settings From Database"); 316 403 return false; 404 317 405 } else { 406 318 407 while($therecord=$this->db->fetchArray($queryresult)){ 319 408 320 409 //old versions used a reserved constant in certain php versions 321 410 if($therecord["name"] == "currency_symbol") 322 411 $therecord["name"] = "currency_sym"; 323 412 324 413 if(!defined(strtoupper($therecord["name"]))) 325 414 define(strtoupper($therecord["name"]),$therecord["value"]); … … 330 419 if(!isset($_SERVER['REQUEST_URI'])) { 331 420 $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; 332 421 333 422 if(!defined("HOUR_FORMAT")) 334 423 define("HOUR_FORMAT","%I"); 335 424 336 425 // Append the query string if it exists and isn't null 337 426 if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) … … 342 431 343 432 return true; 344 } 345 } 346 347 433 434 }//endif queryresult 435 436 }//end function 437 438 439 // This is in a function in case we want to do sessions differently in the future 348 440 function startSession(){ 349 // This is in a function in case we want to do sessions differently in the future 350 441 351 442 session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v096ID"); 352 443 session_start(); 353 } 354 355 356 function verifyAPIlogin($user,$pass){ 357 $thereturn=false; 444 445 }//end function startSesion 446 447 448 function verifyAPIlogin($user, $pass){ 449 450 $thereturn = false; 358 451 $this->db->stopOnError = false; 359 360 $querystatement = "SELECT id, firstname, lastname, email, phone, department, employeenumber, admin 361 FROM users 362 WHERE login!=\"Scheduler\" AND login=\"".mysql_real_escape_string($user)."\" 363 AND password=ENCODE(\"".mysql_real_escape_string($pass)."\",\"".mysql_real_escape_string(ENCRYPTION_SEED)."\") 364 AND revoked=0 AND portalaccess=1"; 452 453 $querystatement = " 454 SELECT 455 id, 456 firstname, 457 lastname, 458 email, 459 phone, 460 department, 461 employeenumber, 462 admin 463 FROM 464 users 465 WHERE 466 login != 'Scheduler' 467 AND login = '".mysql_real_escape_string($user)."' 468 AND password = ENCODE('".mysql_real_escape_string($pass)."', '".mysql_real_escape_string(ENCRYPTION_SEED)."') 469 AND revoked = 0 470 AND portalaccess = 1"; 471 365 472 $queryresult = $this->db->query($querystatement); 473 366 474 if(!$queryresult) { 475 367 476 $error = new appError(-720,"","Error retrieving user record",true,true,true,"json"); 368 477 return false; 369 } 370 478 479 }//endif 480 371 481 if($this->db->numRows($queryresult)){ 482 372 483 //We found a record that matches in the database 373 484 // populate the session and go in 374 $_SESSION["userinfo"]=$this->db->fetchArray($queryresult); 375 376 $querystatement="UPDATE users SET modifieddate=modifieddate, lastlogin=Now() WHERE id = ".$_SESSION["userinfo"]["id"]; 377 $queryresult=@ $this->db->query($querystatement); 378 if(!$queryresult) { 485 $_SESSION["userinfo"] = $this->db->fetchArray($queryresult); 486 487 $querystatement = " 488 UPDATE 489 users 490 SET 491 modifieddate=modifieddate, 492 lastlogin=Now() 493 WHERE 494 id = ".$_SESSION["userinfo"]["id"]; 495 496 $queryresult = @ $this->db->query($querystatement); 497 498 if(!$queryresult) 379 499 $error = new appError(-730,"","Error Updating User Login Time",true,true,true,"json"); 380 } else 381 $thereturn=true; 382 } 383 return $thereturn; 384 } 385 386 }//end loginSession class 387 388 389 // Start Code 390 //================================================================================================================= 391 //php <4.3.0 compatibility 392 if(!function_exists("mysql_real_escape_string")){ 393 function mysql_real_escape_string($string){ 394 return mysql_escape_string($string); 395 } 396 397 function utf8_replaceEntity($result){ 398 $value = (int)$result[1]; 399 $string = ''; 400 401 $len = round(pow($value,1/8)); 402 403 for($i=$len;$i>0;$i--){ 404 $part = ($value & (255>>2)) | pow(2,7); 405 if ( $i == 1 ) $part |= 255<<(8-$len); 406 407 $string = chr($part) . $string; 408 409 $value >>= 6; 410 } 411 412 return $string; 413 } 414 415 if(!function_exists("mysql_real_escape_string")){ 416 function html_entity_decode($string){ 417 return preg_replace_callback('/&#([0-9]+);/u','utf8_replaceEntity',$string); 418 }//end function 419 }//end if 420 421 }// end PHP<4.3 compatibility 500 else 501 $thereturn = true; 502 503 }//endif numrows 504 505 return $thereturn; 506 507 }//end function verifyAPIlogin 508 509 510 //Check to see if install folders are present. If so, do not continue. 511 function checkForInstallDirs($errorFormat = "xhtml"){ 512 513 //first lets check for the main programs install folder 514 if(file_exists("install") && is_dir("install")) 515 $error = new appError(-353,"You must remove the install directory and all modules' install directories before phpBMS can run.","Main Install Directory Present",true,true,true,$errorFormat); 516 517 $thedir= @ opendir("modules"); 518 519 while($entry = readdir($thedir)){ 520 521 if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("modules/".$entry)){ 522 523 if(file_exists("modules/".$entry."/install") && is_dir("modules/".$entry."/install")){ 524 525 $error = new appError(-354,"You must remove the install directory and all modules' install directories before phpBMS can run.","Module '".$entry."' Install Directory Present",true,true,true,$errorFormat); 526 527 }//endif 528 529 }//endif 530 531 }//end if 532 533 }//end function checkForInstallDirs 534 535 }//end phpbmsSession class 536 422 537 423 538 424 539 // Start Login verification Code 425 //============================================================================== ===================================540 //============================================================================== 426 541 if(!isset($sqlEncoding)) 427 542 $sqlEncoding = "utf8"; 428 543 429 544 if(!defined("noStartup")){ 545 430 546 $scriptname = basename($_SERVER["PHP_SELF"]); 431 547 $phpbmsSession = new phpbmsSession; 432 548 433 549 //Testing for API login 434 550 if(strpos($scriptname,"api_")!==false){ 435 551 if(isset($_POST["phpbmsusername"]) && isset($_POST["phpbmspassword"])){ 552 436 553 $phpbmsSession->loadDBSettings(APP_DEBUG); 437 554 555 if(!APP_DEBUG) 556 $phpbmsSession->checkForInstallDirs("json"); 557 438 558 include_once("include/db.php"); 439 559 $db = new db(); 440 560 $phpbmsSession->db = $db; 441 561 442 include_once("common_functions.php"); 562 include_once("common_functions.php"); 443 563 $phpbmsSession->loadSettings($sqlEncoding); 444 564 $phpbms = new phpbms($db); 445 446 565 566 447 567 if(!$phpbmsSession->verifyAPILogin($_POST["phpbmsusername"],$_POST["phpbmspassword"])) 448 568 $error = new appError(-700,"","Login credentials incorrect",true,true,true,"json"); 569 449 570 } else 450 571 $error= new appError(-710,"","No login credentials passed",true,true,true,"json"); 572 451 573 } else { 452 574 453 575 $phpbmsSession->loadDBSettings(APP_DEBUG); 454 455 576 577 if(!APP_DEBUG) 578 $phpbmsSession->checkForInstallDirs(); 579 580 //start database 456 581 include_once("include/db.php"); 457 582 $db = new db(); 458 583 459 584 $phpbmsSession->db = $db; 460 585 586 //load application settings from table 461 587 $phpbmsSession->loadSettings($sqlEncoding); 462 588 463 589 include_once("common_functions.php"); 464 590 $phpbms = new phpbms($db); 465 591 466 592 if(!isset($noSession)) 467 593 $phpbmsSession->startSession(); 468 594 469 595 if (!isset($_SESSION["userinfo"]) && $scriptname != "index.php") { 470 596 471 597 if(isset($loginNoKick)){ 598 472 599 if(!isset($loginNoDisplayError)) 473 600 exit(); 601 474 602 } else{ 603 475 604 goURL(APP_PATH."index.php"); 476 } 477 } 478 479 } 480 481 $db->stopOnError=true; 605 606 }//endif 607 608 }//endif iseet userinfo 609 610 }//endif 611 612 $db->stopOnError = true; 613 482 614 }//end if 483 615 -
trunk/phpbms/include/tables.php
r427 r485 39 39 40 40 41 class phpbmsTable{ 42 43 var $db = NULL; 44 var $backurl = NULL; 45 46 // The table definition record id. 47 var $id=0; 48 49 var $fields = array(); 50 51 function phpbmsTable($db,$tabledefid = 0,$backurl = NULL){ 52 53 if(is_object($db)) 54 if(get_class($db)=="db") 55 $this->db = $db; 56 if($this->db === NULL) 57 $error = new appError(-800,"database object is required for parameter 1.","Initializing phpbmsTable Class"); 58 59 $this->id = ((int) $tabledefid); 60 61 if($backurl == NULL) 62 $this->backurl = APP_PATH."search.php?id=".$this->id; 63 else 64 $this->backurl = $backurl; 65 66 if(!$this->getTableInfo()) 67 $error = new appError(-810,"Table definition not found for id ".$this->id,"Initializing phpbmsTable Class"); 68 } 69 70 71 function getTableInfo(){ 72 $querystatement = "SELECT * FROM tabledefs WHERE id=".$this->id; 73 74 $queryresult = $this->db->query($querystatement); 75 76 if($this->db->numRows($queryresult)){ 77 foreach($this->db->fetchArray($queryresult) as $key => $value) 78 $this->$key = $value; 79 80 $this->fields = $this->db->tableInfo($this->maintable); 81 82 return true; 83 } else 84 return false; 85 } 86 87 function getDefaultByType($fieldtype){ 88 $default = NULL; 89 90 switch ($fieldtype){ 91 case "blob": 92 case "string": 93 $default = ""; 94 break; 95 case "real": 96 case "int": 97 $default = 0; 98 break; 99 case "date": 100 $default=dateToString(mktime(),"SQL"); 101 break; 102 case "time": 103 $default=timeToString(mktime(),"SQL"); 104 break; 105 case "year": 106 $default=strftime("%Y"); 107 break; 108 case "datetime": 109 case "timestamp": 110 $default = dateToString(mktime(),"SQL")." ".timeToString(mktime(),"24 Hour"); 111 break; 112 } 113 114 return $default; 115 116 } 117 118 function prepareFieldForSQL($value,$type,$flags){ 119 switch ($type){ 120 121 case "blob": 122 case "string": 123 if($value === "" or $value === NULL){ 124 if(strpos($flags,"not_null") === false) 125 $value = NULL; 126 else 127 $value = "''"; 128 } else 129 $value = "'".$value."'"; 130 break; 131 132 case "real": 133 if($value === "" or $value === NULL){ 134 if(strpos($flags,"not_null") === false) 135 $value = NULL; 136 else 137 $value = 0; 138 } else 139 $value = (real) $value; 140 break; 141 142 case "int": 143 if($value === "" or $value === NULL){ 144 if(strpos($flags,"not_null") === false) 145 $value = NULL; 146 else 147 $value = 0; 148 } else 149 $value = (int) $value; 150 break; 151 152 case "date": 153 if($value === "" or $value === NULL){ 154 if(strpos($flags,"not_null") === false) 155 $value = NULL; 156 else 157 $value = "'".dateToString(mktime(),"SQL")."'"; 158 } else 159 $value = "'".sqlDateFromString($value)."'"; 160 break; 161 162 case "time": 163 if($value === "" or $value === NULL){ 164 if(strpos($flags,"not_null") === false) 165 $value = NULL; 166 else 167 $value = "'".timeToString(mktime(),"SQL")."'"; 168 } else 169 $value = "'".sqlTimeFromString($value)."'"; 170 break; 171 172 case "year": 173 if($value === "" or $value === NULL) 174 if(strpos($flags,"not_null") === false) 175 $value = NULL; 176 else 177 $value = strftime("%Y"); 178 break; 179 180 case "datetime": 181 case "timestamp": 182 if($value === "" or $value === NULL){ 183 if(strpos($flags,"not_null") === false) 184 $value = NULL; 185 else 186 $value = "'".dateToString(mktime(),"SQL")." ".timeToString(mktime(),"24 Hour")."'"; 187 } else{ 188 $datetimearray = explode(" ",$value); 189 if(count($datetimearray) > 1){ 190 $value = "'".sqlDateFromString($datetimearray[0])." ".sqlTimeFromString($datetimearray[1])."'"; 191 } else 192 $value = "'".$value."'"; 193 } 194 break; 195 case "password": 196 $value = "ENCODE('".$value."','".ENCRYPTION_SEED."')"; 197 break; 198 }//end case 199 200 201 if($value === NULL) 202 $value = "NULL"; 203 return $value; 204 }//end method 205 206 207 function getDefaults(){ 208 $therecord = array(); 209 210 foreach($this->fields as $fieldname => $thefield){ 211 switch($fieldname){ 212 case "id": 213 case "modifiedby": 214 case "modifieddate": 215 $therecord[$fieldname] = NULL; 216 break; 217 218 case "createdby": 219 $therecord["createdby"] = $_SESSION["userinfo"]["id"]; 220 break; 221 222 default: 223 if(strpos($thefield["flags"],"not_null") === false) 224 $therecord[$fieldname] = NULL; 225 else { 226 $therecord[$fieldname] = $this->getDefaultByType($thefield["type"]); 227 } 228 break; 229 }//end switch 230 }//end foreach 231 232 return $therecord; 233 } 234 235 236 function getRecord($id = 0){ 237 $id = (int) $id; 238 239 $querystatement = "SELECT "; 240 241 foreach($this->fields as $fieldname => $thefield){ 242 if(isset($thefield["select"])) 243 $querystatement .= "(".$thefield["select"].") AS `".$fieldname."`, "; 41 class phpbmsTable{ 42 43 var $db = NULL; 44 var $backurl = NULL; 45 var $verifyErrors = array(); 46 47 // The table definition record id. 48 var $id=0; 49 50 var $fields = array(); 51 52 function phpbmsTable($db,$tabledefid = 0,$backurl = NULL){ 53 54 if(is_object($db)) 55 if(get_class($db)=="db") 56 $this->db = $db; 57 if($this->db === NULL) 58 $error = new appError(-800,"database object is required for parameter 1.","Initializing phpbmsTable Class"); 59 60 $this->id = ((int) $tabledefid); 61 62 if($backurl == NULL) 63 $this->backurl = APP_PATH."search.php?id=".$this->id; 244 64 else 245 $querystatement .= "`".$fieldname."`, "; 246 }//end foreach 247 $querystatement = substr($querystatement, 0, strlen($querystatement)-2); 248 249 $querystatement .= " FROM `".$this->maintable."` WHERE `".$this->maintable."`.`id` = ".$id; 250 251 $queryresult = $this->db->query($querystatement); 252 253 if($this->db->numRows($queryresult)) 254 $therecord = $this->db->fetchArray($queryresult); 255 else 256 $therecord = $this-> getDefaults(); 257 258 return $therecord; 259 }//end getRecord function 260 261 262 function updateRecord($variables, $modifiedby = NULL){ 263 $variables = addSlashesToArray($variables); 264 265 if($modifiedby === NULL) 266 if(isset($_SESSION["userinfo"]["id"])) 267 $modifiedby = $_SESSION["userinfo"]["id"]; 268 else 269 $error = new appError(-840,"Session Timed Out.","Creating New Record"); 270 271 if(!isset($variables["id"])) 272 $error = new appError(-820,"id not set","Updating Record"); 273 274 $updatestatement = "UPDATE `".$this->maintable."` SET "; 275 276 foreach($this->fields as $fieldname => $thefield){ 277 if(!isset($thefield["select"])){ 65 $this->backurl = $backurl; 66 67 if(!$this->getTableInfo()) 68 $error = new appError(-810,"Table definition not found for id ".$this->id,"Initializing phpbmsTable Class"); 69 } 70 71 72 function getTableInfo(){ 73 $querystatement = "SELECT * FROM tabledefs WHERE id=".$this->id; 74 75 $queryresult = $this->db->query($querystatement); 76 77 if($this->db->numRows($queryresult)){ 78 foreach($this->db->fetchArray($queryresult) as $key => $value) 79 $this->$key = $value; 80 81 $this->fields = $this->db->tableInfo($this->maintable); 82 83 return true; 84 } else 85 return false; 86 } 87 88 function getDefaultByType($fieldtype){ 89 $default = NULL; 90 91 switch ($fieldtype){ 92 case "blob": 93 case "string": 94 $default = ""; 95 break; 96 case "real": 97 case "int": 98 $default = 0; 99 break; 100 case "date": 101 $default=dateToString(mktime(),"SQL"); 102 break; 103 case "time": 104 $default=timeToString(mktime(),"SQL"); 105 break; 106 case "year": 107 $default=strftime("%Y"); 108 break; 109 case "datetime": 110 case "timestamp": 111 $default = dateToString(mktime(),"SQL")." ".timeToString(mktime(),"24 Hour"); 112 break; 113 } 114 115 return $default; 116 117 } 118 119 function prepareFieldForSQL($value,$type,$flags){ 120 switch ($type){ 121 122 case "blob": 123 case "string": 124 if($value === "" or $value === NULL){ 125 if(strpos($flags,"not_null") === false) 126 $value = NULL; 127 else 128 $value = "''"; 129 } else 130 $value = "'".$value."'"; 131 break; 132 133 case "real": 134 if($value === "" or $value === NULL){ 135 if(strpos($flags,"not_null") === false) 136 $value = NULL; 137 else 138 $value = 0; 139 } else 140 $value = (real) $value; 141 break; 142 143 case "int": 144 if($value === "" or $value === NULL){ 145 if(strpos($flags,"not_null") === false) 146 $value = NULL; 147 else 148 $value = 0; 149 } else 150 $value = (int) $value; 151 break; 152 153 case "date": 154 if($value === "" or $value === NULL){ 155 if(strpos($flags,"not_null") === false) 156 $value = NULL; 157 else 158 $value = "'".dateToString(mktime(),"SQL")."'"; 159 } else 160 $value = "'".sqlDateFromString($value)."'"; 161 break; 162 163 case "time": 164 if($value === "" or $value === NULL){ 165 if(strpos($flags,"not_null") === false) 166 $value = NULL; 167 else 168 $value = "'".timeToString(mktime(),"SQL")."'"; 169 } else 170 $value = "'".sqlTimeFromString($value)."'"; 171 break; 172 173 case "year": 174 if($value === "" or $value === NULL) 175 if(strpos($flags,"not_null") === false) 176 $value = NULL; 177 else 178 $value = strftime("%Y"); 179 break; 180 181 case "datetime": 182 case "timestamp": 183 if($value === "" or $value === NULL){ 184 if(strpos($flags,"not_null") === false) 185 $value = NULL; 186 else 187 $value = "'".dateToString(mktime(),"SQL")." ".timeToString(mktime(),"24 Hour")."'"; 188 } else{ 189 $datetimearray = explode(" ",$value); 190 if(count($datetimearray) > 1){ 191 $value = "'".sqlDateFromString($datetimearray[0])." ".sqlTimeFromString($datetimearray[1])."'"; 192 } else 193 $value = "'".$value."'"; 194 } 195 break; 196 case "password": 197 $value = "ENCODE('".$value."','".ENCRYPTION_SEED."')"; 198 break; 199 }//end case 200 201 202 if($value === NULL) 203 $value = "NULL"; 204 return $value; 205 }//end method 206 207 208 function getDefaults(){ 209 $therecord = array(); 210 211 foreach($this->fields as $fieldname => $thefield){ 278 212 switch($fieldname){ 279 213 case "id": 280 case "creationdate": 214 case "modifiedby": 215 case "modifieddate": 216 $therecord[$fieldname] = NULL; 217 break; 218 281 219 case "createdby": 282 break; 220 $therecord["createdby"] = $_SESSION["userinfo"]["id"]; 221 break; 222 223 default: 224 if(strpos($thefield["flags"],"not_null") === false) 225 $therecord[$fieldname] = NULL; 226 else { 227 $therecord[$fieldname] = $this->getDefaultByType($thefield["type"]); 228 } 229 break; 230 }//end switch 231 }//end foreach 232 233 return $therecord; 234 } 235 236 237 function getRecord($id = 0){ 238 $id = (int) $id; 239 240 $querystatement = "SELECT "; 241 242 foreach($this->fields as $fieldname => $thefield){ 243 if(isset($thefield["select"])) 244 $querystatement .= "(".$thefield["select"].") AS `".$fieldname."`, "; 245 else 246 $querystatement .= "`".$fieldname."`, "; 247 }//end foreach 248 $querystatement = substr($querystatement, 0, strlen($querystatement)-2); 249 250 $querystatement .= " FROM `".$this->maintable."` WHERE `".$this->maintable."`.`id` = ".$id; 251 252 $queryresult = $this->db->query($querystatement); 253 254 if($this->db->numRows($queryresult)) 255 $therecord = $this->db->fetchArray($queryresult); 256 else 257 $therecord = $this-> getDefaults(); 258 259 return $therecord; 260 }//end getRecord function 261 262 263 function prepareVariables($variables){ 264 265 return $variables; 266 267 }//end method --prepareVariables-- 268 269 270 function verifyVariables($variables){ 271 272 $thereturn = array(); 273 274 if(!isset($this->verifyErrors)) 275 $this->verifyErrors = array(); 276 277 if(isset($variables["id"])) 278 if(!is_numeric($variables["id"]) && $variables["id"]) 279 $this->verifyErrors[] = "The `id` field must be numeric or equivalent to zero (although positive is reccomended)."; 280 281 if(isset($variables["inactive"])) 282 if($variables["inactive"] && $variables["inactive"] != 1) 283 $this->verifyErrors[] = "The `inactive` field must be a boolean (equivalent to 0 or exactly 1)."; 283 284 284 case "modifiedby": 285 $updatestatement .= "`modifiedby` = ".((int) $modifiedby).", "; 286 break; 287 288 case "modifieddate": 289 $updatestatement .= "`modifieddate` = NOW(), "; 290 break; 291 292 default: 293 if(!isset($variables[$fieldname]) && strpos($thefield["flags"],"not_null") !== false) 294 $variables[$fieldname] = $this->getDefaultByType($thefield["type"],true); 295 296 if(isset($variables[$fieldname])) 297 $updatestatement .= "`".$fieldname."` = ".$this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 298 break; 299 }//end switch field name 300 }//end if 301 }//end foreach 302 $updatestatement = substr($updatestatement, 0, strlen($updatestatement)-2); 303 304 $updatestatement .= " WHERE `id`=".((int) $variables["id"]); 305 306 $updateresult = $this->db->query($updatestatement); 307 308 return true; 309 } 310 311 312 function insertRecord($variables,$createdby = NULL, $overrideID = false){ 313 314 if($createdby === NULL) 315 if(isset($_SESSION["userinfo"]["id"])) 316 $createdby = $_SESSION["userinfo"]["id"]; 285 if(count($this->verifyErrors)) 286 $thereturn = $this->verifyErrors; 287 288 unset($this->verifyErrors); 289 290 return $thereturn; 291 292 }//end method --verifyVariables-- 293 294 295 function updateRecord($variables, $modifiedby = NULL){ 296 297 $variables = addSlashesToArray($variables); 298 299 if($modifiedby === NULL) 300 if(isset($_SESSION["userinfo"]["id"])) 301 $modifiedby = $_SESSION["userinfo"]["id"]; 302 else 303 $error = new appError(-840,"Session Timed Out.","Creating New Record"); 304 305 if(!isset($variables["id"])) 306 $error = new appError(-820,"id not set","Updating Record"); 307 308 $updatestatement = "UPDATE `".$this->maintable."` SET "; 309 310 foreach($this->fields as $fieldname => $thefield){ 311 if(!isset($thefield["select"])){ 312 switch($fieldname){ 313 case "id": 314 case "creationdate": 315 case "createdby": 316 break; 317 318 case "modifiedby": 319 $updatestatement .= "`modifiedby` = ".((int) $modifiedby).", "; 320 break; 321 322 case "modifieddate": 323 $updatestatement .= "`modifieddate` = NOW(), "; 324 break; 325 326 default: 327 if(!isset($variables[$fieldname]) && strpos($thefield["flags"],"not_null") !== false) 328 $variables[$fieldname] = $this->getDefaultByType($thefield["type"],true); 329 330 if(isset($variables[$fieldname])) 331 $updatestatement .= "`".$fieldname."` = ".$this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 332 break; 333 }//end switch field name 334 }//end if 335 }//end foreach 336 $updatestatement = substr($updatestatement, 0, strlen($updatestatement)-2); 337 338 $updatestatement .= " WHERE `id`=".((int) $variables["id"]); 339 340 $updateresult = $this->db->query($updatestatement); 341 342 343 return true; 344 } 345 346 347 function insertRecord($variables,$createdby = NULL, $overrideID = false){ 348 349 if($createdby === NULL) 350 if(isset($_SESSION["userinfo"]["id"])) 351 $createdby = $_SESSION["userinfo"]["id"]; 352 else 353 $error = new appError(-840,"Session Timed Out.","Creating New Record"); 354 355 356 $variables = addSlashesToArray($variables); 357 358 $fieldlist = ""; 359 $insertvalues = ""; 360 foreach($this->fields as $fieldname => $thefield){ 361 if(!isset($thefield["select"])){ 362 switch($fieldname){ 363 case "id": 364 if(isset($variables["id"])) 365 if($overrideID && $variables["id"]){ 366 $fieldlist .= "id, "; 367 $insertvalues .= ((int) $variables["id"]).", "; 368 }//endif 369 break; 370 371 case "createdby": 372 case "modifiedby": 373 $fieldlist .= $fieldname.", "; 374 $insertvalues .= ((int) $createdby).", "; 375 break; 376 377 case "creationdate": 378 case "modifieddate": 379 $fieldlist .= $fieldname.", "; 380 $insertvalues .= "NOW(), "; 381 break; 382 383 default: 384 if(!isset($variables[$fieldname]) && strpos($thefield["flags"],"not_null") !== false) 385 $variables[$fieldname] = $this->getDefaultByType($thefield["type"],true); 386 387 if(isset($variables[$fieldname])){ 388 $fieldlist .= "`".$fieldname."`, "; 389 $insertvalues .= $this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 390 }//endif - fieldname 391 break; 392 }//end switch field name 393 }//end if 394 }//end foreach 395 $fieldlist = substr($fieldlist, 0, strlen($fieldlist)-2); 396 $insertvalues = substr($insertvalues, 0, strlen($insertvalues)-2); 397 398 $insertstatement = "INSERT INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 399 $insertresult = $this->db->query($insertstatement); 400 401 if($insertresult) 402 return $this->db->insertId(); 317 403 else 318 $error = new appError(-840,"Session Timed Out.","Creating New Record"); 319 320 321 $variables = addSlashesToArray($variables); 322 323 $fieldlist = ""; 324 $insertvalues = ""; 325 foreach($this->fields as $fieldname => $thefield){ 326 if(!isset($thefield["select"])){ 327 switch($fieldname){ 328 case "id": 329 if(isset($variables["id"])) 330 if($overrideID && $variables["id"]){ 331 $fieldlist .= "id, "; 332 $insertvalues .= ((int) $variables["id"]).", "; 333 }//endif 334 break; 335 336 case "createdby": 337 case "modifiedby": 338 $fieldlist .= $fieldname.", "; 339 $insertvalues .= ((int) $createdby).", "; 340 break; 341 342 case "creationdate": 343 case "modifieddate": 344 $fieldlist .= $fieldname.", "; 345 $insertvalues .= "NOW(), "; 346 break; 347 348 default: 349 if(!isset($variables[$fieldname]) && strpos($thefield["flags"],"not_null") !== false) 350 $variables[$fieldname] = $this->getDefaultByType($thefield["type"],true); 351 352 if(isset($variables[$fieldname])){ 353 $fieldlist .= "`".$fieldname."`, "; 354 $insertvalues .= $this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 355 }//endif - fieldname 356 break; 357 }//end switch field name 358 }//end if 359 }//end foreach 360 $fieldlist = substr($fieldlist, 0, strlen($fieldlist)-2); 361 $insertvalues = substr($insertvalues, 0, strlen($insertvalues)-2); 362 363 $insertstatement = "INSERT INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 364 $insertresult = $this->db->query($insertstatement); 365 366 if($insertresult) 367 return $this->db->insertId(); 368 else 369 return false; 370 } 371 372 373 function processAddEditPage(){ 374 if(!isset($_POST["command"])){ 375 376 if(isset($_GET["id"])){ 377 //editing 378 if(!hasRights($this->editroleid)) 379 goURL(APP_PATH."noaccess.php"); 380 else 381 return $this->getRecord((integer) $_GET["id"]); 382 } else { 383 if(!hasRights($this->addroleid)) 384 goURL(APP_PATH."noaccess.php"); 385 else 386 return $this->getDefaults(); 404 return false; 405 } 406 407 408 function processAddEditPage(){ 409 if(!isset($_POST["command"])){ 410 411 if(isset($_GET["id"])){ 412 //editing 413 if(!hasRights($this->editroleid)) 414 goURL(APP_PATH."noaccess.php"); 415 else 416 return $this->getRecord((integer) $_GET["id"]); 417 } else { 418 if(!hasRights($this->addroleid)) 419 goURL(APP_PATH."noaccess.php"); 420 else 421 return $this->getDefaults(); 422 } 387 423 } 388 } 389 else 390 { 391 switch($_POST["command"]){ 392 case "cancel": 393 // if we needed to do any clean up (deleteing temp line items) 394 if(!isset($_POST["id"])) $_POST["id"]=0; 395 396 $theurl = $this->backurl; 397 398 if(isset($_POST["id"])) 399 $theurl .= "#".((int) $_POST["id"]); 400 goURL($theurl); 401 break; 402 case "save": 403 if($_POST["id"]) { 404 $this->updateRecord($_POST); 405 $theid = $_POST["id"]; 406 //get record 407 $therecord = $this->getRecord($theid); 408 $therecord["phpbmsStatus"]="Record Updated"; 409 410 return $therecord; 411 } 412 else { 413 $theid = $this->insertRecord($_POST); 414 415 //get record 416 $therecord=$this->getRecord($theid); 417 $therecord["phpbmsStatus"] = "<div style=\"float:right;margin-top:-3px;\"><button type=\"button\" class=\"smallButtons\" onclick=\"document.location='".str_replace("&","&",$_SERVER["REQUEST_URI"])."'\">add new</button></div>"; 418 $therecord["phpbmsStatus"] .= "Record Created"; 419 420 return $therecord; 421 } 422 break; 423 }//end command switch 424 }// end if 425 }// end function 426 } 424 else 425 { 426 switch($_POST["command"]){ 427 case "cancel": 428 // if we needed to do any clean up (deleteing temp line items) 429 if(!isset($_POST["id"])) $_POST["id"]=0; 430 431 $theurl = $this->backurl; 432 433 if(isset($_POST["id"])) 434 $theurl .= "#".((int) $_POST["id"]); 435 goURL($theurl); 436 break; 437 case "save": 438 439 $variables = $this->prepareVariables($_POST); 440 $errorArray = $this->verifyVariables($variables); 441 442 if($_POST["id"]) { 443 444 $theid = $variables["id"]; 445 446 if(!count($errorArray)){ 447 448 $this->updateRecord($variables); 449 450 //get record 451 $therecord = $this->getRecord($theid); 452 $therecord["phpbmsStatus"] = "Record Updated"; 453 }else{ 454 foreach($errorArray as $error) 455 $logError = new appError(-900, $error, "Verification Error"); 456 457 //get record 458 $therecord = $this->getRecord($theid); 459 $therecord["phpbmsStatus"] = "Data Verification Error"; 460 }//end if 461 462 463 464 return $therecord; 465 } 466 else { 467 468 $theid = 0; 469 470 if(!count($errorArray)){ 471 $theid = $this->insertRecord($variables); 472 //get record 473 $therecord = $this->getRecord($theid); 474 $therecord["phpbmsStatus"] = "<div style=\"float:right;margin-top:-3px;\"><button type=\"button\" class=\"smallButtons\" onclick=\"document.location='".str_replace("&","&",$_SERVER["REQUEST_URI"])."'\">add new</button></div>"; 475 $therecord["phpbmsStatus"] .= "Record Created"; 476 }else{ 477 foreach($errorArray as $error) 478 $logError = new appError(-900, $error, "Verification Error"); 479 480 //get record 481 $therecord = $this->getRecord($theid); 482 $therecord["phpbmsStatus"] .= "Data Verification Error"; 483 }//end if 484 485 return $therecord; 486 } 487 break; 488 }//end command switch 489 }// end if 490 }// end function 491 }//end class 427 492 ?> -
trunk/phpbms/index.php
r308 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 39 39 require_once("include/session.php"); 40 40 require_once("include/login_include.php"); 41 42 $pageTitle = APPLICATION_NAME." Log in"; 43 41 42 43 if(isset($_POST["name"]) && isset($_POST["password"])){ 44 45 $login = new login($db); 46 $failed = $login->verify($_POST["name"], $_POST["password"]); 47 48 } else { 49 50 $failed = ""; 51 $_POST["name"] = ""; 52 53 }//endif 54 55 $pageTitle = formatVariable(APPLICATION_NAME)." Log in"; 56 44 57 $phpbms->cssIncludes[] = "pages/login.css"; 45 58 $phpbms->jsIncludes[] = "common/javascript/login.js"; 46 59 47 60 $phpbms->showMenu = false; 48 $phpbms->showFooter = false; 49 61 $phpbms->showFooter = false; 62 50 63 include("header.php"); 51 64 ?> 52 65 53 66 <div id="loginbox" class="bodyline" > 67 54 68 <h1><span><?php echo APPLICATION_NAME;?></span></h1> 55 69 <?php if ($failed) {?><div class="standout" id="failed"><?php echo $failed?></div><?php } ?> 70 56 71 <noscript> 57 72 <p class="standout" align="center">JavaScript is disabled.</p> 58 73 <p> Please check browser requirements.</p> 59 74 </noscript> 60 75 61 76 <form name="form1" method="post" action="<?php echo $_SERVER["PHP_SELF"]?>"> 62 <fieldset> 63 <legend>Log In</legend> 64 <p> 65 <label for="username">name</label><br /> 66 <input name="name" type="text" id="username" size="25" maxlength="64" value="<?php echo htmlQuotes($_POST["name"])?>" disabled="disabled"/> 77 78 <p> 79 <label for="username">name</label><br /> 80 <input name="name" type="text" id="username" size="25" maxlength="64" value="<?php echo htmlQuotes($_POST["name"])?>" disabled="disabled"/> 81 </p> 82 83 <p> 84 <label for="password">password</label><br /> 85 <input name="password" type="password" id="password" size="25" maxlength="24" disabled="disabled"/> 86 </p> 87 88 89 <p id="moreinfoButtonP"><button id="moreinfoButton" type="button" class="graphicButtons buttonInfo"><span>more info</span></button></p> 90 <p id="buttonP"><button class="Buttons" type="submit" id="loginButton" disabled="disabled">Log In</button></p> 91 92 </form> 93 94 95 <div id="moreinfo" > 96 97 <div class="box"> 98 99 <h2><a href="http://www.phpbms.org" title="phpBMS"><span class="alt">phpBMS</span></a></h2> 100 101 <h3>Business Management Web Application</h3> 102 103 <p class="tiny"> 104 <a href="requirements.php">browser requirements</a> | 105 <a href="info.php">about phpBMS</a> 67 106 </p> 68 69 <p> 70 <label for="password">password</label><br /> 71 <input name="password" type="password" id="password" size="25" maxlength="24" disabled="disabled"/> 72 </p> 73 74 </fieldset> 75 <p id="buttonP"><button class="Buttons" type="submit" id="loginButton" disabled="disabled">Log In</button></p> 76 </form> 77 <p id="moreinfoButtonP"><button id="moreinfoButton" type="button" class="graphicButtons buttonInfo"><span>more info</span></button></p> 78 <div id="moreinfo" > 79 <div class="box"> 80 <h2><a href="http://www.phpbms.org" title="phpBMS"><span class="alt">phpBMS</span></a></h2> 81 <h3>Business Management Web Application</h3> 82 <p class="tiny"> 83 <a href="requirements.php">browser requirements</a> | 84 <a href="info.php">program info</a> 85 </p> 107 86 108 </div> 87 109 </div> 88 110 </div> 89 111 90 112 91 113 <?php if(DEMO_ENABLED=="true"){?> 114 92 115 <div id="demobox" class="bodyline"> 116 93 117 <h2>Demonstration Mode</h2> 118 94 119 <p> 95 Use the following user credentials to log into phpBMS. Each user 120 Use the following user credentials to log into phpBMS. Each user 96 121 highlights a different security access level. 97 122 </p> 123 98 124 <dl> 99 125 <dt>Shipping Personnel</dt> … … 101 127 username: shipping<br /> 102 128 password: shipping 103 </dd> 129 </dd> 130 104 131 <dt>Sales Personnel</dt> 105 <dd>username: sales<br /> 106 password: sales</dd> 132 <dd> 133 username: sales<br /> 134 password: sales 135 </dd> 136 107 137 <dt>Sales Manager</dt> 108 <dd>username: salesmanager<br /> 138 <dd> 139 username: salesmanager<br /> 109 140 password: salesmanager 110 </dd>141 </dd> 111 142 </dl> 112 143 </div> 144 113 145 <?php } include("footer.php")?> -
trunk/phpbms/info.php
r427 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 $loginNoKick =true;40 $loginNoDisplayError =true;39 $loginNoKick = true; 40 $loginNoDisplayError = true; 41 41 42 42 require_once("include/session.php"); 43 44 45 function displayVersions($db){46 $querystatement="SELECT displayname,version from modules ORDER BY id";47 $queryresult=$db->query($querystatement);48 43 49 if($queryresult){ 50 while($therecord=$db->fetchArray($queryresult)){ 51 if($therecord["displayname"]!="Base"){ 52 echo $therecord["displayname"].": "; 53 echo "v".$therecord["version"]."<br />"; 54 } else 55 echo "<span class=\"important\">v".$therecord["version"]."</span><br /><br />"; 56 } 57 } 58 } 59 44 class versions{ 45 46 var $db; 47 var $queryresult; 48 49 function versions($db){ 50 51 $this->db = $db; 52 53 }//end function init 54 55 function get(){ 56 57 $querystatement = " 58 SELECT 59 `name`, 60 `displayname`, 61 `version` 62 FROM 63 `modules` 64 ORDER BY 65 `id`"; 66 67 $this->queryresult = $this->db->query($querystatement); 68 69 }//end function get 70 71 72 function show(){ 73 74 if(!$this->queryresult) 75 return false; 76 77 while($therecord = $this->db->fetchArray($this->queryresult)){ 78 79 if($therecord["name"] != "base") 80 echo formatVariable($therecord["displayname"]).": v".$therecord["version"]."<br />"; 81 else 82 echo '<p class="important">v'.$therecord["version"].'</p>'; 83 84 }//endwhile 85 86 return true; 87 88 }//end function show 89 90 }//end class 91 92 $versions = new versions($db); 93 $versions->get(); 94 60 95 $pageTitle="phpBMS Information"; 61 96 $phpbms->cssIncludes[] = "pages/info.css"; 62 97 63 98 $phpbms->showMenu = false; 64 99 $phpbms->showFooter = false; 65 100 66 101 include("header.php"); 67 102 68 103 ?><div class="bodyline" id="container"> 104 105 <div id="phpBMSLogo" class="box small"> 106 <?php $versions->show() ?> 107 </div> 108 69 109 <h1>About phpBMS</h1> 70 <p>phpBMS is commercial open source, web-based, business management software.</p> 71 72 <div id="phpBMSLogo" class="box small"> 73 <?php if(isset($db)) displayVersions($db)?> 74 </div> 75 110 <p>phpBMS is commercial, open source, web-based, business management software.</p> 111 76 112 <div id="companyInfo"> 77 <p class="small">78 Copyright © 2004 -2007 Kreotek, llc. All Rights Reserved.79 phpBMS, and the phpBMS logo are trademarks of Kreotek, llc.113 <p > 114 Copyright © <?php echo date("Y")?> Kreotek, LLC. All Rights Reserved. 115 phpBMS, and the phpBMS logo are trademarks of Kreotek, LLC. 80 116 Software is licensed under a <a href="license.txt">modified BSD license</a>. 81 117 </p> 82 118 83 119 <h3>Kreotek, LLC</h3> 84 <p class="small">120 <p> 85 121 610 Quantum<br /> 86 Rio Rancho, NM 87124 122 Rio Rancho, NM 87124 USA 123 </p> 124 <p><a href="http://www.kreotek.com">http://www.kreotek.com</a></p> 125 <p> 126 sales: <a href="mailto:sales@kreotek.com">sales@kreotek.com</a><br /> 127 support: <a href="mailtosupport@kreotek.com">support@kreotek.com</a> 87 128 </p> 88 129 <p> 89 web: <a href="http://www.kreotek.com">http://www.kreotek.com</a><br /> 90 sales: <a href="mailto:sales@kreotek.com">sales@kreotek.com</a><br /> 91 support: <a href="mailtosupport@kreotek.com">support@kreotek.com</a><br /> 92 phone: <strong>1-800-731-8026</strong> 130 U.S. and Canada Toll Free<br /> 131 1-800-731-8026 132 133 <p> 134 Outside US and Canada<br /> 135 +1-505-994-6388 93 136 </p> 137 94 138 <h3>phpBMS Open Source Project</h3> 95 139 <p> 96 projectweb site: <a href="http://www.kreotek.com">http://www.phpbms.org</a><br />97 project forums: <a href="mailto:sales@kreotek.com">sales@kreotek.com</a><br />140 community web site: <a href="http://www.kreotek.com">http://www.phpbms.org</a><br /> 141 community forums: <a href="http://www.phpbms.org/forum">http://www.phpbms.org/forum</a><br /> 98 142 </p> 99 143 </div> 100 101 <h2>Source Code</h2>102 <ul>103 <li><strong>phpBMS</strong> - Commercial Open Source Business Management Web Appllication (<a href="http://www.kreotek.com">www.phpbms.org</a>)</li>104 <li><strong>fpdf</strong> - A PHP class which allows to generate PDF files with pure PHP (<a href="http://www.fpdf.org">www.fpdf.org</a>)</li>105 <li><strong>moo.fx</strong> - Super lightweight JavaScript effects library (<a href="http://moofx.mad4milk.net/">moofx.mad4milk.net</a>) </li>106 <li><strong>mochikit</strong> - A lightweight JavaScript library (<a href="http://mochichit.com/">mochikit.com</a>) - phpBMS utilizes modified parts mochikit code and it's programming structure.</li>107 <li><strong>parseCSV</strong> - An easy to use PHP class to read and write CSV data properly.(<a href="http://code.google.com/p/parsecsv-for-php/" >code.google.com/p/parsecsv-for-php/</a>)</li>108 </ul>109 <h2>Technologies</h2>110 <ul>111 <li><strong>php</strong> - A widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. (<a href="http://www.php.net">www.php.net</a>)</li>112 <li><strong>MySQL</strong> - An open source relational database management system (RDBMS) that uses Structured Query Language (SQL) (<a href="http://www.mysql.org">www.mysql.org</a>)</li>113 <li><strong>AJAX</strong> - Asynchronous Javascript And XML is a group of technologies that help browser based applications behave more like applications you run from your desktop.</li>114 </ul>115 144 116 <p align="right"> 117 <input type="button" value="Back" class="Buttons" onclick="document.location='<?php echo APP_PATH; if(isset($_SESSION["userinfo"])) echo DEFAULT_LOAD_PAGE?>'" id="loginButton"/> 118 </p> 145 <h2>Source Code</h2> 146 <ul> 147 <li> 148 <h3>phpBMS (<a href="http://www.phpbms.org">www.phpbms.org</a>)</h3> 149 <p>Commercial Open Source Business Management Web Appllication</p> 150 </li> 151 152 <li> 153 <h3>fpdf (<a href="http://www.fpdf.org">www.fpdf.org</a>)</h3> 154 <p>A PHP class which allows to generate PDF files with pure PHP</p> 155 </li> 156 157 <li> 158 <h3>moo.fx (<a href="http://moofx.mad4milk.net/">moofx.mad4milk.net</a>)</h3> 159 <p>Super lightweight JavaScript effects library</p> 160 </li> 161 162 <li> 163 <h3>mochikit (<a href="http://mochichit.com/">mochikit.com</a>)</h3> 164 <p>A lightweight JavaScript library - phpBMS utilizes modified parts of mochikit code and it's programming structure for JavaScript as inspiration.</p> 165 </li> 166 167 <li> 168 <h3>parseCSV (<a href="http://code.google.com/p/parsecsv-for-php/" >code.google.com/p/parsecsv-for-php/</a>)</h3> 169 <p>An easy to use PHP class to read and write CSV data properly.</p> 170 </li> 171 </ul> 172 173 <p align="right"><input type="button" value="Log In" class="Buttons" onclick="document.location='./'" id="loginButton" /></p> 174 119 175 </div><?php include("footer.php") ?> -
trunk/phpbms/install/createtables.sql
r427 r485 58 58 `assignedtodate` date default NULL, 59 59 `subject` varchar(128) default NULL, 60 `type` char(2) default NULL,60 `type` char(2) NOT NULL default 'NT', 61 61 `createdby` int(11) NOT NULL default '0', 62 62 `creationdate` datetime NOT NULL default '0000-00-00 00:00:00', … … 115 115 `displayorder` int(11) NOT NULL default '0', 116 116 `roleid` int(11) NOT NULL default '0', 117 `reportfile` varchar(128) defaultNULL,117 `reportfile` varchar(128) NOT NULL, 118 118 `description` text, 119 119 `createdby` int(11) NOT NULL default '0', … … 169 169 `modifieddate` timestamp NOT NULL, 170 170 PRIMARY KEY (`id`) 171 ) ENGINE=INNODB AUTO_INCREMENT=1000; 171 ) ENGINE=INNODB AUTO_INCREMENT=1000; 172 172 173 173 CREATE TABLE tablefindoptions ( … … 180 180 PRIMARY KEY (id), 181 181 KEY tabledef (tabledefid) 182 ) ENGINE=INNODB AUTO_INCREMENT=2000; 182 ) ENGINE=INNODB AUTO_INCREMENT=2000; 183 183 184 184 CREATE TABLE tableoptions ( … … 193 193 PRIMARY KEY (id), 194 194 KEY tabledef (tabledefid) 195 ) ENGINE=INNODB AUTO_INCREMENT=2000; 195 ) ENGINE=INNODB AUTO_INCREMENT=2000; 196 196 197 197 CREATE TABLE tablesearchablefields ( … … 211 211 firstname varchar(64) NOT NULL default '', 212 212 lastname varchar(64) NOT NULL default '', 213 `lastip` VARCHAR(45) NOT NULL DEFAULT '', 213 214 creationdate datetime NOT NULL default '0000-00-00 00:00:00', 214 215 revoked tinyint(1) NOT NULL default '0', … … 259 260 `roleid` int(11) NOT NULL default '0', 260 261 PRIMARY KEY (`id`) 261 ) ENGINE=INNODB AUTO_INCREMENT=100; 262 ) ENGINE=INNODB AUTO_INCREMENT=100; 262 263 263 264 CREATE TABLE `attachments` ( … … 274 275 KEY `thetable` (`tabledefid`), 275 276 KEY `thefile` (`fileid`) 276 ) ENGINE=INNODB ; 277 ) ENGINE=INNODB ; 277 278 278 279 CREATE TABLE `roles` ( … … 280 281 `name` VARCHAR(64) NOT NULL, 281 282 `description` TEXT, 282 `inactive` tinyint(4) NOT NULL ,283 `inactive` tinyint(4) NOT NULL DEFAULT 0, 283 284 `createdby` INTEGER UNSIGNED, 284 285 `creationdate` DATETIME, … … 351 352 PRIMARY KEY (`id`) 352 353 ) ENGINE=INNODB; 353 -
trunk/phpbms/install/install.css
r285 r485 1 .bodyline,#topTitle{width:740px; margin:10px auto;} 2 h1{margin-bottom:20px;} 3 p{margin:0;padding:0px 10px 10px;} 1 li{ 2 margin-bottom: 20px; 3 } 4 5 .bodyline,#topTitle{ 6 width:100%; 7 max-width: 740px; 8 margin:10px auto; 9 } 10 11 h1{ 12 margin-bottom:20px; 13 } 14 15 p{ 16 margin:10px 0; 17 padding:0; 18 } 19 20 #navPanel{ 21 float: left; 22 width: 190px; 23 } 24 25 #navSelect{ 26 font-size: 12px; 27 padding:0; 28 width: 98% 29 } 30 31 #stepsPanel{ 32 margin-left: 198px; 33 min-height: 400px; 34 border-left: 1px solid #CCCCCC; 35 padding-left: 8px; 36 } 37 38 39 .success{ 40 color: green; 41 line-height: 16px; 42 background: url("success.gif") no-repeat left; 43 padding:2px 0 2px 20px; 44 } 45 46 .fail { 47 color: red; 48 line-height: 16px; 49 background: url("fail.gif") no-repeat left; 50 padding:2px 0 2px 20px; 51 } 52 53 .warning { 54 line-height: 16px; 55 background: url("warning.gif") no-repeat left; 56 padding:2px 0 2px 20px; 57 } 58 59 .running { 60 line-height: 16px; 61 background: url("../common/image/spinner.gif") no-repeat left; 62 padding:2px 0 2px 20px; 63 } 64 65 66 #sysRequirements td{ 67 border-bottom: 1px solid #CCCCCC; 68 padding: 5px 10px; 69 } 4 70 5 71 .results{width:99%;font-family:'Courier New', Courier, mono;font-size:13px;} 6 72 .testButtonsP{text-align:center; padding:20px;} 7 73 8 .nextprevP{text-align:right;} 9 .nextprevButtons{padding-right:20px;padding-left:20px;} 74 .nextprevP{ 75 float: right; 76 margin: 0; 77 } 10 78 11 #moduleInformation h2{margin-top:0;padding-top:5px;} 79 .nextButtons, .prevButtons{ 80 padding:3px 20px; 81 } 82 83 .debugResults{ 84 display: none; 85 } 86 87 #moduleTable td{ 88 89 padding: 5px 10px; 90 border-top: 1px solid #CCCCCC; 91 vertical-align: top; 92 } 93 94 #moduleTable td h3{ 95 margin-top: 0; 96 margin-left: 0; 97 } 98 99 #moduleTable th{ 100 text-align: left; 101 background: #7B8DA1; 102 color: white; 103 padding: 10px; 104 } 105 106 .moduleInstall{ 107 white-space: nowrap; 108 min-width: 120px; 109 } 110 111 #userpassTable{ 112 113 margin: 0 auto; 114 115 } 116 117 #userpassTable td{ 118 119 font-size: 22px; 120 121 } -
trunk/phpbms/install/install.js
r308 r485 1 window.onload = function(){ 2 var sections = getElementsByClassName("bodyline"); 3 4 var i; 5 for(i=0; i< sections.length; i++){ 6 if(sections[i].id != "step1"){ 7 sections[i].style.display = "none"; 1 installer = { 2 3 testConnection: function(){ 4 5 var response = installer.runCommand("testconnection"); 6 var testConnectionNoDebug = getObjectFromID("testConnectionNoDebug"); 7 8 if(response.success === true){ 9 testConnectionNoDebug.className = "success" 10 testConnectionNoDebug.innerHTML = "Connection Successful"; 11 } else { 12 testConnectionNoDebug.className = "fail" 13 testConnectionNoDebug.innerHTML = "Connection Failed"; 8 14 } 15 16 },//endfunction testConnection 17 18 19 createDatabase: function(){ 20 21 var response = installer.runCommand("createdatabase"); 22 var noDebug = getObjectFromID("createDatabaseNoDebug"); 23 24 if(response.success === true){ 25 26 noDebug.className = "success" 27 noDebug.innerHTML = "Database Schema Created"; 28 29 } else { 30 31 noDebug.className = "fail" 32 noDebug.innerHTML = "Database Schema Creation Failed"; 33 34 }//endif 35 36 }, // endfunction createdatabase 37 38 39 coreDataInstall: function(){ 40 41 var noDebug = getObjectFromID("coreDataNoDebug"); 42 43 noDebug.className = "running"; 44 noDebug.innerHTML = "Running..."; 45 46 47 //we pass the entered application name and e-mail address as a "::" separated pair 48 var appname = getObjectFromID("appname"); 49 var email = getObjectFromID("email"); 50 51 var extras = encodeURIComponent(appname.value + "::" + email.value) 52 53 var response = installer.runCommand("coredatainstall", extras); 54 55 if(response.success === true){ 56 57 noDebug.className = "success"; 58 noDebug.innerHTML = "Core Data Installed Succefully"; 59 60 var pass2 = getObjectFromID("pass2") 61 62 pass2.innerHTML = response.extras; 63 64 } else { 65 66 noDebug.className = "fail"; 67 noDebug.innerHTML = "Core Data Installation Failed"; 68 69 }//endif 70 71 }, // endfunction coreDataInstall 72 73 74 moduleInstall: function(e){ 75 76 var theButton = e.src(); 77 78 var foo = ""; 79 80 var module = theButton.id.substring(12); 81 82 var noDebug = getObjectFromID("Results"+module); 83 84 noDebug.className = "running"; 85 noDebug.innerHTML = "Running..."; 86 87 var response = installer.runCommand("moduleinstall", module); 88 89 if(response.success === true){ 90 91 noDebug.className = "success"; 92 noDebug.innerHTML = "Module Installed"; 93 94 } else { 95 96 noDebug.className = "fail"; 97 noDebug.innerHTML = "Installation Failed"; 98 99 }//endif 100 101 },//end function moduleInstall 102 103 104 runCommand: function(command, extras){ 105 106 if(typeof(extras) == "undefined") 107 extras = ""; 108 else 109 extras = "&extras=" + extras 110 111 var theURL = "installajax.php?command=" + command + extras; 112 113 loadXMLDoc(theURL,null,false); 114 115 var JSONresponse; 116 eval("JSONresponse = (" + req.responseText +")"); 117 118 var responseText = getObjectFromID(command + "results"); 119 if(typeof(responseText) != "undefined"){ 120 121 if(responseText.value) 122 responseText.value += "\n"; 123 124 responseText.value += JSONresponse.details; 125 126 }//endif 127 128 return JSONresponse 129 130 },//endfunction runCommand 131 132 133 toggleDebug: function(){ 134 135 var debug = getObjectFromID("debug"); 136 var display = "none"; 137 if(debug.checked) 138 display = "block"; 139 140 var debugDisplays = getElementsByClassName("debugResults"); 141 142 for(var i = 0; i < debugDisplays.length; i ++) 143 debugDisplays[i].style.display = display; 144 145 }//end function toggleDebug 146 147 }//end class installer 148 149 150 151 stepsNav = { 152 153 currentSection: 1, 154 sections: null, 155 156 navNext: function(){ 157 158 if(stepsNav.currentSection + 1 <= stepsNav.sections.length){ 159 stepsNav.navTo(stepsNav.currentSection + 1); 160 } 161 }, 162 163 164 navPrev: function(){ 165 if(stepsNav.currentSection - 1 > 0) 166 stepsNav.navTo(stepsNav.currentSection - 1); 167 }, 168 169 170 navTo: function(section){ 171 172 for(var i=0; i< stepsNav.sections.length; i++){ 173 174 if(stepsNav.sections[i].id != "step" + section){ 175 stepsNav.sections[i].style.display = "none"; 176 } else { 177 stepsNav.sections[i].style.display = "block"; 178 }//endif 179 180 }//endfor 181 182 navBar = getObjectFromID("navSelect"); 183 for(i=0; i < navBar.options.length; i++){ 184 if(navBar.options[i].value == section){ 185 navBar.options[i].selected = true; 186 } 187 }//endfor 188 //navBar.selectedIndex = section 189 190 stepsNav.currentSection = section; 191 192 },//end function navTo 193 194 195 navLeft: function(){ 196 197 var navSelect = getObjectFromID("navSelect"); 198 stepsNav.navTo(parseInt(navSelect.value)); 199 200 9 201 } 202 10 203 } 11 204 12 function goSection(direction){ 13 var sections = getElementsByClassName("bodyline"); 14 var currSection = 1; 15 16 for(i=0; i< sections.length; i++){ 17 if(sections[i].style.display == "block") 18 currSection = parseInt(sections[i].id.substr(4),10); 19 } 20 21 if(direction == "next") 22 direction = 1; 23 else 24 direction = -1; 25 26 if(currSection + direction == 0) 27 return false; 28 else{ 29 var currDiv = getObjectFromID("step"+currSection); 30 var newDiv = getObjectFromID("step"+(currSection + direction)) 31 32 currDiv.style.display = "none"; 33 newDiv.style.display = "block"; 34 } 35 }//end function 36 37 38 function runCommand(command){ 39 var theURL="installxml.php?command="+command; 40 if(command=="updatesettings"){ 41 var mServer=getObjectFromID("mysqlserver"); 42 var mDatabase=getObjectFromID("mysqldb"); 43 var mUser=getObjectFromID("mysqluser"); 44 var mPassword=getObjectFromID("mysqluserpass"); 45 theURL+="&ms="+encodeURIComponent(mServer.value); 46 theURL+="&mdb="+encodeURIComponent(mDatabase.value); 47 theURL+="&mu="+encodeURIComponent(mUser.value); 48 theURL+="&mup="+encodeURIComponent(mPassword.value); 49 } 50 var responseText= getObjectFromID(command+"results"); 51 loadXMLDoc(theURL,null,false); 52 if(req.responseXML) 53 response = req.responseXML.documentElement.firstChild.data+"\n"; 54 else 55 response = req.responseText+"\n"; 56 responseText.value += response; 57 } 58 59 60 function changeModule(){ 61 var moduleSel=getObjectFromID("modules"); 62 var installButton=getObjectFromID("installmodule"); 63 var modinfo = getObjectFromID("moduleInformation"); 64 65 var modName = getObjectFromID("modulename"); 66 var modVer = getObjectFromID("moduleversion"); 67 var modDesc = getObjectFromID("moduledescription"); 68 var modReq = getObjectFromID("modulerequirements"); 69 70 if(moduleSel.value!=0){ 71 installButton.disabled=false; 72 73 modName.innerHTML = modules[moduleSel.value]["name"]; 74 modVer.innerHTML = modules[moduleSel.value]["version"]; 75 modDesc.innerHTML = modules[moduleSel.value]["description"]; 76 modReq.innerHTML = modules[moduleSel.value]["requirements"]; 77 78 modinfo.style.display = "block"; 79 } 80 else{ 81 installButton.disabled=true; 82 modinfo.style.display = "none"; 83 } 84 } 85 86 function runModuleInstall(){ 87 var themodule=getObjectFromID("modules"); 88 var responseText= getObjectFromID("moduleresults"); 89 if(themodule.value=="") 90 alert("You must select a module to install first."); 91 else { 92 var theURL="../modules/"+themodule.value+"/install/install.php"; 93 loadXMLDoc(theURL,null,false); 94 if(req.responseXML) 95 response = req.responseXML.documentElement.firstChild.data+"\n"; 96 else 97 response = req.responseText; 98 responseText.value+=response; 99 } 100 } 205 // ====== Init Listeners ======================================================= 206 207 connect(window,"onload",function() { 208 209 stepsNav.sections = getElementsByClassName("steps"); 210 stepsNav.navTo(1); 211 212 var nextButtons = getElementsByClassName("nextButtons"); 213 for(var i=0; i< nextButtons.length; i++) 214 connect(nextButtons[i], "onclick", stepsNav.navNext); 215 216 var prevButtons = getElementsByClassName("prevButtons"); 217 for(var i=0; i< prevButtons.length; i++) 218 connect(prevButtons[i], "onclick", stepsNav.navPrev); 219 220 var navSelect = getObjectFromID("navSelect"); 221 connect(navSelect, "onchange", stepsNav.navLeft); 222 223 var debug = getObjectFromID("debug"); 224 connect(debug, "onchange", installer.toggleDebug); 225 226 var testConnectionButton = getObjectFromID("testConnectionButton"); 227 connect(testConnectionButton, "onclick", installer.testConnection); 228 229 var createDatabaseButton = getObjectFromID("createDatabaseButton"); 230 connect(createDatabaseButton, "onclick", installer.createDatabase) 231 232 var coreDataButton = getObjectFromID("coreDataButton"); 233 connect(coreDataButton, "onclick", installer.coreDataInstall); 234 235 moduleButtons = getElementsByClassName("moduleButtons"); 236 for(i = 0; i < moduleButtons.length; i++) 237 connect(moduleButtons[i], "onclick", installer.moduleInstall); 238 239 }) -
trunk/phpbms/install/install_include.php
r448 r485 1 1 <?php 2 function processSQLfile($db,$filename){ 3 global $dblink; 4 5 $thefile = @ fopen($filename,"r"); 6 if(!$thefile) 7 return "Could not open the file ".$filename.".\n"; 8 9 $thereturn="Processing SQL from file '".$filename."'\n"; 10 while(!feof($thefile)) { 11 $sqlstatement=trim(fgets($thefile,2048)); 12 if(strrpos($sqlstatement,";")==strlen($sqlstatement)-1){ 13 $theresult=$db->query($sqlstatement); 14 if($db->error) 15 $thereturn = "Error processing SQL file ".$filename.": ".$db->error."\n".$sqlstatement; 16 $sqlstatement=""; 17 }//end if; 18 }//end while 19 20 $thereturn.="Done processing SQL from file '".$filename."'. \n\n"; 21 return $thereturn; 22 }//end function 23 24 25 function verifyAdminLogin($db,$user,$pass){ 26 27 if((real) getCurrentVersion($db,"base")>=.7) 28 $querystatement="SELECT id FROM users WHERE login=\"".mysql_real_escape_string($user)."\" AND password=encode(\"".mysql_real_escape_string($pass)."\",\"".ENCRYPTION_SEED."\") AND admin=1"; 29 else 30 $querystatement="SELECT id FROM users WHERE login=\"".mysql_real_escape_string($user)."\" AND password=encode(\"".mysql_real_escape_string($pass)."\",\"".ENCRYPTION_SEED."\") AND accesslevel>=90"; 31 32 $queryresult=$db->query($querystatement); 33 34 if(!$queryresult) 35 return false; 36 return ($db->numRows($queryresult)>0); 37 } 38 39 40 function getCurrentVersion($db,$module){ 41 42 $querystatement="SELECT version FROM modules WHERE name=\"".mysql_real_escape_string($module)."\";"; 43 $queryresult=$db->query($querystatement); 44 45 $ver=$db->fetchArray($queryresult); 46 return $ver["version"]; 47 } 48 49 50 function loadModules($type){ 51 $currdirectory = @getcwd(); 52 53 $thedir= @ opendir("../modules/"); 54 55 echo 'modules = Array();'."\n"; 56 57 $modules = array(); 58 while($entry=readdir($thedir)){ 59 if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("../modules/".$entry)){ 60 if(file_exists("../modules/".$entry."/install/".$type.".php") && file_exists("../modules/".$entry."/install/version.php")){ 61 include("../modules/".$entry."/install/version.php"); 62 } 63 } 64 } 65 66 foreach($modules as $name=>$module) 67 if(is_array($module)){ 68 echo 'modules["'.$name.'"] = Array()'."\n"; 69 foreach($module as $key=>$value) 70 echo 'modules["'.$name.'"]["'.$key.'"] = "'.$value.'";'."\n"; 71 } 72 73 @ chdir ($currdirectory); 74 75 return $modules; 76 }//end function 77 78 79 function showModules($modules){ 80 if(is_array($modules)){ 81 foreach($modules as $name => $module) 82 if($name != "base") 83 if(is_array($module)){ 84 ?><option value="<?php echo $name ?>"><?php echo $module["name"]?></option><?php 85 } 86 } 87 } 88 89 90 function createTables($db,$sqlfile){ 91 92 $sqlstatement=""; 93 $thereturn = ""; 94 95 $createfile = @ fopen("createtables.sql","r"); 96 if(!$createfile) 97 return "Could not open SQL file: ".$sqlfile; 98 else{ 99 while(!feof($createfile)) { 100 $sqlstatement.= @ fgets($createfile,1024); 101 if(strpos($sqlstatement,";")){ 102 103 $theresult = $db->query(trim($sqlstatement)); 104 105 if($db->error){ 106 return "Error creating tables: ".$db->error."\n\n".trim($sqlstatement); 107 } 108 $sqlstatement=""; 109 }//end if; 110 }//end while 111 112 }//end if 113 114 return true; 115 } 116 117 118 function importData($db,$tablename){ 119 120 $tablefile = @ fopen($tablename.".sql","rb"); 121 if(!$tablefile) 122 return "Could not open the file ".$tablename.".sql\n"; 123 124 $thereturn=""; 125 $counter=0; 126 $failure = false; 127 128 while(!feof($tablefile)) { 129 $sqlstatement=trim(fgets($tablefile,8184)); 130 if(strrpos($sqlstatement,";")==strlen($sqlstatement)-1){ 131 132 $theresult=$db->query($sqlstatement); 133 134 if($db->error){ 135 $failure = true; 136 $thereturn .= "Error importing record into ".$tablename.": ".$db->error."\n"; 137 } 2 class installer{ 3 4 var $db; 5 6 function installer($db){ 7 8 $this->db = $db; 9 10 }//end function init 11 12 13 function createTables($sqlfile){ 14 15 $sqlstatement=""; 16 $thereturn = ""; 17 $line = 1; 18 19 $filePointer = @ fopen($sqlfile,"r"); 20 21 if(!$filePointer) 22 return "Could not open SQL file: ".$sqlfile; 23 24 while(!feof($filePointer)) { 25 26 $createstatement .= @ fgets($filePointer,1024); 27 28 if(strpos($createstatement,";")){ 29 30 $this->db->query(trim($createstatement)); 31 32 if($this->db->error) 33 return "Error creating tables on line ".$line.": ".$this->db->error." SQL Statement: ".trim($createstatement); 34 35 $createstatement = ""; 36 37 }//end if; 38 39 $line++; 40 41 }//end while 42 43 return true; 44 45 }//end function createTables 46 47 48 function processSQLfile($filename){ 49 50 $thefile = @ fopen($filename,"r"); 51 $line = 1; 52 $thereturn = ""; 53 54 if(!$thefile) 55 return "Could not open the SQL file ".$filename; 56 57 while(!feof($thefile)) { 58 59 $sqlstatement .= @ trim(fgets($thefile)); 60 61 // we look for the ; at the end of the line 62 // If it is not there, we keep adding to the sql statement 63 if(strrpos($sqlstatement,";") == strlen($sqlstatement)-1){ 64 65 $this->db->query(trim($sqlstatement)); 66 if($this->db->error) 67 $thereturn .= "Error processing SQL file '".$filename."' on line ".$line.": ".$this->db->error." - SQL Statement: ".$sqlstatement."\n"; 68 69 $sqlstatement = ""; 70 71 }//end if; 72 73 $line++; 74 75 }//end while 76 77 if($thereturn) 78 return $thereturn; 138 79 else 139 $counter++; 140 141 $sqlstatement=""; 142 }//end if; 143 }//end while 144 145 if($failure) 146 $threturn = "Importing of some records in ".$tablename." occured.\n\n"; 147 else 148 $thereturn.="Import of ".$counter." record(s) for '".$tablename."' complete.\n"; 149 150 return $thereturn; 151 }//end function 80 return true; 81 82 }//end function 83 84 }//end class 85 86 87 88 class modules{ 89 90 var $list = array(); 91 92 // this loads the modules in to an array 93 // type looks for either update, to make sure the 94 // module folder has an install folder, and inside the install 95 // folder is an install.php or update .php (depending on type) 96 // and that it has a version.php file; 97 function modules($type = "install"){ 98 99 $currdirectory = @getcwd(); 100 101 $thedir= @ opendir("../modules/"); 102 103 $modules = array(); 104 105 //this helps build the modules array 106 // each included modules version.php should add to the 107 // array 108 while($entry = readdir($thedir)){ 109 110 if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("../modules/".$entry)){ 111 112 if(file_exists("../modules/".$entry."/install/".$type.".php") && file_exists("../modules/".$entry."/version.php")){ 113 114 include("../modules/".$entry."/version.php"); 115 116 }//endif 117 118 }//endif 119 120 }//end if 121 122 @ chdir ($currdirectory); 123 124 $this->list = $modules; 125 126 }//end function init 127 128 129 function displpayJS(){ 130 131 echo 'modules = Array();'."\n"; 132 133 foreach($this->list as $name=>$module) 134 if(is_array($module) && $name != "base"){ 135 136 echo 'modules["'.$name.'"] = Array()'."\n"; 137 foreach($module as $key=>$value) 138 echo 'modules["'.$name.'"]["'.$key.'"] = "'.$value.'";'."\n"; 139 }//endif 140 141 142 }//end function displayJS 143 144 145 function displayInstallTable(){ 146 147 ?> 148 <table id="moduleTable" cellpadding="0" cellspacing="0" border="0"> 149 <thead> 150 <tr> 151 <th>module</th> 152 <th>version</th> 153 <th> </th> 154 </tr> 155 </thead> 156 <tbody> 157 <?php 158 159 ksort($this->list); 160 161 foreach($this->list as $key=>$module){ 162 163 if($key != "base"){ 164 165 ?> 166 <tr> 167 <td> 168 <h3><strong><?php echo $module["name"]?></strong></h3> 169 <p><?php echo $module["description"]?></p> 170 <p class="notes"><strong>Requirements:</strong> <?php echo $module["requirements"]?></p> 171 </td> 172 <td><?php echo $module["version"] ?></td> 173 <td class="moduleInstall"> 174 <button class="Buttons moduleButtons" id="moduleButton<?php echo $key ?>">Install Module</button> 175 <p><span class="" id="Results<?php echo $key?>"></span></p> 176 </td> 177 </tr> 178 <?php 179 180 }//end if 181 182 }//end foreach 183 184 ?></tbody></table><?php 185 186 }//end function displayInstallTable 187 188 }//end class 189 190 191 192 class installUpdateBase{ 193 194 var $db; 195 var $phpbmsSession; 196 197 function returnJSON($success, $details, $extras = null){ 198 199 $thereturn["success"] = $success; 200 $thereturn["details"] = $details; 201 202 if($extras) 203 $thereturn["extras"] = $extras; 204 205 return json_encode($thereturn); 206 207 }//endfunction returnJSON 208 209 }//end class installUpdateBase 210 152 211 153 212 ?> -
trunk/phpbms/install/menu.sql
r386 r485 1 INSERT INTO `menu` (`id`, `name`, `link`, `parentid`, `displayorder`, `createdby`, `modifiedby`, `creationdate`, `modifieddate`, `roleid`) VALUES ('1', ' Organizer', '', '0', '3', '1', '1', NOW(), NOW(), '0');1 INSERT INTO `menu` (`id`, `name`, `link`, `parentid`, `displayorder`, `createdby`, `modifiedby`, `creationdate`, `modifieddate`, `roleid`) VALUES ('1', 'Tools', '', '0', '3', '1', '1', NOW(), NOW(), '0'); 2 2 INSERT INTO `menu` (`id`, `name`, `link`, `parentid`, `displayorder`, `createdby`, `modifiedby`, `creationdate`, `modifieddate`, `roleid`) VALUES ('2', 'Notes', 'search.php?id=12', '1', '1', '1', '1', NOW(), NOW(), '0'); 3 3 INSERT INTO `menu` (`id`, `name`, `link`, `parentid`, `displayorder`, `createdby`, `modifiedby`, `creationdate`, `modifieddate`, `roleid`) VALUES ('3', 'Tasks', 'search.php?id=23', '1', '2', '1', '1', NOW(), NOW(), '0'); -
trunk/phpbms/install/notes.sql
r308 r485 1 1 INSERT INTO `notes` (`assignedtoid`, `attachedid`, `attachedtabledefid`, `content`, `assignedtodate`, `subject`, `type`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`, `importance`, `parentid`, `startdate`, `enddate`, `completed`, `private`, `status`, `completeddate`, `location`, `category`, `assignedtotime`, `starttime`, `endtime`, `assignedbyid`, `repeating`, `repeattype`, `repeatuntil`, `repeatevery`, `repeattimes`, `repeateachlist`, `repeatontheday`, `repeatontheweek`, `firstrepeat`, `lastrepeat`, `timesrepeated`, `repeatname`) VALUES (NULL,NULL,NULL,'For more help using this software use the following links:\r\n\r\nhttp://www.phpbms.org - community site and wiki.\r\n\r\nhttp://www.phpbms.org/forum -user support forum.\r\n\r\nhttp://www.kreotek.com - paid support and customization.',NULL,'Welcome to phpBMS','SM',1,NOW(),1,NOW(),0,NULL,NULL,NULL,0,0,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0,0,'Daily',NULL,1,NULL,NULL,NULL,NULL,NULL,NULL,0,NULL); 2 INSERT INTO `notes` (`assignedtoid`, `attachedid`, `attachedtabledefid`, `content`, `assignedtodate`, `subject`, `type`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`, `importance`, `parentid`, `startdate`, `enddate`, `completed`, `private`, `status`, `completeddate`, `location`, `category`, `assignedtotime`, `starttime`, `endtime`, `assignedbyid`, `repeating`, `repeattype`, `repeatuntil`, `repeatevery`, `repeattimes`, `repeateachlist`, `repeatontheday`, `repeatontheweek`, `firstrepeat`, `lastrepeat`, `timesrepeated`, `repeatname`) VALUES (NULL, NULL, NULL, '1) From the menu, navigate to Tools->Notes.\r\n2) From the find drop down, choose \'System Messages\' and then click the search button.\r\n3) Select the record(s) you want to delete and then click the delete (-) button.', NULL, 'How To Delete System Messages', 'SM', 1, NOW(), 1, NOW(), '0', NULL, NULL, NULL, '0', '0', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '0', '0', 'Daily', NULL, '1', NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL); -
trunk/phpbms/install/scheduler.sql
r427 r485 1 INSERT INTO `scheduler` (`name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('clean import files', '/scheduler_delete_tempimport.php', '30::*::*::*::*', NULL, NOW(), NULL, 'This will delete any temporary import files that are present (for whatever reason) after 30 minutes of their creation.', '0', 1, NOW(), 1, NOW()); 1 INSERT INTO `scheduler` (`name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Clean Import Files', './scheduler_delete_tempimport.php', '30::*::*::*::*', NULL, NOW(), NULL, 'This will delete any temporary import files that are present (for whatever reason) after 30 minutes of their creation.', '0', 1, NOW(), 1, NOW()); 2 INSERT INTO `scheduler` (`id`, `name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Remove Excess System Log Records', './scheduler_delete_logs.php', '*::24::*::*::*', NULL, '2009-03-31 12:00:00', NULL, 'This script will trim the system log when there are more than 2000 records present at the time of its calling (default will be every 24 hours).', '0', 1, NOW(), 1, NOW()); -
trunk/phpbms/install/tablecolumns.sql
r384 r485 1 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 9,'log in name','users.login','left','',1,'',0,'',NULL,0);2 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 9,'name','concat(users.firstname,\" \",users.lastname)','left','',0,'',0,'100%',NULL,0);3 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 9,'last login','users.lastlogin','left','',3,'',0,'','datetime',0);4 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 9,'revoked','users.revoked','center','',2,'',0,'','boolean',0);5 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 10,'name','relationships.name','left','',0,'',0,'100%',NULL,0);6 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 10,'to','concat(totable.maintable, \'.\', relationships.tofield)','left','',2,'',0,'',NULL,0);7 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 10,'from','concat(fromtable.maintable, \'.\', relationships.fromfield)','left','',1,'',0,'',NULL,0);8 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 10,'inherent','relationships.inherint','center','',3,'',0,'','boolean',0);9 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 11,'id','tabledefs.id','center','',0,'',0,'',NULL,0);10 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 11,'main table','tabledefs.maintable','left','',3,'',0,'',NULL,0);11 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 11,'display','tabledefs.displayname','left','',1,'',0,'100%',NULL,0);12 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 11,'type','tabledefs.type','center','',2,'',0,'',NULL,0);13 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 12,'done','notes.completed','center','',1,'',0,'','boolean',0);14 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 12,'title','notes.subject','left','',0,'',1,'99%',NULL,0);15 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 16,'id','reports.id','center','',0,'',0,'',NULL,0);16 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 16,'name','reports.name','left','',1,'',0,'100%','noencoding',0);17 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 16,'type','reports.type','left','',3,'',0,'',NULL,0);18 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 16,'order','reports.displayorder','center','',2,'',0,'',NULL,0);19 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 17,'id','usersearches.id','center','',0,'',0,'',NULL,0);20 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 17,'name','usersearches.name','left','',1,'',0,'100%',NULL,0);21 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 17,'user','if(usersearches.userid=0,\"<b>global</b>\",concat(users.lastname,\", \",users.firstname))','left','',2,NULL,0,'','noencoding',0);22 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 19,'id','menu.id','center','',0,'',0,'',NULL,0);23 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 19,'link','menu.link','left','',2,'',1,'',NULL,0);24 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 19,'access','if(menu.roleid=0,\'EVERYONE\',if(menu.roleid=-100,\'Administrators\',roles.name))','left','',3,'',0,'',NULL,0);25 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 19,'Item','menu.name','left','',1,'',0,'100%',NULL,0);26 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 21,'id','modules.id','center','',0,'',0,'',NULL,0);27 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 21,'name','modules.displayname','left','',1,'',1,'100%',NULL,0);28 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 21,'version','modules.version','left','',2,'',0,'',NULL,0);29 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 23,'complete','notes.completed','center','',1,'',0,'','boolean',0);30 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 23,'title','notes.subject','left','',2,'',1,'65%',NULL,0);31 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 23,'repeat','notes.repeatname','left','',3,'',1,'30%',NULL,0);32 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 23,'due date','if(notes.endtime is not null,concat(notes.enddate,\" \",notes.endtime),notes.enddate)','left','',0,'',0,'','datetime',0);33 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'start','if(notes.starttime,concat(notes.startdate,\" \",notes.starttime),notes.startdate)','left','',0,'concat(notes.startdate,\" \",notes.starttime)',0,'','datetime',0);34 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'end','if(notes.endtime,concat(notes.enddate,\" \",notes.endtime),notes.enddate)','left','',1,'concat(notes.enddate,\" \",notes.endtime)',0,'','datetime',0);35 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'title','notes.subject','left','',2,'',1,'65%',NULL,0);36 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'status','notes.status','left','',3,'',0,'',NULL,0);37 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'repeating','notes.repeatname','left','',5,'',1,'30%',NULL,0);38 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 24,'location','notes.location','left','',4,'',1,'',NULL,0);39 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 26,'id','files.id','left','',0,'',0,'',NULL,0);40 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 26,'description','files.description','left','',2,'',1,'99%',NULL,0);41 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 26,'file','files.name','left','',1,'',0,'',NULL,0);42 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 26,'download','files.id','center','',3,'',0,'','filelink',0);43 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 27,'attached','attachments.creationdate','left','',2,'',0,'','datetime',0);44 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 27,'file','concat(\"<b>\",files.name,\"</b>\")','left','',0,NULL,0,'','noencoding',0);45 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 27,'download','files.id','center','',3,'',0,'','filelink',0);46 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 27,'description','files.description','left','',1,'',1,'100%',NULL,0);47 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 200,'name','roles.name','left','',1,'',0,'99%',NULL,0);48 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 200,'inactive','roles.inactive','center','',2,'',0,'','boolean',0);49 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 200,'id','roles.id','left','',0,'',0,'',NULL,0);50 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 201,'name','scheduler.name','left','',0,'',0,'95%',NULL,0);51 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 201,'cron interval','scheduler.crontab','left','',1,'',0,'',NULL,0);52 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 201,'inactive','scheduler.inactive','center','',2,'',0,'','boolean',0);53 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'time','log.stamp','left','',1,'',0,'','datetime',0);54 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'id','log.id','left','',0,'',0,'',NULL,0);55 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'type','log.type','left','',2,'',0,'',NULL,0);56 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'value','log.value','left','',3,'',1,'90%',NULL,0);57 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'user','concat(users.firstname,\" \",users.lastname)','left','',4,'',0,'',NULL,0);58 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 202,'ip address','log.ip','left','',5,'',0,'',NULL,0);59 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 203,'name','tabs.name','left','',1,'',0,'',NULL,0);60 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 203,'location','tabs.location','left','',2,'',1,'95%',NULL,0);61 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 203,'display order','tabs.displayorder','center','',3,'',0,'',NULL,0);62 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 203,'id','tabs.id','left','',0,'',0,'',NULL,0);63 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 203,'access','if(tabs.roleid=0,\'EVERYONE\',if(tabs.roleid=-100,\'Administrators\',roles.name))','left','',4,'',0,'',NULL,0);1 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('9', 'log in name', 'users.login', 'left', '', '1', '', '0', '', NULL, '0'); 2 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('9', 'name', 'concat(users.firstname,\" \",users.lastname)', 'left', '', '0', '', '0', '100%', NULL, '0'); 3 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('9', 'last login', 'users.lastlogin', 'left', '', '3', '', '0', '', 'datetime', '0'); 4 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('9', 'revoked', 'users.revoked', 'center', '', '2', '', '0', '', 'boolean', '0'); 5 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('10', 'name', 'relationships.name', 'left', '', '0', '', '0', '100%', NULL, '0'); 6 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('10', 'to', 'concat(totable.maintable, \'.\', relationships.tofield)', 'left', '', '2', '', '0', '', NULL, '0'); 7 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('10', 'from', 'concat(fromtable.maintable, \'.\', relationships.fromfield)', 'left', '', '1', '', '0', '', NULL, '0'); 8 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('10', 'inherent', 'relationships.inherint', 'center', '', '3', '', '0', '', 'boolean', '0'); 9 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('11', 'id', 'tabledefs.id', 'center', '', '0', '', '0', '', NULL, '0'); 10 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('11', 'main table', 'tabledefs.maintable', 'left', '', '3', '', '0', '', NULL, '0'); 11 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('11', 'display', 'tabledefs.displayname', 'left', '', '1', '', '0', '100%', NULL, '0'); 12 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('11', 'type', 'tabledefs.type', 'center', '', '2', '', '0', '', NULL, '0'); 13 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('12', 'done', 'notes.completed', 'center', '', '1', '', '0', '', 'boolean', '0'); 14 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('12', 'title', 'notes.subject', 'left', '', '0', '', '1', '99%', NULL, '0'); 15 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('16', 'id', 'reports.id', 'center', '', '0', '', '0', '', NULL, '0'); 16 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('16', 'name', 'reports.name', 'left', '', '1', '', '0', '100%', 'noencoding', '0'); 17 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('16', 'type', 'reports.type', 'left', '', '3', '', '0', '', NULL, '0'); 18 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('16', 'order', 'reports.displayorder', 'center', '', '2', '', '0', '', NULL, '0'); 19 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('17', 'id', 'usersearches.id', 'center', '', '0', '', '0', '', NULL, '0'); 20 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('17', 'name', 'usersearches.name', 'left', '', '1', '', '0', '100%', NULL, '0'); 21 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('17', 'user', 'if(usersearches.userid=0,\"<b>global</b>\",concat(users.lastname,\", \",users.firstname))', 'left', '', '2', NULL, '0', '', 'noencoding', '0'); 22 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('19', 'id', 'menu.id', 'center', '', '0', '', '0', '', NULL, '0'); 23 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('19', 'link', 'menu.link', 'left', '', '2', '', '1', '', NULL, '0'); 24 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('19', 'access', 'if(menu.roleid=0,\'EVERYONE\',if(menu.roleid=-100,\'Administrators\',roles.name))', 'left', '', '3', '', '0', '', NULL, '0'); 25 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('19', 'Item', 'menu.name', 'left', '', '1', '', '0', '100%', NULL, '0'); 26 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('21', 'id', 'modules.id', 'center', '', '0', '', '0', '', NULL, '0'); 27 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('21', 'name', 'modules.displayname', 'left', '', '1', '', '1', '100%', NULL, '0'); 28 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('21', 'version', 'modules.version', 'left', '', '2', '', '0', '', NULL, '0'); 29 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('23', 'complete', 'notes.completed', 'center', '', '1', '', '0', '', 'boolean', '0'); 30 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('23', 'title', 'notes.subject', 'left', '', '2', '', '1', '65%', NULL, '0'); 31 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('23', 'repeat', 'notes.repeatname', 'left', '', '3', '', '1', '30%', NULL, '0'); 32 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('23', 'due date', 'if(notes.endtime is not null,concat(notes.enddate,\" \",notes.endtime),notes.enddate)', 'left', '', '0', '', '0', '', 'datetime', '0'); 33 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'start', 'if(notes.starttime,concat(notes.startdate,\" \",notes.starttime),notes.startdate)', 'left', '', '0', 'concat(notes.startdate,\" \",notes.starttime)', '0', '', 'datetime', '0'); 34 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'end', 'if(notes.endtime,concat(notes.enddate,\" \",notes.endtime),notes.enddate)', 'left', '', '1', 'concat(notes.enddate,\" \",notes.endtime)', '0', '', 'datetime', '0'); 35 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'title', 'notes.subject', 'left', '', '2', '', '1', '65%', NULL, '0'); 36 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'status', 'notes.status', 'left', '', '3', '', '0', '', NULL, '0'); 37 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'repeating', 'notes.repeatname', 'left', '', '5', '', '1', '30%', NULL, '0'); 38 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('24', 'location', 'notes.location', 'left', '', '4', '', '1', '', NULL, '0'); 39 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('26', 'id', 'files.id', 'left', '', '0', '', '0', '', NULL, '0'); 40 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('26', 'description', 'files.description', 'left', '', '2', '', '1', '99%', NULL, '0'); 41 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('26', 'file', 'files.name', 'left', '', '1', '', '0', '', NULL, '0'); 42 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('26', 'download', 'files.id', 'center', '', '3', '', '0', '', 'filelink', '0'); 43 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('27', 'attached', 'attachments.creationdate', 'left', '', '2', '', '0', '', 'datetime', '0'); 44 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('27', 'file', 'concat(\"<b>\",files.name,\"</b>\")', 'left', '', '0', NULL, '0', '', 'noencoding', '0'); 45 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('27', 'download', 'files.id', 'center', '', '3', '', '0', '', 'filelink', '0'); 46 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('27', 'description', 'files.description', 'left', '', '1', '', '1', '100%', NULL, '0'); 47 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('200', 'name', 'roles.name', 'left', '', '1', '', '0', '99%', NULL, '0'); 48 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('200', 'inactive', 'roles.inactive', 'center', '', '2', '', '0', '', 'boolean', '0'); 49 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('200', 'id', 'roles.id', 'left', '', '0', '', '0', '', NULL, '0'); 50 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('201', 'name', 'scheduler.name', 'left', '', '0', '', '0', '95%', NULL, '0'); 51 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('201', 'cron interval', 'scheduler.crontab', 'left', '', '1', '', '0', '', NULL, '0'); 52 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('201', 'inactive', 'scheduler.inactive', 'center', '', '2', '', '0', '', 'boolean', '0'); 53 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'time', 'log.stamp', 'left', '', '1', '', '0', '', 'datetime', '0'); 54 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'id', 'log.id', 'left', '', '0', '', '0', '', NULL, '0'); 55 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'type', 'log.type', 'left', '', '2', '', '0', '', NULL, '0'); 56 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'value', 'log.value', 'left', '', '3', '', '1', '90%', NULL, '0'); 57 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'user', 'concat(users.firstname,\" \",users.lastname)', 'left', '', '4', '', '0', '', NULL, '0'); 58 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('202', 'ip address', 'log.ip', 'left', '', '5', '', '0', '', NULL, '0'); 59 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('203', 'name', 'tabs.name', 'left', '', '1', '', '0', '', NULL, '0'); 60 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('203', 'location', 'tabs.location', 'left', '', '2', '', '1', '95%', NULL, '0'); 61 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('203', 'display order', 'tabs.displayorder', 'center', '', '3', '', '0', '', NULL, '0'); 62 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('203', 'id', 'tabs.id', 'left', '', '0', '', '0', '', NULL, '0'); 63 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('203', 'access', 'if(tabs.roleid=0,\'EVERYONE\',if(tabs.roleid=-100,\'Administrators\',roles.name))', 'left', '', '4', '', '0', '', NULL, '0'); 64 64 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('204', 'name', 'smartsearches.name', 'left', '', '0', '', '1', '99%', NULL, '0'); 65 65 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('204', 'table', 'tabledefs.displayname', 'left', '', '1', '', '0', '', NULL, '0'); -
trunk/phpbms/install/tabledefs.sql
r427 r485 1 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('9', 'Users', 'system', '1', 'users', 'users', 'modules/base/users_addedit.php', '0', 'modules/base/users_addedit.php', '0', 'modules/base/users_import.php', '-100', '0', '-100', '-100', 'revoke', 'users.id !=0', 'users.id', NULL, NULL, NULL, 1, NOW(), 1, NOW());2 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('10', 'Relationships', 'system', '1', 'relationships', '(relationships inner join tabledefs as fromtable on relationships.fromtableid=fromtable.id) inner join tabledefs as totable on relationships.totableid=totable.id', 'modules/base/relationships_addedit.php', '0', 'modules/base/relationships_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'relationships.id != 0', 'fromtable.displayname, name', '', '', '', 1, NOW(), 1, NOW());3 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('11', 'Table Definitions', 'system', '1', 'tabledefs', 'tabledefs left join modules on tabledefs.moduleid=modules.id', 'modules/base/tabledefs_addedit.php', '-100', 'modules/base/tabledefs_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'tabledefs.id != 0', 'modules.name, tabledefs.displayname', '', '', '', 1, NOW(), 1, NOW());1 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('9', 'Users', 'system', '1', 'users', 'users', 'modules/base/users_addedit.php', '0', 'modules/base/users_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'revoke', 'users.id !=0', 'users.id', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 2 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('10', 'Relationships', 'system', '1', 'relationships', '(relationships inner join tabledefs as fromtable on relationships.fromtableid=fromtable.id) inner join tabledefs as totable on relationships.totableid=totable.id', 'modules/base/relationships_addedit.php', '0', 'modules/base/relationships_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'relationships.id != 0', 'fromtable.displayname, name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 3 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('11', 'Table Definitions', 'system', '1', 'tabledefs', 'tabledefs left join modules on tabledefs.moduleid=modules.id', 'modules/base/tabledefs_addedit.php', '-100', 'modules/base/tabledefs_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'tabledefs.id != 0', 'modules.name, tabledefs.displayname', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 4 4 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('12', 'Notes', 'table', '1', 'notes', 'notes', 'modules/base/notes_addedit.php', '0', 'modules/base/notes_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'notes.type=\'NT\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0', 'notes.category,notes.type,notes.importance DESC,notes.creationdate', 'search', 'My Unread Notes', 'new', 1, NOW(), 1, NOW()); 5 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('16', 'Reports', 'system', '1', 'reports', 'reports left join tabledefs on reports.tabledefid=tabledefs.id', 'modules/base/reports_addedit.php', '0', 'modules/base/reports_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'reports.id != 0', 'tabledefid,displayorder DESC, reports.name', '', '', '', 1, NOW(), 1, NOW());6 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('17', 'Saved Searches/Sorts', 'system', '1', 'usersearches', '(usersearches left join users on usersearches.userid = users.id) inner join tabledefs on usersearches.tabledefid=tabledefs.id', 'modules/base/usersearches_edit.php', '0', 'N/A', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'usersearches.id != 0', 'usersearches.name', '', '', '', 1, NOW(), 1, NOW());7 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('19', 'Menu', 'system', '1', 'menu', '((menu LEFT JOIN menu as parentmenu on menu.parentid=parentmenu.id) LEFT JOIN roles on menu.roleid=roles.id)', 'modules/base/menu_addedit.php', '-100', 'modules/base/menu_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'menu.id!=0', 'if(parentmenu.name is null,menu.displayorder,parentmenu.displayorder+(menu.displayorder+1)/10000)', '', '', '', 1, NOW(), 1, NOW());5 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('16', 'Reports', 'system', '1', 'reports', 'reports left join tabledefs on reports.tabledefid=tabledefs.id', 'modules/base/reports_addedit.php', '0', 'modules/base/reports_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'reports.id != 0', 'tabledefid,displayorder DESC, reports.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 6 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('17', 'Saved Searches/Sorts', 'system', '1', 'usersearches', '(usersearches left join users on usersearches.userid = users.id) inner join tabledefs on usersearches.tabledefid=tabledefs.id', 'modules/base/usersearches_edit.php', '0', 'N/A', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'usersearches.id != 0', 'usersearches.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 7 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('19', 'Menu', 'system', '1', 'menu', '((menu LEFT JOIN menu as parentmenu on menu.parentid=parentmenu.id) LEFT JOIN roles on menu.roleid=roles.id)', 'modules/base/menu_addedit.php', '-100', 'modules/base/menu_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'menu.id!=0', 'if(parentmenu.name is null,menu.displayorder,parentmenu.displayorder+(menu.displayorder+1)/10000)', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 8 8 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('21', 'Installed Modules', 'system', '1', 'modules', 'modules', 'modules/base/modules_view.php', '0', 'modules/base/modules_view.php', '0', NULL, '-100', '0', '-100', '-100', 'NA', 'modules.id!=0', 'modules.name', '', '', '', 1, NOW(), 1, NOW()); 9 9 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('23', 'Tasks', 'view', '1', 'notes', '((notes left join users as assignedto on assignedto.id= notes.assignedtoid) left join users as assignedby on assignedby.id=notes.assignedbyid)', 'modules/base/notes_addedit.php?backurl=../../search.php?id=23', '0', 'modules/base/notes_addedit.php?ty=TS&backurl=../../search.php?id=23', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'notes.type=\'TS\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0', 'notes.category,notes.enddate,notes.endtime,notes.startdate,notes.starttime,notes.importance DESC,notes.subject', 'search', 'My Uncompleted Tasks', '', 1, NOW(), 1, NOW()); 10 10 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('24', 'Events', 'view', '1', 'notes', '((notes left join users as assignedto on assignedto.id= notes.assignedtoid) left join users as assignedby on assignedby.id=notes.assignedbyid)', 'modules/base/notes_addedit.php?backurl=../../search.php?id=24', '0', 'modules/base/notes_addedit.php?ty=EV&backurl=../../search.php?id=24', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(curdate()) and week(notes.startdate)=week(curdate())))', 'notes.startdate DESC,notes.starttime DESC,notes.enddate DESC,notes.endtime DESC,notes.importance', 'search', NULL, NULL, 1, NOW(), 1, NOW()); 11 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('26', 'Files', 'table', '1', 'files', 'files', 'modules/base/files_addedit.php', '0', 'modules/base/files_addedit.php', '0', NULL, '-100', '-100', '-100', '-100', 'delete', 'files.id=-1', 'files.name', 'search', '', '', 1, NOW(), 1, NOW());11 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('26', 'Files', 'table', '1', 'files', 'files', 'modules/base/files_addedit.php', '0', 'modules/base/files_addedit.php', '0', NULL, '-100', '-100', '-100', '-100', 'delete', 'files.id=-1', 'files.name', 'search', NULL, NULL, 1, NOW(), 1, NOW()); 12 12 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('27', 'Attachments', 'table', '1', 'attachments', '(attachments INNER JOIN files on attachments.fileid=files.id)', 'modules/base/files_addedit.php', '0', 'modules/base/files_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'delete', 'attachments.id!=0', 'attachments.creationdate DESC', 'search', '', '', 1, NOW(), 1, NOW()); 13 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('200', 'Roles', 'table', '1', 'roles', 'roles', 'modules/base/roles_addedit.php', '-100', 'modules/base/roles_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'inactivate', 'roles.id!=-1', 'name', 'search', '', '', 1, NOW(), 1, NOW());14 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('201', 'Scheduler', 'system', '1', 'scheduler', 'scheduler', 'modules/base/scheduler_addedit.php', '-100', 'modules/base/scheduler_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'scheduler.id!=0', 'scheduler.name', '', '', '', 1, NOW(), 1, NOW());13 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('200', 'Roles', 'table', '1', 'roles', 'roles', 'modules/base/roles_addedit.php', '-100', 'modules/base/roles_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'inactivate', 'roles.id!=-1', 'name', 'search', NULL, NULL, 1, NOW(), 1, NOW()); 14 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('201', 'Scheduler', 'system', '1', 'scheduler', 'scheduler', 'modules/base/scheduler_addedit.php', '-100', 'modules/base/scheduler_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'scheduler.id!=0', 'scheduler.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 15 15 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('202', 'System Log', 'system', '1', 'log', 'log LEFT JOIN users ON log.userid=users.id', 'N/A', '-100', 'N/A', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'log.stamp> DATE_SUB(CURDATE(),INTERVAL 1 DAY)', 'log.stamp', '', '', '', 1, NOW(), 1, NOW()); 16 16 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('203', 'Tabs', 'system', '1', 'tabs', 'tabs LEFT JOIN roles ON tabs.roleid=roles.id', 'modules/base/tabs_addedit.php', '-100', 'modules/base/tabs_addedit.php', '-100', NULL, '-100', '-100', '-100', '-100', 'delete', 'tabs.id!=0', 'tabs.tabgroup,tabs.displayorder', '', '', '', 1, NOW(), 1, NOW()); -
trunk/phpbms/install/tablefindoptions.sql
r384 r485 1 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (3,9,'All Users','users.id!=0',1,0);2 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (4,9,'Revoked Users','users.revoked=1',1,0);3 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (13,10,'All Records','relationships.id !=0',1,0);4 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (5,11,'All Records','tabledefs.id !=0',1,0);5 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (70,12,'Unread Notes Assigned By Me','notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',3,0);6 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (69,12,'Unread Notes Assigned To Me','notes.type=\'NT\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',2,0);7 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (20,12,'My Notes','notes.type=\'NT\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}',1,0);8 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (21,12,'All Viewable Notes and System Notes','notes.type=\'SM\' OR ( notes.type=\'NT\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}}))',7,0);9 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (14,16,'All Reports','reports.id != 0',1,0);10 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (15,17,'All Records','usersearches.id != 0',1,0);11 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (42,19,'All Records','menu.id!=0',1,0);12 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (43,21,'All Records','modules.id!=0',1,0);13 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (71,12,'System Messages','notes.type=\"SM\"',4,0);14 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (72,12,'Public Notes','notes.type=\'NT\' AND notes.private=0',6,0);15 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (73,12,'My Unread Notes','notes.type=\'NT\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0',0,0);16 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (74,12,'Public Unread Notes','notes.type=\'NT\' AND notes.private=0 AND notes.completed=0',5,0);17 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (76,23,'My Uncompleted Tasks','notes.type=\'TS\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0',0,0);18 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (77,23,'My Tasks','notes.type=\'TS\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}',1,0);19 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (78,23,'Uncomplete Tasks Assigned To Me','notes.type=\'TS\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',2,0);20 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (79,23,'Uncomplete Tasks Assigned By Me','notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',3,0);21 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (80,23,'Public Uncomplete Tasks','notes.type=\'TS\' AND notes.private=0 AND notes.completed=0',4,0);22 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (81,23,'Public Tasks','notes.type=\'NT\' AND notes.private=0',5,0);23 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (82,23,'All Viewable Tasks','notes.type=\'TS\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}})',6,0);24 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (83,24,'My Events','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}',0,0);25 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (84,24,'Public Events','notes.type=\'EV\' AND notes.private=0',8,0);26 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (85,24,'Undone Events Assigned To Me','notes.type=\'EV\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',17,0);27 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (86,24,'Undone Events Assigned By Me','notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0',16,0);28 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (87,24,'All Viewable Events','notes.type=\'EV\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}})',18,0);29 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (88,24,'My Events - Today','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = curdate()) OR notes.`repeat`=1)',1,0);30 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (89,24,'My Events - Yesterday','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = date_sub(curdate(),INTERVAL 1 DAY)) OR notes.`repeat`=1)',2,0);31 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (90,24,'My Events - This Week','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(curdate()) and week(notes.startdate)=week(curdate())) OR notes.repeat=1)',4,0);32 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (91,24,'My Events - This Month','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(curdate()) and month(notes.startdate)=month(curdate())) OR notes.repeat=1)',6,0);33 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (92,24,'My Events - Tomorrow','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND (notes.startdate = date_add(curdate(),INTERVAL 1 DAY) OR notes.repeat=1)',3,0);34 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (93,24,'My Events - Next Month','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 MONTH)) and month(notes.startdate)=month(date_add(curdate(),INTERVAL 1 MONTH))) OR notes.repeat=1)',7,0);35 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (94,24,'My Events - Next Week','notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 WEEK)) and week(notes.startdate)=week(date_add(curdate(),INTERVAL 1 WEEK))) OR notes.repeat=1)',5,0);36 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (95,24,'Public Events - Today','notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = curdate()) OR notes.repeat=1)',9,0);37 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (96,24,'Public Events - Yesterday','notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = date_sub(curdate(),INTERVAL 1 DAY)) OR notes.repeat=1)',10,0);38 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (97,24,'Public Events - Tomorrow','notes.type=\'EV\' AND notes.private=0 AND (notes.startdate = date_add(curdate(),INTERVAL 1 DAY) OR notes.repeat=1)',11,0);39 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (98,24,'Public Events - This Week','notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(curdate()) and week(notes.startdate)=week(curdate())) OR notes.repeat=1)',12,0);40 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (99,24,'Public Events - Next Week','notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 WEEK)) and week(notes.startdate)=week(date_add(curdate(),INTERVAL 1 WEEK))) OR notes.repeat=1)',13,0);41 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (100,24,'Public Events - This Month','notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(curdate()) and month(notes.startdate)=month(curdate())) OR notes.repeat=1)',14,0);42 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (101,24,'Public Events - Next Month','notes.type=\'EV\' notes.private=0 AND ((year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 MONTH)) and month(notes.startdate)=month(date_add(curdate(),INTERVAL 1 MONTH))) OR notes.repeat=1)',15,0);43 INSERT INTO `tablefindoptions` (` id`, `tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES (108,26,'All Records','files.id!=0',0,0);44 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 200,'Active Roles','roles.inactive=0',0,0);45 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 200,'Inactive Roles','roles.inactive=1',1,0);46 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 200,'All Records','roles.id!=-100',2,0);47 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 201,'all records','scheduler.id!=0',0,0);48 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 202,'entries within last day','log.stamp> DATE_SUB(CURDATE(),INTERVAL 1 DAY)',0,0);49 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 202,'entries within last week','log.stamp> DATE_SUB(CURDATE(),INTERVAL 1 WEEK)',1,0);50 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 202,'all entries','log.id!=-1',2,0);51 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ( 203,'All Records','tabs.id!=-1',0,-100);1 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('9', 'All Users', 'users.id!=0', '1', '0'); 2 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('9', 'Revoked Users', 'users.revoked=1', '1', '0'); 3 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('10', 'All Records', 'relationships.id !=0', '1', '0'); 4 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('11', 'All Records', 'tabledefs.id !=0', '1', '0'); 5 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'My Notes', 'notes.type=\'NT\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}', '1', '0'); 6 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'All Viewable Notes and System Notes', 'notes.type=\'SM\' OR ( notes.type=\'NT\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}}))', '7', '0'); 7 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'Unread Notes Assigned To Me', 'notes.type=\'NT\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '2', '0'); 8 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'Unread Notes Assigned By Me', 'notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '3', '0'); 9 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'System Messages', 'notes.type=\"SM\"', '4', '0'); 10 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'Public Notes', 'notes.type=\'NT\' AND notes.private=0', '6', '0'); 11 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'My Unread Notes', 'notes.type=\'NT\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0', '0', '0'); 12 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('12', 'Public Unread Notes', 'notes.type=\'NT\' AND notes.private=0 AND notes.completed=0', '5', '0'); 13 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('16', 'All Reports', 'reports.id != 0', '1', '0'); 14 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('17', 'All Records', 'usersearches.id != 0', '1', '0'); 15 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('19', 'All Records', 'menu.id!=0', '1', '0'); 16 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('21', 'All Records', 'modules.id!=0', '1', '0'); 17 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'My Uncompleted Tasks', 'notes.type=\'TS\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND completed=0', '0', '0'); 18 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'My Tasks', 'notes.type=\'TS\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}', '1', '0'); 19 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'Uncomplete Tasks Assigned To Me', 'notes.type=\'TS\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '2', '0'); 20 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'Uncomplete Tasks Assigned By Me', 'notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '3', '0'); 21 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'Public Uncomplete Tasks', 'notes.type=\'TS\' AND notes.private=0 AND notes.completed=0', '4', '0'); 22 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'Public Tasks', 'notes.type=\'NT\' AND notes.private=0', '5', '0'); 23 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('23', 'All Viewable Tasks', 'notes.type=\'TS\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}})', '6', '0'); 24 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}}', '0', '0'); 25 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events', 'notes.type=\'EV\' AND notes.private=0', '8', '0'); 26 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Undone Events Assigned To Me', 'notes.type=\'EV\' and notes.assignedtoid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '17', '0'); 27 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Undone Events Assigned By Me', 'notes.type=\'NT\' and notes.assignedbyid={{$_SESSION[\'userinfo\'][\'id\']}} and notes.completed=0', '16', '0'); 28 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'All Viewable Events', 'notes.type=\'EV\' AND !(notes.private=1 AND notes.createdby!={{$_SESSION[\'userinfo\'][\'id\']}})', '18', '0'); 29 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - Today', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = curdate()) OR notes.`repeat`=1)', '1', '0'); 30 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - Yesterday', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = date_sub(curdate(),INTERVAL 1 DAY)) OR notes.`repeat`=1)', '2', '0'); 31 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - This Week', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(curdate()) and week(notes.startdate)=week(curdate())) OR notes.repeat=1)', '4', '0'); 32 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - This Month', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(curdate()) and month(notes.startdate)=month(curdate())) OR notes.repeat=1)', '6', '0'); 33 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - Tomorrow', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND (notes.startdate = date_add(curdate(),INTERVAL 1 DAY) OR notes.repeat=1)', '3', '0'); 34 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - Next Month', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 MONTH)) and month(notes.startdate)=month(date_add(curdate(),INTERVAL 1 MONTH))) OR notes.repeat=1)', '7', '0'); 35 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'My Events - Next Week', 'notes.type=\'EV\' AND notes.createdby = {{$_SESSION[\'userinfo\'][\'id\']}} AND ((notes.startdate = year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 WEEK)) and week(notes.startdate)=week(date_add(curdate(),INTERVAL 1 WEEK))) OR notes.repeat=1)', '5', '0'); 36 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - Today', 'notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = curdate()) OR notes.repeat=1)', '9', '0'); 37 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - Yesterday', 'notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = date_sub(curdate(),INTERVAL 1 DAY)) OR notes.repeat=1)', '10', '0'); 38 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - Tomorrow', 'notes.type=\'EV\' AND notes.private=0 AND (notes.startdate = date_add(curdate(),INTERVAL 1 DAY) OR notes.repeat=1)', '11', '0'); 39 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - This Week', 'notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(curdate()) and week(notes.startdate)=week(curdate())) OR notes.repeat=1)', '12', '0'); 40 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - Next Week', 'notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 WEEK)) and week(notes.startdate)=week(date_add(curdate(),INTERVAL 1 WEEK))) OR notes.repeat=1)', '13', '0'); 41 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - This Month', 'notes.type=\'EV\' AND notes.private=0 AND ((notes.startdate = year(notes.startdate)=year(curdate()) and month(notes.startdate)=month(curdate())) OR notes.repeat=1)', '14', '0'); 42 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('24', 'Public Events - Next Month', 'notes.type=\'EV\' notes.private=0 AND ((year(notes.startdate)=year(date_add(curdate(),INTERVAL 1 MONTH)) and month(notes.startdate)=month(date_add(curdate(),INTERVAL 1 MONTH))) OR notes.repeat=1)', '15', '0'); 43 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('26', 'All Records', 'files.id!=0', '0', '0'); 44 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('200', 'Active Roles', 'roles.inactive=0', '0', '0'); 45 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('200', 'Inactive Roles', 'roles.inactive=1', '1', '0'); 46 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('200', 'All Records', 'roles.id!=-100', '2', '0'); 47 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('201', 'all records', 'scheduler.id!=0', '0', '0'); 48 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('202', 'entries within last day', 'log.stamp> DATE_SUB(CURDATE(),INTERVAL 1 DAY)', '0', '0'); 49 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('202', 'entries within last week', 'log.stamp> DATE_SUB(CURDATE(),INTERVAL 1 WEEK)', '1', '0'); 50 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('202', 'all entries', 'log.id!=-1', '2', '0'); 51 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('203', 'All Records', 'tabs.id!=-1', '0', '-100'); 52 52 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('204', 'All Records', 'smartsearches.id!=-1', '0', '0'); -
trunk/phpbms/install/tablegroupings.sql
r308 r485 1 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 10,'fromtable.displayname',1,1,'',0);2 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 11,'modules.name',1,0,'',0);3 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 12,'notes.category',1,1,'',0);4 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 16,'if(tabledefs.displayname is null,\"global\",tabledefs.displayname)',1,1,'',0);5 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 17,'tabledefs.displayname',1,1,'',0);6 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 17,'if(usersearches.type=\"SCH\",\"Search\",\"Sort\")',2,1,'',0);7 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 19,'if(menu.parentid=0,concat( lpad(menu.displayorder,3,\"0\"), \" - \" ,menu.name ) , concat( lpad(parentmenu.displayorder,3,\"0\") , \" - \",parentmenu.name))',1,1,'',0);8 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 23,'ELT(notes.importance+3,\'6 - Lowest\',\' 5 - Low\',\'4 - Normal\',\"3 - Medium\",\'2 - High\',\'1 - Highest\')',1,1,'Importance',0);9 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 23,'notes.category',2,1,'Category',0);10 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 24,'notes.category',1,1,'category',0);11 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 203,'tabs.tabgroup',1,1,'Group',0);1 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('10', 'fromtable.displayname', '1', '1', '', '0'); 2 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('11', 'modules.name', '1', '0', '', '0'); 3 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('12', 'notes.category', '1', '1', '', '0'); 4 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('16', 'if(tabledefs.displayname is null,\"global\",tabledefs.displayname)', '1', '1', '', '0'); 5 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('17', 'tabledefs.displayname', '1', '1', '', '0'); 6 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('17', 'if(usersearches.type=\"SCH\",\"Search\",\"Sort\")', '2', '1', '', '0'); 7 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('19', 'if(menu.parentid=0,concat( lpad(menu.displayorder,3,\"0\"), \" - \" ,menu.name ) , concat( lpad(parentmenu.displayorder,3,\"0\") , \" - \",parentmenu.name))', '1', '1', '', '0'); 8 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('23', 'ELT(notes.importance+3,\'6 - Lowest\',\' 5 - Low\',\'4 - Normal\',\"3 - Medium\",\'2 - High\',\'1 - Highest\')', '1', '1', 'Importance', '0'); 9 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('23', 'notes.category', '2', '1', 'Category', '0'); 10 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('24', 'notes.category', '1', '1', 'category', '0'); 11 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('203', 'tabs.tabgroup', '1', '1', 'Group', '0'); -
trunk/phpbms/install/tableoptions.sql
r427 r485 14 14 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('11', 'edit', '1', '1', '0', '0', '0'); 15 15 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('11', 'printex', '1', '0', '0', '0', '0'); 16 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'import', ' 0', '0', '0', '-100', '0');16 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'import', '1', '0', '0', '-100', '0'); 17 17 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'select', '1', '0', '0', '0', '0'); 18 18 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'edit', '1', '1', '0', '0', '0'); -
trunk/phpbms/install/tablesearchablefields.sql
r384 r485 1 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (3,9,'(users.lastname like \"{{value}}%\" or users.firstname like \"{{value}}%\" )','name',0,'whereclause');2 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,9,'users.accesslevel','access level',2,'field');3 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (6,9,'users.login','log in name',1,'field');4 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (7,9,'users.id','id',3,'field');5 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (26,10,'relationships.id','id',0,'field');6 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,11,'tabledefs.maintable','main table',0,'field');7 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (9,11,'tabledefs.displayname','display',1,'field');8 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (10,11,'tabledefs.id','id',2,'field');9 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (35,12,'notes.subject','title',0,'field');10 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (36,12,'notes.content','content',2,'field');11 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (37,12,'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"','assigned to',3,'whereclause');12 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (38,12,'assignedby.firstname like \"{{value}}%\"or assignedby.lastname like \"{{value}}%\"','assigned by',4,'whereclause');13 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (39,12,'notes.id','id',5,'field');14 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (81,12,'notes.category','category',1,'field');15 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (27,16,'reports.name','name',0,'field');16 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (28,16,'reports.reporttable','table',1,'field');17 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (29,16,'reports.type','type',2,'field');18 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (30,16,'reports.id','id',3,'field');19 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (31,17,'usersearches.name','name',0,'field');20 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (32,17,'({{value]]=\"global\" or users.firstname like \"{{value}}%\" or users.lastname like \"{{value}}%\")','user',1,'whereclause');21 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (33,17,'usersearches.table','table',2,'field');22 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (34,17,'usersearches.id','id',3,'field');23 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (67,19,'menu.name','name',0,'field');24 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (68,19,'parentmenu.name','parent name',1,'field');25 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (69,19,'menu.id','id',2,'field');26 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (70,21,'modules.id','id',0,'field');27 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (83,23,'notes.subject','title',0,'field');28 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (84,23,'notes.category','category',1,'field');29 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (85,23,'notes.content','content',2,'field');30 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (86,23,'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"','assigned to',3,'whereclause');31 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (87,23,'assignedby.firstname like \"{{value}}%\"or assignedby.lastname like \"{{value}}%\"','assigned by',4,'whereclause');32 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (88,23,'notes.id','id',5,'field');33 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (89,24,'notes.subject','title',0,'field');34 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (90,24,'notes.category','category',1,'field');35 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (91,24,'notes.content','content',2,'field');36 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (92,24,'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"','assigned to',3,'whereclause');37 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (93,24,'assignedby.firstname like','assigned by',4,'whereclause');38 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (94,24,'notes.id','id',5,'field');39 INSERT INTO `tablesearchablefields` (` id`, `tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (96,26,'files.name','name',0,'field');40 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 200,'roles.name','name',0,'field');41 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 201,'scheduler.name','name',0,'field');42 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 202,'log.type','type',0,'field');43 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 202,'log.ip','ip address',1,'field');44 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 203,'tabs.name','name',1,'field');45 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ( 203,'tabs.tabgroup','group',0,'field');1 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('9', '(users.lastname like \"{{value}}%\" or users.firstname like \"{{value}}%\" )', 'name', '0', 'whereclause'); 2 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('9', 'users.accesslevel', 'access level', '2', 'field'); 3 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('9', 'users.login', 'log in name', '1', 'field'); 4 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('9', 'users.id', 'id', '3', 'field'); 5 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('10', 'relationships.id', 'id', '0', 'field'); 6 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('11', 'tabledefs.id', 'id', '2', 'field'); 7 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('11', 'tabledefs.displayname', 'display', '1', 'field'); 8 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('11', 'tabledefs.maintable', 'main table', '0', 'field'); 9 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'notes.id', 'id', '5', 'field'); 10 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'assignedby.firstname like \"{{value}}%\"or assignedby.lastname like \"{{value}}%\"', 'assigned by', '4', 'whereclause'); 11 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"', 'assigned to', '3', 'whereclause'); 12 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'notes.content', 'content', '2', 'field'); 13 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'notes.subject', 'title', '0', 'field'); 14 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('12', 'notes.category', 'category', '1', 'field'); 15 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('16', 'reports.reporttable', 'table', '1', 'field'); 16 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('16', 'reports.name', 'name', '0', 'field'); 17 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('16', 'reports.id', 'id', '3', 'field'); 18 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('16', 'reports.type', 'type', '2', 'field'); 19 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('17', '({{value]]=\"global\" or users.firstname like \"{{value}}%\" or users.lastname like \"{{value}}%\")', 'user', '1', 'whereclause'); 20 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('17', 'usersearches.id', 'id', '3', 'field'); 21 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('17', 'usersearches.table', 'table', '2', 'field'); 22 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('17', 'usersearches.name', 'name', '0', 'field'); 23 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('19', 'menu.name', 'name', '0', 'field'); 24 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('19', 'parentmenu.name', 'parent name', '1', 'field'); 25 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('19', 'menu.id', 'id', '2', 'field'); 26 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('21', 'modules.id', 'id', '0', 'field'); 27 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'notes.id', 'id', '5', 'field'); 28 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'assignedby.firstname like \"{{value}}%\"or assignedby.lastname like \"{{value}}%\"', 'assigned by', '4', 'whereclause'); 29 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"', 'assigned to', '3', 'whereclause'); 30 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'notes.content', 'content', '2', 'field'); 31 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'notes.category', 'category', '1', 'field'); 32 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('23', 'notes.subject', 'title', '0', 'field'); 33 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'notes.id', 'id', '5', 'field'); 34 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'assignedby.firstname like', 'assigned by', '4', 'whereclause'); 35 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'assignedto.firstname like \"{{value}}%\"or assignedto.lastname like \"{{value}}%\"', 'assigned to', '3', 'whereclause'); 36 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'notes.content', 'content', '2', 'field'); 37 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'notes.category', 'category', '1', 'field'); 38 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('24', 'notes.subject', 'title', '0', 'field'); 39 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('26', 'files.name', 'name', '0', 'field'); 40 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('200', 'roles.name', 'name', '0', 'field'); 41 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('201', 'scheduler.name', 'name', '0', 'field'); 42 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('202', 'log.ip', 'ip address', '1', 'field'); 43 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('202', 'log.type', 'type', '0', 'field'); 44 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('203', 'tabs.name', 'name', '1', 'field'); 45 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('203', 'tabs.tabgroup', 'group', '0', 'field'); 46 46 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('204', 'tabledefs.displayname', 'table', '2', 'field'); 47 47 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('204', 'smartsearches.name', 'name', '1', 'field'); -
trunk/phpbms/install/update.js
r308 r485 1 window.onload = function(){ 2 var sections = getElementsByClassName("bodyline"); 3 4 var i; 5 for(i=0; i< sections.length; i++){ 6 if(sections[i].id != "step1"){ 7 sections[i].style.display = "none"; 1 updater = { 2 3 coreDataUpdate: function(){ 4 5 var noDebug = getObjectFromID("coreDataNoDebug"); 6 7 noDebug.className = "running"; 8 noDebug.innerHTML = "Running..."; 9 10 var response = updater.runCommand("coredataupdate"); 11 12 if(response.success === true){ 13 14 noDebug.className = "success"; 15 noDebug.innerHTML = "Core Program Updated Succefully"; 16 17 } else { 18 19 noDebug.className = "fail"; 20 noDebug.innerHTML = "Core Program Update Failed"; 21 22 }//endif 23 24 }, // endfunction coreDataInstall 25 26 27 moduleUpdate: function(e){ 28 29 var theButton = e.src(); 30 31 var foo = ""; 32 33 var module = theButton.id.substring(12); 34 35 var noDebug = getObjectFromID("Results" + module); 36 37 noDebug.className = "running"; 38 noDebug.innerHTML = "Running..."; 39 40 var response = updater.runCommand("moduleupdate", module); 41 42 if(response.success === true){ 43 44 noDebug.className = "success"; 45 noDebug.innerHTML = "Update Successful"; 46 47 } else { 48 49 noDebug.className = "fail"; 50 noDebug.innerHTML = "Update Failed"; 51 52 }//endif 53 54 },//end function moduleInstall 55 56 57 runCommand: function(command, extras){ 58 59 if(typeof(extras) == "undefined") 60 extras = ""; 61 else 62 extras = "&extras=" + extras 63 64 var theURL = "updateajax.php?command=" + command + extras; 65 66 loadXMLDoc(theURL,null,false); 67 68 var JSONresponse; 69 eval("JSONresponse = (" + req.responseText +")"); 70 71 var responseText = getObjectFromID(command + "results"); 72 if(typeof(responseText) != "undefined"){ 73 74 if(responseText.value) 75 responseText.value += "\n"; 76 77 responseText.value += JSONresponse.details; 78 79 }//endif 80 81 return JSONresponse 82 83 },//endfunction runCommand 84 85 86 toggleDebug: function(){ 87 88 var debug = getObjectFromID("debug"); 89 var display = "none"; 90 if(debug.checked) 91 display = "block"; 92 93 var debugDisplays = getElementsByClassName("debugResults"); 94 95 for(var i = 0; i < debugDisplays.length; i ++) 96 debugDisplays[i].style.display = display; 97 98 }//end function toggleDebug 99 100 }//end class installer 101 102 103 104 stepsNav = { 105 106 currentSection: 1, 107 sections: null, 108 109 navNext: function(){ 110 111 if(stepsNav.currentSection + 1 <= stepsNav.sections.length){ 112 stepsNav.navTo(stepsNav.currentSection + 1); 8 113 } 114 }, 115 116 117 navPrev: function(){ 118 if(stepsNav.currentSection - 1 > 0) 119 stepsNav.navTo(stepsNav.currentSection - 1); 120 }, 121 122 123 navTo: function(section){ 124 125 for(var i=0; i< stepsNav.sections.length; i++){ 126 127 if(stepsNav.sections[i].id != "step" + section){ 128 stepsNav.sections[i].style.display = "none"; 129 } else { 130 stepsNav.sections[i].style.display = "block"; 131 }//endif 132 133 }//endfor 134 135 navBar = getObjectFromID("navSelect"); 136 for(i=0; i < navBar.options.length; i++){ 137 if(navBar.options[i].value == section){ 138 navBar.options[i].selected = true; 139 } 140 }//endfor 141 //navBar.selectedIndex = section 142 143 stepsNav.currentSection = section; 144 145 },//end function navTo 146 147 148 navLeft: function(){ 149 150 var navSelect = getObjectFromID("navSelect"); 151 stepsNav.navTo(parseInt(navSelect.value)); 152 153 9 154 } 155 10 156 } 11 157 12 function goSection(direction){ 13 var sections = getElementsByClassName("bodyline"); 14 var currSection = 1; 15 16 for(i=0; i< sections.length; i++){ 17 if(sections[i].style.display == "block") 18 currSection = parseInt(sections[i].id.substr(4),10); 19 } 20 21 if(direction == "next") 22 direction = 1; 23 else 24 direction = -1; 25 26 if(currSection + direction == 0) 27 return false; 28 else{ 29 var currDiv = getObjectFromID("step"+currSection); 30 var newDiv = getObjectFromID("step"+(currSection + direction)) 158 // ====== Init Listeners ======================================================= 31 159 32 currDiv.style.display = "none"; 33 newDiv.style.display = "block"; 34 } 35 }//end function 160 connect(window,"onload",function() { 36 161 162 stepsNav.sections = getElementsByClassName("steps"); 163 stepsNav.navTo(1); 37 164 38 function changeModule(){ 39 var moduleSel=getObjectFromID("modules"); 40 var updateButton=getObjectFromID("updatemodule"); 41 var modinfo = getObjectFromID("moduleInformation"); 42 43 var modName = getObjectFromID("modulename"); 44 var modVer = getObjectFromID("moduleversion"); 45 var modDesc = getObjectFromID("moduledescription"); 46 var modReq = getObjectFromID("modulerequirements"); 47 48 if(moduleSel.value!=0){ 49 updateButton.disabled=false; 50 51 modName.innerHTML = modules[moduleSel.value]["name"]; 52 modVer.innerHTML = modules[moduleSel.value]["version"]; 53 modDesc.innerHTML = modules[moduleSel.value]["description"]; 54 modReq.innerHTML = modules[moduleSel.value]["requirements"]; 55 56 modinfo.style.display = "block"; 57 } 58 else{ 59 updateButton.disabled=true; 60 modinfo.style.display = "none"; 61 } 62 } 165 var nextButtons = getElementsByClassName("nextButtons"); 166 for(var i=0; i< nextButtons.length; i++) 167 connect(nextButtons[i], "onclick", stepsNav.navNext); 63 168 169 var prevButtons = getElementsByClassName("prevButtons"); 170 for(var i=0; i< prevButtons.length; i++) 171 connect(prevButtons[i], "onclick", stepsNav.navPrev); 64 172 65 function runCommand(command){ 66 var theURL="updatexml.php?command="+command; 67 var adminName=getObjectFromID("username"); 68 var adminPass=getObjectFromID("password"); 69 var version=getObjectFromID("version"); 70 var theModules=getObjectFromID("modules"); 71 72 theURL+="&u="+encodeURIComponent(adminName.value); 73 theURL+="&p="+encodeURIComponent(adminPass.value); 74 theURL+="&v="+encodeURIComponent(version.value); 75 76 if(command == "checkModuleUpdate"){ 77 theURL+="&m="+encodeURIComponent(theModules.value); 78 theURL+="&mv="+encodeURIComponent(modules[theModules.value]["version"]); 79 } 173 var navSelect = getObjectFromID("navSelect"); 174 connect(navSelect, "onchange", stepsNav.navLeft); 80 175 81 var responseText= getObjectFromID(command+"results"); 82 loadXMLDoc(theURL,null,false); 83 if(req.responseXML) 84 response = req.responseXML.documentElement.firstChild.data+"\n"; 85 else 86 response = req.responseText+"\n"; 87 88 responseText.value+=response; 89 } 176 var debug = getObjectFromID("debug"); 177 connect(debug, "onchange", updater.toggleDebug); 90 178 179 var updatecoreButton = getObjectFromID("updatecoreButton"); 180 if(updatecoreButton) 181 connect(updatecoreButton,"onclick", updater.coreDataUpdate); 91 182 92 function runModuleUpdate(){ 93 var themodule=getObjectFromID("modules"); 94 var responseText= getObjectFromID("checkModuleUpdateresults"); 95 if(themodule.value=="") 96 alert("First, Select a module"); 97 else { 98 var theURL="../modules/"+themodule.value+"/install/update.php"; 99 var adminName=getObjectFromID("username"); 100 var adminPass=getObjectFromID("password"); 101 var theModules=getObjectFromID("modules"); 183 moduleButtons = getElementsByClassName("moduleButtons"); 184 for(i = 0; i < moduleButtons.length; i++) 185 connect(moduleButtons[i], "onclick", updater.moduleUpdate); 102 186 103 theURL+="?u="+encodeURIComponent(adminName.value); 104 theURL+="&p="+encodeURIComponent(adminPass.value); 105 theURL+="&v="+encodeURIComponent(modules[theModules.value]["version"]); 106 107 loadXMLDoc(theURL,null,false); 108 if(req.responseXML) 109 response = req.responseXML.documentElement.firstChild.data+"\n"; 110 else 111 response = req.responseText; 112 113 responseText.value+=response 114 } 115 } 187 }) -
trunk/phpbms/install/update.php
r312 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 38 38 */ 39 39 40 include("install_include.php"); 41 include("version.php"); 42 40 include("update_include.php"); 41 42 $updater = new updater(); 43 $updater->buildList(); 44 45 46 //check for php version 47 $neededVer = "5.2.0"; 48 $phpVer = phpversion(); 49 if(floatval($neededVer) <= floatval($phpVer)) 50 $phpVerClass = "success"; 51 else 52 $phpVerClass = "fail"; 53 54 //check to see if mysql plugin present 55 if(phpversion("mysql")) 56 $mysqlPresent = "success"; 57 else 58 $mysqlPresent = "fail"; 59 60 //check the web server 61 $webServer = explode(" ",$_SERVER['SERVER_SOFTWARE']); 62 $webServer = explode("/", $webServer[0]); 63 64 if(strtolower($webServer[0]) == "apache"){ 65 66 if(floatval($webServer[1]) > 2) 67 $webServerReport["class"] = "success"; 68 else 69 $webServerReport["class"] = "warning"; 70 71 $webServerReport["message"] = $webServer[0]."/".$webServer[1]; 72 73 } else { 74 $webServerReport["class"] = "warning"; 75 $webServerReport["message"] = "Non-Apache servers are untested and may have problems."; 76 } 77 78 $mysqlVer = $updater->getMySQLVersion(); 79 80 if(floatval($mysqlVer) >= 5) 81 $mysqlPassFailClass = "success"; 82 else 83 $mysqlPassFailClass = "fail"; 84 43 85 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 44 86 <html xmlns="http://www.w3.org/1999/xhtml"> … … 53 95 <script language="JavaScript" src="../common/javascript/moo/moo.fx.pack.js" type="text/javascript" ></script> 54 96 <script language="JavaScript" src="update.js" type="text/javascript" ></script> 55 <script language="JavaScript" type="text/javascript">56 <?php $modules = array_merge($modules,loadModules("update")) ?>57 </script>58 97 </head> 59 98 60 99 <body> 61 <h1 id="topTitle">phpBMS v<?php echo $modules["base"]["version"]?> Update</h1> 62 63 <div class="bodyline" id="step1"> 64 <h1>Before Updating</h1> 65 66 <p class="important">Backup all of your data and program files before running any update.</p> 67 <p> 68 By downloading and decompressing this update, you may have already replaced script files 69 from the previous version of phpBMS. If you have decompressed these files to a separate 70 directory and have made custom changes directly to the system we recommend backing up 71 those files before continuing. 72 </p> 73 <p>For the latest information about phpBMS check the <a href="http://www.phpbms.org">phpBMS Project web site</a>.</p> 74 75 <p class="nextprevP"> 76 <button type="button" class="disabledButtons nextprevButtons" onclick="goSection('back')" disabled="disabled">back</button> 77 <button type="button" class="Buttons nextprevButtons" onclick="goSection('next')">next</button> 78 </p> 100 <noscript> 101 <div class="bodyline"> 102 <h1>Javascript Support Disabled</h1> 103 <p>Both the installer and the main phpBMS program require JavaScript support in order to run.</p> 104 </div> 105 </noscript> 106 107 <h1 id="topTitle">phpBMS v<?php echo $updater->list["base"]["version"]?> Update</h1> 108 109 <div class="bodyline"> 110 111 <div id="navPanel"> 112 <select id="navSelect" size="10"> 113 <option value="1" selected="selected">* Preparing For Update</option> 114 <option value="2">* Update Core Program</option> 115 <option value="3">* Update Modules</option> 116 <option value="4">* Finish Update</option> 117 </select> 118 <p><input type="checkbox" id="debug" /><label for="debug">updating debug</label></p> 119 </div> 120 <div id="stepsPanel"> 121 122 <div class="steps" id="step1"> 123 124 <p class="nextprevP"> 125 <button type="button" class="disabledButtons prevButtons" disabled="disabled">back</button> 126 <button type="button" class="Buttons nextButtons">next</button> 127 </p> 128 129 <h1>Preparing For Update</h1> 130 <p> 131 Before updating, There are several steps to take and insure that backup runs smoothly. 132 </p> 133 <ul> 134 <li> 135 <strong>Backup</strong> your data file. If you have access to a shell, using 136 the mysqldump command is a fast way of creating a reliable backup of your data. 137 </li> 138 139 <li> 140 By downloading and decompressing this update, you may have already replaced script files 141 from the previous version of phpBMS. If you have decompressed these files to a separate 142 directory and have made custom changes directly to the system we recommend backing up 143 those files before continuing. 144 </li> 145 146 <li> 147 For the latest information about phpBMS check the <a href="http://www.phpbms.org">phpBMS Project web site</a>. 148 </li> 149 </ul> 150 151 <h2>Server Requirements</h2> 152 <table id="sysRequirements" cellpadding="0" cellspacing="0" border="0"> 153 <thead> 154 <tr> 155 <td>requirement</td> 156 <td>server</td> 157 </tr> 158 </thead> 159 <tbody> 160 <tr> 161 <td>PHP 5.2.0 or higher</td> 162 <td><span class="<?php echo $phpVerClass?>"><?php echo $phpVer?></span></td> 163 </tr> 164 <tr> 165 <td>PHP MySQL Support</td> 166 <td><span class="<?php echo $mysqlPresent?>"><?php echo $mysqlPresent?></span></td> 167 </tr> 168 <tr> 169 <td>Apache 2.0 or higher</td> 170 <td><span class="<?php echo $webServerReport["class"]?>"><?php echo $webServerReport["message"]?></span></td> 171 </tr> 172 <tr> 173 <td>MySQL Server 5.0 or higher</td> 174 <td><span class="<?php echo $mysqlPassFailClass ?>"><?php echo $mysqlVer ?></span></td> 175 </tr> 176 177 </tbody> 178 </table> 179 180 </div> 181 182 <div class="steps" id="step2"> 183 184 <p class="nextprevP"> 185 <button type="button" class="Buttons prevButtons">back</button> 186 <button type="button" class="Buttons nextButtons">next</button> 187 </p> 188 189 <h1>Update Core Program</h1> 190 191 <p> 192 The database reports the current version is <strong><?php echo $updater->list["base"]["currentversion"] ?></strong>. 193 The application files show the application version to upgrade to is <strong><?php echo $updater->list["base"]["version"] ?></strong>. 194 </p> 195 196 <?php if($updater->checkBaseUpdate()) { ?> 197 198 <p class="notes"><strong>Versions match. No update is necessary.</strong></p> 199 200 <?php } else { ?> 201 202 <p class="notes"><strong>You must update the phpBMS Core Program before updating any modules.</strong></p> 203 204 205 <p><button class="Buttons" id="updatecoreButton">Update Core Program</button> <span id="coreDataNoDebug"></span></p> 206 207 <div class="debugResults"> 208 <h3>Update Core Results</h3> 209 <p><textarea name="results" id="coredataupdateresults" cols="40" rows="4" class="results"></textarea></p> 210 </div> 211 212 <?php } //endif ?> 213 </div> 214 215 <div class="steps" id="step3"> 216 217 <p class="nextprevP"> 218 <button type="button" class="Buttons prevButtons">back</button> 219 <button type="button" class="Buttons nextButtons">next</button> 220 </p> 221 222 <h1>Udate Modules</h1> 223 224 <?php $updater->showModulesUpdate(); ?> 225 226 <div class="debugResults"> 227 <h3>Module Installation Results</h3> 228 <p><textarea name="results" id="moduleupdateresults" class="results" cols="80" rows="10"></textarea></p> 229 </div> 230 231 </div> 232 233 <div class="steps" id="step4"> 234 235 <p class="nextprevP"> 236 <button type="button" class="Buttons prevButtons">back</button> 237 <button type="button" class="disabledButtons nextButtons" disabled="disabled">next</button> 238 </p> 239 240 <h1>Finish Update</h1> 241 <p> 242 To finish the update process you will need to: 243 </p> 244 <ul> 245 <li> 246 <h3>Delete Install Folders</h3> 247 <p> 248 You must delete both the core installation folder, as well as all modules' installation 249 folders before you can use the system 250 </p> 251 </li> 252 <li> 253 <h3>Clear your Browser Cache</h3> 254 <p> 255 Part of the update process may have replaced javascript and stylesheet (css) files. 256 Most browsers cache these files to speed loading times. In order to insure that 257 your web application is using all of the latest updates, you will need to 258 clear the browser cache of all client browsers that access the application. 259 </p> 260 <p> 261 Most browsers will clear this cache automatically if you simply restart the browser 262 </p> 263 </li> 264 265 </ul> 266 <h2>Troubleshooting</h2> 267 <h3>General Help </h3> 268 <p> 269 If you have problems during updating, have questions about how the program works, or would like additional 270 information about phpBMS, please visit the <a href="http://www.phpbms.org">phpBMS Project web site</a>. The phpBMS project web site 271 has many resources to help you including a user wiki, users forum, and mailing list that can help you.</p> 272 <h3>Paid Customization, Update, Support Options</h3> 273 <p>Paid technical support and phpBMS customization is available from <a href="http://www.kreotek.com">Kreotek</a>,</p> 274 275 </div> 276 277 </div> 278 79 279 </div> 80 280 81 82 <div class="bodyline" id="step2">83 <h1>Enter Administrative Log In Information</h1>84 <p>85 Running the update requires administrative access privleges. Please enter the login credentials86 that have administrative priveleges.87 </p>88 89 <fieldset>90 <legend>administrative login</legend>91 <p>92 <label for="username">name</label><br />93 <input name="name" type="text" id="username" size="32" maxlength="64" />94 <input name="name" type="hidden" id="version" value="<?php echo $modules["base"]["version"] ?>" />95 </p>96 <p>97 <label for="password">password</label><br />98 <input name="password" type="password" id="password" size="32" maxlength="24" />99 </p>100 <p>101 <input type="button" value="Verify" class="Buttons" onclick="runCommand('verifyLogin')" />102 </p>103 </fieldset>104 <h3>Administrative Verification Results</h3>105 <p>106 <textarea name="results" id="verifyLoginresults" class="results" cols="80" rows="2"></textarea>107 </p>108 109 <p class="nextprevP">110 <button type="button" class="Buttons nextprevButtons" onclick="goSection('back')">back</button>111 <button type="button" class="Buttons nextprevButtons" onclick="goSection('next')">next</button>112 </p>113 </div>114 115 116 <div class="bodyline" id="step3">117 <h1>Check for phpBMS Core Update Availability</h1>118 119 <p>Check to see if the phpBMS core needs to be updated</p>120 <p class="testButtonsP">121 <input type="button" value="Check Core Availability" class="Buttons" onclick="runCommand('checkBaseUpdate')" />122 </p>123 <h3>Availability Results</h3>124 <p>125 <textarea name="results" id="checkBaseUpdateresults" class="results" cols="80" rows="2"></textarea>126 </p>127 128 129 <p class="nextprevP">130 <button type="button" class="Buttons nextprevButtons" onclick="goSection('back')">back</button>131 <button type="button" class="Buttons nextprevButtons" onclick="goSection('next')">next</button>132 </p>133 </div>134 135 136 <div class="bodyline" id="step4">137 <h1>Update phpBMS Core</h1>138 139 <p>If an update was reported as available in the previous section, you should run the update to the phpBMS core.</p>140 141 <p class="notes">142 If no update is available, running the update on an already updated version of phpBMS143 can cause data corruption and break the application.144 </p>145 146 <p class="testButtonsP">147 <input type="button" value="Update Core" class="Buttons" onclick="runCommand('updateBaseVersion')" />148 </p>149 <h3>Core Update Results</h3>150 <p>151 <textarea name="results" id="updateBaseVersionresults" class="results" cols="80" rows="8"></textarea>152 </p>153 154 <p class="nextprevP">155 <button type="button" class="Buttons nextprevButtons" onclick="goSection('back')">back</button>156 <button type="button" class="Buttons nextprevButtons" onclick="goSection('next')">next</button>157 </p>158 </div>159 160 161 <div class="bodyline" id="step5">162 <h1>Update Installed Modules</h1>163 <p>Before updating an installed module, make sure that you meet any module requirements listed.</p>164 165 <p>166 <label for="modules">available modules</label><br />167 <select id="modules" name="modules" onchange="changeModule()">168 <option value="0">Select a module to update...</option>169 <?php showModules($modules);?>170 </select>171 </p>172 173 <div id="moduleInformation" class="box" style="display:none">174 <h2>Module Information</h2>175 <p>176 module Name<br />177 <strong id="modulename"></strong>178 </p>179 <p>180 version: <strong id="moduleversion"></strong>181 </p>182 <p class="notes">183 The version above is not necessarily the current data version. Use the184 "Check For Updates" button to see if an update is necessary.185 </p>186 <p>187 description<br />188 <strong id="moduledescription"></strong>189 </p>190 <p>191 requirements<br />192 <strong id="modulerequirements"></strong>193 </p>194 <p class="notes">make sure your system meets all of the module's requirements.</p>195 <p class="testButtonsP">196 <input type="button" id="checkModule" value="Check For Updates" class="Buttons" onclick="runCommand('checkModuleUpdate')" />197 <input type="button" id="updatemodule" name="updatemodule" value="Update Module" class="Buttons" onclick="runModuleUpdate()" disabled="disabled"/>198 </p>199 </div>200 201 202 <h3>Module Update Results</h3>203 <p>204 <textarea name="results" id="checkModuleUpdateresults" class="results" cols="80" rows="8"></textarea>205 </p>206 207 208 <p class="nextprevP">209 <button type="button" class="Buttons nextprevButtons" onclick="goSection('back')">back</button>210 <button type="button" class="Buttons nextprevButtons" onclick="goSection('next')">next</button>211 </p>212 </div>213 214 <div class="bodyline" id="step6">215 <h1>Complete the Update Process</h1>216 217 <p>218 To complete the update process, you may need to <strong>restart your browser</strong>, or <strong>clear site cookies and browser219 cache</strong> in order for all the changes to take affect.220 </p>221 222 <p class="testButtonsP"><input type="button" id="login" name="login" value="phpBMS Log In" class="Buttons" onclick="document.location='../'" /></p>223 224 <p class="nextprevP">225 <button type="button" class="Buttons nextprevButtons" onclick="goSection('back')">back</button>226 <button type="button" class="disabledButtons nextprevButtons" onclick="goSection('next')" disabled="disabled">next</button>227 </p>228 </div>229 230 281 <p class="tiny" align="center"> $Rev$ | $LastChangedDate$</p> 231 282 </body> -
trunk/phpbms/install/updatev0.98.sql
r427 r485 4 4 ALTER TABLE `log` ENGINE=INNODB; 5 5 ALTER TABLE `menu` ENGINE=INNODB; 6 UPDATE `menu` SET `name` = 'Tools' WHERE `id` = '1' AND `name` = 'Organizer'; 6 7 ALTER TABLE `modules` ENGINE=INNODB; 7 8 ALTER TABLE `notes` ENGINE=INNODB; 9 ALTER TABLE `notes` MODIFY COLUMN `type` CHAR(2) NOT NULL DEFAULT 'NT'; 8 10 ALTER TABLE `relationships` ENGINE=INNODB; 9 11 ALTER TABLE `reports` ENGINE=INNODB; 12 ALTER TABLE `reports` MODIFY COLUMN `reportfile` VARCHAR(128) NOT NULL; 13 UPDATE `reports` SET `description` = 'This report will generate a comma-delimited text file. Values are encapsulated in quotes, and the first line lists the field names.' WHERE `name` = 'Raw Table Export'; 10 14 ALTER TABLE `roles` ENGINE=INNODB; 15 ALTER TABLE `roles` MODIFY COLUMN `inactive` TINYINT(4) NOT NULL DEFAULT 0; 11 16 ALTER TABLE `rolestousers` ENGINE=INNODB; 12 17 ALTER TABLE `scheduler` ENGINE=INNODB; 18 INSERT INTO `scheduler` (`name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Clean Import Files', './scheduler_delete_tempimport.php', '30::*::*::*::*', NULL, NOW(), NULL, 'This will delete any temporary import files that are present (for whatever reason) after 30 minutes of their creation.', '0', 1, NOW(), 1, NOW()); 19 INSERT INTO `scheduler` (`id`, `name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Remove Excess System Log Records', './scheduler_delete_logs.php', '*::24::*::*::*', NULL, '2009-03-31 12:00:00', NULL, 'This script will trim the system log when there are more than 2000 records present at the time of its calling (default will be every 24 hours).', '0', 1, NOW(), 1, NOW()); 13 20 ALTER TABLE `settings` ENGINE=INNODB; 14 21 ALTER TABLE `smartsearches` ENGINE=INNODB; 15 22 ALTER TABLE `tablecolumns` ENGINE=INNODB; 16 23 ALTER TABLE `tabledefs` ENGINE=INNODB; 24 ALTER TABLE `tabledefs` ADD COLUMN `importfile` VARCHAR(128) DEFAULT NULL AFTER `addroleid`, ADD COLUMN `importroleid` int(11) NOT NULL DEFAULT '-100' AFTER `importfile`; 17 25 ALTER TABLE `tablefindoptions` ENGINE=INNODB; 18 26 ALTER TABLE `tablegroupings` ENGINE=INNODB; 19 27 ALTER TABLE `tableoptions` ENGINE=INNODB; 20 ALTER TABLE `tablesearchablefields` ENGINE=INNODB;21 ALTER TABLE `tabs` ENGINE=INNODB;22 ALTER TABLE `users` ENGINE=INNODB;23 ALTER TABLE `usersearches` ENGINE=INNODB;24 INSERT INTO `scheduler` (`name`, `job`, `crontab`, `lastrun`, `startdatetime`, `enddatetime`, `description`, `inactive`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('clean import files', '/scheduler_delete_tempimport.php', '30::*::*::*::*', NULL, NOW(), NULL, 'This will delete any temporary import files that are present (for whatever reason) after 30 minutes of their creation.', '0', 1, NOW(), 1, NOW());25 ALTER TABLE `tabledefs` ADD COLUMN `importfile` VARCHAR(128) DEFAULT NULL AFTER `addroleid`, ADD COLUMN `importroleid` int(11) NOT NULL DEFAULT '-100' AFTER `importfile`;26 UPDATE `tabledefs` SET `importfile`='modules/base/users_import.php' WHERE `id` = 9;27 28 ALTER TABLE `tableoptions` ADD COLUMN `needselect` BOOLEAN NOT NULL DEFAULT 1 AFTER `option`; 28 29 UPDATE `tableoptions` SET `needselect` = 0 WHERE `name` IN('massEmail','new','printex','select') AND `tabledefid` IN (9,10,11,12,16,17,19,21,23,24,26,27,200,201,202,203,204); … … 30 31 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('10', 'import', '0', '0', '0', '-100', '0'); 31 32 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('11', 'import', '0', '0', '0', '-100', '0'); 32 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'import', ' 0', '0', '0', '-100', '0');33 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('12', 'import', '1', '0', '0', '-100', '0'); 33 34 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('16', 'import', '0', '0', '0', '-100', '0'); 34 35 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('17', 'import', '1', '0', '0', '-100', '0'); … … 44 45 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('203', 'import', '0', '0', '0', '-100', '0'); 45 46 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('204', 'import', '0', '0', '0', '-100', '0'); 46 UPDATE `reports` SET `description` = 'This report will generate a comma-delimited text file. Values are encapsulated in quotes, and the first line lists the field names.' WHERE `name` = 'Raw Table Export'; 47 ALTER TABLE `tablesearchablefields` ENGINE=INNODB; 48 ALTER TABLE `tabs` ENGINE=INNODB; 49 ALTER TABLE `users` ENGINE=INNODB; 50 ALTER TABLE `users` ADD COLUMN `lastip` VARCHAR(45) NOT NULL DEFAULT '' AFTER `lastname`; 51 ALTER TABLE `usersearches` ENGINE=INNODB; -
trunk/phpbms/install/update_include.php
r285 r485 1 1 <?php 2 2 3 3 define("APP_DEBUG",false); 4 define("noStartup",true); 5 6 require("../include/session.php"); 7 8 class updater{ 9 10 // database object 11 var $db; 12 13 // module list 14 var $list; 15 16 var $phpbmsSession; 4 17 5 18 6 //======================================================================================= 7 //======================================================================================= 8 function loadSettings() { 9 $settingsfile = fopen("../settings.php","r"); 10 if($settingsfile){ 11 //loop through the settings file and load variables into the session 12 while( !feof($settingsfile)) { 13 $line=NULL; 14 $key=NULL; 15 $value=NULL; 16 $line=fscanf($settingsfile,"%[^=]=%[^[]]",$key,$value); 17 if ($line){ 18 $key=trim($key); 19 $value=trim($value); 20 if($key!="" and !strpos($key,"]")){ 21 $startpos=strpos($value,"\""); 22 $endpos=strrpos($value,"\""); 23 if($endpos!=false) 24 $value=substr($value,$startpos+1,$endpos-$startpos-1); 25 $variables[$key]=$value; 26 } 27 } 28 } 29 if(!isset($variables["mysql_pconnect"])) 30 $variables["mysql_pconnect"]="true"; 31 fclose($settingsfile); 32 return $variables; 33 } else return "Cannot open setting.php file"; 34 } 19 function updater(){ 35 20 36 37 function getNewVersion($dir="."){ 38 $file = @ fopen($dir."/version.txt","r"); 39 $version=fgets($file,1024); 40 @ fclose($file); 41 return $version; 42 } 43 44 function showModules(){ 45 $vars=loadSettings(); 46 if(!is_array($vars)) { 47 echo "<option>Could Not Open Settings File</option>"; 48 return false; 49 } 50 if($vars["mysql_pconnect"]=="true") 51 $dblink = @ mysql_pconnect($vars["mysql_server"],$vars["mysql_user"],$vars["mysql_userpass"]); 52 else 53 $dblink = @ mysql_connect($vars["mysql_server"],$vars["mysql_user"],$vars["mysql_userpass"]); 54 @ mysql_select_db($vars["mysql_database"],$dblink); 55 56 $querystatement="SELECT name,version FROM modules WHERE name!=\"base\" "; 57 $queryresult=$db->query($querystatement); 58 59 while($modulerecord=$db->fetchArray($queryresult)){ 60 $newVersion=getNewVersion("../modules/".$modulerecord["name"]."/install"); 61 if($newVersion!=$modulerecord["version"]) 62 echo "<OPTION value=\"".$modulerecord["name"]."\">".$modulerecord["name"]." (".$modulerecord["version"]." -> ".$newVersion.")</OPTION>\n"; 63 } 64 65 } 21 $this->phpbmsSession = new phpbmsSession; 66 22 67 $version=getNewVersion();23 if($this->phpbmsSession->loadDBSettings(false)){ 68 24 25 @ include_once("include/db.php"); 26 27 $this->db = new db(false); 28 $this->db->stopOnError = false; 29 $this->db->showError = false; 30 $this->db->logError = false; 31 32 } else 33 $error = new appError(-300,"","",true,true,false); 34 35 if(!$this->db->connect()) 36 $error = new appError(-400,"Could not connect to database server.\n\n".$this->db->getError(),"Database Error",true,true,false); 37 38 if(!$this->db->selectSchema()) 39 $error = new appError(-410,"Could not open schema ".$this->db->schema,"Database Error", true, true, false); 40 41 }//end function init 42 43 44 function buildList(){ 45 46 $thedir = @ opendir("../modules/"); 47 48 $modules = array(); 49 50 //this helps build the modules array 51 // each included modules version.php should add to the 52 // array 53 while($entry = readdir($thedir)){ 54 55 if($entry != "." && $entry != ".." && $entry != "base" && $entry != "sample" && is_dir("../modules/".$entry)){ 56 57 if(file_exists("../modules/".$entry."/install/update.php") && file_exists("../modules/".$entry."/version.php")){ 58 59 include("../modules/".$entry."/version.php"); 60 61 }//endif 62 63 }//endif 64 65 }//end if 66 67 //Next we add the base version in 68 include("../phpbmsversion.php"); 69 70 //go retrieve current versions 71 foreach($modules as $key=>$value) 72 $modules[$key]["currentversion"] = $this->getCurrentVersion($key); 73 74 $this->list = $modules; 75 76 }//end function buildList 77 78 79 function getMySQLVersion(){ 80 81 $querystatement = "SELECT VERSION() AS ver"; 82 $queryresult = $this->db->query($querystatement); 83 if($this->db->error) 84 $error = new appError(-425,"Could not retrieve mysql verson. ","Database Error", true, true, false); 85 86 $therecord = $this->db->fetchArray($queryresult); 87 88 return $therecord["ver"]; 89 90 }//endif 91 92 93 function getCurrentVersion($module){ 94 95 $querystatement = " 96 SELECT 97 version 98 FROM 99 modules 100 WHERE 101 name = '".$module."'"; 102 103 $queryresult = $this->db->query($querystatement); 104 if($this->db->error) 105 $error = new appError(-600,"Could not retrieve current version information for ".$module.": ".$this->db->error,"Cannot load module information",true,true,false); 106 107 if($this->db->numRows($queryresult)){ 108 109 $therecord = $this->db->fetchArray($queryresult); 110 111 return floatval($therecord["version"]); 112 113 } else 114 return 0; 115 116 }//end function getCurrentVersion 117 118 119 function checkBaseUpdate(){ 120 121 return ($this->list["base"]["version"] == $this->list["base"]["currentversion"]); 122 123 }//end function showBaseUpdate 124 125 126 function showModulesUpdate(){ 127 128 ?> 129 <table id="moduleTable" cellpadding="0" cellspacing="0" border="0"> 130 <thead> 131 <tr> 132 <th>module</th> 133 <th>database version</th> 134 <th>file version</th> 135 <th> </th> 136 </tr> 137 </thead> 138 <tbody> 139 <?php 140 141 ksort($this->list); 142 143 foreach($this->list as $key=>$module){ 144 145 if($key != "base"){ 146 147 ?> 148 <tr> 149 <td> 150 <h3><strong><?php echo $module["name"]?></strong></h3> 151 <p><?php echo $module["description"]?></p> 152 <p class="notes"><strong>Requirements:</strong> <?php echo $module["requirements"]?> 153 </td> 154 <td><?php echo $module["version"] ?></td> 155 <td><?php echo $module["currentversion"] ?></td> 156 157 <td class="moduleInstall"> 158 <?php 159 if($module["version"] != $module["currentversion"]){ 160 if($module["currentversion"] == 0) { 161 ?> 162 Not Installed> 163 <?php 164 } else {} 165 ?> 166 167 <button class="Buttons moduleButtons" id="moduleButton<?php echo $key ?>">Update Module</button> 168 <p><span class="" id="Results<?php echo $key?>"></span></p> 169 170 <?php } else {?> 171 Versions Match<br /> 172 Update Unnecessary 173 <?php }//endif version!=currentversion ?> 174 </td> 175 </tr> 176 <?php 177 178 }//end if 179 180 }//end foreach 181 182 ?></tbody></table><?php 183 184 }//end function showModuleUpdate 185 186 }//end class 69 187 ?> -
trunk/phpbms/modules/base/adminsettings.php
r448 r485 86 86 $theform->addField($theinput); 87 87 88 $theinput = new inputField("currency_sym",$therecord["currency_sym"],"currency symbol",true,NULL, 4,1);88 $theinput = new inputField("currency_sym",$therecord["currency_sym"],"currency symbol",true,NULL,5,5); 89 89 $theform->addField($theinput); 90 90 … … 225 225 <option value="UK - Loose" <?php if($therecord["phone_format"] == "UK - Loose") echo "selected=\"selected\"";?>>UK - Loose</option> 226 226 <option value="International" <?php if($therecord["phone_format"] == "International") echo "selected=\"selected\"";?>>International</option> 227 <option value="No Verification" <?php if($therecord["phone_format"] == "No Verification") echo "selected=\"selected\"";?>>No Verification</option> 227 228 </select> 228 229 </p> -
trunk/phpbms/modules/base/cron.php
r295 r485 1 <?php 1 <?php 2 2 $loginNoKick=true; 3 3 $loginNoDisplayError=true; 4 4 5 5 include("../../include/session.php"); 6 6 7 7 $now = gmdate('Y-m-d H:i', strtotime('now')); 8 9 $querystatment="SELECT id,name,crontab,job,startdatetime,enddatetime FROM scheduler WHERE inactive=0 AND startdatetime<NOW() AND (enddatetime>NOW() OR enddatetime IS NULL);"; 8 9 $querystatment = " 10 SELECT 11 id, 12 name, 13 crontab, 14 job, 15 startdatetime, 16 enddatetime 17 FROM 18 scheduler 19 WHERE 20 inactive = 0 21 AND startdatetime < NOW() 22 AND (enddatetime > NOW() OR enddatetime IS NULL)"; 23 10 24 $queryresult=$db->query($querystatment); 11 25 12 26 while($schedule_record=$db->fetchArray($queryresult)){ 27 13 28 $datetimearray=explode(" ",$schedule_record["startdatetime"]); 14 29 $schedule_record["startdate"]=stringToDate($datetimearray[0],"SQL"); … … 16 31 17 32 if($schedule_record["enddatetime"]){ 33 18 34 $datetimearray=explode(" ",$schedule_record["enddatetime"]); 19 35 $schedule_record["enddate"]=stringToDate($datetimearray[0],"SQL"); 20 36 $schedule_record["endtime"]=stringToTime($datetimearray[1],"24 Hour"); 21 } 22 23 $validTimes=getTimes($schedule_record); 37 38 }//endif enddateiem 39 40 $validTimes = getTimes($schedule_record); 41 24 42 if(is_array($validTimes) && in_array($now, $validTimes)){ 43 25 44 $success = @ include($schedule_record["job"]); 45 26 46 if($success){ 47 27 48 $updatestatement="UPDATE scheduler SET lastrun=NOW() WHERE id=".$schedule_record["id"]; 28 49 $db->query($updatestatement); 29 $log = new phpbmsLog("Secheduled Job ".$schedule_record["name"]." (".$schedule_record["id"].") completed","SCHEDULER",-2); 30 } else { 31 $log = new phpbmsLog("Secheduled Job ".$schedule_record["name"]." (".$schedule_record["id"].") returned errors","SCHEDULER",-2); 32 } 33 34 } 35 } 36 50 $log = new phpbmsLog("Scheduled Job ".$schedule_record["name"]." (".$schedule_record["id"].") completed","SCHEDULER",-2); 51 52 } else { 53 54 $log = new phpbmsLog("Scheduled Job ".$schedule_record["name"]." (".$schedule_record["id"].") returned errors","SCHEDULER",-2); 55 56 }//endif success 57 58 }//endif is_array(); 59 60 }//endwhile 61 62 37 63 function getTimes($recordarray){ 38 64 39 65 $dayInt = array('*',1,2,3,4,5,6,7); 40 66 $dayLabel = array('*',"Monday","Tuesday","Wedensday","Thursday","Friday","Saturday","Sunday"); … … 43 69 $metricsVar = array("*", "/", "-", ","); 44 70 $metricsVal = array(' every ','',' thru ',' and '); 45 71 46 72 $dateTimes = array(); 47 73 $ints = explode('::', str_replace(' ','',$recordarray["crontab"])); … … 59 85 $theDay = str_replace('*/','',$days); 60 86 $dayName[] = str_replace($dayInt, $dayLabel, $theDay); 61 } elseif($days != '*') { 87 } elseif($days != '*') { 62 88 if(strstr($days, ',')) { 63 89 $exDays = explode(',',$days); 64 90 foreach($exDays as $k1 => $dayGroup) { 65 91 if(strstr($dayGroup,'-')) { 66 $exDayGroup = explode('-', $dayGroup); 92 $exDayGroup = explode('-', $dayGroup); 67 93 for($i=$exDayGroup[0];$i<=$exDayGroup[1];$i++) { 68 94 $dayName[] = str_replace($dayInt, $dayLabel, $i); … … 73 99 } 74 100 } elseif(strstr($days, '-')) { 75 $exDayGroup = explode('-', $days); 101 $exDayGroup = explode('-', $days); 76 102 for($i=$exDayGroup[0];$i<=$exDayGroup[1];$i++) { 77 103 $dayName[] = str_replace($dayInt, $dayLabel, $i); … … 80 106 $dayName[] = str_replace($dayInt, $dayLabel, $days); 81 107 } 82 108 83 109 // check the day to be in scope: 84 110 if(!in_array($today['weekday'], $dayName)) { … … 88 114 return false; 89 115 } 90 91 116 117 92 118 // derive months part 93 119 if($mons == '*') { … … 104 130 // this month is not in one of the multiplier months 105 131 if(!in_array($today['mon'],$compMons)) { 106 return false; 132 return false; 107 133 } 108 134 } elseif($mons != '*') { … … 127 153 $monName[] = $mons; 128 154 } 129 155 130 156 // check that particular months are in scope 131 157 if(!in_array($today['mon'], $monName)) { … … 133 159 } 134 160 } 135 161 136 162 137 163 // derive dates part … … 147 173 $i += $mult; 148 174 } 149 175 150 176 if(!in_array($today['mday'], $dateName)) { 151 return false; 177 return false; 152 178 } 153 179 } elseif($dates != '*') { … … 158 184 $exDateGroup = explode('-', $dateGroup); 159 185 for($i=$exDateGroup[0];$i<=$exDateGroup[1];$i++) { 160 $dateName[] = $i; 186 $dateName[] = $i; 161 187 } 162 188 } else { … … 167 193 $exDateGroup = explode('-', $dates); 168 194 for($i=$exDateGroup[0];$i<=$exDateGroup[1];$i++) { 169 $dateName[] = $i; 195 $dateName[] = $i; 170 196 } 171 197 } else { 172 198 $dateName[] = $dates; 173 199 } 174 200 175 201 // check that dates are in scope 176 202 if(!in_array($today['mday'], $dateName)) { … … 178 204 } 179 205 } 180 206 181 207 // derive hours part 182 208 $currentHour = date('G', strtotime('00:00')); … … 213 239 } 214 240 } 215 241 216 242 // derive minutes 217 243 $currentMin = date('i', strtotime($recordarray["starttime"])); … … 239 265 $i += $mult; 240 266 } 241 267 242 268 } elseif($mins != '*') { 243 269 if(strstr($mins, ',')) { … … 261 287 $minName[] = $mins; 262 288 } 263 } 289 } 264 290 265 291 // prep some boundaries - these are not in GMT b/c gmt is a 24hour period, possibly bridging 2 local days … … 281 307 $hourSeen++; 282 308 foreach($minName as $kMin=>$min) { 283 if($hr < $currentHour || $hourSeen == 25) 309 if($hr < $currentHour || $hourSeen == 25) 284 310 $theDate = date('Y-m-d', strtotime('+1 day')); 285 311 else … … 287 313 288 314 $tsGmt = strtotime($theDate.' '.str_pad($hr,2,'0',STR_PAD_LEFT).":".str_pad($min,2,'0',STR_PAD_LEFT).":00"); // this is LOCAL 289 $validJobTime[] = gmdate('Y-m-d H:i', $tsGmt); 315 $validJobTime[] = gmdate('Y-m-d H:i', $tsGmt); 290 316 } 291 317 } 292 318 sort($validJobTime); 293 319 294 return $validJobTime; 320 return $validJobTime; 295 321 }//end function 296 322 ?> -
trunk/phpbms/modules/base/general_import.php
r432 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 258 $ | $LastChangedBy: brieb $ … … 43 43 include("include/imports.php"); 44 44 include("include/parsecsv.lib.php"); 45 46 //if you need to overide the phpbmsTable class make sure to include the modules file 47 48 // include("modules/[modulename]/include/[tablename].php"); 49 50 51 //If the addedit page will be accessd directly from a page other than the 52 // basic search results page, you may want to grab and pass the previous URL 53 //with the following code 54 55 //=================================================== 56 if(!isset($_GET["backurl"])) 57 $backurl = NULL; 58 else{ 59 $backurl = $_GET["backurl"]; 60 if(isset($_GET["refid"])) 61 $backurl .= "?refid=".$_GET["refid"]; 62 } 63 //=================================================== 64 65 if(isset($_GET["id"])) 66 $tabledefid = ((int)$_GET["id"]); 67 68 69 //Here you invoke the table and import classes. If you are going to use the standard phpbmsTable class 70 // for updates and the such you would access it like this 71 72 $thetable = new phpbmsTable($db,$tabledefid); 73 $import = new phpbmsImport($thetable); 74 75 //if you are going to overide the class you would instantiate 76 // like this 77 78 // $thetable = new [tablename]($db,[table definition id],$backurl); 79 // $import = new [importname]($thetable); 80 81 //and if you are setting the backurl, make sure you pass that as well 82 // like this: 83 84 // $thetable = new [tablename]($db,[table definition id],$backurl); 85 86 87 //Next we process the form (if submitted) and 45 46 47 $tabledefid = (int) $_GET["id"]; 48 49 $querystatement = " 50 SELECT 51 `modules`.`name` AS `modulename`, 52 `tabledefs`.`maintable` AS `maintable` 53 FROM 54 `tabledefs` INNER JOIN `modules` ON `tabledefs`.`moduleid` = `modules`.`id` 55 WHERE 56 `tabledefs`.`id` = '".$tabledefid."'; 57 "; 58 59 $queryresult = $db->query($querystatement); 60 61 $thereturn = $db->fetchArray($queryresult); 62 63 //try to include table specific functions 64 if(file_exists("../".$thereturn["modulename"]."/include/".$thereturn["maintable"].".php")) 65 include("../".$thereturn["modulename"]."/include/".$thereturn["maintable"].".php"); 66 67 //next, see if the table class exists 68 if(class_exists($thereturn["maintable"])){ 69 $classname = $thereturn["maintable"]; 70 $thetable = new $classname($db,$tabledefid); 71 } else 72 $thetable = new phpbmsTable($db,$tabledefid); 73 74 //finally, check to see if import class exists 75 if(class_exists($thereturn["maintable"]."Import")){ 76 $classname = $thereturn["maintable"]."Import"; 77 $import = new $classname($thetable); 78 } else 79 $import = new phpbmsImport($thetable); 80 81 //Next we process the form (if submitted) and 88 82 // return the current record as an array ($therecord) 89 83 // or if this is a new record, it returns the defaults … … 96 90 97 91 $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import"; 98 92 99 93 // Next, we set up to include any 100 94 // additional css or javascript files we will be using … … 106 100 107 101 // if you need to define a body onlload function, do so with the phpbms property 108 102 109 103 // $phpbms->onload[] = "initializePage()"; 110 104 … … 112 106 // Next we need to define any special fields that will be used in the form 113 107 // A list of field objects (with documentation)is available in the /include/fields.php 114 // file. 115 108 // file. 109 116 110 // We need to define them here in the head 117 111 // so that any necessay javascript is loaded appropriately. 118 112 119 113 //Form Elements 120 114 //============================================================== 121 115 122 116 // Create the form 123 117 $theform = new importForm(); … … 125 119 //if you need to set specific form vaiables (like enctype, or extra onsubmit 126 120 // you can set those form properties here. 127 128 // for each field we will use, create the field object and add it to 129 // the forms list. 130 //$theinput = new inputDatePicker("orderdate", $therecord["orderdate"], "order date"); 131 //$theform->addField($theinput); 132 // 133 //$theinput = new inputCheckBox("weborder",$therecord["weborder"],NULL, false, false); 134 //$theform->addField($theinput); 135 // 136 //$theinput = new inputField("accountnumber",$therecord["accountnumber"], "account number" ,false, "integer", 20, 64); 137 //$theform->addField($theinput); 138 139 140 // if you neeed to add additional attributes toa field, it's easy. 141 //$theinput = new inputBasicList("type",$therecord["type"],array("Quote"=>"Quote","Order"=>"Order","Invoice"=>"Invoice","VOID"=>"VOID"), $displayName = NULL, $displayLabel = true); 142 //$theinput->setAttribute("onchange","checkType(this)"); 143 //$theinput->setAttribute("class","important"); 144 //$theform->addField($theinput); 121 145 122 146 123 // lastly, use the jsMerge method to create the final Javascript formatting 147 124 $theform->jsMerge(); 148 125 //============================================================== 149 //End Form Elements 150 151 include("header.php"); 152 126 //End Form Elements 127 128 include("header.php"); 129 153 130 ?><div class="bodyline"> 154 <!-- 131 <!-- 155 132 Next we start the form. This also prints the H1 with title, and top save,cancel buttons 156 133 If you need to have other buttons, or need a specific top, you will need to create your form manually. 157 134 --> 158 <?php $theform->startForm($pageTitle, $import->pageType )?>135 <?php $theform->startForm($pageTitle, $import->pageType, count($import->transactionRecords))?> 159 136 160 137 <div id="leftSideDiv"> … … 164 141 <!-- /* This next input also determines whether the file/import fieldset will be displayed or if the preview sections will be displayed*/ --> 165 142 <input id="pageType" name="pageType" type="hidden" value="<?php echo $import->pageType?>" /> 166 143 167 144 <?php 168 145 if($import->pageType == "main"){ ?> … … 175 152 <input id="import" name="import" type="file" size="64"/><br/> 176 153 </p> 177 154 178 155 <div id="info0" class="info"> 179 156 <p> … … 201 178 <?php 202 179 }//end if 203 180 204 181 if($import->error && $import->pageType != "main"){ 205 182 ?> … … 216 193 </div> 217 194 <div id="createmodifiedby" > 218 <?php 195 <?php 219 196 //Last, we show the create/modifiy with the bottom save and cancel buttons 220 197 // and then close the form. 221 $theform->showButtons(2, $import->pageType );198 $theform->showButtons(2, $import->pageType, count($import->transactionRecords)); 222 199 ?></div><?php 223 200 $theform->endForm(); -
trunk/phpbms/modules/base/include/adminsettings_include.php
r357 r485 43 43 class settings{ 44 44 var $db; 45 45 46 46 function settings($db){ 47 47 48 48 $this->db = $db; 49 50 } 51 52 49 50 } 51 52 53 53 function getSettings(){ 54 54 $therecord = array(); 55 55 56 56 $querystatement = "SELECT `name`, `value` FROM `settings`"; 57 57 $queryresult = $this->db->query($querystatement); 58 58 59 59 while($setting = $this->db->fetchArray($queryresult)) 60 60 $therecord[$setting["name"]] = $setting["value"]; 61 61 62 62 return $therecord; 63 63 } 64 65 64 65 66 66 function updateSettings($variables){ 67 67 68 68 global $phpbms; 69 69 70 70 if(!isset($variables["persistent_login"])) $variables["persistent_login"]=0; 71 71 72 72 //include any procesing that needs to be done by modules 73 73 foreach($phpbms->modules as $module => $moduleinfo) … … 77 77 $extraUpdate = new $class($this->db); 78 78 $variables = $extraUpdate->updateSettings($variables); 79 79 80 80 }//end if 81 81 82 82 // Update the settings records 83 83 foreach($variables as $settingname => $settingvalue){ 84 84 if(defined(strtoupper($settingname))){ 85 85 if(constant(strtoupper($settingname)) != $settingvalue){ 86 86 87 87 $updatestatement = " 88 UPDATE 89 settings 90 SET 91 value ='".$settingvalue."' 92 WHERE 88 UPDATE 89 settings 90 SET 91 value ='".$settingvalue."' 92 WHERE 93 93 name='".mysql_real_escape_string($settingname)."'"; 94 94 95 95 $updateresult = $this->db->query($updatestatement); 96 96 97 97 if(!$this->db->affectedRows()){ 98 98 99 99 //check to see why the update did not work 100 100 $querystatement = " 101 SELECT 101 SELECT 102 102 name 103 103 FROM … … 105 105 WHERE 106 106 name = '".mysql_real_escape_string($settingname)."'"; 107 107 108 108 $queryresult = $this->db->query($querystatement); 109 109 110 110 if(!$this->db->numRows($queryresult)){ 111 111 112 112 //insert the setting if need be 113 113 $insertstatement =" … … 120 120 '".mysql_real_escape_string($settingname)."' 121 121 }"; 122 122 123 123 $this->db-query($insertstatement); 124 124 125 125 }//end if 126 126 127 127 }//end if 128 128 129 129 }//end if 130 130 } 131 131 }//end foreach 132 132 133 133 // deal with logo graphic. 134 134 if(isset($_FILES["printedlogo"])){ 135 if($_FILES["printedlogo"]["type"] == "image/png" || $_FILES["printedlogo"]["type"] == "image/jpeg"){ 135 136 $validFileTypes = array( 137 "image/png", 138 "image/x-png", 139 "image/jpg", 140 "image/jpeg", 141 "imagep/jpeg", 142 ); 143 144 if(in_array($_FILES["printedlogo"]["type"], $validFileTypes)){ 145 136 146 if (function_exists('file_get_contents')) { 147 137 148 $file = mysql_real_escape_string(file_get_contents($_FILES['printedlogo']['tmp_name'])); 149 138 150 } else { 151 139 152 // If using PHP < 4.3.0 use the following: 140 153 $file = mysql_real_escape_string(fread(fopen($_FILES['printedlogo']['tmp_name'], 'r'), filesize($_FILES['printedlogo']['tmp_name']))); 141 } 154 155 }//endif 156 142 157 if($_FILES["printedlogo"]["type"] == "image/jpeg") 143 158 $name = "logo.jpg"; 144 159 else 145 160 $name = "logo.png"; 146 147 $querystatement="UPDATE `files` SET `file` = '".$file."', `type` = '".$_FILES["printedlogo"]["type"]."', `name`='".$name."' WHERE id=1"; 148 $queryresult=$this->db->query($querystatement); 149 } 150 } 161 162 $updatestatement = " 163 UPDATE 164 `files` 165 SET 166 `file` = '".$file."', 167 `type` = '".$_FILES["printedlogo"]["type"]."', 168 `name`='".$name."' 169 WHERE 170 id = 1"; 171 172 $this->db->query($updatestatement); 173 174 }//endif file types 175 176 }//endif file exists 151 177 152 178 return true; 153 179 154 180 }//end method 155 181 156 182 157 183 function updateEncyptionSeed($newseed,$currpassword,$userid){ 158 184 159 185 $userid = (int) $userid; 160 186 161 187 //first let's make sure the password matches 162 188 $querystatement="SELECT id FROM users WHERE id=".$userid." AND password=ENCODE('".$currpassword."','".ENCRYPTION_SEED."')"; … … 165 191 if(!$this->db->numRows($queryresult)) 166 192 return "Encryption Seed not Updated: Invalid Current Password"; 167 193 168 194 //let's update the encryption seed then 169 195 $querystatement="UPDATE settings SET value='".$newseed."' WHERE name='encryption_seed'"; 170 196 $queryresult=$this->db->query($querystatement); 171 197 172 198 //last, reencode the current password 173 199 $querystatement="UPDATE users SET password=ENCODE('".$currpassword."','".$newseed."') WHERE id=".$userid; … … 177 203 $querystatement="UPDATE users SET password = ENCODE(DECODE(password,'".ENCRYPTION_SEED."'),'".$newseed."') WHERE id !=".$userid; 178 204 $queryresult=$this->db->query($querystatement); 179 205 180 206 return "Encryption Seed Updated."; 181 } 207 } 182 208 183 209 … … 185 211 186 212 $variables = addSlashesToArray($variables); 187 213 188 214 switch($variables["command"]){ 189 215 case "update settings": … … 191 217 $statusmessage="Settings Updated"; 192 218 break; 193 219 194 220 case "update encryption seed": 195 221 if(isset($variables["changeseed"])) … … 201 227 202 228 }//end method 203 204 229 230 205 231 function displayStylesheets($stylesheet){ 206 232 207 233 $thedir="../../common/stylesheet"; 208 234 $thedir_stream = @opendir($thedir); 209 235 210 236 while($entry = @ readdir($thedir_stream)){ 211 237 if ($entry!="." and $entry!=".." and is_dir($thedir."/".$entry)) { -
trunk/phpbms/modules/base/include/files.php
r285 r485 40 40 if(class_exists("phpbmsTable")){ 41 41 class files extends phpbmsTable{ 42 42 43 var $availableRoleIDs = array(); 44 43 45 function getPicture($name){ 44 46 if (function_exists('file_get_contents')) { … … 48 50 $file = addslashes(fread(fopen($_FILES[$name]['tmp_name'], 'r'), filesize($_FILES[$name]['tmp_name']))); 49 51 } 50 52 51 53 return $file; 52 54 } 53 54 function formatVariables($variables){ 55 56 if($_FILES['upload']["name"]){ 57 58 $variables["name"] = $_FILES['upload']["name"]; 59 $variables["type"] = $_FILES['upload']['type']; 60 $variables["file"] = $this->getPicture("upload"); 61 62 } else { 63 unset($this->fields["type"]); 64 unset($this->fields["file"]); 55 56 //populates the list of possible role ids 57 //into $this->availableRoleIDs (an array) 58 function populateRoleArray(){ 59 60 $this->availableRoleIDs = array(); 61 62 $querystatement = " 63 SELECT 64 `id` 65 FROM 66 `roles`; 67 "; 68 69 $queryresult = $this->db->query($querystatement); 70 71 //next two should also be allowed, but aren't stored in the database 72 $this->availableRoleIDs[] = 0;//for everyone 73 $this->availableRoleIDs[] = -100;//for administrators 74 75 while($therecord = $this->db->fetchArray($queryresult)) 76 $this->availableRoleIDs[] = $therecord["id"]; 77 78 }//end method --populateRoleArray-- 79 80 81 function verifyVariables($variables){ 82 83 //if it is set, we'll have to check, if not, it defaults to 0 which is an acceptable 84 //value. 85 if(isset($variables["roleid"])){ 86 87 //either its numeric or == 0 88 if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 89 90 //check to see if the RoleIDs are populated 91 if(!count($this->availableRoleIDs)) 92 $this->populateRoleArray();//populate if not 93 94 //check to see if the int typecast of the roleid (to allow for values 95 //equivalent to 0) is an acceptable role id. 96 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 97 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 98 }else 99 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 65 100 }//end if 66 67 return $variables; 68 101 102 return parent::verifyVariables($variables); 103 104 }//end method 105 106 107 function prepareVariables($variables){ 108 109 if(isset($_FILES['upload'])) 110 if($_FILES['upload']["name"]){ 111 112 $variables["name"] = $_FILES['upload']["name"]; 113 $variables["type"] = $_FILES['upload']['type']; 114 $variables["file"] = $this->getPicture("upload"); 115 116 } else { 117 unset($this->fields["type"]); 118 unset($this->fields["file"]); 119 }//end if 120 121 return $variables; 122 69 123 }//end function 70 71 124 125 72 126 function updateRecord($variables, $modifiedby = NULL){ 73 74 $variables = $this->formatVariables($variables); 75 127 76 128 $thereturn = parent::updateRecord($variables, $modifiedby); 77 129 78 130 //restore the fields 79 131 $this->getTableInfo(); 80 132 81 133 return $thereturn; 82 134 }//end method 83 84 135 136 85 137 function insertRecord($variables, $createdby = NULL){ 86 87 $variables = $this->formatVariables($variables); 88 138 89 139 $newid = parent::insertRecord($variables, $createdby); 90 140 91 141 //restore the fields 92 142 $this->getTableInfo(); 93 143 94 144 return $newid; 95 145 96 146 }//end method 97 147 98 148 }//end class 99 149 }//end if … … 101 151 if(class_exists("searchFunctions")){ 102 152 class filesSearchFunctions extends searchFunctions{ 103 153 104 154 function delete_record(){ 105 155 106 156 $whereclause = $this->buildWhereClause(); 107 157 $attachmentwhereclause = $this->buildWhereClause("attachments.fileid"); 108 158 109 159 $querystatement = "DELETE FROM attachments WHERE ".$attachmentwhereclause." AND attachments.fileid!=1;"; 110 160 $queryresult = $this->db->query($querystatement); 111 161 112 162 $querystatement = "DELETE FROM files WHERE ".$whereclause." AND files.id!=1;"; 113 163 $queryresult = $this->db->query($querystatement); 114 164 115 165 $message = $this->buildStatusMessage(); 116 166 $message.=" deleted"; 117 167 return $message; 118 168 } 119 169 120 170 }//end class 121 171 }//end if -
trunk/phpbms/modules/base/include/menu.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class menus extends phpbmsTable{ 41 42 function formatVariables($variables){ 41 42 var $availableRoleIDs = array(); 43 44 function checkParentMenuIDs($currentID = 0, $parentID = 0){ 45 46 //cannot be own parent 47 $currentID = ((int) $currentID); 48 //current setting of the parentid 49 $parentID = ((int) $parentID); 50 51 if(!$parentID) 52 return true; 53 54 $querystatement = " 55 SELECT 56 `id` 57 FROM 58 `menu` 59 WHERE 60 `id` = '".$parentID."' 61 AND 62 `id`!='".$currentID."' 63 AND 64 `parentid` = '0' 65 AND 66 ( 67 `link` = '' 68 OR 69 `link` IS NULL 70 ) 71 ; 72 "; 73 74 $queryresult = $this->db->query($querystatement); 75 76 return $this->db->numRows($queryresult); 77 78 }//end method --getParentMenuIDs-- 79 80 //pouplate the id roles array 81 function populateRoleArray(){ 82 83 $this->availableRoleIDs = array(); 84 85 $querystatement = " 86 SELECT 87 `id` 88 FROM 89 `roles`; 90 "; 91 92 $queryresult = $this->db->query($querystatement); 93 94 $this->availableRoleIDs[] = 0;//for everyone 95 $this->availableRoleIDs[] = -100;//for admin 96 97 98 while($therecord = $this->db->fetchArray($queryresult)) 99 $this->availableRoleIDs[] = $therecord["id"]; 100 101 }//end method --populateRoleArray()-- 102 103 104 function verifyVariables($variables){ 105 106 //table default (0) for `roleid` is ok (i.e. doesn't have to be set) 107 if(isset($variables["roleid"])){ 108 109 //can either be numeric or equivalent to 0 110 if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 111 112 //check for populated role id array 113 if(!count($this->availableRoleIDs)) 114 $this->populateRoleArray(); 115 116 //check to see if the int typecast role id is in one of the available ones 117 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 118 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 119 }else 120 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 121 122 }//end if 123 124 //check parent ids under certain circumstances 125 //not set is acceptable 126 if(isset($variables["parentid"])){ 127 128 //can be either numeric or equivalent to 0 and its int typecast must be non-negative 129 if( !$variables["parentid"] || ((int)$variables["parentid"]) > 0 ){ 130 131 $id = 0; 132 133 //use the current id if it exists (A menu record cannot be its own parent) 134 if(isset($variables["id"])) 135 if(is_numeric($variables["id"]) && ((int) $variables["id"]) > 0) 136 $id = $variables["id"]; 137 138 //Select run every time because `id` can be different 139 if( !$this->checkParentMenuIDs($id, ((int) $variables["parentid"])) ) 140 $this->verifyErrors[] = "The `parentid` field does not give an existing/acceptable parent id number."; 141 142 }else 143 $this->verifyErrors[] = "The `roleid` field must be a non-negative number or equivalent to 0."; 144 145 }//end if 146 147 return parent::verifyVariables($variables); 148 149 }//end method --verifyVariables-- 150 151 152 function prepareVariables($variables){ 43 153 switch($variables["radio"]){ 44 154 case "cat": … … 52 162 default: 53 163 } 54 164 55 165 return $variables; 56 166 } 57 58 59 function updateRecord($variables, $modifiedby = NULL){ 60 61 $variables = $this->formatVariables($variables); 62 63 parent::updateRecord($variables, $modifiedby); 64 } 65 66 67 function insertRecord($variables, $createdby = NULL){ 68 69 $variables = $this->formatVariables($variables); 70 71 return parent::insertRecord($variables, $createdby ); 72 } 73 74 167 168 75 169 function displayTableDropDown($selectedlink){ 76 170 77 171 $querystatement="select id, displayname from tabledefs order by displayname"; 78 172 $thequery=$this->db->query($querystatement); 79 173 80 174 echo "<select id=\"linkdropdown\" name=\"linkdropdown\">\n"; 81 175 while($therecord=$this->db->fetchArray($thequery)){ 82 176 echo "<option value=\"search.php?id=".$therecord["id"]."\" "; 83 84 if ($selectedlink == "search.php?id=".$therecord["id"]) 177 178 if ($selectedlink == "search.php?id=".$therecord["id"]) 85 179 echo "selected=\"selected\""; 86 180 87 181 echo " >".$therecord["displayname"]."</option>\n"; 88 182 } 89 183 echo "</select>\n"; 90 184 91 185 }//end method 92 93 186 187 94 188 function displayParentDropDown($selectedpid,$id=0){ 95 189 96 190 if($id=="")$id=0; 97 191 $querystatement="SELECT id, name FROM menu WHERE id!=".$id." and parentid=0 and (link=\"\" or link is null) ORDER BY displayorder"; 98 192 $thequery=$this->db->query($querystatement); 99 193 100 194 echo "<select name=\"parentid\" id=\"parentid\">\n"; 101 195 echo "<option value=\"0\" "; 102 196 103 197 if ($selectedpid=="0") 104 198 echo "selected=\"selected\""; 105 199 106 200 echo " >-- none --</option>\n"; 107 201 while($therecord=$this->db->fetchArray($thequery)){ 108 202 echo "<option value=\"".$therecord["id"]."\" "; 109 if ($selectedpid==$therecord["id"]) 203 if ($selectedpid==$therecord["id"]) 110 204 echo "selected=\"selected\""; 111 205 112 206 echo " >".$therecord["name"]."</option>\n"; 113 207 } 114 208 echo "</select>\n"; 115 209 116 210 }//end method 117 211 118 212 }//end class 119 213 }//end if … … 122 216 if(class_exists("searchFunctions")){ 123 217 class menuSearchFunctions extends searchFunctions{ 124 218 125 219 function delete_record(){ 126 220 127 221 //passed variable is array of user ids to be revoked 128 222 $whereclause = $this->buildWhereClause(); 129 223 $verifywhereclause = $this->buildWhereClause("menu.parentid"); 130 224 131 225 $querystatement = "SELECT id FROM menu WHERE ".$verifywhereclause; 132 226 $queryresult = $this->db->query($querystatement); … … 136 230 $queryresult = $this->db->query($querystatement); 137 231 } 138 232 139 233 $message=$this->buildStatusMessage(); 140 234 $message.=" deleted."; 141 235 return $message; 142 236 } 143 237 144 238 }//end class 145 239 }//end if -
trunk/phpbms/modules/base/include/notes.php
r351 r485 45 45 var $weekArray = array("First"=>"1", "Second"=>"2", "Third"=>"3", "Fourth"=>"4", "Last"=>"5"); 46 46 var $dayOfWeekArray = array(); 47 48 47 48 49 49 function notes($db,$tabledefid = 0,$backurl = NULL){ 50 50 … … 57 57 } 58 58 59 59 60 60 function showWeeklyOptions($therecord,$repeatbase){ 61 61 if($therecord["repeattype"] == "Weekly") … … 63 63 else 64 64 $daysSelected = array(strftime("%u",$repeatbase)); 65 65 66 66 $daysAvailable = array(7,1,2,3,4,5,6); 67 67 68 68 foreach($daysAvailable as $dayNum){ 69 69 $tempday = ($dayNum != 7)?($dayNum+1):(1); 70 ?><button id="dayOption<?php echo $dayNum?>" class="<?php 71 70 ?><button id="dayOption<?php echo $dayNum?>" class="<?php 71 72 72 if(in_array($dayNum,$daysSelected)) 73 echo "pressed"; 74 75 ?>Buttons" type="button" value="<?php echo $dayNum?>" onclick="daySelect(this)"><?php 76 73 echo "pressed"; 74 75 ?>Buttons" type="button" value="<?php echo $dayNum?>" onclick="daySelect(this)"><?php 76 77 77 echo nl_langinfo(constant("ABDAY_".$tempday)); 78 78 79 79 ?></button><?php 80 80 } 81 82 81 82 83 83 } 84 84 85 85 function showMonthlyOptions($therecord,$repeatbase){ 86 86 if($therecord["repeattype"] == "Monthly" && $therecord["repeateachlist"]) … … 88 88 else 89 89 $daysSelected = array(strftime("%e",$repeatbase)); 90 91 90 91 92 92 for($dayNum = 1; $dayNum <= 31; $dayNum++){ 93 ?><button id="monthDayOption<?php echo $dayNum?>" class="<?php 94 93 ?><button id="monthDayOption<?php echo $dayNum?>" class="<?php 94 95 95 if(in_array($dayNum,$daysSelected)) 96 echo "pressed"; 97 98 ?>Buttons monthDays" type="button" value="<?php echo $dayNum?>" onclick="monthDaySelect(this)" <?php 99 96 echo "pressed"; 97 98 ?>Buttons monthDays" type="button" value="<?php echo $dayNum?>" onclick="monthDaySelect(this)" <?php 99 100 100 if($therecord["repeatontheday"]) 101 101 echo 'disabled="disabled"'; 102 103 ?>><?php 104 102 103 ?>><?php 104 105 105 echo $dayNum; 106 106 107 107 ?></button><?php 108 108 if(($dayNum % 7) == 0) echo "<br />"; 109 } 110 109 } 110 111 111 }//end method 112 112 113 113 114 114 function showYearlyOptions($therecord,$repeatbase){ 115 115 if($therecord["repeattype"] == "Yearly") … … 117 117 else 118 118 $monthsSelected = array(date("n",$repeatbase)); 119 119 120 120 for($monthNum = 1; $monthNum <=12; $monthNum++){ 121 ?><button id="yearlyMonthOption<?php echo $monthNum?>" class="<?php 122 121 ?><button id="yearlyMonthOption<?php echo $monthNum?>" class="<?php 122 123 123 if(in_array($monthNum,$monthsSelected)) 124 echo "pressed"; 125 126 ?>Buttons yearlyMonths" type="button" value="<?php echo $monthNum?>" onclick="yearlyMonthSelect(this)"><?php 127 124 echo "pressed"; 125 126 ?>Buttons yearlyMonths" type="button" value="<?php echo $monthNum?>" onclick="yearlyMonthSelect(this)"><?php 127 128 128 echo nl_langinfo(constant("ABMON_".$monthNum)); 129 129 130 130 ?></button><?php 131 131 if(($monthNum % 4) == 0) echo "<br />"; … … 135 135 136 136 function newerRepeats($parentid,$id){ 137 137 138 138 if ($parentid=="NULL") 139 139 $parentid=$id; 140 140 141 141 $querystatement="SELECT creationdate FROM notes WHERE id=".((int) $id); 142 142 $queryresult = $this->db->query($querystatement); 143 143 $therecord=$this->db->fetchArray($queryresult); 144 144 145 145 $querystatement="SELECT id FROM notes WHERE completed=0 AND parentid=".((int) $parentid)." AND creationdate > '".$therecord["creationdate"]."'"; 146 146 $queryresult = $this->db->query($querystatement); 147 147 148 148 if($this->db->numRows($queryresult)) return true; else return false; 149 149 } 150 151 150 151 152 152 function resetRepeating($parentid){ 153 153 154 154 $deletstatement="DELETE FROM notes WHERE completed=0 AND parentid=".$parentid; 155 155 $this->db->query($deletstatement); 156 156 157 157 $updatestatement="UPDATE notes SET parentid=NULL WHERE completed=1 AND parentid=".$parentid; 158 158 $queryresult = $this->db->query($updatestatement); 159 159 160 160 } 161 162 161 162 163 163 function updateTask($id,$completed,$type){ 164 164 165 165 if($completed) 166 166 $compDate="CURDATE()"; 167 167 else 168 168 $compDate="NULL"; 169 169 170 170 $querystatement="UPDATE notes SET completed=".((int) $completed)." , completeddate=".$compDate." WHERE id=".((int) $id); 171 171 $queryresult=$this->db->query($querystatement); 172 172 173 173 if($completed && $type == "TS") 174 174 $this->repeatTask($id); 175 175 176 176 return "success"; 177 178 } 179 180 177 178 } 179 180 181 181 function repeatTask($id, $dateToCheck = NULL){ 182 if($dateToCheck == NULL) 183 $dateToCheck = mktime(0,0,0); 182 if($dateToCheck == NULL) 183 $dateToCheck = mktime(0,0,0); 184 184 //see if we need to grab the parent 185 185 $querystatement = "SELECT parentid,repeating FROM notes WHERE id=".((int) $id); … … 191 191 return false; 192 192 193 $querystatement = "SELECT notes.repeattype, notes.repeatevery, notes.startdate, notes.enddate, notes.firstrepeat, 193 $querystatement = "SELECT notes.repeattype, notes.repeatevery, notes.startdate, notes.enddate, notes.firstrepeat, 194 194 notes.lastrepeat, 195 notes.timesrepeated, notes.repeatontheday, notes.repeatontheweek, notes.repeateachlist, 195 notes.timesrepeated, notes.repeatontheday, notes.repeatontheweek, notes.repeateachlist, 196 196 notes.repeatuntil, notes.repeattimes 197 197 FROM notes WHERE repeating=1 AND id=".((int) $id)." AND type='TS' … … 207 207 else 208 208 $startDate = stringToDate($therecord["startdate"],"SQL"); 209 209 210 210 if($dateToCheck <= $startDate) 211 211 $dateToCheck = strtotime("tomorrow",$startDate); 212 212 213 213 $dateArray = $this->getValidInRange($startDate,$dateToCheck,$therecord); 214 214 215 215 foreach($dateArray as $date){ 216 216 if($date != $startDate){ … … 219 219 else 220 220 $enddate = NULL; 221 221 222 222 $return = $this->createChildTask($id, $date, stringToDate($therecord["startdate"],"SQL"), $enddate ); 223 223 if($return){ … … 228 228 $updatestatement .= "firstrepeat='".dateToString($date,"SQL")."',"; 229 229 $updatestatement .="timesrepeated = timesrepeated+1 WHERE id =".$id; 230 230 231 231 $this->db->query($updatestatement); 232 232 … … 235 235 }//endif 236 236 }//endforeach 237 237 238 238 }//endif 239 239 }//end method 240 240 241 241 242 242 function getValidInRange($startDate,$endDate,$therecord){ 243 243 $nextDate = $startDate; 244 244 245 245 //should pad the end date to make sure we get all weekly repeats 246 246 $endDate = strtotime("+7 days",$endDate); 247 247 248 248 $validDates = array(); 249 249 250 250 while($nextDate <= $endDate){ 251 251 252 252 switch($therecord["repeattype"]){ 253 253 case "Daily": … … 256 256 $nextDate = strtotime("+".$therecord["repeatevery"]." days",$nextDate); 257 257 break; 258 259 case "Weekly": 258 259 case "Weekly": 260 260 //================================================================================== 261 261 $weekDayArray = explode("::",$therecord["repeateachlist"]); 262 262 263 263 //need to start from the sunday of the current week 264 264 $tempDate = strtotime(nl_langinfo( constant("DAY_1") ),$nextDate); 265 265 $tempDate = strtotime("-7 days",$tempDate); 266 266 267 267 foreach($weekDayArray as $weekday){ 268 268 if($weekday == 7) 269 269 $validDates[]=$tempDate; 270 270 else{ 271 $weekday++; 271 $weekday++; 272 272 $validDates[] = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 273 273 } 274 274 }// endforeach 275 276 275 276 277 277 $nextDate = strtotime("+".$therecord["repeatevery"]." week",$nextDate); 278 279 break; 280 278 279 break; 280 281 281 case "Monthly": 282 282 //================================================================================== 283 $dateArray = localtime($nextDate,true); 283 $dateArray = localtime($nextDate,true); 284 284 $daysInMonth = date("d", mktime(0,0,0,$dateArray["tm_mon"],0,$dateArray["tm_year"]+1900) ); 285 285 286 286 if($therecord["repeateachlist"]){ 287 287 $dayArray = explode("::",$therecord["repeateachlist"]); 288 288 289 289 foreach($dayArray as $theday) 290 $validDates[] = mktime(0,0,0,$dateArray["tm_mon"]+1,$theday,$dateArray["tm_year"]+1900); 291 290 $validDates[] = mktime(0,0,0,$dateArray["tm_mon"]+1,$theday,$dateArray["tm_year"]+1900); 291 292 292 } else{ 293 293 // check for things like second tuesday or last friday; 294 294 $tempDate = mktime(0,0,0,$dateArray["tm_mon"]+1,1,$dateArray["tm_year"]+1900); 295 295 $weekday = $therecord["repeatontheday"]; 296 $weekday = ($weekday == 7)? 1: ($weekday+1); 296 $weekday = ($weekday == 7)? 1: ($weekday+1); 297 297 if($therecord["repeatontheday"] != strftime("%u",$tempDate)); 298 298 $tempDate = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 299 299 300 300 while(date("n",$tempDate) == ($dateArray["tm_mon"]+1)){ 301 301 302 302 if($therecord["repeatontheweek"] == 5){ 303 303 // 5 is the "last" option, so we just need to see if … … 305 305 if($daysInMonth - date("d",$tempDate) < 7) 306 306 $validDates[] = $tempDate; 307 307 308 308 } else { 309 309 if( ceil(date("d",$tempDate)/7) == $therecord["repeatontheweek"]) 310 $validDates[] = $tempDate; 310 $validDates[] = $tempDate; 311 311 }// endif 312 312 313 313 $tempDate = strtotime("+7 days",$tempDate); 314 314 315 315 }// endwhile 316 316 }//endif 317 317 318 318 $nextDate = strtotime("+".$therecord["repeatevery"]." months", $nextDate); 319 319 break; 320 320 321 321 case "Yearly": 322 322 //================================================================================== 323 323 $monthArray = explode("::",$therecord["repeateachlist"]); 324 324 foreach($monthArray as $monthNum){ 325 $dateArray = localtime($nextDate,true); 325 $dateArray = localtime($nextDate,true); 326 326 $daysInMonth = date("d", mktime(0,0,0,$monthNum,0,$dateArray["tm_year"]+1900) ); 327 327 328 328 if(!$therecord["repeatontheday"]){ 329 329 $tempDay = ($dateArray["tm_mday"] > $daysInMonth)? $daysInMonth :$dateArray["tm_mday"]; 330 330 $validDates[] = mktime(0,0,0,$monthNum,$tempDay,$dateArray["tm_year"]+1900); 331 331 332 332 } else { 333 333 // check for things like second tuesday or last friday; 334 334 $tempDate = mktime(0,0,0,$monthNum,1,$dateArray["tm_year"]+1900); 335 335 336 336 $weekday = $therecord["repeatontheday"]; 337 $weekday = ($weekday == 7)? 1: ($weekday+1); 337 $weekday = ($weekday == 7)? 1: ($weekday+1); 338 338 if($therecord["repeatontheday"] != strftime("%u",$tempDate)); 339 339 $tempDate = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 340 341 340 341 342 342 while(date("n",$tempDate) == $monthNum){ 343 343 if($therecord["repeatontheweek"] == 5){ … … 346 346 if($daysInMonth - date("d",$tempDate) < 7) 347 347 $validDates[] = $tempDate; 348 348 349 349 } else { 350 350 if( ceil(date("d",$tempDate)/7) == $therecord["repeatontheweek"]) 351 $validDates[] = $tempDate; 351 $validDates[] = $tempDate; 352 352 }// endif 353 353 354 354 $tempDate = strtotime("+7 days",$tempDate); 355 355 356 356 }// endwhile 357 358 }//endif 359 357 358 }//endif 359 360 360 }//endforeach 361 361 362 362 $nextDate = strtotime("+".$therecord["repeatevery"]." years",$nextDate); 363 363 364 364 break; 365 365 }//endswitch 366 366 367 367 }//end while 368 368 369 369 return $validDates; 370 370 371 371 }//end method 372 372 373 373 374 374 function createChildTask($parentid, $newdate, $startdate, $enddate=NULL){ 375 375 376 376 //let's check to see if the new task already exists 377 377 $querystatement = "SELECT id FROM notes WHERE parentid=".$parentid." AND startdate='".dateToString($newdate,"SQL")."'"; … … 379 379 if($this->db->numRows($queryresult)) 380 380 return false; 381 381 382 382 $newenddate="NULL"; 383 if($enddate) 383 if($enddate) 384 384 $newenddate="\"".dateToString($newdate+($enddate-$startdate),"SQL")."\""; 385 385 386 386 $querystatement="SELECT id,type,subject,content,status,starttime,private,modifiedby,location,importance,endtime,CURDATE() as creationdate,createdby,category, 387 387 attachedtabledefid,attachedid,assignedtoid,assignedtodate,assignedtotime,assignedbyid 388 388 FROM notes WHERE id=".$parentid; 389 389 $queryresult=$this->db->query($querystatement); 390 390 391 391 $therecord=$this->db->fetchArray($queryresult); 392 392 393 393 $querystatement="SELECT id FROM notes WHERE parentid=".((int) $parentid)." AND completed=0 AND startdate=\"".dateToString($newdate,"SQL")."\""; 394 394 $queryresult=$this->db->query($querystatement); 395 395 396 396 if($this->db->numRows($queryresult)) 397 return false; 398 397 return false; 398 399 399 if(!$therecord["assignedtoid"]) 400 400 $therecord["assignedtoid"]="NULL"; 401 401 402 402 $querystatement="INSERT INTO notes (parentid,startdate,enddate,completed,completeddate, 403 403 type,subject,content,status,starttime,private,modifiedby,location,importance,endtime,creationdate,createdby,category, … … 412 412 else 413 413 $querystatement.="NULL, "; 414 414 415 415 $querystatement.=$therecord["private"].", "; 416 416 $querystatement.=$therecord["modifiedby"].", "; … … 430 430 $querystatement.="\"".$therecord["assignedtodate"]."\", "; 431 431 else 432 $querystatement.="NULL, "; 432 $querystatement.="NULL, "; 433 433 if($therecord["assignedtotime"]) 434 434 $querystatement.="\"".$therecord["assignedtotime"]."\", "; … … 436 436 $querystatement.="NULL, "; 437 437 $querystatement.=$therecord["assignedbyid"].") "; 438 438 439 439 $queryresult=$this->db->query($querystatement); 440 440 441 441 return true; 442 442 }//end method 443 444 443 444 445 445 function getAttachedTableDefInfo($id){ 446 446 if($id){ … … 452 452 $therecord["editfile"]=""; 453 453 } 454 455 return $therecord; 456 } 457 458 454 455 return $therecord; 456 } 457 458 459 459 //CLASS OVERRIDES ============================================================================= 460 460 461 461 function getDefaults(){ 462 462 $therecord = parent::getDefaults(); 463 463 464 464 if(isset($_GET["ty"])) 465 465 $therecord["type"]=$_GET["ty"]; 466 466 else 467 467 $therecord["type"]="NT"; 468 468 469 469 $therecord["private"]=true; 470 470 471 471 $therecord["attachedtabledefid"]=(isset($_GET["tabledefid"]))?$_GET["tabledefid"]:NULL; 472 472 $therecord["attachedid"]=(isset($_GET["refid"]))?$_GET["refid"]:NULL; … … 476 476 $therecord["attachedid"]=$_GET["cid"]; 477 477 } 478 478 479 479 $therecord["repeatevery"] = 1; 480 480 $therecord["repeattype"] = "Daily"; 481 481 482 482 return $therecord; 483 483 } 484 485 486 function formatVariables($variables,$userid){ 484 485 486 function verifyVariables($variables){ 487 488 //table default ok 489 if(isset($variables["type"])){ 490 switch($variables["type"]){ 491 492 case "NT": 493 case "TS": 494 case "EV": 495 break; 496 497 case "SM": 498 //for system message, not private 499 if(isset($variables["private"])) 500 if($variables["private"]) 501 $this->verifyErrors[] = "For records with `type` of 'SM' (System Message), the `private 502 field must be equivalent to 0."; 503 break; 504 505 default: 506 $this->verifyErrors[] = "The `type` field given is not an acceptable value. Acceptable values are 'NT', 'TS', 'EV', or 'SM'"; 507 break; 508 509 }//end switch 510 }//end if 511 512 //Doesn't need to be set... only used if repeating 513 514 if(isset($variables["repeat"])) 515 if($variables["repeat"]) 516 if(isset($variables["startdate"])){ 517 if($variables["startdate"]){ 518 519 }else 520 $this->verifyErrors[] = "If a `note` record is set to repeat it must also have a `startdate`."; 521 }else 522 $this->verifyErrors[] = "If a `note` record is set to repeat it must also have a `startdate`."; 523 524 if(isset($variables["repeattype"])) 525 if($variables["repeattype"])//it can be "" or NULL 526 switch($variables["repeattype"]){ 527 528 529 case "Daily": 530 case "Weekly": 531 case "Monthly": 532 case "Yearly": 533 break; 534 535 default: 536 $this->verifyErrors[] = "The `repeatetype` field given is not an acceptable value. 537 Acceptable values are 'Daily', 'Weekly', 'Monthly', or 'Yearly'"; 538 break; 539 540 }//end switch 541 542 543 //check booleans 544 if(isset($variables["completed"])) 545 if($variables["completed"] && $variables["completed"] != 1) 546 $this->verifyErrors[] = "The `completed` field must be a boolean (equivalent to 0 or exactly 1)."; 547 548 if(isset($variables["private"])) 549 if($variables["private"] && $variables["private"] != 1) 550 $this->verifyErrors[] = "The `private` field must be a boolean (equivalent to 0 or exactly 1)."; 551 552 if(isset($variables["repeating"])) 553 if($variables["repeating"] && $variables["repeating"] != 1) 554 $this->verifyErrors[] = "The `repeating` field must be a boolean (equivalent to 0 or exactly 1)."; 555 556 return parent::verifyVariables($variables); 557 558 }//end method --verifyVariables-- 559 560 561 function prepareVariables($variables,$userid = NULL){ 562 563 if($userid == NULL) 564 if(isset($_SESSION["userinfo"]["id"])) 565 $userid = $_SESSION["userinfo"]["id"]; 566 567 if($variables["id"]){ //i.e. only on update 568 569 unset($this->fields["type"]); 570 571 if($variables["typeCheck"]=="TS" && isset($variables["repeating"]) && $variables["lastrepeat"]){ 572 $variables["lastrepeat"] = NULL; 573 $variables["firstrepeat"] = NULL; 574 $variables["timesrepeated"] = NULL; 575 576 if(isset($variables["completed"])) 577 $variables["completedChange"] = 0; 578 579 $this->resetRepeating($variables["id"]); 580 }//end if 581 582 }//end if 487 583 488 584 if(isset($variables["thetype"])) 489 585 $variables["type"] = $variables["thetype"]; 490 586 491 587 if(!isset($variables["completed"])) 492 588 $variables["completeddate"] = NULL; 493 589 494 590 if($variables["enddate"] == "") { 495 591 $variables["enddate"] = NULL; 496 592 $variables["endtime"] = NULL; 497 593 } 498 594 499 595 if($variables["startdate"] == "") { 500 596 $variables["startdate"] = NULL; 501 597 $variables["starttime"] = NULL; 502 598 } 503 599 504 600 if(isset($variables["repeating"])) { 505 601 506 602 $thename="Every "; 507 603 508 604 switch($variables["repeattype"]){ 509 605 case "Daily": … … 512 608 else 513 609 $thename .= " day "; 514 610 515 611 $variables["repeatechlist"] = NULL; 516 612 $variables["repeatontheday"] = NULL; 517 613 $variables["repeatontheweek"] = NULL; 518 614 break; 519 615 520 616 case "Weekly": 521 617 if($variables["repeatevery"] != 1) … … 523 619 else 524 620 $thename .= "week on"; 525 621 526 622 foreach(explode("::",$variables["eachlist"]) as $dayNum){ 527 623 $tempday = ($dayNum != 7)?($dayNum+1):(1); … … 529 625 } 530 626 $thename = substr($thename,0,strlen($thename)-2); 531 627 532 628 if(strpos($thename,",") != false) 533 629 $thename = strrev(preg_replace("/,/","dna ",strrev($thename),1)); 534 630 535 631 $variables["repeateachlist"] = $variables["eachlist"]; 536 632 $variables["repeatontheday"] = NULL; 537 633 $variables["repeatontheweek"] = NULL; 538 634 break; 539 540 case "Monthly": 635 636 case "Monthly": 541 637 if($variables["repeatevery"] != 1) 542 638 $thename .= $variables["repeatevery"]." months"; 543 639 else 544 640 $thename .= "month"; 545 641 546 642 $thename .= " on the"; 547 643 if($variables["monthlyWhat"] == 1){ 548 644 549 645 foreach(explode("::",$variables["eachlist"]) as $dayNum) 550 646 $thename .=" ".ordinal($dayNum).", "; 551 647 552 648 $thename = substr($thename,0,strlen($thename)-2); 553 649 554 650 if(strpos($thename,",") != false) 555 651 $thename = strrev(preg_replace("/,/","dna ",strrev($thename),1)); 556 652 557 653 $variables["repeateachlist"] = $variables["eachlist"]; 558 654 $variables["repeatontheday"] = NULL; … … 562 658 if($value == $variables["monthlyontheweek"]) 563 659 $thename .= " ".strtolower($key); 564 660 565 661 foreach($this->dayOfWeekArray as $key=>$value) 566 662 if($value == $variables["monthlyontheday"]) … … 572 668 } 573 669 break; 574 670 575 671 case "Yearly": 576 672 if($variables["repeatevery"] > 1) … … 578 674 else 579 675 $thename .= "year"; 580 676 581 677 $thename .= " in"; 582 678 583 679 foreach(explode("::",$variables["eachlist"]) as $monthNum) 584 680 $thename .=" ".nl_langinfo(constant("MON_".$monthNum)).", "; 585 681 586 682 $thename = substr($thename,0,strlen($thename)-2); 587 683 if(strpos($thename,",") != false) 588 684 $thename = strrev(preg_replace("/,/","dna ",strrev($thename),1)); 589 685 590 686 $variables["repeateachlist"] = $variables["eachlist"]; 591 687 592 688 if(isset($variables["yearlyOnThe"])){ 593 689 $thename .= " on the"; … … 595 691 if($value == $variables["yearlyontheweek"]) 596 692 $thename .= " ".strtolower($key); 597 693 598 694 foreach($this->dayOfWeekArray as $key=>$value) 599 695 if($value == $variables["yearlyontheday"]) 600 696 $thename .= " ".$key; 601 697 602 698 $variables["repeatontheday"] = $variables["yearlyontheday"]; 603 699 $variables["repeatontheweek"] = $variables["yearlyontheweek"]; 604 700 605 701 } else { 606 702 607 703 $variables["repeatontheday"] = NULL; 608 704 $variables["repeatontheweek"] = NULL; 609 705 610 706 }//end if 611 707 break; 612 708 } 613 709 614 710 switch($variables["repeatend"]){ 615 711 case "never": … … 617 713 $variables["repeattimes"] = NULL; 618 714 break; 619 715 620 716 case "after": 621 717 $thename .= " for ".$variables["repeattimes"]; 622 718 623 719 $variables["repeatuntil"] = NULL; 624 720 break; 625 721 626 722 case "on date": 627 723 $thename .= " until ".$variables["repeatuntil"]; … … 631 727 $thename = trim($thename)."."; 632 728 $variables["repeatname"] = $thename; 633 729 634 730 $variables["firstrepeat"] = dateToString(stringToDate($variables["firstrepeat"],"SQL")); 635 731 $variables["lastrepeat"] = dateToString(stringToDate($variables["lastrepeat"],"SQL"));; 636 $variables["timesrepeated"] = NULL; 637 732 $variables["timesrepeated"] = NULL; 733 638 734 }else { 639 735 … … 645 741 $variables["repeatuntil"] = NULL; 646 742 $variables["repeattimes"] = NULL; 647 743 648 744 $variables["firstrepeat"] = NULL; 649 745 $variables["lastrepeat"] = NULL; … … 654 750 if($variables["assignedtoid"] != $variables["assignedtochange"]){ 655 751 if($variables["assignedtoid"] != "") 656 $variables["assignedbyid"] = $userid; 752 $variables["assignedbyid"] = $userid; 657 753 else 658 $variables["assignedbyid"] = 0; 754 $variables["assignedbyid"] = 0; 659 755 }//endif 660 756 661 757 return $variables; 758 662 759 }//end method 663 664 760 761 665 762 function updateRecord($variables, $modifiedby = NULL){ 666 667 if($modifiedby == NULL) 668 $modifiedby = $_SESSION["userinfo"]["id"]; 669 670 if($variables["typeCheck"]=="TS" && isset($variables["repeating"]) && $variables["lastrepeat"]){ 671 $variables["lastrepeat"] = NULL; 672 $variables["firstrepeat"] = NULL; 673 $variables["timesrepeated"] = NULL; 674 675 if(isset($variables["completed"])) 676 $variables["completedChange"] = 0; 677 678 $this->resetRepeating($variables["id"]); 679 } 680 681 $variables = $this->formatVariables($variables,$modifiedby); 682 683 parent::updateRecord($variables, $modifiedby); 684 685 if($variables["typeCheck"]=="TS" && isset($variables["completed"]) && $variables["completedChange"]==0) { 763 764 $thereturn = parent::updateRecord($variables, $modifiedby); 765 766 $this->getTableInfo(); 767 768 if($variables["typeCheck"]=="TS" && isset($variables["completed"]) && $variables["completedChange"]==0) { 686 769 if($variables["parentid"]){ 687 770 if(!$this->newerRepeats($variables["parentid"],$variables["id"])){ 688 771 $this->repeatTask($variables["parentid"]); 689 772 } 690 773 691 774 } elseif(isset($variables["repeating"])) { 692 775 if(!$this->newerRepeats($variables["id"],$variables["id"])){ 693 776 $this->repeatTask($variables["id"]); 694 777 } 695 778 696 779 }//endif elseif 697 }//endif 698 780 }//endif 781 782 return $thereturn; 783 699 784 }//end endmethod 700 785 701 786 702 787 function insertRecord($variables, $createdby = NULL){ 703 704 if($createdby == NULL) 705 $createdby = $_SESSION["userinfo"]["id"]; 706 707 $variables = $this->formatVariables($variables,$createdby); 708 788 709 789 $newid = parent::insertRecord($variables, $createdby); 710 790 711 791 if(isset($variables["completed"]) && isset($variables["repeating"])) 712 792 $this->repeatTask($newid); 713 793 714 794 return $newid; 715 795 }//end method 716 796 717 797 }//end class 718 798 }//end if … … 722 802 723 803 function mark_asread(){ 724 804 725 805 //passed variable is array of user ids to be revoked 726 806 $whereclause = $this->buildWhereClause(); 727 807 728 808 $querystatement = "UPDATE notes SET notes.completed=1,modifiedby=\"".$_SESSION["userinfo"]["id"]."\" WHERE (".$whereclause.") AND type!=\"SM\";"; 729 809 $queryresult = $this->db->query($querystatement); … … 732 812 733 813 $message.=" marked as completed/read."; 734 814 735 815 //for repeatable tasks, need to repeat dem! 736 816 $querystatement="SELECT id,parentid FROM notes WHERE type='TS' AND ((parentid IS NOT NULL AND parentid!=0 ) OR `repeating`=1) AND (".$whereclause.")"; 737 817 $queryresult = $this->db->query($querystatement); 738 818 if ($this->db->numRows($queryresult)){ 739 819 740 820 $thetable = new notes($this->db,12); 741 821 742 822 while($therecord=$db->fetchArray($queryresult)){ 743 if($variables["parentid"]) 823 if($variables["parentid"]) 744 824 if(!$thetable->newerRepeats($therecord["parentid"],$therecord["id"])) 745 825 $thetable->repeatTask($therecord["parentid"]); … … 748 828 $thetable->repeatTask($therecord["id"]); 749 829 }//endwhile 750 830 751 831 }//endif 752 832 753 833 return $message; 754 834 } 755 756 835 836 757 837 //delete notes 758 838 function delete_record(){ 759 839 760 840 //passed variable is array of user ids to be revoked 761 841 $whereclause = $this->buildWhereClause("notes.id"); 762 842 763 843 //we need to check for incomplete repeatable child tasks 764 844 $querystatement="SELECT notes.id, notes.parentid, notes.repeating, notes.completed 765 845 FROM notes WHERE (".$whereclause.") AND ((notes.createdby=".$_SESSION["userinfo"]["id"]." OR notes.assignedtoid=".$_SESSION["userinfo"]["id"].") 766 846 OR (".$_SESSION["userinfo"]["admin"]." =1))"; 767 847 768 848 $repeatqueryresult = $this->db->query($querystatement); 769 849 770 850 //repeat where applicable 771 851 if ($this->db->numRows($repeatqueryresult)){ 772 852 773 853 $thetable = new notes($this->db,12); 774 854 775 855 $repeatArray=array(); 776 856 $orphanArray= array(); 777 857 while($therecord=$this->db->fetchArray($repeatqueryresult)){ 778 858 779 859 if($therecord["parentid"] && $therecord["completed"] == 0){ 780 860 $repeatArray[] = array("parentid" => $therecord["parentid"], "id"=> $therecord["id"]); … … 782 862 $orphanArray[] = array("id" => $therecord["id"]); 783 863 }//endif elseif 784 864 785 865 }//endwhile 786 866 787 867 foreach($repeatArray as $repeat){ 788 868 if (!in_array($repeat["parentid"],$orphanArray)) … … 790 870 $thetable->repeatTask($repeat["parentid"]); 791 871 }//end foreach 792 872 793 873 foreach($orphanArray as $orphaner){ 794 874 $thetable->resetRepeating($orphaner); 795 875 } 796 876 797 877 }//end if 798 878 799 $querystatement = "DELETE FROM notes WHERE 879 $querystatement = "DELETE FROM notes WHERE 800 880 ((notes.createdby=".$_SESSION["userinfo"]["id"]." OR notes.assignedtoid=".$_SESSION["userinfo"]["id"].") 801 OR (".$_SESSION["userinfo"]["admin"]." =1)) 881 OR (".$_SESSION["userinfo"]["admin"]." =1)) 802 882 AND (".$whereclause.")"; 803 883 $queryresult = $this->db->query($querystatement); 804 884 805 885 $message = $this->buildStatusMessage(); 806 886 $message.=" deleted"; 807 887 808 888 return $message; 809 810 } 811 889 890 } 891 812 892 }//end class 813 893 }//end if -
trunk/phpbms/modules/base/include/relationships.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class relationships extends phpbmsTable{ 41 41 42 var $availableTabledefIDs = array(); 43 var $availableTabledefNames = array(); 44 45 //function populateds the tabledef ids 46 //and the tabledef names corresponding to those ids 47 function populateTabledefArrays(){ 48 49 $this->availableTabledefIDs = array(); 50 $this->availableTabledefNames = array(); 51 52 $querystatement = " 53 SELECT 54 `id`, 55 `displayname` 56 FROM 57 `tabledefs` 58 WHERE 59 `type` != 'view' 60 ORDER BY 61 `displayname`; 62 "; 63 64 $queryresult = $this->db->query($querystatement); 65 66 if($this->db->numRows($queryresult)){ 67 while($therecord = $this->db->fetchArray($queryresult)){ 68 69 $this->availableTabledefIDs[] = $therecord["id"]; 70 $this->availableTabledefNames[] = $therecord["displayname"]; 71 72 }//end while 73 }else{ 74 //if no valid id/names, I put in a value that will 75 //give the arrays a count but not actually match any integers 76 $this->availableTabledefIDs[] = "none"; 77 $this->availableTabledefNames[] = "none"; 78 }//end if 79 80 }//end method --populateArrays-- 81 82 83 function verifyVariables($variables){ 84 85 //cannot be table default ("") 86 if(isset($variables["tofield"])){ 87 if($variables["tofield"] === "" || $variables["tofield"] === NULL) 88 $this->verifyErrors[] = "The `tofield` field cannot be blank."; 89 }else 90 $this->verifyErrors[] = "The `tofield` field must be set."; 91 92 //cannot be table default ("") 93 if(isset($variables["fromfield"])){ 94 if($variables["fromfield"] === "" || $variables["fromfield"] === NULL) 95 $this->verifyErrors[] = "The `from` field cannot be blank."; 96 }else 97 $this->verifyErrors[] = "The `fromfield` field must be set."; 98 99 //cannot be table default (0) 100 if(isset($variables["fromtableid"])){ 101 102 //must be a positive number 103 if(((int) $variables["fromtableid"]) > 0 ){ 104 105 if(!count($this->availableTabledefIDs)) 106 $this->populateTableDefArrays(); 107 108 if(!in_array(((int)$variables["fromtableid"]), $this->availableTabledefIDs)) 109 $this->verifyErrors[] = "The `fromtableid` field does not give an existing/acceptable parent id number."; 110 }else 111 $this->verifyErrors[] = "The `fromtableid` field must be a positive number."; 112 113 }else 114 $this->verifyErrors[] = "The `fromtableid` field must be set."; 115 116 //cannot be table default (0) 117 if(isset($variables["totableid"])){ 118 119 //must be a positive number 120 if(((int) $variables["totableid"]) > 0 ){ 121 122 if(!count($this->availableTabledefIDs)) 123 $this->populateTableDefArrays(); 124 125 if(!in_array(((int)$variables["totableid"]), $this->availableTabledefIDs)) 126 $this->verifyErrors[] = "The `totableid` field does not give an existing/acceptable to table id number."; 127 }else 128 $this->verifyErrors[] = "The `totableid` field must be a positive number."; 129 }else 130 $this->verifyErrors[] = "The `totableid` field must be set."; 131 132 //check boolean 133 if(isset($variables["inherit"])) 134 if($variables["inherit"] && $variables["inherit"] != 1) 135 $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1)."; 136 137 return parent::verifyVariables($variables); 138 139 }//end method --verifyVariables-- 140 141 42 142 function displayTables($fieldname,$selectedid){ 43 44 $querystatement="SELECT id, displayname FROM tabledefs WHERE type!=\"view\" ORDER BY displayname";45 $thequery=$this->db->query($querystatement);46 143 144 if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 145 $this->populateTabledefArrays(); 146 47 147 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 48 while($therecord=$this->db->fetchArray($thequery)){ 49 echo " <option value=\"".$therecord["id"]."\""; 50 if($selectedid==$therecord["id"]) echo " selected=\"selected\""; 51 echo ">".$therecord["displayname"]."</option>\n"; 148 149 for($i = 0; $i < count($this->availableTabledefIDs); $i++){ 150 echo " <option value=\"".$this->availableTabledefIDs[$i]."\""; 151 if($selectedid==$this->availableTabledefIDs[$i]) echo " selected=\"selected\""; 152 echo ">".$this->availableTabledefNames[$i]."</option>\n"; 52 153 } 53 154 54 155 echo "</select>\n"; 55 156 } 56 157 57 158 }//end class 58 159 }//end if -
trunk/phpbms/modules/base/include/reports.php
r285 r485 39 39 if(class_exists("phpbmsTable")) { 40 40 class reports extends phpbmsTable{ 41 41 42 var $availableTabledefIDs = array(); 43 var $availableRoleIDs = array(); 44 42 45 function getDefaults(){ 43 46 $therecord = parent::getDefaults(); 44 47 45 48 $therecord["type"]="report"; 46 49 47 50 return $therecord; 48 51 49 52 } 50 53 54 //populates tabledef id array 55 function populateTabledefArray(){ 56 57 $this->availableTabledefIDs = array(); 58 59 $querystatement = " 60 SELECT 61 `id` 62 FROM 63 `tabledefs`; 64 "; 65 66 $queryresult = $this->db->query($querystatement); 67 68 //This is for the "global" option 69 $this->availableTabledefIDs[] = 0; 70 71 while($therecord = $this->db->fetchArray($queryresult)) 72 $this->availableTabledefIDs[] = $therecord["id"]; 73 74 75 76 }//end method --populateRoleArray-- 77 78 //populates role id array 79 function populateRoleArray(){ 80 81 $this->availableRoleIDs = array(); 82 83 $querystatement = " 84 SELECT 85 `id` 86 FROM 87 `roles`; 88 "; 89 90 $queryresult = $this->db->query($querystatement); 91 92 //These two are added for no restriction on the role (0) and for 93 //administrative restrictioin (-100) 94 $this->availableRoleIDs[] = 0; 95 $this->availableRoleIDs[] = -100; 96 97 while($therecord = $this->db->fetchArray($queryresult)) 98 $this->availableRoleIDs[] = $therecord["id"]; 99 100 }//end method --populateRoleArray-- 101 102 103 function verifyVariables($variables){ 104 105 //cannot be table default ("") 106 if(isset($variables["reportfile"])){ 107 if($variables["reportfile"] === "" || $variables["reportfile"] === NULL) 108 $this->verifyErrors[] = "The `reportfile` field must not be blank."; 109 }else 110 $this->verifyErrors[] = "The `reportfile` field must be set."; 111 112 //Table default (NULL) OK 113 if(isset($variables["type"])) 114 if($variables["type"])//don't care if it's "" 115 switch($variables["type"]){ 116 case "report": 117 case "PDF Report": 118 case "export": 119 break; 120 121 default: 122 $this->verifyErrors[] = "The `type` field is not an accepted value. It must be 'report', 'PDF Report', or 'export."; 123 break; 124 125 }//end switch 126 127 //Table Default (0) ok becuase it means report is globally available to any table 128 if(isset($variables["tabledefid"])){ 129 130 //must be a non-negative number or NULL/"" 131 if( (!$variables["tabledefid"]) || ((int)$variables["tabledefid"]) > 0 ){ 132 133 if(!count($this->availableTabledefIDs)) 134 $this->populateTabledefArray(); 135 136 if( !in_array((int)$variables["tabledefid"], $this->availableTabledefIDs) ) 137 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable to table definition id number."; 138 139 }else 140 $this->verifyErrors[] = "The `tabledefid` field must be either a non-negative number or equivalent to 0."; 141 142 }//end if 143 144 //Table Default (0) ok becuase it means report is globally available to any user 145 if(isset($variables["roleid"])){ 146 147 //must be a number or NULL/"" 148 if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 149 150 if(!count($this->availableRoleIDs)) 151 $this->populateRoleArray(); 152 153 if( !in_array((int)$variables["roleid"], $this->availableRoleIDs) ) 154 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable to role id number."; 155 156 }else 157 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 158 159 }//end if 160 161 return parent::verifyVariables($variables); 162 163 }//end method 164 165 51 166 function displayTables($fieldname,$selectedid){ 52 167 53 168 $querystatement="SELECT id, displayname FROM tabledefs ORDER BY displayname"; 54 $thequery=$this->db->query($querystatement); 55 169 $thequery=$this->db->query($querystatement); 170 56 171 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 57 172 58 173 echo "<option value=\"0\" "; 59 174 if ($selectedid=="0") echo "selected=\"selected\""; 60 175 echo " style=\"font-weight:bold\">global</option>\n"; 61 176 62 177 while($therecord=$this->db->fetchArray($thequery)){ 63 178 echo " <option value=\"".$therecord["id"]."\""; … … 65 180 echo ">".$therecord["displayname"]."</option>\n"; 66 181 } 67 182 68 183 echo "</select>\n"; 69 184 }//end method 70 185 71 186 }//end class 72 187 }//end if -
trunk/phpbms/modules/base/include/roles.php
r290 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class roles extends phpbmsTable{ 41 41 42 42 function updateRecord($variables, $modifiedby = NULL){ 43 43 parent::updateRecord($variables, $modifiedby); -
trunk/phpbms/modules/base/include/scheduler.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class schedulers extends phpbmsTable{ 41 41 42 var $availableRoleIDs = array(); 43 42 44 function getDefaults(){ 43 45 $therecord = parent::getDefaults(); 44 46 45 47 $therecord["crontab"]="*::*::*::*::*"; 46 48 47 49 $therecord["min"]="*"; 48 50 $therecord["hrs"]="*"; … … 50 52 $therecord["mo"]="*"; 51 53 $therecord["day"]="*"; 52 53 $therecord["startdate"] =dateToString(mktime(),"SQL");54 $therecord["starttime"] ="";55 54 55 $therecord["startdate"] = dateToString(mktime(),"SQL"); 56 $therecord["starttime"] = sqlTimeFromString(timeToString(time())); 57 56 58 $therecord["enddate"]=""; 57 59 $therecord["endtime"]=""; 58 60 59 61 return $therecord; 60 62 61 63 }//end method 62 63 64 65 64 66 function getRecord($id = 0){ 65 67 $therecord = parent::getRecord($id); 66 68 67 69 $datearray=explode(" ",$therecord["startdatetime"]); 68 70 $therecord["startdate"]=$datearray[0]; 69 71 if(isset($datearray[1])) $therecord["starttime"]=$datearray[1]; else $therecord["starttime"]=""; 70 72 71 73 $datearray=explode(" ",$therecord["enddatetime"]); 72 74 $therecord["enddate"]=$datearray[0]; 73 75 if(isset($datearray[1])) $therecord["endtime"]=$datearray[1]; else $therecord["endtime"]=""; 74 76 75 77 $cronarray=explode("::",$therecord["crontab"]); 76 78 if(isset($cronarray[0])) $therecord["min"]=$cronarray[0]; else $therecord["min"]="*"; … … 79 81 if(isset($cronarray[3])) $therecord["mo"]=$cronarray[3]; else $therecord["mo"]="*"; 80 82 if(isset($cronarray[4])) $therecord["day"]=$cronarray[4]; else $therecord["day"]="*"; 81 83 82 84 $therecord["lastrun"]=formatFromSQLDatetime($therecord["lastrun"]); 83 85 84 86 return $therecord; 85 87 86 88 }//end method 87 88 89 90 91 function verifyVariables($variables){ 92 93 //must have the file that has the job that will 94 //be run. 95 if(isset($variables["job"])){ 96 if(!$variables["job"] === "" || $variables["job"] === NULL) 97 $this->verifyErrors[] = "The `job` field must not be blank."; 98 }else 99 $this->verifyErrors[] = "The `job` field must be set."; 100 101 //checks to see if crontab is in the (somewhat) right format 102 if(isset($variables["crontab"])){ 103 $explode = explode("::", $variables["crontab"]); 104 if(count($explode) != 5) 105 $this->verifyErrors[] = "The `crontab` field is not of the proper form. There must be four pairs of '::' in the field's value."; 106 }//end if 107 108 return parent::verifyVariables($variables); 109 110 }//end method 111 112 89 113 function prepareVariables($variables){ 90 114 91 115 $temparray[0]=$variables["min"]; 92 116 $temparray[1]=$variables["hrs"]; … … 95 119 $temparray[4]=$variables["day"]; 96 120 $variables["crontab"]=implode("::",$temparray); 97 121 98 122 if($variables["startdate"]){ 99 123 $variables["startdatetime"] = $variables["startdate"]; 100 124 if($variables["starttime"]) 101 125 $variables["startdatetime"] .= " ".$variables["starttime"]; 102 } 103 else 126 }else 104 127 $variables["startdatetime"] = NULL; 105 128 129 106 130 if($variables["enddate"]){ 107 131 $variables["enddatetime"] = $variables["enddate"]; 108 132 if($variables["endtime"]) 109 133 $variables["enddatetime"].=" ".$variables["endtime"]; 110 } 111 else 112 $variables["enddatetime"] = NULL; 113 114 134 }else 135 $variables["enddatetime"] = NULL; 136 137 115 138 return $variables; 116 139 } 117 118 119 function updateRecord($variables, $modifiedby = NULL){ 120 121 $variables = $this->prepareVariables($variables); 122 123 return parent::updateRecord($variables, $modifiedby); 124 } 125 126 127 function insertRecord($variables, $createdby = NULL){ 128 129 $variables = $this->prepareVariables($variables); 130 131 return parent::insertRecord($variables, $createdby); 132 } 133 140 134 141 }//end class 135 142 }//end if -
trunk/phpbms/modules/base/include/snapshot_include.php
r443 r485 69 69 if($this->db->numRows($queryresult)){ ?> 70 70 71 <div class="box"id="systemMessageContainer">71 <div id="systemMessageContainer"> 72 72 <h2>System Messages</h2> 73 73 <?php while($therecord = $this->db->fetchArray($queryresult)) { … … 76 76 77 77 ?> 78 <h3 class="systemMessageLinks"><?php echo htmlQuotes($therecord["subject"])?> <span>[ <?php echo htmlQuotes(formatFromSQLDateTime($therecord["creationdate"]))?> <?php echo htmlQuotes($therecord["createdby"])?>]</span></h3> 79 <div class="systemMessages"> 80 <p><?php echo $therecord["content"]?></p> 81 </div> 78 <div class="systemMessageLinks"> 79 <h3><?php echo htmlQuotes($therecord["subject"])?></h3> 80 <div>by <?php echo htmlQuotes($therecord["createdby"])?> on <?php echo htmlQuotes(formatFromSQLDateTime($therecord["creationdate"]))?></div> 81 </div> 82 <div class="systemMessages"><p><?php echo $therecord["content"]?></p></div> 82 83 <?php }//end while ?> 83 84 </div> … … 113 114 114 115 $querystatement.=" 115 assignedtoid = ".$this->userid." 116 OR ( 117 type = 'TS' 118 AND (assignedtoid = 0 OR assignedtoid IS NULL) 119 AND createdby = ".$this->userid." 120 ) AND (completed = 0 121 OR (completed = 1 AND completeddate >= CURDATE()) 116 (( 117 assignedtoid = ".$this->userid." 118 OR ( 119 type = 'TS' 120 AND (assignedtoid = 0 OR assignedtoid IS NULL) 121 AND createdby = ".$this->userid." 122 ) 123 ) 124 AND ( 125 completed = 0 126 OR ( 127 completed = 1 128 AND completeddate >= CURDATE() 129 ) 130 ) 122 131 )"; 123 132 … … 129 138 130 139 $querystatement.=" 131 assignedbyid = ".$this->userid."140 (assignedbyid = ".$this->userid." 132 141 AND (completed = 0 133 142 OR (completed = 1 AND completeddate >= CURDATE()) 134 ) ";143 ))"; 135 144 136 145 $title = "Delegations"; … … 142 151 143 152 $querystatement.="AND ( 144 (startdate IS NULL AND enddate IS NULL AND assignedtodate IS NULL) OR 145 (startdate IS NOT NULL AND startdate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) OR 146 (enddate IS NOT NULL AND enddate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) OR 147 (assignedtodate IS NOT NULL AND assignedtodate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) 153 (startdate IS NULL AND enddate IS NULL AND assignedtodate IS NULL) 154 155 OR ( 156 (startdate IS NOT NULL AND startdate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) 157 AND ( 158 (enddate IS NOT NULL AND enddate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) 159 OR (assignedtodate IS NOT NULL AND assignedtodate <= DATE_ADD(CURDATE(),INTERVAL 30 DAY)) 160 ) 161 ) 148 162 )"; 149 163 … … 234 248 case "Now": 235 249 $section["title"] = "Soon"; 236 $section["date"] = mktime(0,0,0,date("m"),date("d")+7,date("Y")); ;250 $section["date"] = mktime(0,0,0,date("m"),date("d")+7,date("Y")); 237 251 break; 238 252 239 253 case "Soon": 240 254 $section["title"] = "Later"; 241 $section["date"] = mktime(0,0,0,date("m"),date("d")+31,date("Y"));; 255 // $section["date"] = mktime(0,0,0,date("m"),date("d")+31,date("Y")); 256 $section["date"] = mktime(0,0,0,date("m"),date("d"),2038); 242 257 break; 243 258 -
trunk/phpbms/modules/base/include/tabledefs.php
r427 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class tableDefinitions extends phpbmsTable{ 41 41 42 var $availableRoleIDs = array(); 43 42 44 function getDefaults(){ 43 45 $therecord = parent::getDefaults(); 44 46 45 47 $therecord["moduleid"]=1; 46 48 $therecord["deletebutton"]="delete"; … … 50 52 $therecord["advsearchroleid"]=-100; 51 53 $therecord["viewsqlroleid"]=-100; 52 54 53 55 return $therecord; 54 56 } 55 57 58 //populates $this->availableRoleIDs 59 function populateRoleArray(){ 60 61 $this->availableRoleIDs = array(); 62 63 $querystatement = " 64 SELECT 65 `id` 66 FROM 67 `roles`; 68 "; 69 70 $queryresult = $this->db->query($querystatement); 71 72 $this->availableRoleIDs[] = 0;//for everyone 73 $this->availableRoleIDs[] = -100;//for administrators 74 75 while($therecord = $this->db->fetchArray($queryresult)) 76 $this->availableRoleIDs[] = $therecord["id"]; 77 78 }//end method --populateRoleArray-- 79 80 81 function verifyVariables($variables){ 82 83 84 //the following ifs are constructed in such a way as to allow 85 //the integer 0 as an acceptable value 86 87 if(isset($variables["maintable"])){ 88 if($variables["maintable"] === "" || $variables["maintable"] === NULL) 89 $this->verifyErrors[] = "The `maintable` field must not be blank."; 90 }else 91 $this->verifyErrors[] = "The `maintable` field must be set."; 92 93 if(isset($variables["addfile"])){ 94 if($variables["addfile"] === "" || $variables["addfile"] === NULL) 95 $this->verifyErrors[] = "The `addfile` field must not be blank."; 96 }else 97 $this->verifyErrors[] = "The `addfile` field must be set."; 98 99 if(isset($variables["editfile"])){ 100 if($variables["editfile"] === "" || $variables["editfile"] === NULL) 101 $this->verifyErrors[] = "The `editfile` field must not be blank."; 102 }else 103 $this->verifyErrors[] = "The `editfile` field must be set."; 104 105 if(isset($variables["querytable"])){ 106 if($variables["querytable"] === "" || $variables["querytable"] === NULL) 107 $this->verifyErrors[] = "The `querytable` field must not be blank."; 108 }else 109 $this->verifyErrors[] = "The `querytable` field must be set."; 110 111 if(isset($variables["defaultwhereclause"])){ 112 if($variables["defaultwhereclause"] === "" || $variables["defaultwhereclause"] === NULL) 113 $this->verifyErrors[] = "The `defaultwhereclause` field must not be blank."; 114 }else 115 $this->verifyErrors[] = "The `defaultwhereclause` field must be set."; 116 117 if(isset($variables["defaultsortorder"])){ 118 if($variables["defaultsortorder"] === "" || $variables["defaultsortorder"] === NULL) 119 $this->verifyErrors[] = "The `defaultsortorder` field must not be blank."; 120 }else 121 $this->verifyErrors[] = "The `defaultsortorder` field must be set."; 122 123 if(isset($variables["deletebutton"])){ 124 if($variables["deletebutton"] === "" || $variables["deletebutton"] === NULL) 125 $this->verifyErrors[] = "The `delete` field must not be blank."; 126 }else 127 $this->verifyErrors[] = "The `delete` field must be set."; 128 129 //table default sufficient 130 if(isset($variables["type"])) 131 switch($variables["type"]){ 132 133 case "table": 134 case "view": 135 case "system": 136 break; 137 138 default: 139 $this->verifyErrors[] = "The value of `type` field is invalid. Its value must be 140 'table', 'view', or 'system'."; 141 break; 142 143 }//end switch 144 145 if(isset($variables["addroleid"])){ 146 147 if(is_numeric($variables["addroleid"]) || !$variables["addroleid"]){ 148 149 if(!count($this->availableRoleIDs)) 150 $this->populateRoleArray(); 151 152 if(!in_array(((int)$variables["addroleid"]), $this->availableRoleIDs)) 153 $this->verifyErrors[] = "The `addroleid` field does not give an existing/acceptable role id number."; 154 155 }else 156 $this->verifyErrors[] = "The `addroleid` field must be numeric or equivalent to 0."; 157 158 }//end if 159 160 if(isset($variables["editroleid"])){ 161 162 if(is_numeric($variables["editroleid"]) || !$variables["editroleid"]){ 163 164 if(!count($this->availableRoleIDs)) 165 $this->populateRoleArray(); 166 167 if(!in_array(((int)$variables["editroleid"]), $this->availableRoleIDs)) 168 $this->verifyErrors[] = "The `editroleid` field does not give an existing/acceptable role id number."; 169 170 }else 171 $this->verifyErrors[] = "The `editroleid` field must be numeric or equivalent to 0."; 172 173 }//end if 174 175 if(isset($variables["importroleid"])){ 176 177 if(is_numeric($variables["importroleid"]) || !$variables["importroleid"]){ 178 179 if(!count($this->availableRoleIDs)) 180 $this->populateRoleArray(); 181 182 if(!in_array(((int)$variables["importroleid"]), $this->availableRoleIDs)) 183 $this->verifyErrors[] = "The `importroleid` field does not give an existing/acceptable role id number."; 184 185 }else 186 $this->verifyErrors[] = "The `importroleid` field must be numeric or equivalent to 0."; 187 188 }//end if 189 190 if(isset($variables["searchroleid"])){ 191 192 if(is_numeric($variables["searchroleid"]) || !$variables["searchroleid"]){ 193 194 if(!count($this->availableRoleIDs)) 195 $this->populateRoleArray(); 196 197 if(!in_array(((int)$variables["searchroleid"]), $this->availableRoleIDs)) 198 $this->verifyErrors[] = "The `searchroleid` field does not give an existing/acceptable role id number."; 199 200 }else 201 $this->verifyErrors[] = "The `searchroleid` field must be numeric or equivalent to 0."; 202 203 }//end if 204 205 if(isset($variables["advsearchroleid"])){ 206 207 if(is_numeric($variables["advsearchroleid"]) || !$variables["advsearchroleid"]){ 208 209 if(!count($this->availableRoleIDs)) 210 $this->populateRoleArray(); 211 212 if(!in_array(((int)$variables["advsearchroleid"]), $this->availableRoleIDs)) 213 $this->verifyErrors[] = "The `advsearchroleid` field does not give an existing/acceptable role id number."; 214 215 }else 216 $this->verifyErrors[] = "The `advsearchroleid` field must be numeric or equivalent to 0."; 217 218 }//end if 219 220 if(isset($variables["viewsqlroleid"])){ 221 222 if(is_numeric($variables["viewsqlroleid"]) || !$variables["viewsqlroleid"]){ 223 224 if(!count($this->availableRoleIDs)) 225 $this->populateRoleArray(); 226 227 if(!in_array(((int)$variables["viewsqlroleid"]), $this->availableRoleIDs)) 228 $this->verifyErrors[] = "The `viewsqlroleid` field does not give an existing/acceptable role id number."; 229 230 }else 231 $this->verifyErrors[] = "The `viewsqlroleid` field must benumeric or quivalent to 0."; 232 233 }//end if 234 235 return parent::verifyVariables($variables); 236 237 }//end method --verifyVariables-- 238 56 239 function insertRecord($variables,$createdby = NULL){ 57 240 58 241 if(!isset($variables["newid"])) 59 242 $variables["newid"] = ""; 60 243 61 244 if($variables["newid"]){ 62 //this will set a specific ID to be used. 245 //this will set a specific ID to be used. 63 246 $variables["id"] = $variables["newid"]; 64 247 parent::insertRecord($variables,$createdby,true); 65 248 $newid = $variables["newid"]; 66 249 67 250 } else { 68 251 69 252 $newid = parent::insertRecord($variables,$createdby); 70 253 71 254 }//endif - newid 72 255 73 256 //we need to create the some default supporting records 74 257 //first a single column. 75 $querystatement = "INSERT INTO `tablecolumns` 76 (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) 258 $querystatement = "INSERT INTO `tablecolumns` 259 (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) 77 260 VALUES (".$newid.",'id','".$variables["maintable"].".id','left','',0,'',0,'',NULL,0);"; 78 261 $this->db->query($querystatement); 79 262 80 263 //next default button options 81 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 264 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 82 265 VALUES (".$newid.",'new','1',0,0,0);"; 83 266 $this->db->query($querystatement); 84 267 85 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 268 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 86 269 VALUES (".$newid.",'edit','1','1',0,0);"; 87 270 $this->db->query($querystatement); 88 271 89 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 272 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 90 273 VALUES (".$newid.",'printex','1',0,0,0);"; 91 274 $this->db->query($querystatement); 92 275 93 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 276 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 94 277 VALUES (".$newid.",'select','1',0,0,0);"; 95 278 $this->db->query($querystatement); 96 97 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 279 280 $querystatement = "INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`) 98 281 VALUES (".$newid.",'import','1',0,0,'-100');"; 99 282 $this->db->query($querystatement); 100 283 101 284 //next quicksearch 102 $querystatement = "INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) 285 $querystatement = "INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) 103 286 VALUES (".$newid.",'All Records','".$variables["maintable"].".id!=-1',0,0);"; 104 287 $this->db->query($querystatement); 105 288 106 289 //and last findfields 107 $querystatement = "INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) 290 $querystatement = "INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) 108 291 VALUES (".$newid.",'".$variables["maintable"].".id','id',1,'field');"; 109 292 $this->db->query($querystatement); 110 293 111 294 return $newid; 112 295 113 296 } 114 297 }//end class … … 119 302 120 303 function delete_record(){ 121 304 122 305 //passed variable is array of user ids to be revoked 123 306 $whereclause=""; … … 127 310 $linkedwhereclause = $this->buildWhereClause("tabledefid"); 128 311 $relationshipswhereclause = $this->buildWhereClause("fromtableid")." or ".$this->buildWhereClause("totableid"); 129 312 130 313 $querystatement = "DELETE FROM tablecolumns WHERE ".$linkedwhereclause.";"; 131 314 $queryresult = $this->db->query($querystatement); 132 315 133 316 $querystatement = "DELETE FROM tablefindoptions WHERE ".$linkedwhereclause.";"; 134 317 $queryresult = $this->db->query($querystatement); 135 318 136 319 $querystatement = "DELETE FROM tableoptions WHERE ".$linkedwhereclause.";"; 137 320 $queryresult = $this->db->query($querystatement); 138 321 139 322 $querystatement = "DELETE FROM tablesearchablefields WHERE ".$linkedwhereclause.";"; 140 323 $queryresult = $this->db->query($querystatement); 141 324 142 325 $querystatement = "DELETE FROM usersearches WHERE ".$linkedwhereclause.";"; 143 326 $queryresult = $this->db->query($querystatement); 144 327 145 328 $querystatement = "DELETE FROM relationships WHERE ".$relationshipswhereclause.";"; 146 329 $queryresult = $this->db->query($querystatement); 147 330 148 331 $querystatement = "DELETE FROM tabledefs WHERE ".$whereclause.";"; 149 332 $queryresult = $this->db->query($querystatement); 150 333 151 334 $message = $this->buildStatusMessage(); 152 335 $message.=" deleted."; 153 return $message; 336 return $message; 154 337 }//end method 155 338 -
trunk/phpbms/modules/base/include/users.php
r427 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class users extends phpbmsTable{ 41 42 function updateRecord($variables, $modifiedby = NULL){ 43 41 42 var $usedLoginNames = array(); 43 44 function populateLoginNameArray(){ 45 46 $querystatement=" 47 SELECT 48 `id`, 49 `login` 50 FROM 51 `users`; 52 "; 53 54 $queryresult = $this->db->query($querystatement); 55 56 if($this->db->numRows($queryresult)){ 57 while($therecord = $this->db->fetchArray($queryresult)){ 58 59 $login = $therecord["login"]; 60 $id = $therecord["id"]; 61 $this->usedLoginNames[$login]["id"] = $id; 62 63 }//end while 64 }else{ 65 //if no valid login names, I put in a value that will 66 //give the arrays a count but not actually match any realistic login names 67 $login = "THIS is @ ve|2`/ D|_||\/|B |_0GI|\| and stupid too."; 68 $id = -1; 69 70 $this->usedLoginNames[$login]["id"] = $id; 71 }//end if 72 73 }//end method 74 75 76 function verifyVariables($variables){ 77 //---------[ check login names ]------------------------------ 78 79 if(isset($variables["login"])){ 80 if( $variables["login"] !== "" || $variables["login"] !== NULL ){ 81 82 if(!count($this->usedLoginNames)) 83 $this->populateLoginNameArray(); 84 85 if(!isset($variables["id"])) 86 $variables["id"] = 0; 87 88 if($variables["id"] < 0) 89 $variables["id"] = 0; 90 91 //check to see new login name is taken 92 $templogin = $variables["login"];// using this because it looks ugly to but the brackets within brackets 93 if( array_key_exists($variables["login"], $this->usedLoginNames) ){ 94 95 if( $this->usedLoginNames[$templogin]["id"] !== $variables["id"] ) 96 $this->verifyErrors[] = "The `login` field must give an unique login name."; 97 98 }else{ 99 $this->availableProducts[$templogin]["id"] = -1;// impossible id put in (besides the type will through off the if anyways) 100 }//end if 101 102 }else 103 $this->verifyErrors[] = "The `login` field must not be blank."; 104 }else 105 $this->verifyErrors[] = "The `login` field must be set."; 106 107 //---------[ check email ]--------------------------------- 108 if(isset($variables["email"])) 109 if( $variables["email"] !== NULL && $variables["email"] !== "" && !validateEmail($variables["email"])) 110 $this->verifyErrors[] = "The `email` field must have a valid email or must be left blank."; 111 112 //---------[ check booleans ]--------------------------------- 113 if(isset($variables["revoked"])) 114 if($variables["revoked"] && $variables["revoked"] != 1) 115 $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1)."; 116 117 if(isset($variables["portalaccess"])) 118 if($variables["portalaccess"] && $variables["portalaccess"] != 1) 119 $this->verifyErrors[] = "The `portalaccess` field must be a boolean (equivalent to 0 or exactly 1)."; 120 121 if(isset($variables["admin"])) 122 if($variables["admin"] && $variables["admin"] != 1) 123 $this->verifyErrors[] = "The `admin` field must be a boolean (equivalent to 0 or exactly 1)."; 124 125 return parent::verifyVariables($variables); 126 127 }//end method --verifyVariables-- 128 129 130 function updateRecord($variables, $modifiedby = NULL){ 131 44 132 if($variables["password"]) 45 133 $this->fields["password"]["type"] = "password"; … … 48 136 49 137 unset($this->fields["lastlogin"]); 50 138 51 139 parent::updateRecord($variables, $modifiedby); 52 140 53 141 if($variables["roleschanged"]==1) 54 142 $this->assignRoles($variables["id"],$variables["newroles"]); 55 143 56 144 //reset field information 57 145 $this->fields = $this->db->tableInfo($this->maintable); 58 146 } 59 147 60 61 function insertRecord($variables, $createdby = NULL){ 62 148 149 function insertRecord($variables, $createdby = NULL){ 150 63 151 $this->fields["password"]["type"] = "password"; 64 152 unset($this->fields["lastlogin"]); 65 153 66 154 $theid = parent::insertRecord($variables, $createdby); 67 155 68 156 //reset field information 69 157 $this->fields = $this->db->tableInfo($this->maintable); … … 71 159 return $theid; 72 160 } 73 161 74 162 function assignRoles($id,$roles){ 75 163 $querystatement="DELETE FROM rolestousers WHERE userid=".$id; 76 164 $queryresult=$this->db->query($querystatement); 77 165 78 166 $newroles=explode(",",$roles); 79 167 80 168 foreach($newroles as $therole) 81 169 if($therole!=""){ … … 84 172 } 85 173 } 86 87 174 175 88 176 function displayRoles($id,$type){ 89 177 $querystatement="SELECT roles.id,roles.name 90 FROM roles INNER JOIN rolestousers ON rolestousers.roleid=roles.id 178 FROM roles INNER JOIN rolestousers ON rolestousers.roleid=roles.id 91 179 WHERE rolestousers.userid=".((int) $id); 92 180 $assignedquery=$this->db->query($querystatement); 93 181 94 182 $thelist=array(); 95 183 96 184 if($type=="available"){ 97 185 $excludelist=array(); 98 186 while($therecord=$this->db->fetchArray($assignedquery)) 99 187 $excludelist[]=$therecord["id"]; 100 188 101 189 $querystatement="SELECT id,name FROM roles WHERE inactive=0"; 102 190 $availablequery=$this->db->query($querystatement); 103 191 while($therecord=$this->db->fetchArray($availablequery)) 104 192 if(!in_array($therecord["id"],$excludelist)) 105 $thelist[]=$therecord; 106 } else 193 $thelist[]=$therecord; 194 } else 107 195 while($therecord=$this->db->fetchArray($assignedquery)) 108 196 $thelist[]=$therecord; 109 197 110 198 foreach($thelist as $theoption){ 111 199 ?> <option value="<?php echo $theoption["id"]?>"><?php echo htmlQuotes($theoption["name"])?></option> 112 <?php 200 <?php 113 201 } 114 202 }//end function … … 120 208 121 209 function delete_record(){ 122 210 123 211 //passed variable is array of user ids to be revoked 124 212 $whereclause = $this->buildWhereClause(); 125 213 126 214 $querystatement = "UPDATE users SET revoked=1,modifiedby=".$_SESSION["userinfo"]["id"]." WHERE ".$whereclause.";"; 127 215 $queryresult = $this->db->query($querystatement); 128 216 129 217 $message = $this->buildStatusMessage(); 130 218 $message.=" revoked access."; 131 return $message; 132 } 133 134 219 return $message; 220 } 221 222 135 223 }//end class 136 224 }//end if -
trunk/phpbms/modules/base/include/usersearches.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class userSearches extends phpbmsTable{ 41 41 42 var $availableUserIDs = array(); 43 var $availableTabledefIDs = array(); 44 var $availableRoleIDs = array(); 45 46 47 function populateUserArray(){ 48 49 $this->availableUserIDs = array(); 50 51 $querystatement = " 52 SELECT 53 `id` 54 FROM 55 `users`; 56 "; 57 58 $queryresult = $this->db->query($querystatement); 59 60 $this->availableUserIDs[] = 0;//for global 61 62 while($therecord = $this->db->fetchArray($queryresult)) 63 $this->availableUserIDs[] = $therecord["id"]; 64 65 }//end method --populateUserArray-- 66 67 68 function populateRoleArray(){ 69 70 $this->availableRoleIDs = array(); 71 72 $querystatement = " 73 SELECT 74 `id` 75 FROM 76 `roles`; 77 "; 78 79 $queryresult = $this->db->query($querystatement); 80 81 $this->availableRoleIDs[] = 0;//for global 82 $this->availableRoleIDs[] = -100;//for admin 83 84 while($therecord = $this->db->fetchArray($queryresult)) 85 $this->availableRoleIDs[] = $therecord["id"]; 86 87 88 }//end method --populateRoleArray-- 89 90 91 function populateTabledefArray(){ 92 93 $this->availableTabledefIDs = array(); 94 95 $querystatement = " 96 SELECT 97 `id` 98 FROM 99 `tabledefs`; 100 "; 101 102 $queryresult = $this->db->query($querystatement); 103 104 if($this->db->numRows($queryresult)){ 105 while($therecord = $this->db->fetchArray($queryresult)) 106 $this->availableTabledefIDs[] = $therecord["id"]; 107 }else 108 $this->availableTabledefIDs[] = "none";// so the function doesn't keep 109 //getting called 110 111 112 }//end method --populateRoleArray-- 113 114 115 function verifyVariables($variables){ 116 117 //table default (SCH) is sufficient 118 if(isset($variables["type"])){ 119 120 switch($variables["type"]){ 121 122 case "SRT": 123 case "SCH": 124 break; 125 126 default: 127 $this->verifyErrors[] = "The value of `type` field is invalid. Its value must be 128 'SRT' or 'SCH'."; 129 break; 130 131 }//end switch 132 133 }//end if 134 135 //table default (0) is sufficient 136 if(isset($variables["userid"])){ 137 138 if( !$variables["userid"] || ((int) $variables["userid"] > 0) ){ 139 140 if(!count($this->availableUserIDs)) 141 $this->populateUserArray(); 142 143 if(!in_array(((int)$variables["userid"]), $this->availableUserIDs)) 144 $this->verifyErrors[] = "The `userid` field does not give an existing/acceptable user id number."; 145 146 }else 147 $this->verifyErrors[] = "The `userid` field must be a non-negative number or equivalent to 0."; 148 149 }//end if 150 151 //The table default is not enough, so it must be set 152 if(isset($variables["tabledefid"])){ 153 154 if(is_numeric($variables["tabledefid"]) || !$variables["tabledefid"]){ 155 156 if(!count($this->availableTabledefIDs)) 157 $this->populateTabledefArray(); 158 159 if(!in_array(((int)$variables["tabledefid"]), $this->availableTabledefIDs)) 160 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition id number."; 161 }else 162 $this->verifyErrors[] = "The `tabledefid` field must be numeric or equivalent to 0."; 163 }else 164 $this->verifyErrors[] = "The `tabledefid` field must be set."; 165 166 //table default (0) is sufficient 167 if(isset($variables["roleid"])){ 168 169 if(is_numeric($variables["roleid"]) || !$variables["roleid"]){ 170 171 if(!count($this->availableRoleIDs)) 172 $this->populateRoleArray(); 173 174 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 175 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 176 }else 177 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 178 179 }//end if 180 181 return parent::verifyVariables($variables); 182 183 }//end method 184 185 42 186 function displayTables($fieldname,$selectedid){ 43 187 44 188 $querystatement="SELECT id, displayname FROM tabledefs ORDER BY displayname"; 45 189 $thequery=$this->db->query($querystatement); 46 190 47 191 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 48 192 while($therecord=$this->db->fetchArray($thequery)){ … … 53 197 echo "</select>\n"; 54 198 } 55 199 200 56 201 function updateRecord($variables, $modifiedby = NULL){ 57 202 58 203 if(isset($variables["makeglobal"])) 59 204 $variables["userid"] = 0; 60 205 61 206 parent::updateRecord($variables, $modifiedby); 62 207 } 63 208 64 209 }//end class 65 210 }//end if -
trunk/phpbms/modules/base/notes_addedit.php
r384 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 40 require_once("../../include/session.php"); 39 //var_dump($_POST); 40 //exit; 41 require_once("../../include/session.php"); 41 42 require_once("include/fields.php"); 42 43 require_once("include/tables.php"); 43 44 require_once("include/notes.php"); 44 45 45 if(isset($_GET["backurl"])){ 46 if(isset($_GET["backurl"])){ 46 47 $backurl=$_GET["backurl"]; 47 48 if(isset($_GET["refid"])) … … 49 50 } else 50 51 $backurl = NULL; 51 52 52 53 $thetable = new notes($db,12,$backurl); 53 54 $therecord = $thetable->processAddEditPage(); 54 55 55 56 if(isset($therecord["phpbmsStatus"])) 56 $statusmessage = $therecord["phpbmsStatus"]; 57 $statusmessage = $therecord["phpbmsStatus"]; 57 58 58 59 … … 69 70 $theform->onsubmit = "return submitForm(this)"; 70 71 $theform->id = "record"; 71 72 72 73 $temparray = array("Note"=>"NT","Task"=>"TS","Event"=>"EV","System Message"=>"SM"); 73 74 $theinput = new inputBasicList("thetype",$therecord["type"],$temparray,"type"); … … 75 76 $theinput->setAttribute("onchange","changeType()"); 76 77 $theform->addField($theinput); 77 78 78 79 $theinput = new inputField("subject",$therecord["subject"], "title" ,true); 79 $theform->addField($theinput); 80 $theform->addField($theinput); 80 81 81 82 $temparray = array("Highest"=>3,"High"=>2,"Medium"=>1,"Normal"=>0,"Low"=>-1,"Lowest"=>-2); 82 83 $theinput = new inputBasicList("importance",$therecord["importance"],$temparray,"importance",false); 83 84 $theform->addField($theinput); 84 85 85 86 $theinput = new inputCheckbox("private",$therecord["private"]); 86 87 $theform->addField($theinput); 87 88 88 89 $theinput = new inputDatePicker("startdate",$therecord["startdate"], "start date" ,false, 11, 15, false); 89 $theinput->setAttribute("onchange","checkEndDate();"); 90 $theinput->setAttribute("onchange","checkEndDate();"); 90 91 $theform->addField($theinput); 91 92 92 93 $theinput = new inputTimePicker("starttime",$therecord["starttime"], "start time" ,false,11, 15, false); 93 $theinput->setAttribute("onchange","checkEndDate();"); 94 $theform->addField($theinput); 95 94 $theinput->setAttribute("onchange","checkEndDate();"); 95 $theform->addField($theinput); 96 96 97 $theinput = new inputDatePicker("enddate",$therecord["enddate"], "end date" ,false, 11, 15, false); 97 98 $theform->addField($theinput); 98 99 99 100 $theinput = new inputTimePicker("endtime",$therecord["endtime"], "end time" ,false,11, 15, false); 100 $theform->addField($theinput); 101 $theform->addField($theinput); 101 102 102 103 $theinput = new inputCheckbox("completed",$therecord["completed"],"completed",false,false); … … 110 111 $theinput = new inputChoiceList($db, "status",$therecord["status"],"notestatus"); 111 112 $theform->addField($theinput); 112 113 113 114 $theinput = new inputSmartSearch($db, "assignedtoid", "Pick Active User", $therecord["assignedtoid"], "assigned to", false, 18, 255, false); 114 115 $theform->addField($theinput); 115 116 116 117 $theinput = new inputDatePicker("assignedtodate",$therecord["assignedtodate"], "follow up date"); 117 118 $theform->addField($theinput); 118 119 119 120 $theinput = new inputTimePicker("assignedtotime",$therecord["assignedtotime"], "follow up time" ,false,11, 15, false); 120 $theform->addField($theinput); 121 $theform->addField($theinput); 121 122 122 123 $theinput = new inputChoiceList($db, "category",$therecord["category"],"notecategories"); … … 129 130 else 130 131 $repeatBase = mktime(); 131 132 132 133 $theinput = new inputCheckbox("repeating",$therecord["repeating"],"repeat"); 133 134 $theinput->setAttribute("onchange","checkRepeat();"); 134 135 $theform->addField($theinput); 135 136 136 137 $temparray = array("Daily"=>"Daily", "Weekly"=>"Weekly", "Monthly"=>"Monthly", "Yearly"=>"Yearly"); 137 138 $theinput = new inputBasiclist("repeattype",$therecord["repeattype"],$temparray,"frequency"); 138 139 $theinput->setAttribute("onchange","changeRepeatType();"); 139 140 $theform->addField($theinput); 140 141 141 142 $theinput = new inputField("repeatevery",$therecord["repeatevery"],"frequency of repeating",false,"integer",2,4,false); 142 143 $theform->addField($theinput); 143 144 144 145 $theinput = new inputBasiclist("monthlyontheweek",$therecord["repeatontheweek"],$thetable->weekArray,"on the week of",false); 145 146 $theinput2 = new inputBasiclist("yearlyontheweek",$therecord["repeatontheweek"],$thetable->weekArray,"on the week of",false); … … 150 151 $weekNumber = ceil(date("d",$repeatBase)/7); 151 152 if($weekNumber > 4) $weekNumber = 5; 152 153 153 154 $theinput->value = $weekNumber; 154 155 $theinput2->value = $weekNumber; 155 156 156 157 } 157 158 $theform->addField($theinput); 158 159 $theform->addField($theinput2); 159 160 160 161 $temparray = array(); 161 162 for($i=1; $i<8; $i++) … … 186 187 $theinput = new inputField("repeattimes",$therecord["repeattimes"],"repeat until number of times",false,"integer",3,5,false); 187 188 $theform->addField($theinput); 188 189 189 190 if(!$therecord["repeatuntil"]) 190 191 $therecord["repeatuntil"] = dateToString(mktime(),"SQL"); … … 193 194 $theform->addField($theinput); 194 195 //end repeat fields 195 196 196 197 $theform->jsMerge(); 197 198 //============================================================== 198 //End Form Elements 199 199 //End Form Elements 200 200 201 include("header.php"); 201 202 202 203 ?><div class="bodyline"> 203 204 <?php $theform->startForm($pageTitle)?> … … 211 212 <input name="thebackurl" id="thebackurl" type="hidden" value="<?php if(isset($_GET["backurl"])) echo $_GET["backurl"]; ?>" /> 212 213 </p> 213 214 214 215 <p> 215 216 <?php $theform->showField("thetype")?> 216 <input type="hidden" id="typeCheck" name="typeCheck" value="<?php echo $therecord["type"]?>" /> 217 <input type="hidden" id="typeCheck" name="typeCheck" value="<?php echo $therecord["type"]?>" /> 217 218 </p> 218 219 219 220 <p><?php $theform->showField("subject") ?></p> 220 221 </fieldset> 221 222 222 223 <div id="leftSideDiv"> 223 224 <fieldset> … … 234 235 <label for="startdate" id="starttext">start</label><br /> 235 236 <input name="dostart" id="startcheck" type="checkbox" value="1" <?php if($therecord["startdate"]) echo "checked=\"checked\"" ?> onclick="dateChecked('start')" class="radiochecks" /> 236 <?php $theform->showField("startdate");?> 237 <?php $theform->showField("startdate");?> 237 238 <?php $theform->showField("starttime");?> 238 239 </p> … … 240 241 <label for="enddate" id="endtext">end</label><br /> 241 242 <input name="doend" id="endcheck" type="checkbox" value="1" <?php if($therecord["enddate"]) echo "checked=\"checked\"" ?> onclick="dateChecked('end')" class="radiochecks" /> 242 <?php $theform->showField("enddate");?> 243 <?php $theform->showField("enddate");?> 243 244 <?php $theform->showField("endtime");?> 244 245 </p> 245 246 </fieldset> 246 247 247 248 <div id="thecompleted" class="fauxP"> 248 249 <p> … … 251 252 <?php $theform->showField("completeddate")?> 252 253 </p> 253 <p id="thestatus"><?php $theform->showField("status") ?></p> 254 <p id="thestatus"><?php $theform->showField("status") ?></p> 254 255 </div> 255 256 256 257 <fieldset> 257 258 <legend><label for="ds-assignedtoid">assigned to</label></legend> … … 275 276 <p><?php $theform->showField("assignedtodate");?> <?php $theform->showField("assignedtotime")?></p> 276 277 </fieldset> 277 278 278 279 <input id="attachedtabledefid" name="attachedtabledefid" type="hidden" value="<?php echo $therecord["attachedtabledefid"]?>" /> 279 280 <fieldset id="theassociated"> … … 283 284 <input id="assocarea" type="text" readonly="readonly" class="uneditable" value="<?php echo $attachedtableinfo["displayname"];?>" /> 284 285 </p> 285 286 286 287 <p> 287 288 <label for="attachedid">record id</label><br /> … … 296 297 <input name="location" id="location" type="text" value="<?php echo $therecord["location"]?>"/> 297 298 </p> 298 299 <p><?php $theform->showField("category") ?></p> 300 </fieldset> 301 299 300 <p><?php $theform->showField("category") ?></p> 301 </fieldset> 302 302 303 </div> 303 304 … … 316 317 317 318 <div id="repeatDiv"> 318 319 319 320 <div <?php if($therecord["parentid"]) echo 'style="display:none;"'?>> 320 321 <input type="hidden" id="bypass" name="bypass" value=""/> … … 325 326 <fieldset> 326 327 <legend>repeat</legend> 327 328 328 329 <p><?php $theform->showField("repeating")?></p> 329 330 330 331 <div id="repeatOptions" <?php if(!$therecord["repeating"]) echo 'style="display:none"'?>> 331 332 332 333 <p><?php $theform->showField("repeattype")?></p> 333 334 334 335 <p>every <?php $theform->showField("repeatevery")?> <span id="repeatTypeText">day(s)</span></p> 335 336 336 337 <div id="DailyDiv"></div> 337 338 338 339 <div id="WeeklyDiv"> 339 340 <p><?php $thetable->showWeeklyOptions($therecord,$repeatBase)?></p> 340 341 </div> 341 342 342 343 <div id="MonthlyDiv"> 343 344 <p><input type="radio" id="monthlyEach" name="monthlyWhat" onchange="monthlyChange();" value="1" <?php if(!$therecord["repeatontheday"]) echo 'checked="checked"'?> /><label for="monthlyEach"> each</label></p> 344 345 345 346 <p><?php $thetable->showMonthlyOptions($therecord,$repeatBase)?></p> 346 347 347 348 <p><input type="radio" id="monthlyOnThe" name="monthlyWhat" onchange="monthlyChange();" value="2" <?php if($therecord["repeatontheday"]) echo 'checked="checked"'?> /><label for="monthlyOnThe"> on the</label></p> 348 349 <p> … … 351 352 </p> 352 353 </div> 353 354 354 355 <div id="YearlyDiv"> 355 356 <p><?php $thetable->showYearlyOptions($therecord,$repeatBase)?></p> 356 357 357 358 <p><input id="yearlyOnThe" type="checkbox" name="yearlyOnThe" onclick="yearlyOnTheChecked();" value="1" <?php if($therecord["repeattype"]=="Yearly" && $therecord["repeatontheday"]) echo 'checked="checked"'?>/><label for="yearlyOnThe"> on the</label></p> 358 359 <p> … … 360 361 <?php $theform->showField("yearlyontheday");?> 361 362 </p> 362 363 363 364 </div> 364 365 </div> 365 366 </fieldset> 366 367 367 368 <fieldset id="repeatEnding" <?php if(!$therecord["repeating"]) echo 'style="display:none"'?>> 368 369 <legend>end</legend> … … 383 384 <p>This record was created from a repeated task/event.</p> 384 385 <p>Click the <strong>Edit Repeating Options</strong> button to edit the options for the repeatable parent record.</p> 385 <p class="notes">Any unsaved changes with the current record will be lost.</p> 386 <p class="notes">Any unsaved changes with the current record will be lost.</p> 386 387 <p><input id="goparent" name="goparent" type="button" value="Edit Repeating Options..." onclick="goParent('<?php echo getAddEditFile($db,12) ?>')" class="Buttons" /></p> 387 388 </fieldset> 388 389 <?php }//endif ?> 389 390 </div> 390 <?php 391 <?php 391 392 $theform->showCreateModify($phpbms,$therecord); 392 393 $theform->endForm(); -
trunk/phpbms/modules/base/scheduler_addedit.php
r290 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 197 $ | $LastChangedBy: brieb $ … … 45 45 $thetable = new schedulers($db,201); 46 46 $therecord = $thetable->processAddEditPage(); 47 47 48 48 if(isset($therecord["phpbmsStatus"])) 49 $statusmessage = $therecord["phpbmsStatus"]; 50 49 $statusmessage = $therecord["phpbmsStatus"]; 50 51 51 $pageTitle="Scheduler"; 52 52 53 53 $currentpath=getcwd(); 54 54 55 55 $phpbms->cssIncludes[] = "pages/scheduler.css"; 56 56 … … 58 58 //============================================================== 59 59 $theform = new phpbmsForm(); 60 60 61 61 $theinput = new inputCheckbox("inactive",$therecord["inactive"]); 62 62 $theform->addField($theinput); … … 72 72 $theform->addField($theinput); 73 73 74 $theinput = new inputTimePicker("starttime",$therecord["starttime"], "start time" , false,11, 15, false);75 $theinput->setAttribute("onchange","checkEndDate();");76 $theform->addField($theinput); 77 74 $theinput = new inputTimePicker("starttime",$therecord["starttime"], "start time" ,true,11, 15, false); 75 //$theinput->setAttribute("onchange","checkEndDate();"); 76 $theform->addField($theinput); 77 78 78 $theinput = new inputDatePicker("enddate",$therecord["enddate"], "end date" ,false, 11, 15, false); 79 79 $theform->addField($theinput); 80 80 81 81 $theinput = new inputTimePicker("endtime",$therecord["endtime"], "end time" ,false,11, 15, false); 82 $theform->addField($theinput); 82 $theform->addField($theinput); 83 83 84 84 $theform->jsMerge(); 85 85 //============================================================== 86 //End Form Elements 87 86 //End Form Elements 87 88 88 include("header.php"); 89 89 90 90 ?><div class="bodyline"> 91 <?php $theform->startForm($pageTitle)?> 92 91 <?php $theform->startForm($pageTitle)?> 92 93 93 <fieldset id="fsAttributes"> 94 94 <legend>attributes</legend> … … 97 97 <input id="id" name="id" type="text" value="<?php echo htmlQuotes($therecord["id"]); ?>" size="10" maxlength="10" readonly="readonly" class="uneditable" /> 98 98 </p> 99 99 100 100 <p><?php $theform->showField("inactive");?></p> 101 101 … … 105 105 </p> 106 106 </fieldset> 107 107 108 108 <div id="leftSideDiv"> 109 109 <fieldset> … … 116 116 <legend>Scheduled Job</legend> 117 117 118 <p><?php $theform->showField("name");?></p> 118 <p><?php $theform->showField("name");?></p> 119 119 120 120 <p> … … 127 127 </p> 128 128 </fieldset> 129 129 130 130 <fieldset> 131 131 <legend>Interval</legend> … … 151 151 </p> 152 152 <p class="notes" id="standarNotationP">(Uses standard crontab notation.)</p> 153 153 154 154 </fieldset> 155 155 <fieldset> … … 157 157 <p> 158 158 <label for="startdate">start</label><br /> 159 <?php $theform->showField("startdate");?> <?php $theform->showField("starttime");?> 159 <?php $theform->showField("startdate");?> <?php $theform->showField("starttime");?> 160 160 </p> 161 161 <p> 162 162 <label for="enddate">end</label><br /> 163 <?php $theform->showField("enddate");?> <?php $theform->showField("endtime");?> 163 <?php $theform->showField("enddate");?> <?php $theform->showField("endtime");?> 164 164 </p> 165 165 </fieldset> 166 166 </div> 167 167 168 <?php 168 <?php 169 169 $theform->showCreateModify($phpbms,$therecord); 170 170 $theform->endForm(); -
trunk/phpbms/modules/base/scheduler_delete_tempimport.php
r427 r485 1 1 <?php 2 if(!class_exists("appError")) 3 include_once("../../include/session.php"); 2 3 //uncomment for debug purposes 4 //if(!class_exists("appError")) 5 // include_once("../../include/session.php"); 4 6 5 7 class cleanImports{ 6 8 7 9 function cleanImports($db){ 8 10 $this->db = $db; 9 11 }//end method --cleanImports-- 10 11 function removeTempCSV($tempFileID = 0){ 12 13 $querystatement = " 14 DELETE FROM 15 `files` 16 WHERE 17 `type` = 'phpbms/temp' 18 AND 19 ( 20 `id` = ".((int)$tempFileID)." 21 OR 22 `creationdate` <= NOW() - INTERVAL 30 MINUTE 23 ); 24 "; 25 26 $queryresult = $this->db->query($querystatement); 27 28 }//end method --_removeTempCSV-- 29 12 13 function removeTempCSV(){ 14 15 $querystatement = " 16 DELETE FROM 17 `files` 18 WHERE 19 `type` = 'phpbms/temp' 20 AND 21 `creationdate` <= NOW() - INTERVAL '30' MINUTE 22 ; 23 "; 24 25 $queryresult = $this->db->query($querystatement); 26 27 }//end method --_removeTempCSV-- 28 30 29 }//end class --cleanImports-- 31 30 -
trunk/phpbms/modules/base/snapshot.php
r443 r485 43 43 $pageTitle = APPLICATION_NAME; 44 44 45 $phpbms->cssIncludes[] = "pages/ snapshot.css";45 $phpbms->cssIncludes[] = "pages/base/snapshot.css"; 46 46 47 47 $phpbms->jsIncludes[] = "modules/base/javascript/snapshot.js"; … … 63 63 <div class="bodyline"> 64 64 <h1><?php echo $_SESSION["userinfo"]["firstname"]; if($_SESSION["userinfo"]["lastname"]) echo " ".$_SESSION["userinfo"]["lastname"]?>'s Snapshot</h1> 65 65 66 <?php $myBase->showSystemMessages() ?> 66 67 -
trunk/phpbms/modules/base/tabs_addedit.php
r285 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 205 $ | $LastChangedBy: brieb $ … … 46 46 47 47 if(isset($therecord["phpbmsStatus"])) 48 $statusmessage = $therecord["phpbmsStatus"]; 48 $statusmessage = $therecord["phpbmsStatus"]; 49 49 50 $pageTitle="Tab"; 50 $pageTitle="Tab"; 51 51 $phpbms->cssIncludes[] = "pages/tabs.css"; 52 52 … … 54 54 //============================================================== 55 55 $theform = new phpbmsForm(); 56 56 57 57 $theinput = new inputField("name",$therecord["name"],NULL,true,NULL,32,64); 58 58 $theinput->setAttribute("class","important"); … … 61 61 $theinput = new inputField("displayorder",$therecord["displayorder"],"display order",true,NULL,10,10); 62 62 $theform->addField($theinput); 63 63 64 64 $theinput = new inputRolesList($db,"roleid",$therecord["roleid"],"access (role)"); 65 $theform->addField($theinput); 65 $theform->addField($theinput); 66 66 67 67 $theinput = new inputChoiceList($db,"tabgroup",$therecord["tabgroup"],"tabgroups", "tab group"); 68 $theform->addField($theinput); 68 $theform->addField($theinput); 69 69 70 70 $theinput = new inputCheckbox("enableonnew",$therecord["enableonnew"],"enable on new"); 71 $theform->addField($theinput); 72 71 $theform->addField($theinput); 72 73 73 $theform->jsMerge(); 74 74 //============================================================== 75 //End Form Elements 76 75 //End Form Elements 76 77 77 include("header.php"); 78 78 79 79 ?><div class="bodyline"> 80 <?php $theform->startForm($pageTitle)?> 80 <?php $theform->startForm($pageTitle)?> 81 81 <fieldset id="fsAttributes"> 82 82 <legend>attributes</legend> … … 85 85 <input id="id" name="id" type="text" value="<?php echo htmlQuotes($therecord["id"]); ?>" size="10" maxlength="10" readonly="readonly" class="uneditable" /> 86 86 </p> 87 87 88 88 <p> 89 89 <?php $theform->showField("displayorder"); ?><br /> 90 90 <span class="notes">Lower numbers are displayed first.</span> 91 91 </p> 92 92 93 93 <p><?php $theform->showField("roleid")?></p> 94 94 … … 96 96 97 97 </fieldset> 98 98 99 99 <div id="leftSideDiv"> 100 100 <fieldset> … … 104 104 105 105 <p><?php $theform->showField("tabgroup"); ?></p> 106 106 107 107 <p> 108 108 <label for="location">location</label><br /> … … 123 123 </div> 124 124 125 <?php 125 <?php 126 126 $theform->showCreateModify($phpbms,$therecord); 127 127 $theform->endForm(); -
trunk/phpbms/modules/base/users_addedit.php
r285 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 45 45 $thetable = new users($db,9); 46 46 $therecord = $thetable->processAddEditPage(); 47 47 48 48 if(isset($therecord["phpbmsStatus"])) 49 $statusmessage = $therecord["phpbmsStatus"]; 50 49 $statusmessage = $therecord["phpbmsStatus"]; 50 51 51 $pageTitle="User"; 52 52 53 53 $phpbms->cssIncludes[] = "pages/users.css"; 54 54 $phpbms->jsIncludes[] = "modules/base/javascript/users.js"; … … 58 58 $theform = new phpbmsForm(); 59 59 $theform->onsubmit="return submitForm(this);"; 60 60 61 61 $theinput = new inputCheckbox("admin",$therecord["admin"],"administrator"); 62 62 $theform->addField($theinput); 63 63 64 64 $theinput = new inputCheckbox("revoked",$therecord["revoked"],"access revoked"); 65 65 $theform->addField($theinput); … … 86 86 $theinput = new inputField("phone",$therecord["phone"],"phone/extension",false,"phone",32,64); 87 87 $theform->addField($theinput); 88 88 89 $theinput = new inputField("lastip", $therecord["lastip"], "last log in IP"); 90 $theinput->setAttribute("readonly", "readonly"); 91 $theinput->setAttribute("class", "uneditable"); 92 $theform->addField($theinput); 93 89 94 $theinput = new inputChoiceList($db,"department",$therecord["department"],"department"); 90 95 $theform->addField($theinput); … … 92 97 $theform->jsMerge(); 93 98 //============================================================== 94 //End Form Elements 95 99 //End Form Elements 100 96 101 include("header.php"); 97 102 98 103 ?><div class="bodyline"> 99 <?php $theform->startForm($pageTitle)?> 104 <?php $theform->startForm($pageTitle)?> 100 105 <fieldset id="fsAttributes"> 101 106 <legend>attributes</legend> 102 107 103 108 <p> 104 109 <label for="id">id</label><br /> 105 <input id="id" name="id" type="text" value="<?php echo $therecord["id"]; ?>" size="5" maxlength="5" readonly="readonly" class="uneditable"/> 110 <input id="id" name="id" type="text" value="<?php echo $therecord["id"]; ?>" size="5" maxlength="5" readonly="readonly" class="uneditable"/> 106 111 </p> 107 112 … … 117 122 </p> 118 123 </fieldset> 119 124 120 125 <div id="leftSideDiv"> 121 126 <fieldset id="fsName"> … … 135 140 <p> 136 141 <label for="lastlogin" >last log in</label><br /> 137 <input id="lastlogin" name="lastlogin" type="text" value="<?php echo formatFromSQLDateTime($therecord["lastlogin"]); ?>" size="32" maxlength="64" readonly="readonly" class="uneditable" /> 138 </p> 142 <input id="lastlogin" name="lastlogin" type="text" value="<?php echo formatFromSQLDateTime($therecord["lastlogin"]); ?>" size="32" maxlength="64" readonly="readonly" class="uneditable" /> 143 </p> 144 145 <p><?php $theform->showField("lastip"); ?></p> 139 146 140 147 <p> 141 148 <label for="password">set new password</label><br /> 142 <input id="password" name="password" type="password" size="32" maxlength="32" /> 143 </p> 144 149 <input id="password" name="password" type="password" size="32" maxlength="32" /> 150 </p> 151 145 152 <p> 146 153 <label for="password2">confirm new password</label><br /> … … 155 162 156 163 <p><?php $theform->showField("phone");?></p> 157 164 158 165 <p><?php $theform->showField("department");?></p> 159 166 160 167 <p> 161 168 <label for="employeenumber">employee number</label><br /> 162 <input type="text" id="employeenumber" name="employeenumber" value="<?php echo htmlQuotes($therecord["employeenumber"]) ?>" size="32" maxlength="32" /> 169 <input type="text" id="employeenumber" name="employeenumber" value="<?php echo htmlQuotes($therecord["employeenumber"]) ?>" size="32" maxlength="32" /> 163 170 </p> 164 171 </fieldset> … … 190 197 </div> 191 198 </div> 192 </fieldset> 199 </fieldset> 193 200 <?php }?> 194 </div> 195 196 <?php 201 </div> 202 203 <?php 197 204 $theform->showCreateModify($phpbms,$therecord); 198 205 $theform->endForm(); -
trunk/phpbms/modules/bms/clients_addedit.php
r419 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 39 40 include("../../include/session.php"); 40 41 include("include/tables.php"); … … 44 45 include("include/clients.php"); 45 46 46 if(!isset($_GET["backurl"])) 47 $backurl = NULL; 48 else{ 47 if(!isset($_GET["backurl"])) 48 $backurl = NULL; 49 else{ 49 50 $backurl = $_GET["backurl"]; 50 51 if(isset($_GET["refid"])) … … 54 55 $thetable = new clients($db,2,$backurl); 55 56 $therecord = $thetable->processAddEditPage(); 56 57 57 58 if(isset($therecord["phpbmsStatus"])) 58 59 $statusmessage = $therecord["phpbmsStatus"]; 59 60 60 61 $pageTitle=ucwords($therecord["type"]); 61 62 62 63 if($therecord["inactive"]) 63 64 $pageTitle="Inactive ".$pageTitle; 64 65 65 66 66 67 $phpbms->cssIncludes[] = "pages/client.css"; 67 68 $phpbms->jsIncludes[] = "modules/bms/javascript/client.js"; … … 70 71 //============================================================== 71 72 $theform = new phpbmsForm(); 72 73 73 74 $phpbms->bottomJS[] = 'var thefirstname=getObjectFromID("firstname");thefirstname.focus();'; 74 75 75 76 $theinput = new inputCheckbox("inactive",$therecord["inactive"]); 76 77 $theform->addField($theinput); 77 78 78 79 $theinput = new inputBasicList("type",$therecord["type"],array("prospect"=>"prospect","client"=>"client"), "type"); 79 80 $theinput->setAttribute("class","important"); … … 86 87 }//endif 87 88 $theform->addField($theinput); 88 89 89 90 $theinput = new inputChoiceList($db, "category",$therecord["category"],"clientcategories"); 90 91 $theform->addField($theinput); … … 92 93 $theinput = new inputSmartSearch($db, "salesmanagerid", "Pick Active User", $therecord["salesmanagerid"], "sales person"); 93 94 $theform->addField($theinput); 94 95 95 96 $theinput = new inputChoiceList($db, "leadsource",$therecord["leadsource"],"leadsource", "lead source"); 96 97 $theinput->setAttribute("class","small"); 97 98 $theform->addField($theinput); 98 99 99 100 $theinput = new inputDataTableList($db, "paymentmethodid",$therecord["paymentmethodid"],"paymentmethods","id","name", 100 101 "inactive=0", "priority,name", true, "payment method"); … … 104 105 "inactive=0", "priority,name", true, "shipping method"); 105 106 $theform->addField($theinput); 106 107 107 108 $theinput = new inputDataTableList($db, "discountid",$therecord["discountid"],"discounts","id","name", 108 109 "inactive=0", "name", true, "discount"); … … 112 113 "inactive=0", "name", true, "tax area"); 113 114 $theform->addField($theinput); 114 115 115 116 $theinput = new inputField("workphone",$therecord["workphone"],"work phone",false,"phone",25,32); 116 117 $theform->addField($theinput); … … 133 134 $theinput = new inputField("webaddress",$therecord["webaddress"],"web address",false,"www",68,128); 134 135 $theform->addField($theinput); 135 136 136 137 $theinput = new inputField("taxid", $therecord["taxid"], "tax id", false, "", 25, 32); 137 138 $theform->addField($theinput); … … 140 141 //============================================================== 141 142 //End Form Elements 142 143 include("header.php"); 143 144 include("header.php"); 144 145 145 146 $action = htmlQuotes($_SERVER["REQUEST_URI"]); … … 155 156 156 157 <h1 id="h1Title"><span><?php echo $pageTitle ?></span></h1> 157 158 158 159 <div id="rightSideDiv"> 159 160 <?php if(isset($_GET["invoiceid"])){?> … … 161 162 <input name="gotoinvoice" id="gotoinvoice" type="button" value="return to order" onclick="location.href='<?php echo getAddEditFile($db,3) ?>?id=<?php echo $_GET["invoiceid"] ?>'" class="Buttons" /> 162 163 </p> 163 <?php } ?> 164 <?php } ?> 164 165 <fieldset> 165 166 <legend>attributes</legend> … … 170 171 <input type="hidden" id="creditlimit" name="creditlimit" value="<?php echo $therecord["creditlimit"]?>"/> 171 172 </p> 172 173 173 174 <p><?php $theform->showField("type");?></p> 174 175 175 176 <p><?php $theform->showField("inactive")?></p> 176 177 177 178 <p id="becameclientDiv" <?php if($therecord["type"]=="prospect") echo "style=\"display:none;\"" ?>> 178 179 <label for="becameclient">became a client</label><br /> 179 180 <input type="text" id="becameclient" name="becameclient" readonly="readonly" class="uneditable" value="<?php echo formatFromSQLDate($therecord["becameclient"])?>" size="8" /> 180 181 </p> 181 182 182 183 <p><?php $theform->showField("category")?></p> 183 184 </fieldset> 185 184 185 </fieldset> 186 186 187 <fieldset> 187 188 <legend>sales</legend> 188 189 <div class="fauxP"><?php $theform->showField("salesmanagerid")?></div> 189 190 190 191 <p><?php $theform->showField("leadsource")?></p> 191 192 </fieldset> 192 193 193 194 <fieldset> 194 195 <legend>order defaults</legend> … … 220 221 </fieldset> 221 222 </div> 222 223 <div id="leftSideDiv"> 223 224 <div id="leftSideDiv"> 224 225 <fieldset> 225 226 <legend>name / company</legend> … … 230 231 <p> 231 232 <label for="lastname" class="important">last name</label><br /> 232 <input id="lastname" name="lastname" type="text" value="<?php echo htmlQuotes($therecord["lastname"])?>" size="32" maxlength="65" class="important" /> 233 <input id="lastname" name="lastname" type="text" value="<?php echo htmlQuotes($therecord["lastname"])?>" size="32" maxlength="65" class="important" /> 233 234 </p> 234 235 <p> … … 236 237 <input name="company" type="text" id="company" value="<?php echo htmlQuotes($therecord["company"])?>" size="71" maxlength="128" class="important"/> 237 238 </p> 238 </fieldset> 239 240 <fieldset> 239 </fieldset> 240 241 <fieldset> 241 242 <legend>contact</legend> 242 243 243 244 <p class="phonelefts"><?php $theform->showField("workphone")?></p> 244 245 245 246 <p><?php $theform->showField("homephone")?></p> 246 247 247 248 <p class="phonelefts"><?php $theform->showField("mobilephone")?></p> 248 249 249 250 <p><?php $theform->showField("fax")?></p> 250 251 251 252 <p><?php $theform->showField("otherphone")?></p> 252 253 253 254 <p><?php $theform->showField("email")?></p> 254 255 255 256 <p><?php $theform->showField("webaddress")?></p> 256 257 257 258 <p><?php $theform->showField("taxid")?></p> 258 259 </fieldset> 259 260 260 261 <fieldset> 261 262 <legend> … … 263 264 <button type="button" class="graphicButtons buttonMap" id="buttonMap" title="show map"><span>map</span></button> 264 265 </legend> 265 266 266 267 <p> 267 268 <input type="hidden" id="addressid" name="addressid" value="<?php echo $therecord["addressid"]?>"/> … … 281 282 <p> 282 283 <label for="postalcode">zip/postal code</label><br /> 283 <input name="postalcode" type="text" id="postalcode" value="<?php echo htmlQuotes($therecord["postalcode"])?>" size="12" maxlength="15" /> 284 <input name="postalcode" type="text" id="postalcode" value="<?php echo htmlQuotes($therecord["postalcode"])?>" size="12" maxlength="15" /> 284 285 </p> 285 286 <p> … … 287 288 <input id="country" name="country" type="text" value="<?php echo htmlQuotes($therecord["country"])?>" size="44" maxlength="128" /> 288 289 </p> 289 290 </fieldset> 291 292 290 291 </fieldset> 292 293 293 294 <fieldset> 294 295 <legend><label for="comments">memo</label></legend> … … 297 298 </p> 298 299 </fieldset> 299 300 300 301 </div><?php $theform->showCreateModify($phpbms,$therecord);?> 301 302 </div> -
trunk/phpbms/modules/bms/clients_import.php
r432 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 258 $ | $LastChangedBy: brieb $ … … 43 43 include("include/imports.php"); 44 44 include("include/parsecsv.lib.php"); 45 45 46 46 //if you need to overide the phpbmsTable class make sure to include the modules file 47 47 48 48 include("modules/bms/include/clients.php"); 49 49 include("modules/bms/include/addresses.php"); 50 include("modules/bms/include/addresstorecord.php"); 51 52 //If the addedit page will be accessd directly from a page other than the 50 include("modules/bms/include/addresstorecord.php"); 51 52 //If the addedit page will be accessd directly from a page other than the 53 53 // basic search results page, you may want to grab and pass the previous URL 54 54 //with the following code 55 55 56 56 //=================================================== 57 if(!isset($_GET["backurl"])) 58 $backurl = NULL; 59 else{ 57 if(!isset($_GET["backurl"])) 58 $backurl = NULL; 59 else{ 60 60 $backurl = $_GET["backurl"]; 61 61 if(isset($_GET["refid"])) … … 66 66 if(isset($_GET["id"])) 67 67 $tabledefid = ((int)$_GET["id"]); 68 68 69 69 70 70 //Here you invoke the table and import classes. If you are going to use the standard phpbmsTable class 71 71 // for updates and the such you would access it like this 72 72 73 73 //$thetable = new phpbmsTable($db,$tabledefid); 74 74 //$import = new phpbmsImport($thetable); 75 75 76 76 //if you are going to overide the class you would instantiate 77 77 // like this 78 78 79 79 $importType = "csv"; 80 80 if(isset($_POST["importType"])){ 81 81 82 82 switch($_POST["importType"]){ 83 83 84 84 case 0: 85 85 $importType = "csv"; 86 86 break; 87 87 88 88 case 1: 89 89 $importType = "sugarcrm"; 90 90 break; 91 91 92 92 }//end switch 93 93 94 94 }//end if 95 95 96 96 $thetable = new clients($db,2,$backurl); 97 97 $import = new clientsImport($thetable, $importType); 98 98 99 99 //and if you are setting the backurl, make sure you pass that as well 100 100 // like this: 101 101 102 102 // $thetable = new [tablename]($db,[table definition id],$backurl); 103 104 105 //Next we process the form (if submitted) and 103 104 105 //Next we process the form (if submitted) and 106 106 // return the current record as an array ($therecord) 107 107 // or if this is a new record, it returns the defaults … … 114 114 115 115 $pageTitle = ($therecord["title"])?$therecord["title"]:"General Table Import"; 116 116 117 117 // Next, we set up to include any 118 118 // additional css or javascript files we will be using … … 124 124 125 125 // if you need to define a body onlload function, do so with the phpbms property 126 126 127 127 // $phpbms->onload[] = "initializePage()"; 128 128 … … 130 130 // Next we need to define any special fields that will be used in the form 131 131 // A list of field objects (with documentation)is available in the /include/fields.php 132 // file. 133 132 // file. 133 134 134 // We need to define them here in the head 135 135 // so that any necessay javascript is loaded appropriately. 136 136 137 137 //Form Elements 138 138 //============================================================== 139 139 140 140 // Create the form 141 141 $theform = new importForm(); … … 143 143 //if you need to set specific form vaiables (like enctype, or extra onsubmit 144 144 // you can set those form properties here. 145 146 // for each field we will use, create the field object and add it to 145 146 // for each field we will use, create the field object and add it to 147 147 // the forms list. 148 148 149 149 $list = array("phpBMS csv file" => 0, "Sugar CRM (v5.0)" => 1); 150 150 $default = 0; … … 163 163 $theform->jsMerge(); 164 164 //============================================================== 165 //End Form Elements 166 167 include("header.php"); 168 165 //End Form Elements 166 167 include("header.php"); 168 169 169 ?><div class="bodyline"> 170 <!-- 170 <!-- 171 171 Next we start the form. This also prints the H1 with title, and top save,cancel buttons 172 172 If you need to have other buttons, or need a specific top, you will need to create your form manually. 173 173 --> 174 <?php $theform->startForm($pageTitle, $import->pageType )?>174 <?php $theform->startForm($pageTitle, $import->pageType, count($import->transactionRecords))?> 175 175 176 176 <div id="leftSideDiv"> … … 180 180 <!-- /* This next input also determines whether the file/import fieldset will be displayed or if the preview sections will be displayed*/ --> 181 181 <input id="pageType" name="pageType" type="hidden" value="<?php echo $import->pageType?>" /> 182 182 183 183 <?php 184 184 if($import->pageType == "main"){ ?> 185 185 <fieldset> 186 186 <legend>import</legend> 187 187 188 188 <p><?php $theform->showField("importType"); ?></p> 189 189 190 190 <div id="uploadlabel"> 191 191 <p> … … 193 193 <input id="import" name="import" type="file" size="64"/><br/> 194 194 </p> 195 195 196 196 <div id="info0" class="info"> 197 197 <p> … … 244 244 <?php 245 245 }//end if 246 246 247 247 if($import->error && $import->pageType != "main"){ 248 248 ?> … … 259 259 </div> 260 260 <div id="createmodifiedby" > 261 <?php 261 <?php 262 262 //Last, we show the create/modifiy with the bottom save and cancel buttons 263 263 // and then close the form. 264 $theform->showButtons(2, $import->pageType );264 $theform->showButtons(2, $import->pageType, count($import->transactionRecords)); 265 265 ?></div><?php 266 266 $theform->endForm(); -
trunk/phpbms/modules/bms/include/addresses.php
r384 r485 41 41 class addresses extends phpbmsTable{ 42 42 43 function getName($tabledefid, $recordid){ 43 44 44 function getName($tabledefid, $recordid){45 46 45 switch($tabledefid){ 47 46 48 47 case 2: 49 48 default: 50 49 $querystatement = " 51 SELECT 50 SELECT 52 51 if(clients.lastname!='',concat(clients.lastname,', ',clients.firstname,if(clients.company!='',concat(' (',clients.company,')'),'')),clients.company) AS thename 53 52 FROM … … 56 55 id = ".$recordid; 57 56 break; 58 57 59 58 }//endswitch tabledefid 60 59 61 60 $queryresult = $this->db->query($querystatement); 62 61 63 62 if($this->db->numRows($queryresult)){ 64 63 65 64 $therecord = $this->db->fetchArray($queryresult); 66 65 return htmlQuotes($therecord["thename"]); 67 66 68 67 } else 69 68 return "orphaned record: tableDefinitionID=".$tabledefid.", RecordID:".$recordid; 70 69 71 70 }//end method - getName 72 71 73 72 74 73 function showAssociations($addressid){ 75 // This function generates a table listing all the records 74 // This function generates a table listing all the records 76 75 // associated with the address record. 77 76 78 77 $querystatement = " 79 78 SELECT … … 81 80 addresstorecord.recordid, 82 81 addresstorecord.primary, 83 addresstorecord.defaultshipto 84 FROM 82 addresstorecord.defaultshipto 83 FROM 85 84 addresstorecord 86 85 WHERE … … 89 88 addresstorecord.tabledefid 90 89 "; 91 90 92 91 $queryresult = $this->db->query($querystatement); 93 92 94 93 ?> 95 94 <table class="querytable" cellspacing="0" cellpadding="0" border="0"> … … 108 107 </tfoot> 109 108 <tbody> 110 <?php 109 <?php 111 110 $row =1; 112 111 while($therecord = $this->db->fetchArray($queryresult)) { 113 112 114 113 $row = ($row==1)? 2:1; 115 114 116 115 ?><tr class="qr<?php echo $row?>"> 117 116 <td><?php echo $therecord["recordid"]?></td> … … 121 120 </tr> 122 121 <?php 123 124 }//endwhile - therecord 122 123 }//endwhile - therecord 125 124 ?> 126 125 </tbody> 127 126 </table> 128 127 <?php 129 128 130 129 }//end method - showAssociation 131 130 131 }//end class 132 132 133 // CLASS OVERRIDES =================================================134 135 function formatVariables($variables){136 137 return $variables;138 139 }//end function140 141 142 function updateRecord($variables, $modifiedby = NULL){143 144 $variables = $this->formatVariables($variables);145 146 $thereturn = parent::updateRecord($variables, $modifiedby);147 148 return $thereturn;149 150 }//end method151 152 153 function insertRecord($variables, $createdby = NULL){154 155 $variables = $this->formatVariables($variables);156 157 $newid = parent::insertRecord($variables, $createdby);158 159 return $newid;160 161 }//end method162 163 }//end class164 165 133 }//end if 166 134 167 135 if(class_exists("searchFunctions")){ 168 136 class filesSearchFunctions extends searchFunctions{ 169 137 170 138 function delete_record(){ 171 139 172 140 $whereclause = $this->buildWhereClause(); 173 141 $attachmentwhereclause = $this->buildWhereClause("attachments.fileid"); 174 142 175 143 $querystatement = "DELETE FROM attachments WHERE ".$attachmentwhereclause." AND attachments.fileid!=1;"; 176 144 $queryresult = $this->db->query($querystatement); 177 145 178 146 $querystatement = "DELETE FROM files WHERE ".$whereclause." AND files.id!=1;"; 179 147 $queryresult = $this->db->query($querystatement); 180 148 181 149 $message = $this->buildStatusMessage(); 182 150 $message.=" deleted"; 183 151 return $message; 184 152 } 185 153 186 154 }//end class 187 155 }//end if -
trunk/phpbms/modules/bms/include/addresstorecord.php
r427 r485 39 39 if(class_exists("addresses")){ 40 40 class addresstorecord extends addresses{ 41 41 42 var $availableTabledefIDs = array(); 43 var $availableTabledefNames = array(); 42 44 43 45 function createAddressToRecord($variables, $addressid, $createdby = NULL){ 44 46 // This functions adds the addresstorecord record tying the client and address 45 47 // records. 46 48 47 49 if(!$createdby && isset($_SESSION["userinfo"]["id"])) 48 50 $createdby = $_SESSION["userinfo"]["id"]; 49 51 50 52 $insertstatement = " 51 53 INSERT INTO … … 70 72 NOW(), 71 73 ".((int) $createdby).", 72 NOW() 74 NOW() 73 75 )"; 74 76 75 77 $insertresult = $this->db->query($insertstatement); 76 78 77 79 if($insertresult) 78 80 return $this->db->insertId(); 79 81 else 80 82 return false; 81 83 82 84 }//end method - createAddressToRecord 83 85 84 86 // CLASS OVERRIDES =============================================== 85 87 // =============================================================== 86 88 function getRecord($id){ 87 89 $id = (int) $id; 88 90 89 91 $querystatement = " 90 92 SELECT 91 * 92 FROM 93 addresstorecord 94 WHERE 95 id = ".$id; 96 93 * 94 FROM 95 addresstorecord 96 WHERE 97 id = ".$id; 98 97 99 $queryresult = $this->db->query($querystatement); 98 if($this->db->numRows($queryresult)) { 99 100 if($this->db->numRows($queryresult)) { 101 100 102 $therecord = $this->db->fetchArray($queryresult); 101 103 $addressrecord = parent::getRecord($therecord["addressid"]); 102 104 103 105 unset($addressrecord["id"], $addressrecord["createdby"], $addressrecord["creationdate"], $addressrecord["modifiedby"], $addressrecord["modifieddate"]); 104 106 105 107 $therecord = array_merge($addressrecord, $therecord); 106 107 } else 108 109 } else 108 110 $therecord = $this->getDefaults(); 109 111 110 112 return $therecord; 111 113 112 114 }//end method - getRecord 113 114 115 116 115 117 function getDefaults(){ 116 118 117 119 $therecord = parent::getDefaults(); 118 120 119 121 $therecord["addressid"] = 0; 120 122 $therecord["tabledefid"] = 0; 121 123 $therecord["recordid"] = NULL; 122 124 $therecord["defaultshipto"] = 0; 123 $therecord["primary"] = 0; 124 125 return $therecord; 126 125 $therecord["primary"] = 0; 126 127 return $therecord; 128 127 129 }//end method - getDefauls 128 129 130 131 function formatVariables($variables){ 132 130 131 132 function populateTabledefArrays(){ 133 134 $this->availableTabledefIDs = array(); 135 $this->availableTabledefNames = array(); 136 137 $querystatement = " 138 SELECT 139 `id`, 140 `maintable` 141 FROM 142 `tabledefs`; 143 "; 144 145 $queryresult = $this->db->query($querystatement); 146 147 if($this->db->numRows($queryresult)){ 148 while($therecord = $this->db->fetchArray($queryresult)){ 149 $this->availableTabledefIDs[] = $therecord["id"]; 150 $this->availableTabledefNames[$therecord["id"]] = $therecord["maintable"]; 151 }//end while 152 }else{ 153 $this->availableTabledefIDs[] = "none"; 154 $this->availableTabledefNames[] = "none"; 155 }//end if 156 157 }//end method --populateTabledefArray-- 158 159 160 function checkRecordID($recordid, $tablename){ 161 162 $recordid = ((int) $recordid); 163 $tablename = addslashes($tablename); 164 165 $querystatement = " 166 SELECT 167 `id` 168 FROM 169 `".$tablename."` 170 WHERE 171 `id` = '".$recordid."'; 172 "; 173 174 $queryresult = $this->db->query($querystatement); 175 176 return $this->db->numRows($queryresult); 177 178 }//end method --checkRecordID-- 179 180 181 function verifyVariables($variables){ 182 //POSSIBLY CHANGE>>>> NOT FINISHIED >>>> 183 //Check tabledefs 184 if(isset($variables["tabledefid"])){ 185 186 if(is_numeric($variables["tabledefid"])){ 187 188 if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 189 $this->populateTabledefArrays(); 190 191 if(in_array($variables["tabledefid"], $this->availableTabledefIDs)){ 192 193 //check recordid 194 if(isset($variables["recordid"])){ 195 196 if((int) $variables["recordid"] > 0){ 197 198 if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 199 $this->populateTabledefArrays(); 200 201 if(!$this->checkRecordID($variables["recordid"], $this->availableTabledefNames[$variables["tabledefid"]])) 202 $this->verifyErrors[] = "The `recordid` field does match an id number in ".$this->availableTabledefNames[$variables["tabledefid"]]."."; 203 204 }else 205 $this->verifyErrors[] = "The `recordid` field must be a positive number."; 206 207 }else 208 $this->verifyErrors[] = "The `recordid` field must be set."; 209 210 }else 211 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition id number."; 212 213 }else 214 $this->verifyErrors[] = "The `tabledefid` field must be numeric."; 215 216 }else 217 $this->verifyErrors[] = "The `tabledefid` field must be set."; 218 219 return parent::verifyVariables($variables); 220 221 }//end method --verifyVariables-- 222 223 224 function prepareVariables($variables){ 225 133 226 if(!isset($variables['primary'])) 134 227 $variables['primary'] = 0; … … 136 229 if(!isset($variables['defaultshipto'])) 137 230 $variables['defaultshipto'] = 0; 138 231 139 232 if(!isset($variables["existingaddressid"])) 140 233 $variables["existingaddressid"] = false; 141 142 return $variables; 143 234 235 if(isset($variables["id"])) 236 if($variables["id"]){// if update 237 238 $variables["id"] = $variables["addressid"]; 239 240 }//end if 241 242 return $variables; 243 144 244 }//end function 145 245 146 246 147 148 function updateRecord($variables, $modifiedby = NULL){149 150 $variables = $this->formatVariables($variables);151 152 $variables["id"] = $variables["addressid"];153 154 $thereturn = parent::updateRecord($variables, $modifiedby);155 156 return $thereturn;157 158 }//end method159 160 161 247 function insertRecord($variables, $createdby = NULL){ 162 248 163 $variables = $this->formatVariables($variables);249 //$variables = $this->prepareVariables($variables); 164 250 165 251 if($variables["existingaddressid"]){ 166 252 167 253 $this->createAddressToRecord($variables, $variables["existingaddressid"], $createdby); 168 254 169 255 $newAtrID = $variables["existingaddressid"]; 170 256 171 257 } else { 172 258 173 259 $newid = parent::insertRecord($variables, $createdby); 174 260 175 261 //create the addresstorecord 176 262 $newAtrID = $this->createAddressToRecord($variables, $newid, $createdby); 177 263 178 264 }//endif - existingaddressid 179 265 180 266 return $newAtrID; 181 267 182 268 }//end method 183 269 184 270 }//end class 185 271 }//end if … … 192 278 193 279 $whereclause = $this->buildWhereClause(); 194 280 195 281 //We need to itterate trhough each record 196 // to check for cross-record addresses 282 // to check for cross-record addresses 197 283 $querystatement = " 198 284 SELECT … … 201 287 addresstorecord 202 288 WHERE ".$whereclause; 203 289 204 290 $queryresult = $this->db->query($querystatement); 205 291 206 292 $removedCount = 0; 207 293 $deletedCount = 0; 208 294 $beenMarked = false; 209 295 210 296 while($therecord = $this->db->fetchArray($queryresult)){ 211 297 … … 213 299 // cannot be removed 214 300 if(!$therecord["primary"] && !$therecord["defaultshipto"]){ 215 301 216 302 //look up address to see if it is associated with other records 217 303 $querystatement = " … … 224 310 AND tabledefid = ".$therecord["tabledefid"]." 225 311 AND recordid != ".$therecord["recordid"]; 226 312 227 313 $lookupResult = $this->db->query($querystatement); 228 314 229 315 if(!$this->db->numRows($lookupResult)){ 230 316 231 317 //we can safely delete the address (no other associations) 232 318 $deletestatement = " … … 237 323 238 324 $this->db->query($deletestatement); 239 325 240 326 $deletedCount++; 241 327 $removedCount--; 242 328 243 329 }//end if - numRows 244 330 245 331 //remove the connecting record 246 332 $deletestatement = " … … 249 335 WHERE 250 336 id =".$therecord["id"]; 251 337 252 338 $this->db->query($deletestatement); 253 339 254 340 $removedCount++; 255 341 256 342 } else { 257 258 $beenMarked = true; 259 343 344 $beenMarked = true; 345 260 346 }//endif - primary or defaultshipto 261 347 262 348 }//endwhile - fetchArray 263 349 264 350 //next, craft the response 265 351 266 352 $message = ""; 267 268 if($removedCount){ 269 353 354 if($removedCount){ 355 270 356 $message .= $removedCount." address"; 271 357 272 358 if($removedCount > 1) 273 359 $message .= "es"; 274 360 275 361 $message .= " dissociated from record. "; 276 362 277 363 }//endif removedCount 278 279 if($deletedCount){ 280 364 365 if($deletedCount){ 366 281 367 $message .= $deletedCount." address"; 282 368 283 369 if($deletedCount > 1) 284 370 $message .= "es"; 285 371 286 372 $message .= " deleted. "; 287 373 288 374 }//endif removedCount 289 375 … … 294 380 $message .= "(Addresses marked primary or default ship to cannot be removed.)"; 295 381 return $message; 296 382 297 383 }//end method - delete 298 384 299 385 300 386 function markPrimary(){ 301 387 302 388 return $this->_markAs("primary")." primary address."; 303 389 304 390 }//end method - markPrimary 305 306 391 392 307 393 function markDefaultShipTo(){ 308 394 … … 323 409 WHERE 324 410 id =".((int) $this->idsArray[0]); 325 411 326 412 $relatedInfo = $this->db->fetchArray($this->db->query($querystatement)); 327 413 328 414 //Next, mark all addresses associated with record as false 329 415 $updatestatement = " … … 335 421 tabledefid = ".$relatedInfo["tabledefid"]." 336 422 AND recordid = ".$relatedInfo["recordid"]; 337 423 338 424 $this->db->query($updatestatement); 339 425 340 426 //Finally, mark the first record. 341 427 $updatestatement = " … … 346 432 WHERE 347 433 id = ".((int) $this->idsArray[0]); 348 434 349 435 $this->db->query($updatestatement); 350 436 … … 357 443 358 444 return $message; 359 445 360 446 }//end method _markAs 361 447 -
trunk/phpbms/modules/bms/include/clients.php
r431 r485 40 40 if(class_exists("phpbmsTable")){ 41 41 class clients extends phpbmsTable{ 42 42 43 var $availablePaymentMethodIDs = array(); 44 var $availableShippingMethodIDs = array(); 45 var $availableDiscountIDs = array(); 46 var $availableTaxIDs = array(); 47 var $availableUserIDs = array(); 48 var $verifyErrors = array(); 49 43 50 function checkForInvoices($id){ 44 51 $querystatement="SELECT id FROM invoices WHERE clientid=".((int) $id); 45 52 $queryresult = $this->db->query($querystatement); 46 53 47 54 return !($this->db->numRows($queryresult)===0); 48 55 }//end method 49 50 56 57 51 58 // CLASS OVERRIDES =================================================================== 52 59 // =================================================================================== 53 60 54 61 function clients($db,$tabledefid = 0,$backurl = NULL){ 55 62 56 63 $this->phpbmsTable($db,$tabledefid,$backurl); 57 64 58 65 $this->address = new addresstorecord($db, 306); 59 66 60 67 }//end function - init 61 68 62 69 63 70 function getDefaults(){ … … 66 73 67 74 $therecord["type"] = DEFAULT_CLIENTTYPE; 68 75 69 76 if($therecord["type"] == "client") { 70 77 … … 74 81 75 82 }//end if 76 83 77 84 $therecord["webaddress"] = "http://"; 78 85 79 86 //now for the address information. 80 87 $addressinfo = $this->address->getDefaults(); 81 88 unset($addressinfo["id"], $addressinfo["createdby"], $addressinfo["creationdate"], $addressinfo["modifiedby"], $addressinfo["modifieddate"]); 82 89 $addressinfo["addressid"] = NULL; 83 90 84 91 return array_merge($therecord, $addressinfo); 85 92 86 93 }//end function - getDefaults 87 88 94 95 89 96 function getRecord($id){ 90 97 91 98 $id = (int) $id; 92 99 93 100 $therecord = parent::getRecord($id); 94 101 95 102 if($therecord["id"]){ 96 103 //need to grab the address as well 97 104 98 105 $querystatement = " 99 106 SELECT … … 107 114 108 115 $queryresult = $this->db->query($querystatement); 109 116 110 117 $addressinfo = $this->db->fetchArray($queryresult); 111 118 112 119 if($addressinfo) { 113 120 114 121 $addressinfo = $this->address->getRecord($addressinfo["id"]); 115 122 116 123 } else { 117 124 118 125 $addressinfo = $this->address->getDefaults(); 119 126 $addressinfo["addressid"] = NULL; 120 121 }//endif 127 128 }//endif 122 129 123 130 unset($addressinfo["id"], $addressinfo["notes"], $addressinfo["email"], $addressinfo["createdby"], $addressinfo["creationdate"], $addressinfo["modifiedby"], $addressinfo["modifieddate"]); 124 131 125 132 $therecord = array_merge($therecord, $addressinfo); 126 133 127 134 }//endif 128 135 129 136 return $therecord; 130 137 131 138 }//end function - getRecord 132 139 140 141 function populatePaymentMethodArray(){ 142 143 $this->availablePaymentMethodIDs = array(); 144 145 $querystatement = " 146 SELECT 147 `id` 148 FROM 149 `paymentmethods`; 150 "; 151 152 $queryresult = $this->db->query($querystatement); 153 154 $this->availablePaymentMethodIDs[] = 0;//for none 155 156 while($therecord = $this->db->fetchArray($queryresult)) 157 $this->availablePaymentMethodIDs[] = $therecord["id"]; 158 159 }//end method --populatePaymentMethodArray-- 160 161 162 function populateShippingMethodArray(){ 163 164 $this->availableShippingMethodIDs = array(); 165 166 $querystatement = " 167 SELECT 168 `id` 169 FROM 170 `shippingmethods`; 171 "; 172 173 $queryresult = $this->db->query($querystatement); 174 175 $this->availableShippingMethodIDs[] = 0;//for none 176 177 while($therecord = $this->db->fetchArray($queryresult)) 178 $this->availableShippingMethodIDs[] = $therecord["id"]; 179 180 }//end method --populateShippingMethodArray-- 181 182 183 function populateDiscountArray(){ 184 185 $this->availableDiscountIDs = array(); 186 187 $querystatement = " 188 SELECT 189 `id` 190 FROM 191 `discounts`; 192 "; 193 194 $queryresult = $this->db->query($querystatement); 195 196 $this->availableDiscountIDs[] = 0;//for none 197 198 while($therecord = $this->db->fetchArray($queryresult)) 199 $this->availableDiscountIDs[] = $therecord["id"]; 200 201 }//end method --populateDiscountArray-- 202 203 204 function populateTaxArray(){ 205 206 $this->availableTaxIDs = array(); 207 208 $querystatement = " 209 SELECT 210 `id` 211 FROM 212 `tax`; 213 "; 214 215 $queryresult = $this->db->query($querystatement); 216 217 $this->availableTaxIDs[] = 0;//for none 218 219 while($therecord = $this->db->fetchArray($queryresult)) 220 $this->availableTaxIDs[] = $therecord["id"]; 221 222 }//end method --populateTaxArray-- 223 224 225 function populateUserArray(){ 226 227 $this->availableUserIDs = array(); 228 229 $querystatement = " 230 SELECT 231 `id` 232 FROM 233 `users`; 234 "; 235 236 $queryresult = $this->db->query($querystatement); 237 238 $this->availableUserIDs[] = 0;//for none 239 240 while($therecord = $this->db->fetchArray($queryresult)) 241 $this->availableUserIDs[] = $therecord["id"]; 242 243 }//end method --populateUserArray-- 244 245 246 function verifyVariables($variables){ 247 248 if(isset($variables["type"])){ 249 switch($variables["type"]){ 250 251 case "prospect": 252 253 if(isset($variables["becameclient"])){ 254 if($variables["becameclient"] !== "" || $variables["becameclient"] !== NULL) 255 $this->verifyErrors[] = "Records with `type` of 'prospect' 256 must have the `becameclient` field kept blank."; 257 }//end if 258 259 if(isset($variables["hascredit"])){ 260 if($variables["hascredit"]) 261 $this->verifyErrors[] = "Records with `type` of 'prospect' 262 must have the `hascredit` field kept blank or 0."; 263 }//end if 264 265 if(isset($variables["creditlimit"])){ 266 if($variables["creditlimit"]) 267 $this->verifyErrors[] = "Records with `type` of 'prospect' 268 must have the `creditlimit` field kept blank or 0."; 269 }//end if 270 271 break; 272 273 case "client": 274 if(isset($variables["becameclient"])){ 275 //Possibly run through string to date functions 276 if(!$variables["becameclient"]) 277 $this->verifyErrors[] = "Records with `type` of 'client' 278 must have not have the `becameclient` field blank."; 279 }else 280 $this->verifyErrors[] = "Records with `type` of 'client' 281 must set the `becameclient` field."; 282 break; 283 284 default: 285 $this->verifyErrors[] = "The value of the `type` field is invalid. 286 It must either be 'prospect' or 'client'."; 287 break; 288 289 }//end switch 290 }else 291 $this->verifyErrors[] = "The `type` field must be set."; 292 293 //check for currency on credit limit (((real value) >= 0 ... non-negative) 294 if(isset($variables["creditlimit"])) 295 if(!is_numeric($variables["creditlimit"]) && $variables["creditlimit"]) 296 $this->verifyErrors[] = "The `creditlimit` field must be a real number or equivalent to zero."; 297 298 //----------------[ phone & email ]------------------------------------------------------ 299 //check valid email 300 if(isset($variables["email"])) 301 if( $variables["email"] !== NULL && $variables["email"] !== "" && !validateEmail($variables["email"])) 302 $this->verifyErrors[] = "The `email` field must have a valid email or must be left blank."; 303 304 //check valid homephone 305 if(isset($variables["homephone"])) 306 if( $variables["homephone"] !== NULL && $variables["homephone"] !== "" && !validatePhone($variables["homephone"])) 307 $this->verifyErrors[] = "The `homephone` field must have a valid phone number (as set in configuration) or must be left blank."; 308 309 //check valid workphone 310 if(isset($variables["workphone"])) 311 if( $variables["workphone"] !== NULL && $variables["workphone"] !== "" && !validatePhone($variables["workphone"])) 312 $this->verifyErrors[] = "The `workphone` field must have a valid phone number (as set in configuration) or must be left blank."; 313 314 //check valid mobilephone 315 if(isset($variables["mobilephone"])) 316 if( $variables["mobilephone"] !== NULL && $variables["mobilephone"] !== "" && !validatePhone($variables["mobilephone"])) 317 $this->verifyErrors[] = "The `mobilephone` field must have a valid phone number (as set in configuration) or must be left blank."; 318 319 //check valid fax 320 if(isset($variables["fax"])) 321 if( $variables["fax"] !== NULL && $variables["fax"] !== "" && !validatePhone($variables["fax"])) 322 $this->verifyErrors[] = "The `fax` field must have a valid phone number (as set in configuration) or must be left blank."; 323 324 //check valid otherphone 325 if(isset($variables["otherphone"])) 326 if( $variables["otherphone"] !== NULL && $variables["otherphone"] !== "" && !validatePhone($variables["otherphone"])) 327 $this->verifyErrors[] = "The `otherphone` field must have a valid phone number (as set in configuration) or must be left blank."; 328 329 //check bool on has credit 330 if(isset($variables["hascredit"])) 331 if($variables["hascredit"] && $variables["hascredit"] != 1) 332 $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1)."; 333 334 335 //----------------[ Order Defaults]------------------------------------------------------ 336 337 //Payement Method 338 if(isset($variables["paymentmethodid"])){ 339 340 if( !$variables["paymentmethodid"] || ((int)$variables["paymentmethodid"]) > 0 ){ 341 342 if(!count($this->availablePaymentMethodIDs)) 343 $this->populatePaymentMethodArray(); 344 345 if(!in_array($variables["paymentmethodid"], $this->availablePaymentMethodIDs)) 346 $this->verifyErrors[] = "The `paymentmethodid` field does not give an existing/acceptable payment method id number."; 347 348 }else 349 $this->verifyErrors[] = "The `addroleid` field must be a non-negative number or equivalent to 0."; 350 351 }//end if 352 353 if(isset($variables["shippingmethodid"])){ 354 355 if( !$variables["shippingmethodid"] || ((int)$variables["shippingmethodid"]) > 0){ 356 357 if(!count($this->availableShippingMethodIDs)) 358 $this->populateShippingMethodArray(); 359 360 if(!in_array($variables["shippingmethodid"], $this->availableShippingMethodIDs)) 361 $this->verifyErrors[] = "The `shippingmethodid` field does not give an existing/acceptable shipping method id number."; 362 363 }else 364 $this->verifyErrors[] = "The `shippingmethodid` field must be a non-negative number or equivalent to 0."; 365 366 }//end if 367 368 if(isset($variables["discountid"])){ 369 370 if( !$variables["discountid"] || ((int)$variables["discountid"]) > 0){ 371 372 if(!count($this->availableDiscountIDs)) 373 $this->populateDiscountArray(); 374 375 if(!in_array($variables["discountid"], $this->availableDiscountIDs)) 376 $this->verifyErrors[] = "The `discount` field does not give an existing/acceptable discount id number."; 377 378 }else 379 $this->verifyErrors[] = "The `discountid` field must be a non-negative number or equivalent to 0."; 380 381 }//end if 382 383 if(isset($variables["taxareaid"])){ 384 385 if( !$variables["taxareaid"] || ((int)$variables["taxareaid"]) > 0){ 386 387 if(!count($this->availableTaxIDs)) 388 $this->populateTaxArray(); 389 390 if(!in_array($variables["taxareaid"], $this->availableTaxIDs)) 391 $this->verifyErrors[] = "The `taxareaid` field does not give an existing/acceptable tax id number."; 392 393 }else 394 $this->verifyErrors[] = "The `taxareaid` field must be a non-negative number or equivalent to 0."; 395 396 }//end if 397 398 //---------------------[ end order defaults ]---------------------------------------- 399 400 //check sales manager id 401 if(isset($variables["salesmanagerid"])){ 402 403 if( !$variables["salesmanagerid"] || ((int)$variables["salesmanagerid"]) > 0 ){ 404 405 if(!count($this->availableUserIDs)) 406 $this->populateUserArray(); 407 408 if(!in_array($variables["salesmanagerid"], $this->availableUserIDs)) 409 $this->verifyErrors[] = "The `salesmanagerid` field does not give an existing/acceptable user id number."; 410 411 }else 412 $this->verifyErrors[] = "The `salesmanagerid` field must be a non-negative number or equivalent to 0."; 413 414 }//end if 415 416 417 return parent::verifyVariables($variables); 418 419 }//end method 420 133 421 134 422 function prepareVariables($variables){ 135 423 136 424 if(isset($variables["webaddress"])) 137 if ($variables["webaddress"]=="http://") 425 if ($variables["webaddress"]=="http://") 138 426 $variables["webaddress"] = NULL; 139 427 140 428 if(!isset($variables["type"])) 141 429 $variables["type"] = "client"; 142 430 143 431 if($variables["type"] == "prospect"){ 144 432 … … 149 437 $variables["type"] = "client"; 150 438 if(!isset($variables["becameclient"])) 439 $variables["becameclient"] = NULL; 440 if(!$variables["becameclient"]) 151 441 $variables["becameclient"] = dateToString(mktime()); 152 442 }//end if 153 443 154 444 return $variables; 155 445 156 446 }//end method 157 158 447 448 159 449 function updateRecord($variables, $modifiedby = NULL){ 160 161 $variables = $this->prepareVariables($variables);162 450 451 //$variables = $this->prepareVariables($variables); 452 163 453 $thereturn = parent::updateRecord($variables, $modifiedby); 164 454 455 $variables["recordid"] = $variables["id"];//here to pass addresstorecord validation 456 $variables["tabledefid"] = 2;//here to pass addresstorecord validation 165 457 //need to update the address 166 458 $variables["id"] = $variables["addressid"]; … … 174 466 unset($this->address->fields["creationdate"]); 175 467 176 $this->address->updateRecord($variables, $modifiedby); 468 $variables = $this->address->prepareVariables($variables); 469 $errorArray = $this->address->verifyVariables($variables); 470 if(!count($errorArray)){ 471 $this->address->updateRecord($variables, $modifiedby); 472 }else{ 473 foreach($errorArray as $error) 474 $logError = new appError(-910, $error, "Address Verification Error"); 475 }//end if 177 476 178 477 //restore the fields 179 478 $this->address->getTableInfo(); 180 479 181 480 return $thereturn; 182 481 183 482 }//end method - updateRecord 184 185 483 484 186 485 function insertRecord($variables, $createdby = NULL){ 187 188 $variables = $this->prepareVariables($variables);189 486 487 //$variables = $this->prepareVariables($variables); 488 190 489 $newid = parent::insertRecord($variables, $createdby); 191 490 192 491 //need to create the address and addresstorecord id 193 492 // make sure we are not setting extra info … … 200 499 $variables["defaultshipto"] = 1; 201 500 $variables["primary"] = 1; 202 203 $this->address->insertRecord($variables, $createdby); 501 502 $variables = $this->address->prepareVariables($variables); 503 $errorArray = $this->address->verifyVariables($variables); 504 if(!count($errorArray)){ 505 $this->address->insertRecord($variables, $createdby); 506 }else{ 507 foreach($errorArray as $error) 508 $logError = new appError(-910, $error, "Address Verification Error"); 509 }//end if 204 510 205 511 //restore the fields 206 512 $this->address->getTableInfo(); 207 513 208 514 return $newid; 209 515 210 516 }//end method - insertRecord 211 517 212 518 }//end class 213 519 214 520 }//end if 215 521 … … 219 525 220 526 function mark_asclient(){ 221 527 222 528 //passed variable is array of user ids to be revoked 223 $whereclause = $this->buildWhereClause(); 224 529 $whereclause = $this->buildWhereClause(); 530 225 531 $querystatement = "UPDATE clients SET clients.type=\"client\",modifiedby=\"".$_SESSION["userinfo"]["id"]."\" WHERE (".$whereclause.");"; 226 532 $queryresult = $this->db->query($querystatement); 227 533 228 534 $message = $this->buildStatusMessage(); 229 535 $message.=" converted to client."; 230 536 return $message; 231 537 } 232 233 538 539 234 540 //Stamp Comments Field with info packet sent 235 541 function stamp_infosent(){ 236 542 237 543 //passed variable is array of user ids to be revoked 238 544 $whereclause = $this->buildWhereClause(); 239 545 240 546 $querystatement = " 241 547 UPDATE 242 clients 548 clients 243 549 SET 244 clients.comments = concat('Information Packet Sent', char(10), clients.comments), 550 clients.comments = concat('Information Packet Sent', char(10), clients.comments), 245 551 clients.modifiedby=".$_SESSION["userinfo"]["id"].", 246 552 clients.modifieddate = NOW() 247 553 WHERE (".$whereclause.") AND clients.comments IS NOT NULL"; 248 554 $queryresult = $this->db->query($querystatement); 249 555 250 556 $affected = $this->db->affectedRows(); 251 557 252 558 $querystatement = " 253 559 UPDATE 254 clients 560 clients 255 561 SET 256 clients.comments = 'Information Packet Sent', 562 clients.comments = 'Information Packet Sent', 257 563 clients.modifiedby=".$_SESSION["userinfo"]["id"].", 258 564 clients.modifieddate = NOW() … … 261 567 262 568 $affected += $this->db->affectedRows(); 263 569 264 570 $message = $this->buildStatusMessage($affected); 265 571 $message.=" marked as info packet sent."; 266 572 return $message; 267 573 } 268 269 574 575 270 576 //remove prospects 271 577 function delete_prospects(){ 272 578 273 579 //passed variable is array of user ids to be revoked 274 580 $clientWhereClause = $this->buildWhereClause(); … … 282 588 (".$clientWhereClause.") 283 589 AND clients.type = 'prospect'"; 284 590 285 591 $queryresult = $this->db->query($querystatement); 286 592 287 593 //build array of ids to be removed 288 594 $deleteIDs = array(); … … 291 597 292 598 if(count($deleteIDs)){ 293 599 294 600 $a2rWhere = $this->buildWhereClause("recordid", $deleteIDs); 295 601 … … 303 609 tabledefid = 2 304 610 AND (".$a2rWhere.")"; 305 611 306 612 $a2rResult = $this->db->query($querystatement); 307 613 308 614 $addressIDs = array(); 309 615 while($a2r = $this->db->fetchArray($a2rResult)) 310 616 array_push($addressIDs, $a2r["addressid"]); 311 312 // delete all a2r records for prospect 617 618 // delete all a2r records for prospect 313 619 $deletestatement = " 314 620 DELETE FROM … … 317 623 tabledefid = 2 318 624 AND (".$a2rWhere.")"; 319 625 320 626 $this->db->query($deletestatement); 321 627 322 628 //now go get a list of orphaned addresses 323 629 $querystatement = " 324 SELECT 325 addresses.id, 326 addresstorecord.id as a2rid 327 FROM 630 SELECT 631 addresses.id, 632 addresstorecord.id as a2rid 633 FROM 328 634 addresses LEFT JOIN addresstorecord ON addresstorecord.addressid = addresses.id 329 635 WHERE 330 636 ".$this->buildWhereClause("addresses.id", $addressIDs); 331 637 332 638 $addressResult = $this->db->query($querystatement); 333 639 334 640 $addressIDs = array(); 335 641 while($address = $this->db->fetchArray($addressResult)) 336 642 if(!$address["a2rid"]) 337 643 array_push($addressIDs, $address["id"]); 338 644 339 645 if(count($addressIDs)){ 340 341 //delete orphaned addresses 646 647 //delete orphaned addresses 342 648 $deletestatement = " 343 DELETE FROM 649 DELETE FROM 344 650 addresses 345 651 WHERE 346 652 ".$this->buildWhereClause("addresses.id", $addressIDs); 347 653 348 654 $this->db->query($deletestatement); 349 655 350 656 }//endif - addressids 351 657 … … 359 665 WHERE 360 666 ".$invoiceWhereClause; 361 667 362 668 $invoiceresult = $this->db->query($invoicestatement); 363 669 364 670 //build invoice id array 365 671 $invoiceids = array(); 366 672 while($therecord = $this->db->fetchArray($invoiceresult)) 367 673 array_push($invoiceids, $therecord["id"]); 368 674 369 675 if(count($invoiceids)) { 370 676 $invoiceWhereClause = $this->buildWhereClause("invoices.id", $invoiceids); 371 677 372 678 $lineitemWhereClause = $this->buildWhereClause("invoiceid", $invoiceids); 373 679 374 680 $lineItemDeleteStatement = " 375 681 DELETE FROM … … 377 683 WHERE 378 684 ".$lineitemWhereClause; 379 685 380 686 $queryresult = $this->db->query($lineItemDeleteStatement); 381 687 382 688 $statushistoryDeleteStatement = " 383 689 DELETE FROM … … 385 691 WHERE 386 692 ".$lineitemWhereClause; 387 693 388 694 $queryresult = $this->db->query($statushistoryDeleteStatement); 389 695 390 696 $invoiceDeleteStatement = " 391 697 DELETE FROM 392 698 invoices 393 WHERE 699 WHERE 394 700 ".$invoiceWhereClause; 395 701 396 702 $queryresult = $this->db->query($invoiceDeleteStatement); 397 703 398 704 }//end if 399 705 … … 402 708 403 709 $deletestatement = " 404 DELETE FROM 710 DELETE FROM 405 711 clients 406 WHERE 712 WHERE 407 713 ".$delWhere; 408 714 409 715 $this->db->query($deletestatement); 410 411 }//endif - count deleteIDS 412 413 716 717 }//endif - count deleteIDS 718 719 414 720 $message = $this->buildStatusMessage(count($deleteIDs)); 415 721 $message.=" deleted."; 416 return $message; 417 722 return $message; 723 418 724 }// end method - delete_prospects 419 420 725 726 421 727 function massEmail(){ 422 728 if(DEMO_ENABLED != "true"){ … … 428 734 } 429 735 430 736 431 737 }//end class 432 738 }//end if 433 739 if(class_exists("phpbmsImport")){ 434 740 class clientsImport extends phpbmsImport{ 435 436 741 742 437 743 function clientsImport($table, $importType = "csv"){ 438 744 439 745 if($importType == "sugarcrm"){ 440 746 441 747 $importType = "csv"; 442 748 $switchedFrom = "sugarcrm"; 443 749 444 750 }//end if 445 751 446 752 parent::phpbmsImport($table, $importType); 447 753 448 754 if(isset($switchedFrom)) 449 755 $this->importType = $switchedFrom; 450 756 451 757 }//end method --clientsImport-- 452 453 758 759 454 760 function _parseFromData($data){ 455 761 456 762 if($this->importType == "sugarcrm"){ 457 763 458 764 $this->importType = "csv"; 459 765 $switchedFrom = "sugarcrm"; 460 766 461 767 }//end if 462 768 463 769 $thereturn = parent::_parseFromData($data); 464 770 465 771 if(isset($switchedFrom)) 466 772 $this->importType = $switchedFrom; 467 773 468 774 return $thereturn; 469 775 470 776 }//end method --_parseFromFile-- 471 472 777 778 473 779 function _formatSugarVariables($rows, $titles){ 474 780 475 781 //Replace the titles with valid ones 476 782 //(At the moment we only really need … … 480 786 $newTitles = array(); 481 787 foreach($titles as $index => $name){ 482 788 483 789 switch($name){ 484 790 485 791 case "name": 486 792 $newTitles[] = "company"; 487 793 break; 488 794 489 795 case "date_entered": 490 796 $newTitles[] = "becameclient"; 491 797 break; 492 798 493 799 case "description": 494 800 $newTitles[] = "comments"; 495 801 break; 496 802 497 803 case "deleted": 498 804 $newTitles[] = "inactive"; 499 805 break; 500 806 501 807 case "account_type": 502 808 $newTitles[] = "type"; 503 809 break; 504 810 505 811 case "industry": 506 812 $newTitles[] = "category"; 507 813 break; 508 814 509 815 case "phone_fax": 510 816 $newTitles[] = "fax"; 511 817 break; 512 818 513 819 case "billing_address_street": 514 820 $newTitles[] = "address1"; 515 821 break; 516 822 517 823 case "billing_address_city": 518 824 $newTitles[] = "city"; 519 825 break; 520 826 521 827 case "billing_address_state": 522 828 $newTitles[] = "state"; 523 829 break; 524 830 525 831 case "billing_address_postalcode": 526 832 $newTitles[] = "postalcode"; 527 833 break; 528 834 529 835 case "billing_address_country": 530 836 $newTitles[] = "country"; 531 837 break; 532 838 533 839 case "phone_office": 534 840 $newTitles[] = "workphone"; 535 841 break; 536 842 537 843 case "phone_alternate": 538 844 $newTitles[] = "otherphone"; 539 845 break; 540 846 541 847 case "website": 542 848 $newTitles[] = "webaddress"; 543 849 break; 544 850 545 851 case "shipping_address_street": 546 852 $newTitles[] = "shipaddress1"; 547 853 break; 548 854 549 855 case "shipping_address_city": 550 856 $newTitles[] = "shipcity"; 551 857 break; 552 858 553 859 case "shipping_address_state": 554 860 $newTitles[] = "shipstate"; 555 861 break; 556 862 557 863 case "shipping_address_postalcode": 558 864 $newTitles[] = "shippostalcode"; 559 865 break; 560 866 561 867 case "shipping_address_country": 562 868 $newTitles[] = "shipcountry"; 563 869 break; 564 870 565 871 }//end switch 566 872 567 873 }//end foreach 568 569 874 875 570 876 $newRows = array(); 571 877 foreach($rows as $rowData){ 572 878 573 879 $newRowData = array(); 574 880 $addComments = ""; 575 881 foreach($rowData as $name => $data){ 576 882 577 883 switch($name){ 578 884 579 885 case "name": 580 886 $newRowData["company"] = trim($data); 581 887 break; 582 888 583 889 case "date_entered": 584 890 $newRowData["becameclient"] = trim($data); 585 891 break; 586 892 587 893 case "description": 588 894 $newRowData["comments"] = trim($data); 589 895 break; 590 896 591 897 case "deleted": 592 898 $newRowData["inactive"] = trim($data); 593 899 break; 594 900 595 901 case "industry": 596 902 $newRowData["category"] = trim($data); 597 903 break; 598 904 599 905 case "account_type": 600 906 $newRowData["type"] = trim($data); 601 907 break; 602 908 603 909 case "phone_fax": 604 910 $newRowData["fax"] = trim($data); 605 911 break; 606 912 607 913 case "billing_address_street": 608 914 $newRowData["address1"] = trim($data); 609 915 break; 610 916 611 917 case "billing_address_city": 612 918 $newRowData["city"] = trim($data); 613 919 break; 614 920 615 921 case "billing_address_state": 616 922 $newRowData["state"] = trim($data); 617 923 break; 618 924 619 925 case "billing_address_postalcode": 620 926 $newRowData["postalcode"] = trim($data); 621 927 break; 622 928 623 929 case "billing_address_country": 624 930 $newRowData["country"] = trim($data); 625 931 break; 626 932 627 933 case "phone_office": 628 934 $newRowData["workphone"] = trim($data); 629 935 break; 630 936 631 937 case "phone_alternate": 632 938 $newRowData["otherphone"] = trim($data); 633 939 break; 634 940 635 941 case "website": 636 942 $newRowData["webaddress"] = trim($data); 637 943 break; 638 944 639 945 case "shipping_address_street": 640 946 $newRowData["shipaddress1"] = trim($data); 641 947 break; 642 948 643 949 case "shipping_address_city": 644 950 $newRowData["shipcity"] = trim($data); 645 951 break; 646 952 647 953 case "shipping_address_state": 648 954 $newRowData["shipstate"] = trim($data); 649 955 break; 650 956 651 957 case "shipping_address_postalcode": 652 958 $newRowData["shippostalcode"] = trim($data); 653 959 break; 654 960 655 961 case "shipping_address_country": 656 962 $newRowData["shipcountry"] = trim($data); 657 963 break; 658 964 659 965 case "annual_revenue": 660 966 case "rating": … … 665 971 $addComments .= "\n".str_replace("_"," ",$name).": ".trim($data); 666 972 break; 667 973 668 974 }//end switch 669 975 670 976 }//end foreach 671 977 672 978 if($newRowData["type"] == "prospect") 673 979 $newRowData["becameclient"] = NULL; 674 980 else 981 $newRowData["type"] = "client"; 982 675 983 $newRowData["comments"] .= $addComments; 676 984 $newRows[] = $newRowData; 677 985 678 986 }//end foreach 679 987 680 988 $thereturn["rows"] = $newRows; 681 989 $thereturn["titles"] = $newTitles; 682 990 return $thereturn; 683 991 684 992 }//end method --_formatSugarvariables-- 685 686 993 994 687 995 function importRecords($rows, $titles){ 688 996 689 997 switch($this->importType){ 690 998 691 999 case "sugarcrm": 692 1000 $thereturn = $this->_formatSugarVariables($rows, $titles); 693 1001 $rows = $thereturn["rows"]; 694 1002 $titles = $thereturn["titles"]; 695 696 case "csv": 1003 1004 case "csv": 697 1005 //count total fieldnames (top row of csv document) 698 1006 $fieldNum = count($titles); 699 1007 700 1008 //the file starts at line number 1, but since line 1 is 701 1009 //supposed to be the fieldnames in the table(s), the lines 702 1010 //being insereted start @ 2. 703 1011 $rowNum = 2; 704 1012 705 1013 //get the data one row at a time 706 1014 foreach($rows as $rowData){ 707 708 $theid = 0; 709 1015 1016 $theid = 0; // set for when verifification does not pass 1017 $verify = array(); //set for when number of field rows does not match number of titles 1018 710 1019 //trim off leading/trailing spaces 711 1020 $trimmedRowData = array(); 712 1021 foreach($rowData as $name => $data) 713 1022 $trimmedRowData[$name] = trim($data); 714 1023 715 1024 //check to see if number of fieldnames is consistent for each row 716 1025 $rowFieldNum = count($trimmedRowData); 717 1026 718 1027 //if valid, insert, if not, log error and don't insert. 719 if($rowFieldNum == $fieldNum) 720 $theid = $this->table->insertRecord($trimmedRowData); 721 else 1028 if($rowFieldNum == $fieldNum){ 1029 //$trimmedRowData = $this->table->prepareVariables($trimmedRowData); 1030 $verify = $this->table->verifyVariables($trimmedRowData); 1031 if(!count($verify)) 1032 $theid = $this->table->insertRecord($trimmedRowData); 1033 }else 722 1034 $this->error .= '<li> incorrect amount of fields for line number '.$rowNum.'.</li>'; 723 1035 724 1036 if($theid){ 725 1037 //keep track of the ids in the transaction to be able to select them 726 1038 //for preview purposes 727 1039 $this->transactionIDs[] = $theid; 728 1040 729 1041 //get first id to correct auto increment 730 1042 if(!$this->revertID) 731 1043 $this->revertID = $theid; 732 1044 733 1045 //If it is a sugarcrm import, insert the shipping address as well 1046 $addressVerify = array(); 734 1047 if($this->importType == "sugarcrm"){ 735 736 1048 1049 737 1050 $variables = array(); 738 1051 if($trimmedRowData["shipaddress1"]) $variables["address1"] = $trimmedRowData["shipaddress1"]; … … 740 1053 if($trimmedRowData["shipstate"]) $variables["state"] = $trimmedRowData["shipstate"]; 741 1054 if($trimmedRowData["shipcountry"]) $variables["country"] = $trimmedRowData["shipcountry"]; 742 1055 743 1056 //check to see if there is a shipping address 744 1057 if(count($variables)){ 745 1058 746 1059 //If there is a shipping address, we need to make any others' 747 1060 //`defaultshipto` to 0 748 1061 749 1062 $querystatement = " 750 1063 UPDATE … … 757 1070 `addresstorecord`.`tabledefid` = '2'; 758 1071 "; 759 1072 760 1073 $this->table->db->query($querystatement); 761 1074 762 1075 $variables["title"] = "Main Shipping Addresss"; 763 1076 $variables["tabledefid"] = 2; … … 765 1078 $variables["defaultshipto"] = 1; 766 1079 $variables["primary"] = 0; 767 768 $this->table->address->insertRecord($variables); 769 1080 $variables["existingaddressid"] = false; 1081 1082 $addressVerify = $this->table->address->verifyVariables($variables);//verify address 1083 if(!count($addressVerify))//check for errors 1084 $this->table->address->insertRecord($variables);//insert if no errors 1085 770 1086 }//end if 771 1087 772 1088 }//end if 773 1089 }else 774 1090 $this->error .= '<li> failed insert for line number '.$rowNum.'.</li>'; 775 1091 1092 foreach($verify as $error)//log verify errors for display 1093 $this->error .= '<li class="subError">'.$error.'</li>'; 1094 1095 if(isset($addressVerify)) 1096 foreach($addressVerify as $error)//log address verify errors for display 1097 $this->error .= '<li class="subError">'.$error.'</li>'; 1098 776 1099 $rowNum++; 777 1100 778 1101 }//end foreach 779 1102 break; 780 1103 781 1104 }//end switch 782 1105 783 1106 }//end method --importRecords-- 784 785 1107 1108 786 1109 function _getTransactionData(){ 787 1110 788 1111 $inStatement = ""; 789 1112 foreach($this->transactionIDs as $theid) … … 792 1115 if($inStatement) 793 1116 $inStatement = substr($inStatement, 0, -1); 794 1117 else 1118 $inStatement = "0"; 1119 795 1120 //There are two cases to minimize joins for csv files 796 1121 switch($this->importType){ 797 1122 798 1123 case "sugarcrm": 799 1124 $querystatement = " … … 854 1179 "; 855 1180 break; 856 1181 857 1182 case "csv": 858 1183 $querystatement = " … … 895 1220 `addresses`.`postalcode`, 896 1221 `addresses`.`country`, 897 `addresses`.`phone`, 898 `addresses`.`email` 1222 `addresses`.`phone` 899 1223 FROM 900 1224 ((clients INNER JOIN addresstorecord ON clients.id = addresstorecord.recordid AND addresstorecord.tabledefid=2 AND addresstorecord.primary=1) INNER JOIN addresses ON addresstorecord.addressid = addresses.id) … … 905 1229 "; 906 1230 break; 907 1231 908 1232 }//end switch 909 1233 910 1234 $queryresult = $this->table->db->query($querystatement); 911 1235 912 1236 while($therecord = $this->table->db->fetchArray($queryresult)) 913 1237 $this->transactionRecords[] = $therecord; 914 915 1238 1239 916 1240 }//end method --_gettransactionData-- 917 918 1241 1242 919 1243 function displayTransaction($recordsArray, $fieldsArray){ 920 1244 921 1245 if(count($recordsArray) && count($fieldsArray)){ 922 1246 923 1247 //Need to include addresses in the fieldArray 924 1248 925 1249 //list of values that should not be displayed 926 1250 $removalArray = array("id", "modifiedby", "modifieddate", "createdby", "creationdate", "notes", "title", "shiptoname"); 927 1251 //gets the address table's columnnames/information (fields) 928 1252 $addressArray = $this->table->address->fields; 929 1253 930 1254 //gets rid of the values that should not be displayed 931 1255 foreach($removalArray as $removalField){ 932 1256 933 1257 if(isset($addressArray[$removalField])){ 934 1258 935 1259 unset($addressArray[$removalField]); 936 1260 937 1261 }//end if 938 1262 939 1263 }//end foreach 940 1264 941 1265 //get rid of stuff that should only be in addresses but is present in clients 942 1266 foreach($addressArray as $removalField => $junk){ 943 1267 944 1268 if(isset($fieldsArray[$removalField])){ 945 1269 946 1270 unset($fieldsArray[$removalField]); 947 1271 948 1272 }//end if 949 1273 950 1274 }//end foreach 951 1275 952 1276 //need to get two sets of address fields, one named main* and the other ship*. 953 1277 if($this->importType == "sugarcrm"){ 954 1278 955 1279 foreach($addressArray as $field => $junk){ 956 1280 957 1281 $mainAddressArray["main".$field] = $junk; 958 1282 $shipAddressArray["ship".$field] = $junk; 959 1283 960 1284 }//end foreach 961 1285 962 1286 $addressArray = $mainAddressArray + $shipAddressArray; 963 1287 964 1288 }//end if 965 1289 966 1290 $fieldsArray = $fieldsArray + $addressArray; 967 1291 968 1292 parent::displayTransaction($recordsArray, $fieldsArray); 969 1293 970 1294 }//end if 971 1295 972 1296 }//end method --displayTransaction-- 973 1297 974 1298 }//end class --clientsImport-- 975 1299 }//end if -
trunk/phpbms/modules/bms/include/discounts.php
r285 r485 39 39 if(class_exists("phpbmsTable")){ 40 40 class discounts extends phpbmsTable{ 41 41 42 42 function getDefaults(){ 43 43 44 44 $therecord = parent::getDefaults(); 45 45 46 46 $therecord["type"]="percent"; 47 47 48 48 return $therecord; 49 49 } 50 51 52 function formatValue($variables){ 53 50 51 52 function verifyVariables($variables){ 53 54 //table's default is fine 55 if(isset($variables["type"])){ 56 57 switch($variables["type"]){ 58 59 case "percent": 60 case "amount": 61 break; 62 63 default: 64 $this->verifyErrors[] = "The value of the `type` field is invalid. 65 It must be either 'percent' or 'amount'."; 66 break; 67 68 }//end switch 69 70 }//end if 71 72 return parent::verifyVariables($variables); 73 74 }//end method --verifyVariables-- 75 76 77 function prepareVariables($variables){ 78 54 79 if($variables["type"] == "percent") 55 80 $variables["value"] = ((real) str_replace("%","",$variables["percentvalue"])); 56 else 81 else 57 82 $variables["value"] = currencyToNumber($variables["amountvalue"]); 58 83 59 84 return $variables; 60 85 } 61 62 63 function updateRecord($variables, $modifiedby = NULL){ 64 65 $variables = $this->formatValue($variables); 66 67 parent::updateRecord($variables,$modifiedby); 68 } 69 70 71 function insertRecord($variables,$createdby = NULL){ 72 73 $variables = $this->formatValue($variables); 74 return parent::insertRecord($variables,$createdby); 75 } 76 77 86 87 78 88 function getTotals($id=0){ 79 89 80 90 $returnArray["Invoice"]["total"]=0; 81 91 $returnArray["Invoice"]["sum"]=0; 82 92 $returnArray["Order"]["total"]=0; 83 93 $returnArray["Order"]["sum"]=0; 84 94 85 95 if($id>0){ 86 96 $querystatement="SELECT invoices.type,count(invoices.id) as total,sum(discountamount) as sum 87 FROM discounts inner join invoices on discounts.id=invoices.discountid 97 FROM discounts inner join invoices on discounts.id=invoices.discountid 88 98 WHERE discounts.id=".((int) $id)." and (invoices.type=\"Order\" or invoices.type=\"Invoice\") GROUP BY invoices.type"; 89 99 $queryresult = $this->db->query($querystatement); 90 100 91 101 while($therecord=$this->db->fetchArray($queryresult)){ 92 102 $returnArray[$therecord["type"]]["total"]=$therecord["total"]; 93 103 $returnArray[$therecord["type"]]["sum"]=$therecord["sum"]; 94 104 } 95 105 96 106 } 97 107 98 108 return $returnArray; 99 109 100 110 }//end function 101 111 102 112 }//end class 103 113 }//end if -
trunk/phpbms/modules/bms/include/invoices.php
r451 r485 40 40 class invoices extends phpbmsTable{ 41 41 42 var $availableClientIDs = array(); 43 var $availableUserIDs = array(); 44 var $availableStatusIDs = array(); 45 42 46 function showClientType($id){ 43 47 … … 437 441 } 438 442 443 /*------[verification related functions]---------------------------*/ 444 445 function populateClientArray(){ 446 447 $this->availableClientIDs = array(); 448 449 $querystatement = " 450 SELECT 451 `id` 452 FROM 453 `clients`; 454 "; 455 456 $queryresult = $this->db->query($querystatement); 457 458 if($this->db->numRows($queryresult)){ 459 while($therecord = $this->db->fetchArray($queryresult)) 460 $this->availableClientIDs[] = $therecord["id"]; 461 }else{ 462 $this->availableClientIDs[] = "none"; 463 }//end if 464 465 }//end method --populateClientArray-- 466 467 468 function populateUserArray(){ 469 470 $this->availableUserIDs = array(); 471 472 $querystatement = " 473 SELECT 474 `id` 475 FROM 476 `users`; 477 "; 478 479 $queryresult = $this->db->query($querystatement); 480 481 $this->availableUserIDs[] = 0;//for none 482 483 while($therecord = $this->db->fetchArray($queryresult)) 484 $this->availableUserIDs[] = $therecord["id"]; 485 486 }//end method --populateUserArray-- 487 488 489 function populateInvoiceStatusArray(){ 490 491 $this->availableStatusIDs = array(); 492 493 $querystatement = " 494 SELECT 495 `id` 496 FROM 497 `invoicestatuses`; 498 "; 499 500 $queryresult = $this->db->query($querystatement); 501 502 if($this->db->numRows($queryresult)){ 503 while($therecord = $this->db->fetchArray($queryresult)) 504 $this->availableStatusIDs[] = $therecord["id"]; 505 }else{ 506 $this->availableStatusIDs[] = "none"; 507 }//end if 508 509 }//end method --populateInvoiceStatusArray-- 510 511 512 function verifyVariables($variables){ 513 514 //must have a client 515 if(isset($variables["clientid"])){ 516 517 //must be numeric and positive 518 if(!$variables["clientid"] || (int)$variables["clientid"] > 0){ 519 520 if(!count($this->availableClientIDs)) 521 $this->populateClientArray(); 522 523 if(!in_array(((int)$variables["clientid"]),$this->availableClientIDs)) 524 $this->verifyErrors[] = "The `clientid` field does not give an existing/acceptable client id number."; 525 }else 526 $this->verifyErrors[] = "The `clientid` field must be a non-negative number or equivalent to 0."; 527 528 }else 529 $this->verifyErrors[] = "The `clientid` field must be set."; 530 531 //table default (NULL) is not enough 532 if(isset($variables["type"])){ 533 534 switch($variables["type"]){ 535 536 case "Quote": 537 case "Order": 538 case "Invoice": 539 case "VOID": 540 break; 541 542 default: 543 $this->verifyErrors[] = "The value of the `type` field is invalid. It must be 'Quote', 544 'Order', 'Invoice', or 'VOID'."; 545 break; 546 547 }//end switch 548 549 }else 550 $this->verifyErrors[] = "The `type` field must be set."; 551 552 //check assigned to id 553 if(isset($variables["assignedtoid"])){ 554 555 //assignedtoid needs to be a non-negative number or equivalent to 0 556 if( !$variables["assignedtoid"] || ((int)$variables["assignedtoid"]) > 0 ){ 557 558 if(!count($this->availableUserIDs)) 559 $this->populateUserArray(); 560 561 if(!in_array(((int)$variables["assignedtoid"]),$this->availableUserIDs)) 562 $this->verifyErrors[] = "The `assignedtoid` field does not give an existing/acceptable user id number."; 563 }else 564 $this->verifyErrors[] = "The `assignedtoid` field must be a non-negative number or equivalent to 0."; 565 566 }//end if 567 568 //check status id 569 if(isset($variables["statusid"])){ 570 571 //assignedtoid needs to be a non-negative number or equivalent to 0 572 if( !$variables["statusid"] || ((int)$variables["statusid"]) > 0 ){ 573 574 if(!count($this->availableStatusIDs)) 575 $this->populateInvoiceStatusArray(); 576 577 if(!in_array(((int)$variables["statusid"]),$this->availableStatusIDs)) 578 $this->verifyErrors[] = "The `statusid` field does not give an existing/acceptable status id number."; 579 }else 580 $this->verifyErrors[] = "The `statusid` field must be a non-negative number or equivalent to 0."; 581 582 }//end if 583 584 //check booleans 585 //readytopost 586 if(isset($variables["readytopost"])) 587 if($variables["readytopost"] && $variables["readytopost"] != 1) 588 $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 589 590 //weborder 591 if(isset($variables["weborder"])) 592 if($variables["weborder"] && $variables["weborder"] != 1) 593 $this->verifyErrors[] = "The `weborder` field must be a boolean (equivalent to 0 or exactly 1)."; 594 595 //shiptosameasbilling 596 if(isset($variables["shiptosameasbilling"])) 597 if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != 1) 598 $this->verifyErrors[] = "The `shiptosameasbilling` field must be a boolean (equivalent to 0 or exactly 1)."; 599 //check addresss ids 600 //check secondary line item ids 601 602 return parent::verifyVariables($variables); 603 604 }//end method 605 439 606 440 607 function prepareVariables($variables){ … … 544 711 function updateRecord($variables, $modifiedby = NULL){ 545 712 546 if($modifiedby === NULL)547 $modifiedby = $_SESSION["userinfo"]["id"];713 //if($modifiedby === NULL) 714 // $modifiedby = $_SESSION["userinfo"]["id"]; 548 715 549 716 … … 551 718 return false; 552 719 553 $variables = $this->prepareVariables($variables);720 //$variables = $this->prepareVariables($variables); 554 721 555 722 if(!hasRights(20)){ … … 606 773 $createdby = $_SESSION["userinfo"]["id"]; 607 774 608 $variables = $this->prepareVariables($variables);775 //$variables = $this->prepareVariables($variables); 609 776 610 777 $newid = parent::insertRecord($variables, $createdby); -
trunk/phpbms/modules/bms/include/invoicestatuses.php
r285 r485 40 40 if(class_exists("phpbmsTable")){ 41 41 class invoiceStatus extends phpbmsTable { 42 42 43 var $availableUserIDs = array(); 44 45 function populateUserArray(){ 46 47 $querystatement = " 48 SELECT 49 `id` 50 FROM 51 `users`; 52 "; 53 54 $queryresult = $this->db->query($querystatement); 55 56 $this->availableUserIDs[] = 0;//for everyone 57 58 while($therecord = $this->db->fetchArray($queryresult)) 59 $this->availableUserIDs[] = $therecord["id"]; 60 61 }//end method --populateUserArray-- 62 63 64 function verifyVariables($variables){ 65 66 if(isset($variables["setreadytopost"])) 67 if($variables["setreadytopost"] && $variables["setreadytopost"] != 1) 68 $this->verifyErrors[] = "The `setreadytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 69 70 if(isset($variables["invoicedefault"])) 71 if($variables["invoicedefault"] && $variables["invoicedefault"] != 1) 72 $this->verifyErrors[] = "The `invoicedefault` field must be a boolean (equivalent to 0 or exactly 1)."; 73 74 if(isset($variables["defaultassignedtoid"])){ 75 76 if( !$variables["defaultassignedtoid"] || ((int)$variables["defaultassignedtoid"]) > 0 ){ 77 78 if(!count($this->availableUserIDs)) 79 $this->populateUserArray(); 80 81 if(!in_array(((int)$variables["defaultassignedtoid"]), $this->availableUserIDs)) 82 $this->verifyErrors[] = "The `defaultassignedtoid` field does not give an existing/acceptable user id number."; 83 84 }else 85 $this->verifyErrors[] = "The `defaultassignedtoid` field must be a non-negative number or equivalent to 0."; 86 87 }//end if 88 89 return parent::verifyVariables($variables); 90 91 }//end method --verifyVariables-- 92 93 43 94 function updateRecord($variables, $modifiedby = NULL){ 44 95 if(isset($variables["invoicedefault"])) 45 96 $this->updateInvoiceDefault(); 46 97 47 98 parent::updateRecord($variables, $modifiedby = NULL); 48 } 49 99 } 100 50 101 function updateInvoiceDefault(){ 51 102 $querystatement="UPDATE `".$this->maintable."` SET `invoicedefault` = 0"; … … 59 110 60 111 function delete_record(){ 61 112 62 113 $whereclause = $this->buildWhereClause($theids,"invoicestatuses.id"); 63 114 64 115 $querystatement = "UPDATE invoicestatuses SET inactive=1,modifiedby=".$_SESSION["userinfo"]["id"]." WHERE (".$whereclause.") AND invoicedefault=0;"; 65 116 $queryresult = $this->db->query($querystatement); 66 117 67 118 $message = $this->buildStatusMessage(); 68 119 $message.=" marked inactive."; -
trunk/phpbms/modules/bms/include/products.php
r427 r485 40 40 if(class_exists("phpbmsTable")){ 41 41 class products extends phpbmsTable{ 42 42 43 var $availableCategoryIDs = array(); 44 var $availableProducts = array(); 45 43 46 function getDefaults(){ 44 47 $therecord = parent::getDefaults(); 45 48 46 49 $therecord["type"]="Inventory"; 47 $therecord["status"]="In Stock"; 50 $therecord["status"]="In Stock"; 48 51 $therecord["taxable"]=1; 49 52 50 53 return $therecord; 51 54 } 52 55 53 56 function getPicture($name){ 54 57 if (function_exists('file_get_contents')) { … … 58 61 $file = addslashes(fread(fopen($_FILES[$name]['tmp_name'], 'r'), filesize($_FILES[$name]['tmp_name']))); 59 62 } 60 63 61 64 return $file; 62 65 } 63 64 //This method is for when there is not categoryid specified 65 function _getCategoryID(){ 66 66 67 68 function populateCategoryArray(){ 69 70 $this->availableCategoryIDs = array(); 71 67 72 $querystatement = " 68 73 SELECT 69 74 `id` 70 75 FROM 71 `productcategories` 72 ORDER BY 73 `inactive` ASC 74 LIMIT 1; 76 `productcategories`; 75 77 "; 78 79 $queryresult = $this->db->query($querystatement); 80 81 if($this->db->numRows($queryresult)){ 82 while($therecord = $this->db->fetchArray($queryresult)) 83 $this->availableCategoryIDs[] = $therecord["id"]; 84 }else 85 $this->availableCategoryIDs[] = "none"; 86 87 }//end method --populateCategoryArray-- 88 89 90 function populateProductArray(){ 91 92 // I need id as well to let updates work with our verify function 93 // i.e. if its an update on existing record, its ok if the productnumber 94 // is not unique iff its already associated to the record being updated 95 $this->availableProducts = array(); 96 97 $querystatement = " 98 SELECT 99 `id`, 100 `partnumber` 101 FROM 102 `products`; 103 "; 104 105 $queryresult = $this->db->query($querystatement); 106 107 if($this->db->numRows($queryresult)){ 108 109 while($therecord = $this->db->fetchArray($queryresult)){ 110 $partnumber = $therecord["partnumber"]; 111 $id = $therecord["id"]; 112 113 $this->availableProducts[$partnumber]["id"] = $id; 114 }//end while 115 116 }else{ 117 $partnumber = "NoT a REAl parTNuMBE|7 DU|\/|MY!";//put in an impossible partnumber 118 $id = -1;//put in an impossible product id 119 120 $this->availableProducts[$partnumber]["id"] = $id; 121 }//end if 122 123 }//end method --populateProductArray-- 124 125 126 function verifyVariables($variables){ 127 128 //must have a partnumber...table default is not enough 129 if(isset($variables["partnumber"])){ 130 131 //must have some sort of partnumber 132 if($variables["partnumber"] !== "" || $variables["partnumber"] !== NULL){ 133 134 if(!count($this->availableProducts)) 135 $this->populateProductArray(); 136 137 //can't have this partnumber already chosen 138 if(!isset($variables["id"])) 139 $variables["id"] = 0; 140 141 if($variables["id"] < 0) 142 $variables["id"] = 0; 143 144 $temppartnumber = $variables["partnumber"];// using this because it looks ugly to but the brackets within brackets 145 if( array_key_exists($variables["partnumber"], $this->availableProducts) ){ 146 147 if( $this->availableProducts[$temppartnumber]["id"] !== $variables["id"] ) 148 $this->verifyErrors[] = "The `partnumber` field must give an unique part number."; 149 150 }else{ 151 $this->availableProducts[$temppartnumber]["id"] = -1;// impossible id put in 152 }//end if 153 154 }else 155 $this->verifyErrors[] = "The `partnumber` field must not be blank."; 156 157 }else 158 $this->verifyErrors[] = "The `partnumber` field must be set."; 159 160 161 //STORE CATEGORY IDS, DON'T SELECT EVERY TIME 162 if(isset($variables["categoryid"])){ 163 164 if(((int) $variables["categoryid"]) > 0){ 165 166 if(!count($this->availableCategoryIDs)) 167 $this->populateCategoryArray(); 168 169 if( !in_array(((int) $variables["categoryid"]), $this->availableCategoryIDs) ) 170 $this->verifyErrors[] = "The `categoryid` field does not give an existing/acceptable category id number."; 171 172 }else 173 $this->verifyErrors[] = "The `categoryid` field must be a positive number."; 174 175 }else 176 $this->verifyErrors[] = "The `categoryid` must be set."; 177 178 179 if(isset($variables["status"])){ 180 181 switch($variables["status"]){ 182 183 case "In Stock": 184 case "Out of Stock": 185 case "Backordered": 186 break; 187 188 default: 189 $this->verifyErrors[] = "The value of the `status` field is invalid. 190 It must be 'In Stock', 'Out of Stock', or 'Backordered'."; 191 break; 192 193 }//end switch 194 195 }//end if 196 197 198 if(isset($variables["type"])){ 199 200 switch($variables["type"]){ 201 202 case "Inventory": 203 case "Non-Inventory": 204 case "Service": 205 case "Kit": 206 case "Assembly": 207 break; 208 209 default: 210 $this->verifyErrors[] = "The value of the `type` field is invalid. 211 It must be 'Inventory', 'Non-Inventory', 'Service', 'Kit', or 'Assembly'."; 212 break; 213 214 }//end switch 215 216 }//end if 217 218 //check boolean 219 if(isset($variables["webenabled"])) 220 if($variables["webenabled"] && $variables["webenabled"] != 1) 221 $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1)."; 76 222 77 $queryresult = $this->db->query($querystatement); 78 $therecord = $this->db->fetchArray($queryresult); 79 80 if(!isset($therecord["id"])) 81 $therecord["id"] = 0; 82 83 if(!$therecord["id"]){ 84 85 $querystatement = " 86 INSERT INTO 87 `productcategories` 88 ( 89 `name`, 90 `inactive`, 91 `description`, 92 `webenabled`, 93 `webdisplayname`, 94 `createdby`, 95 `creationdate`, 96 `modifiedby`, 97 `modifieddate` 98 )VALUES( 99 'import_category', 100 '0', 101 'This category was automatically created by an import routine. Please replace with a more applicable record', 102 '0', 103 '', 104 '".((int) $_SESSION["userinfo"]["id"])."', 105 NOW(), 106 '".((int) $_SESSION["userinfo"]["id"])."', 107 NOW() 108 ); 109 "; 110 111 $queryresult = $this->db->query($querystatement); 112 $therecord["id"] = $this->db->insertId(); 113 114 }//end if 115 116 return $therecord["id"]; 117 118 }//end method --_getCategoryID-- 119 120 function formatVariables($variables){ 121 223 if(isset($variables["isoversized"])) 224 if($variables["isoversized"] && $variables["isoversized"] != 1) 225 $this->verifyErrors[] = "The `isoversized` field must be a boolean (equivalent to 0 or exactly 1)."; 226 227 if(isset($variables["isprepackaged"])) 228 if($variables["isprepackaged"] && $variables["isprepackaged"] != 1) 229 $this->verifyErrors[] = "The `isprepackaged` field must be a boolean (equivalent to 0 or exactly 1)."; 230 231 if(isset($variables["taxable"])) 232 if($variables["taxable"] && $variables["taxable"] != 1) 233 $this->verifyErrors[] = "The `taxable` field must be a boolean (equivalent to 0 or exactly 1)."; 234 235 return parent::verifyVariables($variables); 236 237 }//end method --verifyVariables-- 238 239 240 function _commonPrepareVariables($variables){ 241 122 242 if(!isset($variables["unitprice"])) 123 243 $variables["thumchange"] = 0; 124 244 125 245 if(!isset($variables["unitcost"])) 126 246 $variables["thumchange"] = 0; 127 247 128 248 $variables["unitprice"] = currencyToNumber($variables["unitprice"]); 129 249 $variables["unitcost"] = currencyToNumber($variables["unitcost"]); 130 250 131 251 if(!isset($variables["thumbchange"])) 132 252 $variables["thumbchange"] = NULL; 133 253 134 254 if($variables["thumbchange"]){ 135 255 136 256 if($variables["thumbchange"] == "upload"){ 137 257 $variables["thumbnail"] = $this->getPicture("thumbnailupload"); 138 $variables["thumbnailmime"] = $_FILES['thumbnailupload']['type']; 258 $variables["thumbnailmime"] = $_FILES['thumbnailupload']['type']; 139 259 } else { 140 260 //delete … … 142 262 $variables["thumbnailmime"] = NULL; 143 263 } 144 264 145 265 } // end thumbnail picture change if 146 147 266 267 148 268 if(!isset($variables["picturechange"])) 149 269 $variables["picturechange"] = NULL; 150 270 151 271 if($variables["picturechange"]){ 152 272 153 273 if($variables["picturechange"] == "upload"){ 154 274 $variables["picture"] = $this->getPicture("pictureupload"); 155 $variables["picturemime"] = $_FILES['pictureupload']['type']; 275 $variables["picturemime"] = $_FILES['pictureupload']['type']; 156 276 } else { 157 277 //delete … … 159 279 $variables["picturemime"] = NULL; 160 280 } 161 162 }//end main picture change if 163 164 if(!isset($variables["categoryid"])) 165 $variables["categoryid"] = 0; 166 167 if(!$variables["categoryid"]) 168 $variables["categoryid"] = $this->_getCategoryID(); 169 281 282 }//end main picture change if 283 170 284 return $variables; 171 285 286 }//end method --_commonPrepareVariables-- 287 288 289 function prepareVariables($variables){ 290 291 switch($variables["id"]){ 292 293 case "": 294 case NULL: 295 case 0: 296 if(!hasRights(20)){ 297 unset($this->fields["partnumber"]); 298 unset($this->fields["partname"]); 299 unset($this->fields["upc"]); 300 unset($this->fields["description"]); 301 unset($this->fields["inactive"]); 302 unset($this->fields["taxable"]); 303 unset($this->fields["unitprice"]); 304 unset($this->fields["unitcost"]); 305 unset($this->fields["unitofmeasure"]); 306 unset($this->fields["type"]); 307 unset($this->fields["categoryid"]); 308 309 unset($this->fields["webenabled"]); 310 unset($this->fields["keywords"]); 311 unset($this->fields["webdescription"]); 312 313 } else { 314 315 //user has rights. Let's format everything. 316 $variables = $this->_commonPrepareVariables($variables); 317 318 }//end if 319 320 if($variables["packagesperitem"]) 321 $variables["packagesperitem"]=1/$variables["packagesperitem"]; 322 323 break; 324 325 default: 326 $variables = $this->_commonPrepareVariables($variables); 327 if(isset($variables["packagesperitem"])) 328 if($variables["packagesperitem"]) 329 $variables["packagesperitem"] = 1 / $variables["packagesperitem"]; 330 break; 331 332 }//end switch 333 334 return $variables; 335 172 336 }//end function 173 174 337 338 175 339 function updateRecord($variables, $modifiedby = NULL){ 176 177 //need to override field information if they don't have the rights 178 if(!hasRights(20)){ 179 unset($this->fields["partnumber"]); 180 unset($this->fields["partname"]); 181 unset($this->fields["upc"]); 182 unset($this->fields["description"]); 183 unset($this->fields["inactive"]); 184 unset($this->fields["taxable"]); 185 unset($this->fields["unitprice"]); 186 unset($this->fields["unitcost"]); 187 unset($this->fields["unitofmeasure"]); 188 unset($this->fields["type"]); 189 unset($this->fields["categoryid"]); 190 191 unset($this->fields["webenabled"]); 192 unset($this->fields["keywords"]); 193 unset($this->fields["webdescription"]); 194 195 } else { 196 //user has rights. Let's format everything. 197 198 $variables = $this->formatVariables($variables); 199 200 201 } 202 203 if($variables["packagesperitem"]) 204 $variables["packagesperitem"]=1/$variables["packagesperitem"]; 205 206 340 207 341 parent::updateRecord($variables, $modifiedby); 208 342 209 343 //need to reset the field information. If they did not have rights 210 344 // we temporarilly removed the fields to be updated. 211 345 $this->getTableInfo(); 212 346 } 213 214 215 function insertRecord($variables, $createdby = NULL){ 216 217 218 $variables = $this->formatVariables($variables); 219 220 if(isset($variables["packagesperitem"])) 221 if($variables["packagesperitem"]) 222 $variables["packagesperitem"]=1/$variables["packagesperitem"]; 223 224 $newid = parent::insertRecord($variables, $createdby); 225 226 return $newid; 227 } 228 229 347 348 230 349 function checkNumberCategories(){ 231 350 $querystatement="SELECT count(id) AS thecount FROM productcategories WHERE inactive=0"; 232 351 $queryresult=$this->db->query($querystatement); 233 352 $therecord=$this->db->fetchArray($queryresult); 234 353 235 354 return $therecord["thecount"]; 236 355 } 237 238 356 357 239 358 function displayProductCategories($categoryid){ 240 359 $querystatement="SELECT `id`,`name` FROM `productcategories` WHERE `inactive` =0 OR `id` =".((int) $categoryid)." ORDER BY `name`"; 241 360 $queryresult=$this->db->query($querystatement); 242 361 243 362 ?><select name="categoryid" id="categoryid"> 244 <?php 363 <?php 245 364 while($therecord = $this->db->fetchArray($queryresult)){ 246 365 ?><option value="<?php echo $therecord["id"]?>" <?php if($categoryid==$therecord["id"]) echo "selected=\"selected\""?>><?php echo $therecord["name"];?></option> … … 249 368 ?> 250 369 </select><?php 251 252 } 253 370 371 } 372 254 373 }//end products class 255 374 }//end if -
trunk/phpbms/modules/bms/include/receipts.php
r384 r485 40 40 41 41 class receiptitems{ 42 42 43 43 function receiptitems($db){ 44 44 45 45 $this->db = $db; 46 47 }//end method 48 46 47 }//end method 48 49 49 function get($receiptid){ 50 50 … … 67 67 aritems.type, 68 68 aritems.itemdate"; 69 69 70 70 return $this->db->query($querystatement); 71 71 72 72 }//end function 73 74 73 74 75 75 function show($queryresult, $receiptPosted, $receiptid){ 76 76 77 77 $count = 1; 78 78 79 79 while($therecord = $this->db->fetchArray($queryresult)){ 80 80 81 81 $recID = "i".$count; 82 82 83 83 if($therecord["type"] == "invoice"){ 84 84 85 85 $tempDate = stringToDate($therecord["itemdate"], "SQL"); 86 86 $dueDate = dateToString( strtotime(TERM1_DAYS." days", $tempDate) ); 87 88 } else 87 88 } else 89 89 $dueDate = " "; 90 90 91 91 if($therecord["type"] == "deposit" && $therecord["relatedid"] == $receiptid){ 92 92 $therecord["relatedid"] = ""; … … 94 94 $therecord["aritemid"] = 0; 95 95 } 96 97 if($receiptPosted) 98 $docDue = $therecord["amount"] - $therecord["paid"]; 96 97 if($receiptPosted) 98 $docDue = $therecord["amount"] - $therecord["paid"]; 99 99 elseif($therecord["relatedid"]) 100 $docDue = $therecord["amount"] - $therecord["paid"] - $therecord["applied"] - $therecord["discount"] - $therecord["taxadjustment"]; 100 $docDue = $therecord["amount"] - $therecord["paid"] - $therecord["applied"] - $therecord["discount"] - $therecord["taxadjustment"]; 101 101 else 102 102 $docDue = 0; 103 104 103 104 105 105 ?> 106 106 … … 122 122 <td><input id="<?php echo $recID?>TaxAdj" class="currency" value="<?php echo formatVariable($therecord["taxadjustment"], "currency")?>" size="10" maxlength="12"/></td> 123 123 <td><button type="button" id="<?php echo $recID?>RemoveARItemButton" class="graphicButtons buttonMinus" title="remove item"><span>-</span></button></td> 124 </tr> 125 124 </tr> 125 126 126 <?php 127 127 128 128 $count++; 129 129 }//endwhile 130 131 132 }//end method 133 134 130 131 132 }//end method 133 134 135 135 function set($itemlist, $receiptid, $clientid, $userid){ 136 136 137 137 //remove any exisiting items 138 138 $deletestatement = "DELETE FROM receiptitems WHERE receiptid =".((int) $receiptid); 139 139 $this->db->query($deletestatement); 140 140 141 141 //remove any ar deposits created by ths receipt 142 142 $deletestatement = "DELETE FROM aritems WHERE relatedid = ".((int) $receiptid)." AND `type` = 'deposit'"; … … 146 146 147 147 foreach($itemsArray as $item){ 148 148 149 149 $itemRecord = explode("::", $item); 150 150 151 151 if(count($itemRecord) > 1){ 152 152 153 153 //if no ar id, or the deposit is from this record, we need to create the ar item 154 154 if(!$itemRecord[0] || ($itemRecord[1] == $receiptid && $itemRecord[2] == "deposit") ){ 155 155 156 156 $arrecord = array(); 157 157 $arrecord["type"] = "deposit"; 158 158 $arrecord["status"] = "open"; 159 159 $arrecord["posted"] = 0; 160 $arrecord["amount"] = -1 * currencyToNumber($itemRecord[8]); 160 $arrecord["amount"] = -1 * currencyToNumber($itemRecord[8]); 161 161 $arrecord["itemdate"] = $itemRecord[3]; 162 162 $arrecord["clientid"] = $clientid; 163 163 $arrecord["relatedid"] = $receiptid; 164 165 164 165 166 166 if(!isset($aritems)) 167 167 $aritems = new phpbmsTable($this->db, 303); 168 168 169 169 $aritems->insertRecord($arrecord, $userid); 170 170 171 171 $itemRecord[0] = $this->db->insertId(); 172 172 173 173 }//end if 174 174 175 175 $insertstatement =" 176 176 INSERT INTO … … 184 184 ".currencyToNumber($itemRecord[10])." 185 185 )"; 186 186 187 187 $this->db->query($insertstatement); 188 188 189 189 }//endif 190 190 191 191 }//endforeach 192 193 }//end method 194 192 193 }//end method 194 195 195 }// end class 196 196 … … 199 199 //====================================================================== 200 200 class receipts extends phpbmsTable{ 201 201 202 var $availableClientIDs = array(); 203 var $availablePaymentMethodIDs = array(); 202 204 203 205 function showPaymentOptions($selectedid){ 204 206 205 207 global $phpbms; 206 208 207 209 $querystatement = " 208 210 SELECT … … 221 223 priority, 222 224 name"; 223 225 224 226 $queryresult = $this->db->query($querystatement); 225 227 226 228 ?> 227 229 <label for="paymentmethodid">payment type</label><br /> 228 230 <select id="paymentmethodid" name="paymentmethodid"> 229 <?php 231 <?php 230 232 $phpbms->bottomJS[] = 'paymentTypes = Array()'; 231 233 $phpbms->bottomJS[] = 'paymentTypes["s-1"] = Array();'; … … 233 235 $phpbms->bottomJS[] = 'paymentTypes["s-1"]["onlineprocess"] = 0'; 234 236 $phpbms->bottomJS[] = 'paymentTypes["s-1"]["onlineprocess"] = null'; 235 237 236 238 while($therecord = $this->db->fetchArray($queryresult)){ 237 239 … … 240 242 $phpbms->bottomJS[] = 'paymentTypes["s'.$therecord["id"].'"]["onlineprocess"] = "'.$therecord["onlineprocess"].'";'; 241 243 $phpbms->bottomJS[] = 'paymentTypes["s'.$therecord["id"].'"]["processscript"] = "'.$therecord["processscript"].'";'; 242 243 ?><option value="<?php echo $therecord["id"]?>" <?php if($therecord["id"] == $selectedid) echo 'selected="selected"'?>><?php echo $therecord["name"]?></option><?php 244 245 ?><option value="<?php echo $therecord["id"]?>" <?php if($therecord["id"] == $selectedid) echo 'selected="selected"'?>><?php echo $therecord["name"]?></option><?php 244 246 echo "\n"; 245 247 246 248 }//endwhile 247 249 248 250 ?> 249 251 <option value="-1" <?php if($selectedid == -1) echo 'selected="selected"'?>>Other...</option> 250 </select><?php 251 252 253 }//end method 254 252 </select><?php 253 254 255 }//end method 256 255 257 // CLASS OVERRIDES ====================================================================================== 256 258 257 259 function getDefaults(){ 258 260 $therecord = parent::getDefaults(); 259 261 260 262 $therecord["clientid"] = ""; 261 263 $therecord["status"] = "open"; 262 264 $therecord["receiptdate"] = dateToString(mktime(),"SQL"); 263 265 264 266 return $therecord; 265 267 } 266 267 268 269 270 function populateClientArray(){ 271 272 $this->availableClientIDs = array(); 273 274 $querystatement = " 275 SELECT 276 `id` 277 FROM 278 `clients`; 279 "; 280 281 $queryresult = $this->db->query($querystatement); 282 283 if($this->db->numRows($queryresult)){ 284 while($therecord = $this->db->fetchArray($queryresult)) 285 $this->availableClientIDs[] = $therecord["id"]; 286 }else 287 $this->availableClientIDs[] = "none"; 288 289 }//end method --populateClientArray-- 290 291 292 function populatePaymentArray(){ 293 294 $this->availablePaymentMethodIDs = array(); 295 296 $querystatement = " 297 SELECT 298 `id` 299 FROM 300 `paymentmethods`; 301 "; 302 303 $queryresult = $this->db->query($querystatement); 304 305 //for the "other" choice on receipts 306 $this->availablePaymentMethodIDs[] = -1; 307 308 while($therecord = $this->db->fetchArray($queryresult)) 309 $this->availablePaymentMethodIDs[] = $therecord["id"]; 310 311 }//end method --populatePaymentArray-- 312 313 314 function verifyVariables($variables){ 315 316 //default not sufficient 317 if(isset($variables["clientid"])){ 318 319 if(((int) $variables["clientid"]) > 0){ 320 321 if(!count($this->availableClientIDs)) 322 $this->populateClientArray(); 323 324 if(!in_array(((int)$variables["clientid"]),$this->availableClientIDs)) 325 $this->verifyErrors[] = "The `clientid` field does not give an existing/acceptable client id number."; 326 }else 327 $this->verifyErrors[] = "The `clientid` field must be a positive number."; 328 329 }else 330 $this->verifyErrors[] = "The `clientid` field must be set."; 331 332 //because enum, default not sufficient 333 if(isset($variables["status"])){ 334 switch($variables["status"]){ 335 336 case "open": 337 case "collected": 338 break; 339 340 default: 341 $this->verifyErrors[] = "The value of the `status` field is invalid. It must 342 be either 'open' or 'closed'."; 343 break; 344 345 }//end switch 346 }else 347 $this->verifyErrors[] = "The `status` field must be set."; 348 349 // Default is not sufficient 350 if(isset($variables["paymentmethodid"])){ 351 352 if(is_numeric($variables["paymentmethodid"])){ 353 354 if(!count($this->availablePaymentMethodIDs)) 355 $this->populatePaymentArray(); 356 357 if(!in_array(((int)$variables["paymentmethodid"]),$this->availablePaymentMethodIDs)) 358 $this->verifyErrors[] = "The `paymentmethod` field does not give an existing/accpetable payment method id number."; 359 }else 360 $this->verifyErrors[] = "The `paymentmethodid` field must be numeric."; 361 362 }else 363 $this->verifyErrors[] = "The `paymentmethodid` field must be set."; 364 365 //check booleans 366 if(isset($variables["readytopost"])) 367 if($variables["readytopost"] && $variables["readytopost"] != 1) 368 $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 369 370 if(isset($variables["posted"])) 371 if($variables["posted"] && $variables["posted"] != 1) 372 $this->verifyErrors[] = "The `posted` field must be a boolean (equivalent to 0 or exactly 1)."; 373 374 return parent::verifyVariables($variables); 375 376 }//end method --verifyVariables-- 377 378 268 379 function prepareVariables($variables){ 269 380 270 381 $variables["amount"] = currencyToNumber($variables["amount"]); 271 382 272 383 return $variables; 273 384 } 274 275 385 386 276 387 function updateRecord($variables, $modifiedby = NULL){ 277 278 if($modifiedby === NULL) 279 $modifiedby = $_SESSION["userinfo"]["id"]; 280 281 $variables = $this->prepareVariables($variables); 282 388 283 389 if(parent::updateRecord($variables, $modifiedby)){ 284 390 285 391 if($variables["itemschanged"]==1){ 286 392 287 393 $items = new receiptitems($this->db); 288 394 289 395 $items->set($variables["itemslist"], $variables["id"], $variables["clientid"], $modifiedby); 290 396 291 397 }//end if 292 398 293 399 }//end if 294 400 295 401 }//end method 296 297 298 402 403 404 299 405 function insertRecord($variables, $createdby = NULL){ 300 301 if($createdby === NULL) 302 $createdby = $_SESSION["userinfo"]["id"]; 303 304 $variables = $this->prepareVariables($variables); 305 406 306 407 $newid = parent::insertRecord($variables, $createdby); 307 408 308 409 if($variables["itemschanged"]==1){ 309 410 310 411 $items = new receiptitems($this->db); 311 412 312 413 $items->set($variables["itemslist"], $newid, $variables["clientid"], $createdby); 313 414 314 415 }//end if 315 416 316 417 return $newid; 317 418 } … … 322 423 if(class_exists("searchFunctions")){ 323 424 class receiptsSearchFunctions extends searchFunctions{ 324 425 325 426 function post(){ 326 427 327 428 $whereclause = $this->buildWhereClause(); 328 429 329 430 include_once("include/post_class.php"); 330 431 defineReceiptPost(); 331 432 332 433 $receiptPost = new receiptPost($this->db); 333 434 334 435 $count = $receiptPost->post($whereclause); 335 436 336 437 $message = $this->buildStatusMessage($count); 337 438 $message .= " posted."; 338 439 339 440 return $message; 340 441 }//end method 341 342 442 443 343 444 function delete_record(){ 344 445 345 446 //passed variable is array of user ids to be revoked 346 447 $whereclause = $this->buildWhereClause(); 347 448 348 449 $querystatement =" 349 SELECT 450 SELECT 350 451 id 351 452 FROM … … 357 458 358 459 $queryresult = $this->db->query($querystatement); 359 460 360 461 $count = $this->db->numRows($queryresult); 361 462 362 463 $newWhere = ""; 363 464 while($therecord = $this->db->fetchArray($queryresult)) 364 465 $newWhere .= " OR id = ".$therecord["id"]; 365 466 366 467 if(strlen($newWhere)) 367 468 $newWhere = substr($newWhere, 4); 368 469 else 369 470 $newWhere = "id = -1974"; 370 471 371 472 $deletestatement = " 372 473 DELETE FROM … … 375 476 `type` = 'deposit' 376 477 AND (".str_replace("id =", "relatedid =", $newWhere).")"; 377 478 378 479 $this->db->query($deletestatement); 379 480 380 481 $deletestatement = " 381 482 DELETE FROM … … 383 484 WHERE 384 485 ".str_replace("id =", "receiptid =", $newWhere); 385 486 386 487 $this->db->query($deletestatement); 387 488 … … 391 492 WHERE 392 493 ".$newWhere; 393 394 $this->db->query($deletestatement); 395 494 495 $this->db->query($deletestatement); 496 396 497 $message = $this->buildStatusMessage($count); 397 498 $message.=" deleted."; 398 499 399 500 return $message; 400 501 }//end method 401 402 502 503 403 504 function _getFullyDistributed(){ 404 505 405 506 $whereclause = $this->buildWhereClause(); 406 507 407 508 $querystatement = " 408 509 SELECT … … 420 521 $count = 0; 421 522 while($therecord = $this->db->fetchArray($queryresult)){ 422 523 423 524 $querystatement = " 424 525 SELECT … … 432 533 433 534 $checkrecord = $this->db->fetchArray($checkresult); 434 535 435 536 if($therecord["amount"] == $checkrecord["thesum"]){ 436 537 $newWhere .= " OR id = ".$therecord["id"]; 437 538 $count++; 438 539 439 540 }//endif 440 541 441 542 }//endif 442 543 … … 445 546 else 446 547 $newWhere = "id = -1974"; 447 548 448 549 return array("clause" => $newWhere, "count" => $count); 449 450 }//end method 451 452 550 551 }//end method 552 553 453 554 function mark_rtp(){ 454 555 455 556 $where = $this->_getFullyDistributed(); 456 557 457 558 $updatestatement=" 458 559 UPDATE … … 462 563 readytopost = 1, 463 564 modifiedby = ".$_SESSION["userinfo"]["id"].", 464 modifieddate = NOW() 565 modifieddate = NOW() 465 566 WHERE 466 567 ".$where["clause"]; 467 568 468 569 $this->db->query($updatestatement); 469 570 470 571 $message = $this->buildStatusMessage($where["count"]); 471 572 $message.=" marked ready to post."; 472 573 473 574 return $message; 474 575 }//end method 475 476 576 577 477 578 function mark_collected(){ 478 579 479 580 $where = $this->_getFullyDistributed(); 480 581 481 582 $updatestatement=" 482 583 UPDATE … … 488 589 WHERE 489 590 ".$where["clause"]; 490 591 491 592 $this->db->query($updatestatement); 492 593 493 594 $message = $this->buildStatusMessage($where["count"]); 494 595 $message.=" marked collected."; 495 596 496 597 return $message; 497 598 }//end method 498 599 499 600 }//end class 500 601 }//end if … … 504 605 505 606 class receiptPost extends tablePost{ 506 607 507 608 function receiptPost($db, $modifiedby = NULL){ 508 609 509 610 parent::tablePost($db, $modifiedby); 510 611 511 612 }//end method 512 613 513 614 514 615 function prepareWhere($whereclause=NULL){ 515 616 516 617 $this->whereclause = ""; 517 518 if($whereclause) 618 619 if($whereclause) 519 620 $this->whereclause = "(".$whereclause.") AND "; 520 621 521 622 $this->whereclause .= "receipts.posted = 0 AND receipts.readytopost = 1"; 522 523 }//end method 524 525 623 624 }//end method 625 626 526 627 function post($whereclause=NULL){ 527 628 528 629 if($whereclause) 529 630 $this->prepareWhere($whereclause); 530 631 531 632 532 633 $querystatement = " … … 537 638 WHERE 538 639 ".$this->whereclause; 539 640 540 641 $queryresult = $this->db->query($querystatement); 541 642 542 643 $count = $this->db->numRows($queryresult); 543 644 $newWhere = ""; 544 645 while($therecord = $this->db->fetchArray($queryresult)){ 545 646 546 647 $querystatement = " 547 648 SELECT … … 559 660 WHERE 560 661 receiptitems.receiptid = ".$therecord["id"]; 561 662 562 663 $itemsresult = $this->db->query($querystatement); 563 664 564 665 while($itemrecord = $this->db->fetchArray($itemsresult)){ 565 666 566 667 if($itemrecord["relatedid"] == $therecord["id"] && $itemrecord["type"] == "deposit") 567 668 $paid = $itemrecord["paid"]; … … 573 674 else 574 675 $status = "open"; 575 676 576 677 $updatestatement =" 577 678 UPDATE … … 582 683 `status` = '".$status."', 583 684 modifiedby = ".$_SESSION["userinfo"]["id"].", 584 modifieddate = NOW() 685 modifieddate = NOW() 585 686 WHERE 586 687 id = ".$itemrecord["aritemid"]; 587 688 588 689 $this->db->query($updatestatement); 589 690 590 691 if($itemrecord["type"] == "invoice"){ 591 692 592 693 $updatestatement = " 593 UPDATE 694 UPDATE 594 695 invoices 595 696 SET … … 601 702 602 703 $this->db->query($updatestatement); 603 704 604 705 }//endif 605 706 606 707 }//endwhile 607 708 … … 611 712 if(strlen($newWhere)) 612 713 $newWhere = substr($newWhere, 4); 613 714 614 715 if($newWhere){ 615 716 616 717 $updatestatement = " 617 718 UPDATE … … 628 729 ccnumber = LPAD(SUBSTRING(ccnumber,-4),LENGTH(ccnumber),'*'), 629 730 "; 630 }//endif 631 731 }//endif 732 632 733 $updatestatement .=" 633 734 modifiedby = ".$_SESSION["userinfo"]["id"].", … … 635 736 WHERE 636 737 ".$newWhere; 637 738 638 739 $this->db->query($updatestatement); 639 740 640 741 641 742 }//endif 642 743 643 744 return $count; 644 645 }//end method 646 745 746 }//end method 747 647 748 }//end class invoicePost 648 749 -
trunk/phpbms/modules/bms/install/install.php
r384 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 42 include("../../../install/install_include.php"); 43 include("../../../include/session.php"); 44 45 $phpbmsSession = new phpbmsSession; 46 $success = $phpbmsSession->loadDBSettings(false); 47 include_once("include/db.php"); 48 $db = new db(false); 49 $db->stopOnError = false; 50 $db->showError = false; 51 $db->logError = false; 52 53 if($success !== false){ 54 55 if(!$db->connect()) 56 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 57 else { 58 if(!$db->selectSchema()) 59 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 60 else { 61 62 $thereturn = "Business Management System Installation\n"; 63 $thereturn .= "_______________________________________\n"; 64 65 $tempreturn = createTables($db,"createtables.sql"); 66 67 if($tempreturn === true){ 68 69 $thereturn.= "Done Creating Tables \n"; 70 71 $tables = array( 72 "choices", 73 "menu", 74 "tabs", 75 "roles", 76 "modules", 77 "smartsearches", 78 "relationships", 79 "reports", 80 "tablecolumns", 81 "tabledefs", 82 "tablegroupings", 83 "tablefindoptions", 84 "tableoptions", 85 "tablesearchablefields", 86 "usersearches", 87 "settings", 88 "shippingmethods", 89 "paymentmethods", 90 "invoicestatuses", 91 ); 92 foreach($tables as $table){ 93 94 $failure = false; 95 $tempreturn = importData($db,$table); 96 $thereturn .= $tempreturn; 97 if(!strpos($tempreturn,"complete.") === false){ 98 $failed = true; 99 } 100 101 }//end foreach 102 103 if(!$failure){ 104 $thereturn .= "________________________\n"; 105 $thereturn .= "Done Installing BMS Data\n"; 106 } 107 } else 108 $thereturn = $tempreturn; 109 } 110 } 111 } else 112 $thereturn = "Could not access settings.php"; 113 114 115 header('Content-Type: text/xml'); 116 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 117 <response><?php echo $thereturn?></response> 39 $theModule = new installModuleAjax($this->db, $this->phpbmsSession, "../modules/bms/install/"); 40 $theModule->tables = array( 41 "choices", 42 "menu", 43 "tabs", 44 "roles", 45 "modules", 46 "smartsearches", 47 "relationships", 48 "reports", 49 "tablecolumns", 50 "tabledefs", 51 "tablegroupings", 52 "tablefindoptions", 53 "tableoptions", 54 "tablesearchablefields", 55 "usersearches", 56 "settings", 57 "shippingmethods", 58 "paymentmethods", 59 "invoicestatuses", 60 ); -
trunk/phpbms/modules/bms/install/reports.sql
r408 r485 26 26 INSERT INTO `reports` (`name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Summary', 'report', '303', '10', '80', 'modules/bms/report/aritems_summary.php', 'Items grouped and totaled by clients, with grand totals.', 1, NOW(), 1, NOW()); 27 27 INSERT INTO `reports` (`name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Payment Type Totals', 'report', '304', '10', '80', 'modules/bms/report/receipts_pttotals.php', 'Totals grouped by payment method.', 1, NOW(), 1, NOW()); 28 INSERT INTO `reports` (`name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Incoming Cash Flow', 'report', '3', '55', '50', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of it\'s own start and end dates.', 1, NOW(), 1, NOW()); -
trunk/phpbms/modules/bms/install/tablecolumns.sql
r442 r485 4 4 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('2', 'type', 'clients.type', 'left', '', '0', '', '0', '', NULL, '0'); 5 5 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('2', 'phone', 'IF(clients.workphone != \'\' OR clients.homephone != \'\' OR clients.mobilephone != \'\' OR clients.otherphone != \'\',IF(clients.workphone != \'\', concat(clients.workphone, \' (w)\'), IF(clients.homephone != \'\', concat(clients.homephone, \' (h)\'), IF(clients.mobilephone != \'\', concat(clients.mobilephone, \' (m)\'), IF(clients.otherphone != \'\', concat(clients.otherphone, \' (o)\'), \'\')))) ,\'\')', 'left', '', '4', 'concat(clients.workphone, clients.homephone, clients.mobilephone,clients.otherphone)', '0', '', NULL, '0'); 6 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'id','invoices.id','left','',0,'',0,'',NULL,0);7 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'type','invoices.type','left','',2,'',0,'',NULL,0);8 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'status','invoicestatuses.name','left','',3,'',0,'',NULL,0);9 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'date','if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate)','left','',5,'',0,'','date',0);10 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'client name / company','concat(\"<strong>\",if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company),\"</strong>\")','left','',6,NULL,0,'100%','noencoding',0);11 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'total','if(invoices.type!=\"VOID\",invoices.totalti,\"-----\")','right','sum(if(invoices.type!=\"VOID\",invoices.totalti,0))',8,'if(invoices.type!=\"VOID\",invoices.totalti,0)',0,'','currency',0);12 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'due','if(invoices.type!=\"VOID\",invoices.totalti-invoices.amountpaid,\"-----\")','right','sum(if(invoices.type!=\"VOID\",(invoices.totalti-invoices.amountpaid),0))',9,'if(invoices.type!=\"VOID\",invoices.totalti-invoices.amountpaid,0)',0,'','currency',0);13 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'web','invoices.weborder','center','',4,'',0,'','boolean',0);14 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'RTP','invoices.readytopost','center','',1,'',0,'','boolean',0);15 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 3,'payment','paymentmethods.name','left','',7,'',0,'',NULL,0);16 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 4,'part number','products.partnumber','left','',0,'',0,'',NULL,0);17 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 4,'name','products.partname','left','',1,'',1,'100%',NULL,0);18 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 4,'status','products.status','left','',3,'',0,'',NULL,0);19 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 4,'unit price','products.unitprice','right','',4,'',0,'','currency',0);20 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 4,'type','products.type','left','',2,'',0,'',NULL,0);21 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'id','lineitems.id','left','',0,'',0,'',NULL,0);22 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'invoice id','lineitems.invoiceid','left','',1,'',0,'',NULL,0);23 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'part #','products.partnumber','left','',4,'',0,'',NULL,0);24 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'name','products.partname','left','',5,'',1,'100%',NULL,0);25 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'unit price','lineitems.unitprice','right','sum(lineitems.unitprice)',6,'lineitems.unitprice',0,'','currency',0);26 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'qty','format(lineitems.quantity,2)','center','format(sum(lineitems.quantity),2)',7,'lineitemd.quantity',0,'',NULL,0);27 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'price ext.','lineitems.unitprice*lineitems.quantity','right','sum(lineitems.unitprice*lineitems.quantity)',8,'',0,'','currency',0);28 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'cost ext.','lineitems.unitcost*lineitems.quantity','right','sum(lineitems.unitcost*lineitems.quantity)',9,'',0,'','currency',0);29 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'total wt.','format((lineitems.unitweight*lineitems.quantity),2)','right','format(sum(lineitems.unitweight*lineitems.quantity),2)',11,'lineitems.unitweight*lineitems.quantity',0,'',NULL,0);30 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'type','invoices.type','left','',2,'',0,'',NULL,0);31 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'date','if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate)\r\n','left','',3,'',1,'','date',0);32 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 5,'tax','lineitems.taxable','center','',10,'',0,'','boolean',0);33 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 6,'id','tax.id','center','',0,'',0,'',NULL,0);34 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 6,'name','concat(\"<strong>\",tax.name,\"</strong>\")','left','',1,NULL,0,'','noencoding',0);35 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 6,'percentage','concat(tax.percentage,\"%\")','left','',2,'tax.percentage',0,'98%',NULL,0);36 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 7,'id','productcategories.id','center','',0,'',0,'',NULL,0);37 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 7,'name','productcategories.name','left','',1,'',0,'100%',NULL,0);38 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 7,'date created','productcategories.creationdate','left','',2,'productcategories.creationdate',0,'','datetime',0);39 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 8,'name','childproducts.partname','left','',1,'',1,'100%',NULL,0);40 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 8,'part number','childproducts.partnumber','left','',0,'',0,'',NULL,0);6 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'id', 'invoices.id', 'left', '', '0', '', '0', '', NULL, '0'); 7 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'type', 'invoices.type', 'left', '', '2', '', '0', '', NULL, '0'); 8 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'status', 'invoicestatuses.name', 'left', '', '3', '', '0', '', NULL, '0'); 9 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'date', 'if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate)', 'left', '', '5', '', '0', '', 'date', '0'); 10 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'client name / company', 'concat(\"<strong>\",if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company),\"</strong>\")', 'left', '', '6', NULL, '0', '100%', 'noencoding', '0'); 11 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'total', 'if(invoices.type!=\"VOID\",invoices.totalti,\"-----\")', 'right', 'sum(if(invoices.type!=\"VOID\",invoices.totalti,0))', '8', 'if(invoices.type!=\"VOID\",invoices.totalti,0)', '0', '', 'currency', '0'); 12 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'due', 'if(invoices.type!=\"VOID\",invoices.totalti-invoices.amountpaid,\"-----\")', 'right', 'sum(if(invoices.type!=\"VOID\",(invoices.totalti-invoices.amountpaid),0))', '9', 'if(invoices.type!=\"VOID\",invoices.totalti-invoices.amountpaid,0)', '0', '', 'currency', '0'); 13 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'web', 'invoices.weborder', 'center', '', '4', '', '0', '', 'boolean', '0'); 14 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'RTP', 'invoices.readytopost', 'center', '', '1', '', '0', '', 'boolean', '0'); 15 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('3', 'payment', 'paymentmethods.name', 'left', '', '7', '', '0', '', NULL, '0'); 16 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('4', 'part number', 'products.partnumber', 'left', '', '0', '', '0', '', NULL, '0'); 17 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('4', 'name', 'products.partname', 'left', '', '1', '', '1', '100%', NULL, '0'); 18 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('4', 'status', 'products.status', 'left', '', '3', '', '0', '', NULL, '0'); 19 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('4', 'unit price', 'products.unitprice', 'right', '', '4', '', '0', '', 'currency', '0'); 20 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('4', 'type', 'products.type', 'left', '', '2', '', '0', '', NULL, '0'); 21 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'id', 'lineitems.id', 'left', '', '0', '', '0', '', NULL, '0'); 22 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'invoice id', 'lineitems.invoiceid', 'left', '', '1', '', '0', '', NULL, '0'); 23 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'part #', 'products.partnumber', 'left', '', '4', '', '0', '', NULL, '0'); 24 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'name', 'products.partname', 'left', '', '5', '', '1', '100%', NULL, '0'); 25 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'unit price', 'lineitems.unitprice', 'right', 'sum(lineitems.unitprice)', '6', 'lineitems.unitprice', '0', '', 'currency', '0'); 26 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'qty', 'format(lineitems.quantity,2)', 'center', 'format(sum(lineitems.quantity),2)', '7', 'lineitemd.quantity', '0', '', NULL, '0'); 27 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'price ext.', 'lineitems.unitprice*lineitems.quantity', 'right', 'sum(lineitems.unitprice*lineitems.quantity)', '8', '', '0', '', 'currency', '0'); 28 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'cost ext.', 'lineitems.unitcost*lineitems.quantity', 'right', 'sum(lineitems.unitcost*lineitems.quantity)', '9', '', '0', '', 'currency', '0'); 29 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'total wt.', 'format((lineitems.unitweight*lineitems.quantity),2)', 'right', 'format(sum(lineitems.unitweight*lineitems.quantity),2)', '11', 'lineitems.unitweight*lineitems.quantity', '0', '', NULL, '0'); 30 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'type', 'invoices.type', 'left', '', '2', '', '0', '', NULL, '0'); 31 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'date', 'if(invoices.type=\"Invoice\",invoices.invoicedate,invoices.orderdate)\r\n', 'left', '', '3', '', '1', '', 'date', '0'); 32 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('5', 'tax', 'lineitems.taxable', 'center', '', '10', '', '0', '', 'boolean', '0'); 33 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('6', 'id', 'tax.id', 'center', '', '0', '', '0', '', NULL, '0'); 34 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('6', 'name', 'concat(\"<strong>\",tax.name,\"</strong>\")', 'left', '', '1', NULL, '0', '', 'noencoding', '0'); 35 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('6', 'percentage', 'concat(tax.percentage,\"%\")', 'left', '', '2', 'tax.percentage', '0', '98%', NULL, '0'); 36 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('7', 'id', 'productcategories.id', 'center', '', '0', '', '0', '', NULL, '0'); 37 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('7', 'name', 'productcategories.name', 'left', '', '1', '', '0', '100%', NULL, '0'); 38 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('7', 'date created', 'productcategories.creationdate', 'left', '', '2', 'productcategories.creationdate', '0', '', 'datetime', '0'); 39 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('8', 'name', 'childproducts.partname', 'left', '', '1', '', '1', '100%', NULL, '0'); 40 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('8', 'part number', 'childproducts.partnumber', 'left', '', '0', '', '0', '', NULL, '0'); 41 41 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('18', 'id', 'clients.id', 'center', '', '0', '', '0', '', NULL, '0'); 42 42 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('18', 'type', 'clients.type', 'left', '', '1', '', '0', '', NULL, '0'); 43 43 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('18', 'name', 'IF(clients.company != \'\', CONCAT(clients.company,IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(\' (\',if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\'),\')\'), \'\')), IF(clients.lastname != \'\' OR clients.firstname != \'\', CONCAT(if(clients.lastname != \'\', clients.lastname, \'{blank}\'),\', \',if(clients.firstname != \'\', clients.firstname, \'{blank}\')), \'\'))', 'left', '', '2', 'concat(clients.company,clients.lastname,clients.firstname)', '1', '100%', NULL, '0'); 44 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 22,'name','clientemailprojects.name','left','',0,'',0,'100%',NULL,0);45 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 22,'last run','clientemailprojects.lastrun','right','',1,'',0,'','datetime',0);46 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 25,'amount/percent','discounts.value','right','',2,'',0,'',NULL,0);47 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 25,'type','discounts.type','left','',1,'',0,'',NULL,0);48 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 25,'name','discounts.name','left','',0,'',0,'100%',NULL,0);49 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 300,'name','shippingmethods.name','left','',1,'',0,'99%',NULL,0);50 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 300,'estimate','shippingmethods.canestimate','center','',2,'',0,'','boolean',0);51 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 300,'priority','shippingmethods.priority','right','',0,'',0,'',NULL,0);52 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 301,'name','paymentmethods.name','left','',1,'',0,'99%',NULL,0);53 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 301,'type','paymentmethods.type','left','',2,'',0,'',NULL,0);54 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 301,'id','paymentmethods.id','center','',0,'',0,'',NULL,0);55 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 301,'priority','paymentmethods.priority','center','',3,'',0,'',NULL,0);56 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 301,'online process','paymentmethods.onlineprocess','center','',4,'',0,'','boolean',0);57 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 302,'name','invoicestatuses.name','left','',0,'',1,'99%',NULL,0);58 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 302,'priority','invoicestatuses.priority','right','',1,'',0,'',NULL,0);59 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 302,'inactive','invoicestatuses.inactive','center','',2,'',0,'','boolean',0);60 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'type','aritems.type','left','',1,'',0,'',NULL,0);61 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'date','aritems.itemdate','left','',3,'',0,'','date',0);62 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'client','if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)','left','',4,'',1,'100%',NULL,0);63 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'doc amt','aritems.amount','right','SUM(aritems.amount)',5,'',0,'','currency',0);64 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'amt due','aritems.amount-aritems.paid','right','SUM(aritems.amount-aritems.paid)',6,'',0,'','currency',0);65 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'doc ref','aritems.relatedid','left','',2,'',0,'',NULL,0);66 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 303,'status','aritems.status','left','',0,'',0,'',NULL,0);67 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'id','receipts.id','left','',0,'',0,'',NULL,0);68 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'client','if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)','left','',4,'',1,'100%',NULL,0);69 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'RTP','receipts.readytopost','center','',1,'',0,'','boolean',0);70 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'amount','receipts.amount','right','sum(receipts.amount)',6,'',0,'','currency',0);71 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'payment','IF(receipts.paymentmethodid = -1,concat( concat("Other... (", receipts.paymentother), ")"), paymentmethods.name)','left','',5,'',0,'',NULL,0);72 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'date','receipts.receiptdate','left','',3,'',0,'','date',0);73 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ( 304,'status','receipts.status','left','',2,'',0,'',NULL,0);44 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('22', 'name', 'clientemailprojects.name', 'left', '', '0', '', '0', '100%', NULL, '0'); 45 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('22', 'last run', 'clientemailprojects.lastrun', 'right', '', '1', '', '0', '', 'datetime', '0'); 46 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('25', 'amount/percent', 'discounts.value', 'right', '', '2', '', '0', '', NULL, '0'); 47 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('25', 'type', 'discounts.type', 'left', '', '1', '', '0', '', NULL, '0'); 48 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('25', 'name', 'discounts.name', 'left', '', '0', '', '0', '100%', NULL, '0'); 49 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('300', 'name', 'shippingmethods.name', 'left', '', '1', '', '0', '99%', NULL, '0'); 50 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('300', 'estimate', 'shippingmethods.canestimate', 'center', '', '2', '', '0', '', 'boolean', '0'); 51 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('300', 'priority', 'shippingmethods.priority', 'right', '', '0', '', '0', '', NULL, '0'); 52 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('301', 'name', 'paymentmethods.name', 'left', '', '1', '', '0', '99%', NULL, '0'); 53 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('301', 'type', 'paymentmethods.type', 'left', '', '2', '', '0', '', NULL, '0'); 54 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('301', 'id', 'paymentmethods.id', 'center', '', '0', '', '0', '', NULL, '0'); 55 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('301', 'priority', 'paymentmethods.priority', 'center', '', '3', '', '0', '', NULL, '0'); 56 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('301', 'online process', 'paymentmethods.onlineprocess', 'center', '', '4', '', '0', '', 'boolean', '0'); 57 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('302', 'name', 'invoicestatuses.name', 'left', '', '0', '', '1', '99%', NULL, '0'); 58 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('302', 'priority', 'invoicestatuses.priority', 'right', '', '1', '', '0', '', NULL, '0'); 59 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('302', 'inactive', 'invoicestatuses.inactive', 'center', '', '2', '', '0', '', 'boolean', '0'); 60 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'type', 'aritems.type', 'left', '', '1', '', '0', '', NULL, '0'); 61 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'date', 'aritems.itemdate', 'left', '', '3', '', '0', '', 'date', '0'); 62 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'client', 'if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)', 'left', '', '4', '', '1', '100%', NULL, '0'); 63 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'doc amt', 'aritems.amount', 'right', 'SUM(aritems.amount)', '5', '', '0', '', 'currency', '0'); 64 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'amt due', 'aritems.amount-aritems.paid', 'right', 'SUM(aritems.amount-aritems.paid)', '6', '', '0', '', 'currency', '0'); 65 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'doc ref', 'aritems.relatedid', 'left', '', '2', '', '0', '', NULL, '0'); 66 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('303', 'status', 'aritems.status', 'left', '', '0', '', '0', '', NULL, '0'); 67 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'id', 'receipts.id', 'left', '', '0', '', '0', '', NULL, '0'); 68 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'client', 'if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)', 'left', '', '4', '', '1', '100%', NULL, '0'); 69 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'RTP', 'receipts.readytopost', 'center', '', '1', '', '0', '', 'boolean', '0'); 70 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'amount', 'receipts.amount', 'right', 'sum(receipts.amount)', '6', '', '0', '', 'currency', '0'); 71 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'payment', 'IF(receipts.paymentmethodid = -1,concat( concat(\"Other... (\", receipts.paymentother), \")\"), paymentmethods.name)', 'left', '', '5', '', '0', '', NULL, '0'); 72 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'date', 'receipts.receiptdate', 'left', '', '3', '', '0', '', 'date', '0'); 73 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('304', 'status', 'receipts.status', 'left', '', '2', '', '0', '', NULL, '0'); 74 74 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('305', 'address', 'concat(if(addresses.title != \'\',concat(\'[b]\',addresses.title,\'[/b][br]\'),\'\'),IF(addresses.address1!=\'\',addresses.address1,\'\'),if(addresses.address2 != \'\',concat(\'[br]\', addresses.address2),\'\'),if(addresses.city != \'\',concat(\'[br]\',addresses.city,\', \',if(addresses.state != \'\',addresses.state, \'\'),\' \',if(addresses.postalcode != \'\', addresses.postalcode, \'\')),\'\'),if(addresses.country != \'\',concat(\'[br]\',addresses.country),\'\'))', 'left', '', '0', '', '1', '100%', 'bbcode', '0'); 75 75 INSERT INTO `tablecolumns` (`tabledefid`, `name`, `column`, `align`, `footerquery`, `displayorder`, `sortorder`, `wrap`, `size`, `format`, `roleid`) VALUES ('305', 'default ship to', 'addresstorecord.defaultshipto', 'center', '', '4', '', '0', '', 'boolean', '0'); -
trunk/phpbms/modules/bms/install/tabledefs.sql
r427 r485 1 1 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('2', 'Clients', 'table', '2', 'clients', '((clients INNER JOIN addresstorecord on clients.id = addresstorecord.recordid AND addresstorecord.tabledefid=2 AND addresstorecord.primary=1) INNER JOIN addresses ON addresstorecord.addressid = addresses.id)', 'modules/bms/clients_addedit.php', '0', 'modules/bms/clients_addedit.php', '0', 'modules/bms/clients_import.php', '-100', '0', '-100', '-100', 'inactivate', 'clients.id=-100', 'clients.company, clients.lastname, clients.firstname', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 2 2 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('3', 'Sales Orders', 'table', '2', 'invoices', '(((invoices INNER JOIN clients ON invoices.clientid=clients.id) INNER JOIN invoicestatuses ON invoices.statusid=invoicestatuses.id) LEFT JOIN paymentmethods ON invoices.paymentmethodid = paymentmethods.id)', 'modules/bms/invoices_addedit.php', '0', 'modules/bms/invoices_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'void', 'invoices.type+0<3 OR (invoices.type = \'Invoice\' AND invoices.totalti != invoices.amountpaid)', 'invoices.id', '', '', '', 1, NOW(), 1, NOW()); 3 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Products', 'table', '2', 'products', '(products inner join productcategories on products.categoryid=productcategories.id)', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_import.php', '-100', '0', '-100', '-100', 'inactivate', 'products.id =-100', 'products.partnumber', NULL, NULL, NULL, 1, NOW(), 1, NOW());3 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('4', 'Products', 'table', '2', 'products', '(products inner join productcategories on products.categoryid=productcategories.id)', 'modules/bms/products_addedit.php', '0', 'modules/bms/products_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'inactivate', 'products.id =-100', 'products.partnumber', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 4 4 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('5', 'Line Items', 'table', '2', 'lineitems', '((lineitems left join products on lineitems.productid=products.id) inner join invoices on lineitems.invoiceid=invoices.id)', 'N/A', '0', 'N/A', '0', NULL, '-100', '0', '-100', '-100', 'NA', 'lineitems.id =-1', 'lineitems.invoiceid,lineitems.id', '', '', '', 1, NOW(), 1, NOW()); 5 5 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('6', 'Tax Areas', 'table', '2', 'tax', 'tax', 'modules/bms/tax_addedit.php', '0', 'modules/bms/tax_addedit.php', '0', NULL, '-100', '0', '-100', '-100', 'inactivate', 'tax.inactive=0', 'tax.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); … … 11 11 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('300', 'Shipping Methods', 'table', '2', 'shippingmethods', 'shippingmethods', 'modules/bms/shippingmethods_addedit.php', '30', 'modules/bms/shippingmethods_addedit.php', '30', NULL, '-100', '30', '30', '-100', 'inactivate', 'shippingmethods.inactive!=0', 'shippingmethods.priority, shippingmethods.name', '', '', '', 1, NOW(), 1, NOW()); 12 12 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('301', 'Payment Methods', 'table', '2', 'paymentmethods', 'paymentmethods', 'modules/bms/paymentmethods_addedit.php', '30', 'modules/bms/paymentmethods_addedit.php', '30', NULL, '-100', '30', '30', '-100', 'inactivate', 'paymentmethods.inactive=0', 'paymentmethods.priority,paymentmethods.name', '', '', '', 1, NOW(), 1, NOW()); 13 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('302', 'Invoice Statuses', 'table', '2', 'invoicestatuses', 'invoicestatuses', 'modules/bms/invoicestatuses_addedit.php', '30', 'modules/bms/invoicestatuses_addedit.php', '30', NULL, '-100', '30', '-100', '-100', 'inactivate', 'invoicestatuses.inactive=0', 'invoicestatuses.priority,invoicestatuses.name', '', '', '', 1, NOW(), 1, NOW());13 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('302', 'Invoice Statuses', 'table', '2', 'invoicestatuses', 'invoicestatuses', 'modules/bms/invoicestatuses_addedit.php', '30', 'modules/bms/invoicestatuses_addedit.php', '30', NULL, '-100', '30', '-100', '-100', 'inactivate', 'invoicestatuses.inactive=0', 'invoicestatuses.priority,invoicestatuses.name', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 14 14 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('303', 'AR Items', 'table', '2', 'aritems', '(aritems INNER JOIN clients ON aritems.clientid = clients.id)', 'modules/bms/aritems_view.php', '0', 'NA', '0', NULL, '-100', '0', '-100', '-100', 'NA', 'aritems.posted=1 AND aritems.status = \'open\'', 'aritems.itemdate, aritems.status, aritems.id', NULL, NULL, NULL, 1, NOW(), 1, NOW()); 15 15 INSERT INTO `tabledefs` (`id`, `displayname`, `type`, `moduleid`, `maintable`, `querytable`, `editfile`, `editroleid`, `addfile`, `addroleid`, `importfile`, `importroleid`, `searchroleid`, `advsearchroleid`, `viewsqlroleid`, `deletebutton`, `defaultwhereclause`, `defaultsortorder`, `defaultsearchtype`, `defaultcriteriafindoptions`, `defaultcriteriaselection`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('304', 'Receipts', 'table', '2', 'receipts', '((receipts INNER JOIN clients ON receipts.clientid = clients.id) LEFT JOIN paymentmethods ON receipts.paymentmethodid = paymentmethods.id)', 'modules/bms/receipts_addedit.php', '80', 'modules/bms/receipts_addedit.php', '80', NULL, '-100', '80', '-100', '-100', 'delete', 'receipts.posted=0', 'receipts.receiptdate', NULL, NULL, NULL, 1, NOW(), 1, NOW()); -
trunk/phpbms/modules/bms/install/tablegroupings.sql
r323 r485 1 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 2,'clients.type',1,1,'',0);2 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 3,'concat(invoices.type,\"s\")',1,1,'',0);3 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 4,'productcategories.name',1,1,'',0);4 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 8,'concat(products.partnumber,\' - \',products.partname)',1,1,'',0);5 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ( 22,'if(clientemailprojects.userid=0, \"global\", concat( users.firstname,\" \", users.lastname))',1,1,'',0);1 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('2', 'clients.type', '1', '1', '', '0'); 2 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('3', 'concat(invoices.type,\"s\")', '1', '1', '', '0'); 3 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('4', 'productcategories.name', '1', '1', '', '0'); 4 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('8', 'concat(products.partnumber,\' - \',products.partname)', '1', '1', '', '0'); 5 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('22', 'if(clientemailprojects.userid=0, \"global\", concat( users.firstname,\" \", users.lastname))', '1', '1', '', '0'); 6 6 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('303', 'if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)', '1', '1', '', '0'); 7 7 INSERT INTO `tablegroupings` (`tabledefid`, `field`, `displayorder`, `ascending`, `name`, `roleid`) VALUES ('304', 'if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company)', '1', '1', '', '0'); -
trunk/phpbms/modules/bms/install/tableoptions.sql
r427 r485 76 76 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'import', '0', '0', '0', '-100', '0'); 77 77 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'printex', '1', '0', '0', '0', '0'); 78 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'run_aging', 'run aging', ' 1', '1', '80', '0');78 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'run_aging', 'run aging', '0', '1', '80', '0'); 79 79 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'new', '0', '0', '0', '0', '0'); 80 80 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('303', 'edit', '1', '1', '0', '0', '0'); -
trunk/phpbms/modules/bms/install/tablesearchablefields.sql
r385 r485 1 1 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', '(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")', ' name', '0', 'whereclause'); 2 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', '(clients.homephone like \"{{value}}%\" or clients.workphone like \"{{value}}%\" or clients.mobilephone like \"{{value}}%\" or clients.otherphone like \"{{value}}%\" or clients.fax like \"{{value}}%\")', 'phone', '1', 'whereclause'); 3 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.city', 'city', '2', 'field'); 4 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.state', 'state/province', '3', 'field'); 5 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.postalcode', 'postal code', '4', 'field'); 6 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'clients.email', 'e-mail', '5', 'field'); 7 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'clients.leadsource', 'lead source', '6', 'field'); 2 8 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'clients.id', 'id', '7', 'field'); 3 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'clients.leadsource', 'lead source', '6', 'field'); 4 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'clients.email', 'e-mail', '5', 'field'); 5 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.postalcode', 'postal code', '4', 'field'); 6 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.state', 'state/province', '3', 'field'); 7 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', 'addresses.city', 'city', '2', 'field'); 8 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('2', '(clients.homephone like \"{{value}}%\" or clients.workphone like \"{{value}}%\" or clients.mobilephone like \"{{value}}%\" or clients.otherphone like \"{{value}}%\" or clients.fax like \"{{value}}%\")', 'phone', '1', 'whereclause'); 9 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (3,'invoices.orderdate','order date',2,'field'); 10 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (3,'invoices.invoicedate','invoice date',3,'field'); 11 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (3,'(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")','company / name',1,'whereclause'); 12 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (3,'invoices.id','id',0,'field'); 13 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (4,'products.partnumber','part number',0,'field'); 14 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (4,'products.partname','part name',1,'field'); 15 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (4,'products.unitprice','unit price',2,'field'); 16 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (4,'products.id','id',3,'field'); 17 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'products.partnumber','part number',0,'field'); 18 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'lineitems.invoiceid','invoice id',2,'field'); 19 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'lineitems.id','id',8,'field'); 20 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'invoices.orderdate','order date',3,'field'); 21 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'invoices.invoicedate','invoice date',4,'field'); 22 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (5,'products.partname','part name',1,'field'); 23 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (6,'tax.name','name',0,'field'); 24 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (6,'tax.id','id',1,'field'); 25 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (7,'productcategories.name','name',0,'field'); 26 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (7,'productcategories.id','id',1,'field'); 27 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,'products.partnumber','part number',0,'field'); 28 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,'products.partname','part name',1,'field'); 29 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,'childproducts.partnumber','dependent part number',2,'field'); 30 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,'childproducts.partname','dependent name',3,'field'); 31 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (8,'prerequisites.id','id',4,'field'); 9 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('3', 'invoices.orderdate', 'order date', '2', 'field'); 10 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('3', 'invoices.invoicedate', 'invoice date', '3', 'field'); 11 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('3', '(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")', 'company / name', '1', 'whereclause'); 12 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('3', 'invoices.id', 'id', '0', 'field'); 13 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('4', 'products.id', 'id', '3', 'field'); 14 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('4', 'products.unitprice', 'unit price', '2', 'field'); 15 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('4', 'products.partname', 'part name', '1', 'field'); 16 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('4', 'products.partnumber', 'part number', '0', 'field'); 17 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'products.partname', 'part name', '1', 'field'); 18 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'invoices.invoicedate', 'invoice date', '4', 'field'); 19 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'invoices.orderdate', 'order date', '3', 'field'); 20 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'lineitems.id', 'id', '8', 'field'); 21 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'lineitems.invoiceid', 'invoice id', '2', 'field'); 22 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('5', 'products.partnumber', 'part number', '0', 'field'); 23 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('6', 'tax.name', 'name', '0', 'field'); 24 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('6', 'tax.id', 'id', '1', 'field'); 25 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('7', 'productcategories.id', 'id', '1', 'field'); 26 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('7', 'productcategories.name', 'name', '0', 'field'); 27 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('8', 'products.partnumber', 'part number', '0', 'field'); 28 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('8', 'products.partname', 'part name', '1', 'field'); 29 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('8', 'childproducts.partnumber', 'dependent part number', '2', 'field'); 30 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('8', 'childproducts.partname', 'dependent name', '3', 'field'); 31 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('8', 'prerequisites.id', 'id', '4', 'field'); 32 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', 'clients.id', 'id', '6', 'field'); 33 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', 'clients.email', 'e-mail', '5', 'field'); 34 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', '(clients.homephone like \"{{value}}%\" or clients.workphone like \"{{value}}%\" or clients.mobilephone like \"{{value}}%\" or clients.otherphone like \"{{value}}%\" or clients.fax like \"{{value}}%\")', 'phone', '1', 'whereclause'); 32 35 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', '(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")', 'name', '0', 'whereclause'); 33 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', '(clients.homephone like \"{{value}}%\" or clients.workphone like \"{{value}}%\" or clients.mobilephone like \"{{value}}%\" or clients.otherphone like \"{{value}}%\" or clients.fax like \"{{value}}%\")', 'phone', '1', 'whereclause'); 34 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', 'clients.email', 'e-mail', '5', 'field'); 35 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('18', 'clients.id', 'id', '6', 'field'); 36 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (22,'clientemailprojects.name','name',0,'field'); 37 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (22,'users.firstname like \"{{value}}%\" or users.lastname like \"{{value}}%\"','user',1,'whereclause'); 38 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (25,'discounts.name','name',0,'field'); 39 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (300,'shippingmethods.name','name',0,'field'); 40 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (301,'paymentmethods.name','name',0,'field'); 41 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (302,'invoicestatuses.name','name',0,'field'); 42 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (303,'aritems.id','id',4,'field'); 43 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (303,'aritems.relatedid','invoice id',2,'field'); 44 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (303,'aritems.amount','amount',3,'field'); 45 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (303,'(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")','client',1,'whereclause'); 46 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (304,'receipts.id','id',2,'field'); 47 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (304,'(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")','client',1,'whereclause'); 48 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (304,'paymentmethods.name','payment',3,'field'); 49 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES (304,'receipts.amount','amount',4,'field'); 36 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('22', 'clientemailprojects.name', 'name', '0', 'field'); 37 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('22', 'users.firstname like \"{{value}}%\" or users.lastname like \"{{value}}%\"', 'user', '1', 'whereclause'); 38 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('25', 'discounts.name', 'name', '0', 'field'); 39 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('300', 'shippingmethods.name', 'name', '0', 'field'); 40 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('301', 'paymentmethods.name', 'name', '0', 'field'); 41 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('302', 'invoicestatuses.name', 'name', '0', 'field'); 42 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('303', 'aritems.id', 'id', '4', 'field'); 43 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('303', 'aritems.relatedid', 'invoice id', '2', 'field'); 44 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('303', 'aritems.amount', 'amount', '3', 'field'); 45 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('303', '(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")', 'client', '1', 'whereclause'); 46 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('304', 'receipts.amount', 'amount', '4', 'field'); 47 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('304', 'paymentmethods.name', 'payment', '3', 'field'); 48 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('304', '(clients.lastname like \"{{value}}%\" or clients.firstname like \"{{value}}%\" or clients.company like \"{{value}}%\")', 'client', '1', 'whereclause'); 49 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('304', 'receipts.id', 'id', '2', 'field'); 50 50 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('305', 'addresstorecord.id', 'id', '1', 'field'); 51 51 INSERT INTO `tablesearchablefields` (`tabledefid`, `field`, `name`, `displayorder`, `type`) VALUES ('306', 'addresses.id', 'id', '1', 'field'); -
trunk/phpbms/modules/bms/install/update.php
r419 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 42 43 include("../../../install/install_include.php"); 44 include("../../../include/session.php"); 45 46 function doUpdate($db) { 47 $thereturn="Updating Business Management System Module\n"; 48 49 if(!verifyAdminLogin($db,$_GET["u"],$_GET["p"])){ 50 $thereturn="Update Requires Administrative Access.\n\n"; 51 return $thereturn; 52 } 53 54 $newVersion = $_GET["v"]; 55 56 $querystatement="SELECT version FROM modules WHERE name=\"bms\""; 57 $queryresult=$db->query($querystatement); 58 if(!$queryresult) { 59 $thereturn="Error Accessing module table in database.\n\n"; 60 return $thereturn; 61 } 62 63 $ver=$db->fetchArray($queryresult); 64 65 while($ver["version"] != $newVersion){ 66 switch($ver["version"]){ 67 // ================================================================================================ 68 case "0.5": 69 $thereturn.="Updating BMS Module to 0.51\n"; 70 71 //Updating Module Table 72 $querystatement="UPDATE modules SET version=\"0.51\" WHERE name=\"bms\";"; 73 $queryresult=$db->query($querystatement); 74 $thereturn.=" - modified bms record in modules table\n"; 75 76 $thereturn.="Update to 0.51 Finished\n\n"; 77 78 $ver["version"]="0.51"; 79 break; 80 // ================================================================================================ 81 case "0.51": 82 $thereturn.="Updating BMS Module to 0.6\n"; 83 84 $thereturn.=processSQLfile($db,"updatev0.6.sql"); 85 86 $thereturn.=importData($db,"choices"); 87 $thereturn.=importData($db,"menu"); 88 $thereturn.=importData($db,"reports"); 89 $thereturn.=importData($db,"tablecolumns"); 90 $thereturn.=importData($db,"tabledefs"); 91 $thereturn.=importData($db,"tablefindoptions"); 92 $thereturn.=importData($db,"tableoptions"); 93 $thereturn.=importData($db,"tablesearchablefields"); 94 95 $querystatement="SELECT clients.id,DATE_FORMAT(clients.creationdate,\"%Y-%m-%d\") as creationdate,max(invoices.orderdate) as orderdate 96 FROM `clients` LEFT JOIN invoices on clients.id=invoices.clientid 97 WHERE clients.type=\"client\" GROUP BY clients.id;"; 98 $queryresult=$db->query($querystatement); 99 100 while($therecord=$db->fetchArray($queryresult,$dblink)){ 101 $querystatement="UPDATE clients set becameclient=\""; 102 if($therecord["orderdate"]) 103 $querystatement.=$therecord["orderdate"]; 104 else 105 $querystatement.=$therecord["creationdate"]; 106 $querystatement.="\" WHERE id=".$therecord["id"]; 107 $updateresult=$db->query($querystatement); 108 } 109 $thereturn.=" - set intitial client becamclient field\n"; 110 111 112 //Updating Module Table 113 $querystatement="UPDATE modules SET version=\"0.6\" WHERE name=\"bms\";"; 114 $updateresult=$db->query($querystatement); 115 $thereturn.=" - modified bms record in modules table\n"; 116 117 $thereturn.="Update to 0.6 Finished\n\n"; 118 119 $ver["version"]="0.6"; 120 break; 121 // ================================================================================================ 122 case "0.6"; 123 $thereturn.="Updating BMS Module to 0.601\n"; 124 125 $querystatement="SELECT invoices.id,tax.percentage FROM invoices INNER JOIN tax on invoices.taxareaid=tax.id"; 126 $queryresult=$db->query($querystatement); 127 128 129 while($therecord=$db->fetchArray($queryresult)){ 130 $querystatement="UPDATE invoices SET taxpercentage=".$therecord["percentage"]."WHERE id=".$therecord["id"]; 131 $updateresult=$db->query($querystatement); 132 } 133 $thereturn.=" - set taxpercentage on invoices\n"; 134 135 //Updating Module Table 136 $querystatement="UPDATE modules SET version=\"0.601\" WHERE name=\"bms\";"; 137 $updateresult=$db->query($querystatement); 138 $thereturn.=" - modified bms record in modules table\n"; 139 140 141 $thereturn.="Update to 0.601 Finished\n\n"; 142 143 $ver["version"]="0.601"; 144 145 break; 146 // ================================================================================================ 147 case "0.601"; 148 $thereturn.="Updating BMS Module to 0.602\n"; 149 150 //Updating Module Table 151 $querystatement="UPDATE modules SET version=\"0.602\" WHERE name=\"bms\";"; 152 $updateresult=$db->query($querystatement); 153 $thereturn.=" - modified bms record in modules table\n"; 154 155 $thereturn.="Update to 0.602 Finished\n\n"; 156 157 $ver["version"]="0.602"; 158 // ================================================================================================ 159 case "0.602"; 160 $thereturn.="Updating BMS Module to 0.61\n"; 161 162 $thereturn.=processSQLfile($db,"updatev0.61.sql"); 163 164 //Updating Module Table 165 $querystatement="UPDATE modules SET version=\"0.61\" WHERE name=\"bms\";"; 166 $updateresult=$db->query($querystatement); 167 $thereturn.=" - modified bms record in modules table\n"; 168 169 $thereturn.="Update to 0.61 Finished\n\n"; 170 171 $ver["version"]="0.61"; 172 break; 173 // ================================================================================================ 174 case "0.61"; 175 $thereturn.="Updating BMS Module to 0.62\n"; 176 177 //Updating Module Table 178 $querystatement="UPDATE modules SET version=\"0.62\" WHERE name=\"bms\";"; 179 $updateresult=$db->query($querystatement); 180 $thereturn.=" - modified bms record in modules table\n"; 181 182 $thereturn.="Update to 0.62 Finished\n\n"; 183 184 $ver["version"]="0.62"; 185 break; 186 // ================================================================================================ 187 case "0.62"; 188 $thereturn.="Updating BMS Module to 0.7\n"; 189 190 $thereturn.=processSQLfile($db,"updatev0.70.sql"); 191 192 //update to new status system 193 $result=updateInvoiceStatus($db); 194 if($result===true) 195 $thereturn.=" - Updated to new invoice status system\n"; 196 else 197 $thereturn.=" - Failed to updated to new invoice status system\n".$result."\n\n"; 198 199 //Update shipping from invoices 200 $result=moveShipping($db); 201 if($result===true) 202 $thereturn.=" - Created default Shipping Methods\n"; 203 else 204 $thereturn.=" - Failed to create default shipping methods\n".$result."\n\n"; 205 206 //update payment From invoices 207 $result=movePayments($db); 208 if($result===true) 209 $thereturn.=" - Created default payment methods\n"; 210 else 211 $thereturn.=" - Failed to create default payment Methods\n".$result."\n\n"; 212 213 //Updating Module Table 214 $querystatement="UPDATE modules SET version=\"0.7\" WHERE name=\"bms\";"; 215 $updateresult=$db->query($querystatement); 216 $thereturn.=" - Updated bms module record with new version\n"; 217 218 $thereturn.="Update to 0.7 Finished\n\n"; 219 220 $ver["version"]="0.7"; 221 break; 222 223 // ================================================================================================ 224 case "0.7"; 225 226 $thereturn.= processSQLfile($db,"updatev0.80.sql"); 227 228 //Updating Module Table 229 $querystatement="UPDATE modules SET version=\"0.8\" WHERE name=\"bms\";"; 230 $updateresult=$db->query($querystatement); 231 232 $thereturn.="Update of Business Management System Module to 0.8 Finished\n\n"; 233 $ver["version"]="0.8"; 234 break; 235 236 // ================================================================================================ 237 case "0.8"; 238 239 $thereturn.= processSQLfile($db,"updatev0.90.sql"); 240 241 //Updating Module Table 242 $querystatement = " 243 UPDATE 244 modules 245 SET 246 version='0.9' 247 WHERE 248 name='bms';"; 249 250 $updateresult = $db->query($querystatement); 251 252 $thereturn .= "Update of Business Management System Module to 0.9 Finished\n\n"; 253 254 $ver["version"] = "0.9"; 255 256 break; 257 258 // ================================================================================================ 259 case "0.9"; 260 261 $thereturn.= processSQLfile($db,"updatev0.92.sql"); 262 263 //Updating Module Table 264 $updatestatement = " 265 UPDATE 266 modules 267 SET 268 version='0.92' 269 WHERE 270 name='bms';"; 271 272 $db->query($updatestatement); 273 274 $thereturn .= "Update of Business Management System Module to 0.92 Finished\n\n"; 275 276 $ver["version"] = "0.92"; 277 278 break; 279 280 // ================================================================================================ 281 case "0.92"; 282 283 $thereturn.= processSQLfile($db,"updatev0.94.sql"); 284 285 //Updating Module Table 286 $updatestatement = " 287 UPDATE 288 modules 289 SET 290 version='0.94' 291 WHERE 292 name='bms';"; 293 294 $db->query($updatestatement); 295 296 $thereturn .= "Update of Business Management System Module to 0.94 Finished\n\n"; 297 298 $ver["version"] = "0.94"; 299 300 break; 301 302 // ================================================================================================ 303 case "0.94"; 304 305 $thereturn.= processSQLfile($db,"updatev0.96.sql"); 306 307 if(v096updateInvoiceAddresses($db)) 308 $thereturn .= "Updating invoice addresses.\n\n"; 309 310 if(v096transferClientAddresses($db)) 311 $thereturn .= "Transfer client addresses.\n\n"; 312 313 //Updating Module Table 314 $updatestatement = " 315 UPDATE 316 modules 317 SET 318 version='0.96' 319 WHERE 320 name='bms';"; 321 322 $db->query($updatestatement); 323 324 $thereturn .= "Update of Business Management System Module to 0.96 Finished\n\n"; 325 326 $ver["version"] = "0.96"; 327 328 break; 329 330 // ================================================================================================ 331 case "0.96"; 332 333 $thereturn.= processSQLfile($db,"updatev0.98.sql"); 334 335 //Updating Module Table 336 $updatestatement = " 337 UPDATE 338 modules 339 SET 340 version='0.98' 341 WHERE 342 name='bms';"; 343 344 $db->query($updatestatement); 345 346 $thereturn .= "Update of Business Management System Module to 0.98 Finished\n\n"; 347 348 $ver["version"] = "0.98"; 349 350 break; 351 352 }//end switch 353 }//end while 354 return $thereturn; 355 356 }//end update 357 358 359 function moveShipping($db){ 360 $querystatement="SELECT DISTINCT shippingmethod FROM invoices WHERE shippingmethod!=\"\" ORDER BY shippingmethod"; 361 $queryresult=$db->query($querystatement); 362 363 while($therecord=$db->fetchArray($queryresult)){ 364 $querystatement="INSERT INTO `shippingmethods` (name,createdby,creationdate) VALUES (\"".$therecord["shippingmethod"]."\",1,NOW())"; 365 $updatequery=$db->query($querystatement); 366 } 367 368 $querystatement="SELECT id,name FROM shippingmethods"; 369 $queryresult=$db->query($querystatement); 370 371 while($therecord=$db->fetchArray($queryresult)){ 372 $querystatement="UPDATE invoices SET shippingmethodid=".$therecord["id"]." 373 WHERE shippingmethod=\"".$therecord["name"]."\""; 374 $updatequery=$db->query($querystatement); 375 } 376 $querystatement="ALTER TABLE invoices DROP shippingmethod"; 377 $updatequery=$db->query($querystatement); 378 379 return true; 380 } 381 382 383 function movePayments($db){ 384 $querystatement="SELECT DISTINCT paymentmethod FROM invoices WHERE paymentmethod!=\"\" ORDER BY paymentmethod"; 385 $queryresult=$db->query($querystatement); 386 387 while($therecord=$db->fetchArray($queryresult)){ 388 switch($therecord["paymentmethod"]){ 389 case "VISA": 390 case "VISA - Debit": 391 case "American Express": 392 case "Master Card": 393 case "MasterCard": 394 case "Discover Card": 395 $type="\"charge\""; 396 break; 397 398 case "Personal Check": 399 case "Check": 400 case "Cashiers Check": 401 case "check": 402 $type="\"draft\""; 403 break; 404 405 default: 406 $type="NULL"; 407 break; 408 } 409 410 $querystatement="INSERT INTO `paymentmethods` (name,`type`,createdby,creationdate) VALUES (\"".$therecord["paymentmethod"]."\",".$type.",1,NOW())"; 411 $updatequery=$db->query($querystatement); 412 } 413 414 $querystatement="SELECT id,name FROM paymentmethods"; 415 $queryresult=$db->query($querystatement); 416 while($therecord=$db->fetchArray($queryresult)){ 417 $querystatement="UPDATE invoices SET paymentmethodid=".$therecord["id"]." 418 WHERE paymentmethod=\"".$therecord["name"]."\""; 419 $updatequery=$db->query($querystatement); 420 } 421 $querystatement="ALTER TABLE invoices DROP paymentmethod"; 422 $updatequery=$db->query($querystatement); 423 424 return true; 425 } 426 427 function updateInvoiceStatus($db){ 428 $querystatement="SELECT id,status,statusdate,orderdate,invoicedate,type FROM invoices"; 429 $queryresult=$db->query($querystatement); 430 431 while($therecord=$db->fetchArray($queryresult)){ 432 433 $newstatus=1; 434 switch($therecord["status"]){ 435 case "Open": 436 $newstatus=1; 437 $statusdate=$therecord["orderdate"]; 438 break; 439 case "Committed": 440 $newstatus=2; 441 $statusdate=$therecord["orderdate"]; 442 break; 443 case "Packed": 444 $newstatus=3; 445 $statusdate=$therecord["orderdate"]; 446 break; 447 case "Shipped": 448 $newstatus=4; 449 if($therecord["statusdate"]) 450 $statusdate=$therecord["statusdate"]; 451 elseif($therecord["invoicedate"]) 452 $statusdate=$therecord["invoicedate"]; 453 else 454 $statusdate=$therecord["orderdate"]; 455 break; 456 }//end switch 457 458 if($therecord["type"]=="Invoice") 459 $statusdate=$therecord["invoicedate"]; 460 461 $querystatement="UPDATE invoices SET statusid=".$newstatus.", statusdate=\"".$statusdate."\" WHERE id=".$therecord["id"]; 462 $updatequery=$db->query($querystatement); 463 464 //now create the history 465 $querystatement="INSERT INTO invoicestatushistory (invoiceid,invoicestatusid,statusdate)VALUES(".$therecord["id"].",".$newstatus.",\"".$statusdate."\")"; 466 $insertquery=$db->query($querystatement); 467 468 } 469 $querystatement="ALTER TABLE `invoices` DROP COLUMN `status`"; 470 $dropcolumnquery=$db->query($querystatement); 471 472 return true; 473 }//end funtion 474 475 476 function v096updateInvoiceAddresses($db){ 477 39 40 // Need custom class for upgrade because 41 // some BMS upgrades require more than just 42 // version SQL file processing 43 class updateBMS extends updateModuleAjax{ 44 45 function updateBMS($db, $phpbmsSession, $moduleName, $pathToModule){ 46 47 $this->updateModuleAjax($db, $phpbmsSession, $moduleName, $pathToModule); 48 49 }//end function init 50 51 //override function for custom upgrading 52 function update(){ 53 54 if(!$this->db->connect()) 55 return $this->returnJSON(false, "Could not connect to database ".$this->db->getError()); 56 57 if(!$this->db->selectSchema()) 58 return $this->returnJSON(false, "Could not open database schema '".MYSQL_DATABASE."'"); 59 60 $updater = new installer($this->db); 61 62 include("../modules/bms/version.php"); 63 $newVersion = $modules["bms"]["version"]; 64 $currentVersion = $this->currentVersion; 65 66 //next we loop through each upgrade process 67 while($currentVersion != $newVersion){ 68 69 switch($currentVersion){ 70 71 // ================================================================================================ 72 case 0.8: 73 74 $version = 0.9; 75 //Processing Data Structure Changes 76 $thereturn = $updater->processSQLfile("../modules/bms/install/updatev".$version.".sql"); 77 if($thereturn !== true) 78 return $this->returnJSON(false, $thereturn); 79 80 //Updating Module Table 81 $thereturn = $this->updateModuleVersion("bms", $version); 82 if($thereturn !== true) 83 return $this->returnJSON(false, $thereturn); 84 85 $currentVersion = $version; 86 87 break; 88 89 // ================================================================================================ 90 case 0.9: 91 92 $version = 0.92; 93 //Processing Data Structure Changes 94 $thereturn = $updater->processSQLfile("../modules/bms/install/updatev".$version.".sql"); 95 if($thereturn !== true) 96 return $this->returnJSON(false, $thereturn); 97 98 //Updating Module Table 99 $thereturn = $this->updateModuleVersion("bms", $version); 100 if($thereturn !== true) 101 return $this->returnJSON(false, $thereturn); 102 103 $currentVersion = $version; 104 105 break; 106 107 // ================================================================================================ 108 case 0.92: 109 110 $version = 0.94; 111 //Processing Data Structure Changes 112 $thereturn = $updater->processSQLfile("../modules/bms/install/updatev".$version.".sql"); 113 if($thereturn !== true) 114 return $this->returnJSON(false, $thereturn); 115 116 //Updating Module Table 117 $thereturn = $this->updateModuleVersion("bms", $version); 118 if($thereturn !== true) 119 return $this->returnJSON(false, $thereturn); 120 121 $currentVersion = $version; 122 123 break; 124 125 // ================================================================================================ 126 case 0.94: 127 128 $version = 0.96; 129 //Processing Data Structure Changes 130 $thereturn = $updater->processSQLfile("../modules/bms/install/updatev".$version.".sql"); 131 if($thereturn !== true) 132 return $this->returnJSON(false, $thereturn); 133 134 if(!$this->v096updateInvoiceAddresses()) 135 return $this->returnJSON(false, "v0.96 Invoice Addresses Movement Failed"); 136 137 if(!$this->v096transferClientAddresses()) 138 return $this->returnJSON(false, "v0.96 Client Addresses Movement Failed"); 139 140 //Updating Module Table 141 $thereturn = $this->updateModuleVersion("bms", $version); 142 if($thereturn !== true) 143 return $this->returnJSON(false, $thereturn); 144 145 $currentVersion = $version; 146 147 break; 148 149 // ================================================================================================ 150 case 0.96: 151 152 $version = 0.98; 153 //Processing Data Structure Changes 154 $thereturn = $updater->processSQLfile("../modules/bms/install/updatev".$version.".sql"); 155 if($thereturn !== true) 156 return $this->returnJSON(false, $thereturn); 157 158 //Updating Module Table 159 $thereturn = $this->updateModuleVersion("bms", $version); 160 if($thereturn !== true) 161 return $this->returnJSON(false, $thereturn); 162 163 $currentVersion = $version; 164 165 break; 166 167 }//endswitch currentVersion 168 169 }//endwhile currentversion/newversion 170 171 172 return $this->returnJSON(true, "Module '".$this->moduleName."' Updated"); 173 174 }//end function update 175 176 177 //==== v0.96 Specific Function ================================================= 178 179 function v096updateInvoiceAddresses(){ 180 478 181 $querystatement = " 479 182 SELECT … … 487 190 FROM 488 191 invoices INNER JOIN clients ON invoices.clientid = clients.id"; 489 490 $queryresult = $ db->query($querystatement);491 492 while($therecord = $ db->fetchArray($queryresult)){493 192 193 $queryresult = $this->db->query($querystatement); 194 195 while($therecord = $this->db->fetchArray($queryresult)){ 196 494 197 $updatestatement = " 495 198 UPDATE … … 511 214 id = ".$therecord["id"]; 512 215 513 $ db->query($updatestatement);514 216 $this->db->query($updatestatement); 217 515 218 }//endwhile - record 516 219 517 220 return true; 518 221 519 222 }//end function - v096updateInvoiceAddresses 520 223 521 224 522 function v096transferClientAddresses( $db){523 225 function v096transferClientAddresses(){ 226 524 227 //retrieve all client records with ship to addresses 525 228 $querystatement = " … … 540 243 FROM 541 244 clients"; 542 543 $queryresult = $ db->query($querystatement);544 545 while($therecord = $ db->fetchArray($queryresult)){546 245 246 $queryresult = $this->db->query($querystatement); 247 248 while($therecord = $this->db->fetchArray($queryresult)){ 249 547 250 // for each client with a ship to, we need to create 548 251 // an address record (and addresstorecord record) 549 252 550 253 // Create the address record 551 254 $address["title"] = "Primary"; … … 556 259 $address["postalcode"] = $therecord["postalcode"]; 557 260 $address["country"] = $therecord["country"]; 558 559 $newid = insertAddress($db, $address);560 261 262 $newid = $this->v096insertAddress($address); 263 561 264 $a2r["clientid"] = $therecord["id"]; 562 265 $a2r["addressid"] = $newid; 563 266 $a2r["primary"] = 1; 564 267 565 268 if($therecord["shiptoaddress1"]){ 566 269 567 270 $a2r["defaultshipto"] = 0; 568 insertA2R($db,$a2r);569 271 $this->v096insertA2R($a2r); 272 570 273 $address["title"] = "Shipping"; 571 274 $address["address1"] = $therecord["shiptoaddress1"]; … … 575 278 $address["postalcode"] = $therecord["shiptopostalcode"]; 576 279 $address["country"] = $therecord["shiptocountry"]; 577 578 $newid = insertAddress($db, $address); 579 280 281 $newid = insertAddress($db, $address); 282 580 283 $a2r["addressid"] = $newid; 581 284 $a2r["primary"] = 0; 582 285 $a2r["defaultshipto"] = 1; 583 286 584 287 } else { 585 288 586 289 $a2r["defaultshipto"] = 1; 587 290 588 291 }//endif - shiptoaddress1 589 292 590 insertA2R($db, $a2r);591 293 $this->v096insertA2R($db, $a2r); 294 592 295 }//endwhile 593 296 594 297 //Lastly, we need to remove the shipto fields 595 298 $alterstatement = " 596 ALTER TABLE `clients` 299 ALTER TABLE `clients` 597 300 DROP COLUMN `address1`, 598 301 DROP COLUMN `address2`, … … 606 309 DROP COLUMN `shiptostate`, 607 310 DROP COLUMN `shiptopostalcode`, 608 DROP COLUMN `shiptocountry`"; 609 610 $ db->query($alterstatement);611 311 DROP COLUMN `shiptocountry`"; 312 313 $this->db->query($alterstatement); 314 612 315 }//end function 613 614 615 function insertA2R($db,$variables){616 316 317 318 function v096insertA2R($variables){ 319 617 320 // Create the relation record 618 321 $insertstatement = " … … 640 343 NOW() 641 344 )"; 642 643 $ db->query($insertstatement);644 345 346 $this->db->query($insertstatement); 347 645 348 }//end function - insertA2R 646 647 648 function insertAddress($db,$variables){649 349 350 351 function v096insertAddress($variables){ 352 650 353 $insertaddress = " 651 354 INSERT INTO 652 addresses 355 addresses 653 356 ( 654 357 title, … … 677 380 ) 678 381 "; 679 680 $ db->query($insertaddress);681 382 383 $this->db->query($insertaddress); 384 682 385 //make sure to get the new address id 683 return $ db->insertId();684 386 return $this->db->insertId(); 387 685 388 }//end function - insertAddress 686 687 688 689 690 //========================================================= 691 // Processor 692 //========================================================= 693 $phpbmsSession = new phpbmsSession; 694 $success = $phpbmsSession->loadDBSettings(false); 695 696 include_once("include/db.php"); 697 $db = new db(false); 698 $db->stopOnError = false; 699 $db->showError = false; 700 $db->logError = false; 701 702 if($success !== false){ 703 704 if(!$db->connect()) 705 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 706 else { 707 if(!$db->selectSchema()) 708 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 709 else { 710 711 $phpbmsSession->db = $db; 712 $phpbmsSession->loadSettings(); 713 714 $thereturn=doUpdate($db); 715 716 } 717 } 718 } else 719 $thereturn = "Could not access settings.php"; 720 721 722 723 header('Content-Type: text/xml'); 724 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 725 <response><?php echo $thereturn?></response> 389 390 }//end class updateBMS 391 392 // Processor 393 //========================================================= 394 $theModule = new updateBMS($this->db, $this->phpbmsSession, "bms", "../modules/bms/install/"); -
trunk/phpbms/modules/bms/install/updatev0.98.sql
r438 r485 3 3 ALTER TABLE `aritems` ENGINE=INNODB; 4 4 ALTER TABLE `clientemailprojects` ENGINE=INNODB; 5 ALTER TABLE `clients` ADD COLUMN `taxid` VARCHAR(64) default NULL AFTER `webaddress`;6 5 ALTER TABLE `clients` ENGINE=INNODB; 7 INSERT INTO `settings` (`name`, `value`) VALUES ('company_taxid', '');8 UPDATE `tabledefs` SET `deletebutton` = 'inactivate' WHERE `displayname` = 'Tax Areas';9 6 ALTER TABLE `discounts` ENGINE=INNODB; 10 7 ALTER TABLE `attachments` ENGINE=INNODB; … … 20 17 ALTER TABLE `receipts` ENGINE=INNODB; 21 18 ALTER TABLE `shippingmethods` ENGINE=INNODB; 19 ALTER TABLE `clients` ADD COLUMN `taxid` VARCHAR(64) default NULL AFTER `webaddress`; 20 ALTER TABLE `receipts` MODIFY COLUMN `paymentmethodid` INTEGER NOT NULL DEFAULT 0; 22 21 INSERT INTO `settings` (`name`, `value`) VALUES ('company_taxid', ''); 23 22 UPDATE `tabledefs` SET `deletebutton` = 'inactivate' WHERE `id` IN (6, 7); 24 23 UPDATE `tabledefs` SET `importfile` = 'modules/bms/clients_import.php' WHERE `id` = 2; 25 UPDATE `tabledefs` SET `importfile` = 'modules/bms/products_import.php' WHERE `id` = 4;26 24 UPDATE `tabledefs` SET `defaultcriteriafindoptions` = 'Active Records', `defaultcriteriaselection` = 'name' WHERE `id` = 25; 25 UPDATE `tabledefs` SET `deletebutton` = 'inactivate' WHERE `displayname` = 'Tax Areas'; 27 26 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('2', 'import', '1', '0', '0', '-100', '0'); 28 27 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('3', 'import', '0', '0', '0', '-100', '0'); … … 43 42 INSERT INTO `tableoptions` (`tabledefid`, `name`, `option`, `needselect`, `othercommand`, `roleid`, `displayorder`) VALUES ('306', 'import', '0', '0', '0', '-100', '0'); 44 43 UPDATE `tableoptions` SET `needselect` = 0 WHERE `tabledefid` = 2 AND `name` = 'massEmail'; 44 UPDATE `tableoptions` SET `needselect` = 0 WHERE `tabledefid` = 303 AND `name` = 'run_aging'; 45 45 INSERT INTO `tablefindoptions` (`tabledefid`, `name`, `search`, `displayorder`, `roleid`) VALUES ('25', 'Active Records', 'discounts.inactive=0', '0', '0'); 46 46 UPDATE `tablefindoptions` SET `displayorder` = 0 WHERE `tabledefid` = 25 AND `name` = 'all records'; 47 47 UPDATE `tablefindoptions` SET `search`= 'clients.firstname=dclients.firstname AND clients.lastname=dclients.lastname AND addresses.postalcode = daddresses.postalcode AND clients.lastname != \'\' AND clients.firstname != \'\' AND addresses.postalcode != \'\' AND clients.id<>dclients.ID' WHERE `name` = 'match names and postal code' AND `tabledefid` = '18'; 48 48 UPDATE `tablefindoptions` SET `search`= 'addresses.address1=daddresses.address1 AND clients.id<>dclients.id' WHERE `name` = 'match addresses' AND `tabledefid` = '18'; 49 ALTER TABLE `receipts` MODIFY COLUMN `paymentmethodid` INTEGER NOT NULL DEFAULT 0;50 UPDATE `tablecolumns` SET `column`='IF(receipts.paymentmethodid = '-1',concat( concat("Other... (", receipts.paymentother), ")"), paymentmethods.name)' WHERE `tabledefid` = '304' AND `name` = 'payment';49 UPDATE `tablecolumns` SET `column`='IF(receipts.paymentmethodid = -1,concat( concat("Other... (", receipts.paymentother), ")"), paymentmethods.name)' WHERE `tabledefid` = '304' AND `name` = 'payment'; 50 INSERT INTO `reports` (`name`, `type`, `tabledefid`, `displayorder`, `roleid`, `reportfile`, `description`, `createdby`, `creationdate`, `modifiedby`, `modifieddate`) VALUES ('Incoming Cash Flow', 'report', '3', '55', '50', 'modules/bms/report/incoming_cashflow.php', 'This report shows total incoming monies for a time period from both posted sales orders AND posted receipts. It can be grouped by week, month, quarter and year.\r\n\r\nThis report runs is unaffected by selected records, search or sort parameters. It requires input of it\'s own start and end dates.', 1, NOW(), 1, NOW()); -
trunk/phpbms/modules/bms/invoices_attachments.php
r285 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 39 39 40 40 include("../../include/session.php"); 41 41 42 42 43 43 require_once("../../include/search_class.php"); 44 44 45 45 46 46 //set the table passing stuff … … 49 49 $refid=(integer) $_GET["id"]; 50 50 $securitywhere=""; 51 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0) 52 $securitywhere=" AND files.roleid IN (".implode(",",$_SESSION["userinfo"]["roles"]).",0)"; 51 if ($_SESSION["userinfo"]["admin"]!=1 && count($_SESSION["userinfo"]["roles"])>0) 52 $securitywhere=" AND files.roleid IN (".implode(",",$_SESSION["userinfo"]["roles"]).",0)"; 53 53 $whereclause="attachments.tabledefid=".$tabledefid." AND attachments.recordid=".$refid.$securitywhere; 54 54 $backurl="../bms/invoices_attachments.php"; … … 60 60 61 61 $refquery="SELECT 62 invoices.id, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name 63 FROM invoices INNER JOIN clients ON invoices.clientid=clients.id 62 invoices.id, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name 63 FROM invoices INNER JOIN clients ON invoices.clientid=clients.id 64 64 WHERE invoices.id=".$refid; 65 65 $refquery=$db->query($refquery); 66 $refrecord=$db->fetchArray($refquery); 67 68 $pageTitle="Attachments: ".$refrecord["id"].", ".$refrecord["name"]; 66 $refrecord=$db->fetchArray($refquery); 67 68 $pageTitle="Attachments: ".$refrecord["id"]; 69 if($refrecord["name"] !== "") 70 $pageTitle .= ", ".$refrecord["name"]; 69 71 70 72 $tabgroup="invoices entry"; 71 73 $selectedtabid=17; 72 74 73 75 include("../base/attachments_records.php"); 74 76 75 77 ?> -
trunk/phpbms/modules/bms/invoices_notes.php
r285 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 39 39 40 40 include("../../include/session.php"); 41 41 42 42 43 43 require_once("../../include/search_class.php"); 44 44 45 45 46 46 //set the table passing stuff … … 53 53 54 54 $refquery="SELECT 55 invoices.id, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name 56 FROM invoices INNER JOIN clients ON invoices.clientid=clients.id 55 invoices.id, if(clients.lastname!=\"\",concat(clients.lastname,\", \",clients.firstname,if(clients.company!=\"\",concat(\" (\",clients.company,\")\"),\"\")),clients.company) as name 56 FROM invoices INNER JOIN clients ON invoices.clientid=clients.id 57 57 WHERE invoices.id=".$refid; 58 58 $refquery=$db->query($refquery); 59 $refrecord=$db->fetchArray($refquery); 60 61 $pageTitle="Notes/Tasks/Events: ".$refrecord["id"].", ".$refrecord["name"]; 59 $refrecord=$db->fetchArray($refquery); 60 61 $pageTitle="Notes/Tasks/Events: ".$refrecord["id"]; 62 if($refrecord["name"] !== "") 63 $pageTitle .= ", ".$refrecord["name"]; 62 64 63 65 $tabgroup="invoices entry"; 64 66 $selectedtabid=18; 65 67 66 68 include("../base/notes_records.php"); 67 69 //=================================================================================== 68 70 //== THAT's IT == 69 71 //=================================================================================== 70 72 71 73 ?> -
trunk/phpbms/modules/bms/javascript/aritem_aging.js
r311 r485 1 1 aging = { 2 2 3 3 submitForm: function(e){ 4 4 5 5 var thebutton = e.src(); 6 6 var theform = getObjectFromID("record"); 7 7 8 8 var command = getObjectFromID("command"); 9 9 10 10 if(thebutton.id == "runButton"){ 11 11 12 12 if(!validateForm(theform)) 13 13 return false; 14 14 15 15 command.value = "run"; 16 16 17 17 } else 18 18 command.value = "cancel"; 19 19 20 20 theform.submit(); 21 21 22 return true; 23 22 24 }//end method 23 25 24 26 }//end class 25 27 … … 29 31 30 32 connect(window,"onload",function() { 31 33 32 34 var runButton = getObjectFromID("runButton"); 33 35 if(runButton) 34 36 connect(runButton, "onclick", aging.submitForm); 35 37 36 38 var cancelButton = getObjectFromID("cancelButton"); 37 39 if(cancelButton) 38 40 connect(cancelButton, "onclick", aging.submitForm); 39 41 40 42 var printStatements = getObjectFromID("printClientStatements"); 41 43 if(printStatements){ 42 44 43 45 var theURL; 44 var printSummary = getObjectFromID("printSummary"); 46 var printSummary = getObjectFromID("printSummary"); 45 47 var agingdate = getObjectFromID("agingdate") 46 48 47 49 var ts = new Date(); 48 50 ts = ts.getTime(); 49 51 50 52 if(printStatements.value == 1){ 51 53 52 54 theURL = APP_PATH+"modules/bms/report/aritems_clientstatement.php?cmd=print&sd="+encodeURIComponent(agingdate.value)+"&ts="+ts+"&ext=.pdf"; 53 55 window.open(theURL, 'phpBMSprint1'); 54 56 55 57 }//endif 56 58 57 59 if(printSummary.value == 1){ 58 60 59 61 theURL = APP_PATH+"modules/bms/report/aritems_summary.php?cmd=print&sd="+encodeURIComponent(agingdate.value)+"&ts="+ts; 60 62 window.open(theURL, 'phpBMSprint2'); 61 63 62 64 }//endif 63 65 64 66 }//end if 65 67 66 68 }) -
trunk/phpbms/modules/bms/javascript/totalreports.js
r373 r485 38 38 39 39 report = { 40 40 41 41 cancel: function(){ 42 42 43 43 window.close(); 44 45 },//endmethod 46 44 45 },//endmethod 46 47 47 validateForm: function (){ 48 48 49 49 if(report.prepareGroupings() && report.prepareColumns()){ 50 50 51 51 var theForm = getObjectFromID("GroupForm"); 52 52 theForm.submit(); 53 53 54 54 }else{ 55 55 56 56 alert("Make sure you have selected unique groups and columns for each line."); 57 57 58 58 } 59 60 },//endmethod 61 59 60 },//endmethod 61 62 62 prepareGroupings: function (){ 63 63 64 64 var groupArray = new Array(); 65 65 66 66 for(var i=0; i<GroupParams.length; i++){ 67 67 68 68 var groupField = getObjectFromID("Group"+GroupParams[i]+"Field"); 69 69 if(groupField.value == "0"){ 70 71 70 71 72 72 }else{ 73 73 74 74 for(var j=0; j<groupArray.length; j++){ 75 75 76 76 if(groupField.value == groupArray[j]+1){ 77 77 78 78 return false; 79 79 80 80 }//endif 81 81 82 82 }//endfor 83 83 84 84 groupArray[groupArray.length] = groupField.value-1; 85 85 86 86 }//endif 87 88 }//endfor 89 87 88 }//endfor 89 90 90 var hiddenGroupings = getObjectFromID("groupings"); 91 91 hiddenGroupings.value = groupArray.join("::"); 92 93 return true; 94 95 },//endmethod 96 92 93 return true; 94 95 },//endmethod 96 97 97 prepareColumns: function (){ 98 98 99 99 var columnArray = new Array(); 100 100 101 101 for(var i=0; i<ColumnParams.length; i++){ 102 102 103 103 var columnField = getObjectFromID("Column"+ColumnParams[i]+"Field"); 104 104 105 105 if(columnField.value == "0"){ 106 106 107 107 return false; 108 108 109 109 }else{ 110 110 111 111 for(var j=0; j<columnArray.length; j++){ 112 112 113 113 if(columnField.value == columnArray[j]+1){ 114 114 115 115 return false; 116 116 117 117 }//endif 118 118 119 119 }//endfor 120 120 121 121 columnArray[columnArray.length] = columnField.value-1; 122 122 123 123 }//endif 124 125 }//endfor 126 124 125 }//endfor 126 127 127 var hiddenColumns = getObjectFromID("columns"); 128 128 hiddenColumns.value = columnArray.join("::"); 129 130 return true; 131 129 130 return true; 131 132 132 },//endmethod 133 133 134 134 groupAddLine: function (){ 135 135 136 136 var tempMinus = getObjectFromID("Group"+GroupParams[0]+"Minus"); 137 137 if(tempMinus.className == "graphicButtons buttonMinusDisabled") … … 143 143 var newid = "Group"+(GroupParams[GroupParams.length-1]+1) 144 144 tempContent = tempContent.replace(REcriteria, newid); 145 145 146 146 var newDiv = document.createElement("div"); 147 147 newDiv.id = newid; 148 148 newDiv.innerHTML = tempContent; 149 149 150 150 var containerDiv = getObjectFromID("theGroups"); 151 151 containerDiv.appendChild(newDiv); 152 152 153 153 GroupParams[GroupParams.length] = GroupParams[GroupParams.length-1]+1; 154 155 154 155 156 156 var newPlusButton = getObjectFromID(newid+"Plus"); 157 157 connect(newPlusButton, "onclick", report.groupAddLine); 158 158 159 159 var newMinusButton = getObjectFromID(newid+"Minus"); 160 160 connect(newMinusButton, "onclick", report.groupRemoveLine); 161 162 163 },//endmethod 164 161 162 163 },//endmethod 164 165 165 groupRemoveLine: function (e){ 166 166 167 167 var thebutton = e.src(); 168 168 169 169 if(thebutton.className=="graphicButtons buttonMinusDisabled") 170 170 return false; 171 171 172 172 var theDiv = thebutton.parentNode; 173 173 174 174 var containerDiv = getObjectFromID("theGroups"); 175 175 containerDiv.removeChild(theDiv); 176 176 var theid = theDiv.id.replace(/Group/g,""); 177 177 theDiv=null; 178 178 179 179 for(var i=0;i<GroupParams.length;i++){ 180 180 181 181 if(GroupParams[i]==theid){ 182 182 183 183 GroupParams.splice(i,1); 184 184 break; 185 185 186 186 }//endif 187 188 }//endfor 189 187 188 }//endfor 189 190 190 if(GroupParams.length==1){ 191 191 192 192 var tempButton = getObjectFromID("Group"+GroupParams[0]+"Minus"); 193 193 tempButton.className="graphicButtons buttonMinusDisabled" 194 194 195 195 }//endif 196 197 },//endmethod 198 196 197 return true; 198 199 },//endmethod 200 199 201 columnAddLine: function (){ 200 202 201 203 var tempMinus = getObjectFromID("Column"+ColumnParams[0]+"Minus"); 202 204 if(tempMinus.className == "graphicButtons buttonMinusDisabled") … … 207 209 var REcriteria = new RegExp("Column"+ColumnParams[0],"g"); 208 210 var newid = "Column"+(ColumnParams[ColumnParams.length-1]+1) 209 211 210 212 tempContent = tempContent.replace(REcriteria, newid); 211 213 212 214 var newDiv = document.createElement("div"); 213 215 newDiv.id = newid; 214 216 newDiv.innerHTML = tempContent; 215 217 216 218 var containerDiv = getObjectFromID("theColumns"); 217 219 containerDiv.appendChild(newDiv); 218 220 219 221 ColumnParams[ColumnParams.length] = ColumnParams[ColumnParams.length-1]+1; 220 221 222 223 222 224 var newPlusButton = getObjectFromID(newid+"Plus"); 223 225 connect(newPlusButton, "onclick", report.columnAddLine); 224 226 225 227 var newMinusButton = getObjectFromID(newid+"Minus"); 226 228 connect(newMinusButton, "onclick", report.columnRemoveLine); 227 228 229 },//endmethod 230 229 230 231 },//endmethod 232 231 233 columnRemoveLine: function (e){ 232 234 233 235 var thebutton = e.src(); 234 236 235 237 if(thebutton.className=="graphicButtons buttonMinusDisabled") 236 238 return false; 237 239 238 240 var theDiv = thebutton.parentNode; 239 241 240 242 var containerDiv = getObjectFromID("theColumns"); 241 243 containerDiv.removeChild(theDiv); 242 244 var theid = theDiv.id.replace(/Column/g,""); 243 245 theDiv=null; 244 246 245 247 for(var i=0;i<ColumnParams.length;i++){ 246 248 247 249 if(ColumnParams[i] == theid){ 248 250 249 251 ColumnParams.splice(i,1); 250 252 break; 251 253 252 254 }//endif 253 254 }//endfor 255 255 256 }//endfor 257 256 258 if(ColumnParams.length == 1){ 257 259 258 260 var tempButton = getObjectFromID("Column"+ColumnParams[0]+"Minus"); 259 261 tempButton.className="graphicButtons buttonMinusDisabled" 260 262 261 263 }//endif 262 264 265 return true; 266 263 267 }//endmethod 264 268 265 269 }//end class 266 270 … … 269 273 270 274 connect(window,"onload",function() { 271 275 272 276 GroupParams = [1]; 273 277 ColumnParams = [1]; 274 278 275 279 var plusGroupButton = getObjectFromID("Group1Plus"); 276 280 connect(plusGroupButton, "onclick", report.groupAddLine); 277 281 278 282 var minusGroupButton = getObjectFromID("Group1Minus"); 279 283 connect(minusGroupButton, "onclick", report.groupRemoveLine); 280 284 281 285 var plusColumnButton = getObjectFromID("Column1Plus"); 282 286 connect(plusColumnButton, "onclick", report.columnAddLine); 283 287 284 288 var minusColumnButton = getObjectFromID("Column1Minus"); 285 289 connect(minusColumnButton, "onclick", report.columnRemoveLine); 286 290 287 291 var printButton = getObjectFromID("print"); 288 292 connect(printButton, "onclick", report.validateForm); 289 293 290 294 var cancelButton = getObjectFromID("cancel"); 291 295 connect(cancelButton, "onclick", report.cancel); -
trunk/phpbms/modules/recurringinvoices/install/install.php
r317 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 42 include("../../../install/install_include.php"); 43 include("../../../include/session.php"); 44 45 $phpbmsSession = new phpbmsSession; 46 $success = $phpbmsSession->loadDBSettings(false); 47 include_once("include/db.php"); 48 $db = new db(false); 49 $db->stopOnError = false; 50 $db->showError = false; 51 $db->logError = false; 52 53 if($success !== false){ 54 55 if(!$db->connect()) 56 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 57 else { 58 if(!$db->selectSchema()) 59 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 60 else { 61 62 63 // ENTER YOUR MODULE NAME HERE 64 $thereturn = "Recurring Invoice Installation\n"; 65 $thereturn .= "______________________________\n"; 66 67 //MAKE SURE THERE IS A createtables.sql FILE 68 //which houses all your SQL create statements 69 // for any tables you will create. 70 $tempreturn = createTables($db,"createtables.sql"); 71 72 if($tempreturn === true){ 73 74 $thereturn.= "Done Creating Tables \n"; 75 76 77 // NEXT, DEFINE AN ARRAY OF TABLE NAMES 78 // for any tables that need initial data populated. (including existing tables) 79 // for each table, make sure there 80 // is a corresponding SQL file 81 // with insert statements for all the records needing to be imported 82 83 /* 84 Need to add entries for tabledefs, tablecolumns, tablefindoptions, tableoptions, and 85 tablesearchablefields 86 */ 87 $tables = array( 88 "menu", 89 "modules", 90 "roles", 91 "scheduler", 92 "tabledefs", 93 "tablecolumns", 94 "tableoptions", 95 "tablefindoptions", 96 "tablesearchablefields", 97 "tabs", 98 "users", 99 ); 100 foreach($tables as $table){ 101 102 $failure = false; 103 $tempreturn = importData($db,$table); 104 $thereturn .= $tempreturn; 105 if(!strpos($tempreturn,"complete.") === false){ 106 $failed = true; 107 } 108 109 }//end foreach 110 111 112 //MAKE SURE TO set the done message for your module. 113 if(!$failure){ 114 $thereturn .= "______________________________________\n"; 115 $thereturn .= "Done Installing Recurring Invoice Data\n"; 116 } 117 } else 118 $thereturn = $tempreturn; 119 } 120 } 121 } else 122 $thereturn = "Could not access settings.php"; 123 124 125 header('Content-Type: text/xml'); 126 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 127 <response><?php echo $thereturn?></response> 39 $theModule = new installModuleAjax($this->db, $this->phpbmsSession, "../modules/recurringinvoices/install/"); 40 $theModule->tables = array( 41 "menu", 42 "modules", 43 "roles", 44 "scheduler", 45 "tabledefs", 46 "tablecolumns", 47 "tableoptions", 48 "tablefindoptions", 49 "tablesearchablefields", 50 "tabs", 51 "users", 52 ); -
trunk/phpbms/modules/recurringinvoices/install/update.php
r427 r485 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 42 43 include("../../../install/install_include.php"); 44 include("../../../include/session.php"); 45 46 function doUpdate($db) { 47 48 $module = array( 49 "title" => "Recurring Invoices", 50 "name" => "recurringinvoices" 51 ); 52 53 $thereturn="Updating ".$module["title"]." Module\n"; 54 55 if(!verifyAdminLogin($db,$_GET["u"],$_GET["p"])){ 56 57 $thereturn="Update Requires Administrative Access.\n\n"; 58 return $thereturn; 59 60 }//end if 61 62 $newVersion = $_GET["v"]; 63 64 $querystatement="SELECT version FROM modules WHERE name = '".$module["name"]."'"; 65 $queryresult=$db->query($querystatement); 66 67 if($db->numRows($queryresult)) { 68 69 $ver=$db->fetchArray($queryresult); 70 while($ver["version"] != $newVersion){ 71 72 switch($ver["version"]){ 73 74 // ================================================================================================ 75 case "1.0": 76 $nextVersion = "1.01"; 77 78 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 79 80 $thereturn.= processSQLfile($db,"updatev1.01.sql"); 81 82 //Updating Module Table 83 $querystatement=" 84 UPDATE 85 modules 86 SET 87 version='".$nextVersion."' 88 WHERE 89 name = '".$module["name"]."'"; 90 91 $queryresult = $db->query($querystatement); 92 93 $thereturn.=" - Updated module record with new version \n"; 94 95 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 96 97 $ver["version"] = $nextVersion; 98 99 break; 100 101 // ================================================================================================ 102 case "1.01": 103 $nextVersion = "1.02"; 104 105 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 106 107 //$thereturn.= processSQLfile($db,"updatev1.01.sql"); 108 109 //Updating Module Table 110 $querystatement=" 111 UPDATE 112 modules 113 SET 114 version='".$nextVersion."' 115 WHERE 116 name = '".$module["name"]."'"; 117 118 $queryresult = $db->query($querystatement); 119 120 $thereturn.=" - Updated module record with new version \n"; 121 122 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 123 124 $ver["version"] = $nextVersion; 125 126 break; 127 // ================================================================================================ 128 case "1.02": 129 $nextVersion = "1.03"; 130 131 $thereturn.="Updating ".$module["title"]." Module to ".$nextVersion."\n"; 132 133 $thereturn.= processSQLfile($db,"updatev1.03.sql"); 134 135 //Updating Module Table 136 $querystatement=" 137 UPDATE 138 modules 139 SET 140 version='".$nextVersion."' 141 WHERE 142 name = '".$module["name"]."'"; 143 144 $queryresult = $db->query($querystatement); 145 146 $thereturn.=" - Updated module record with new version \n"; 147 148 $thereturn.="Update of ".$module["name"]." to ".$nextVersion." Finished\n\n"; 149 150 $ver["version"] = $nextVersion; 151 152 break; 153 154 }//end switch 155 156 }//end while 157 158 } else 159 $thereturn = "Cannot update module ".$module["title"].": Module not installed."; 160 161 return $thereturn; 162 163 }//end update 164 165 //PROCESSING 166 // =================================================================================================== 167 168 $phpbmsSession = new phpbmsSession; 169 $success = $phpbmsSession->loadDBSettings(false); 170 171 include_once("include/db.php"); 172 $db = new db(false); 173 $db->stopOnError = false; 174 $db->showError = false; 175 $db->logError = false; 176 177 if($success !== false){ 178 179 if(!$db->connect()) 180 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 181 else { 182 183 if(!$db->selectSchema()) 184 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 185 else { 186 187 $phpbmsSession->db = $db; 188 $phpbmsSession->loadSettings(); 189 190 $thereturn = doUpdate($db); 191 192 }//endif 193 194 }//end if 195 196 } else 197 $thereturn = "Could not access settings.php"; 198 199 header('Content-Type: text/xml'); 200 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 201 <response><?php echo $thereturn?></response> 39 $theModule = new updateModuleAjax($this->db, $this->phpbmsSession, "recurringinvoices", "../modules/recurringinvoices/install/"); 40 $theModule->updateVersions = array( 41 1.01, 42 1.03 43 ); -
trunk/phpbms/modules/recurringinvoices/scheduler_recurr.php
r384 r485 1 <?php 2 3 if(!class_exists("appError"))4 include_once("../../include/session.php");1 <?php 2 //uncomment for debug purposes 3 //if(!class_exists("appError")) 4 // include_once("../../include/session.php"); 5 5 6 6 class recurr{ … … 10 10 } 11 11 12 12 13 13 function getInvoicesToRepeat($dateToCheck = NULL){ 14 if($dateToCheck == NULL) 14 if($dateToCheck == NULL) 15 15 $dateToCheck = mktime(0,0,0); 16 16 17 17 $invoiceList = array(); 18 18 19 19 $querystatement = "SELECT invoiceid,invoices.invoicedate, firstrepeat, lastrepeat, 20 recurringinvoices.`type`,`eachlist`,`every`,`ontheday`,`ontheweek` 20 recurringinvoices.`type`,`eachlist`,`every`,`ontheday`,`ontheweek` 21 21 FROM recurringinvoices INNER JOIN invoices ON recurringinvoices.invoiceid = invoices.id 22 WHERE invoices.invoicedate <= '".dateToString($dateToCheck,"SQL")."' 22 WHERE invoices.invoicedate <= '".dateToString($dateToCheck,"SQL")."' 23 23 AND (recurringinvoices.until IS NULL OR recurringinvoices.until >= '".dateToString($dateToCheck,"SQL")."') 24 24 AND (recurringinvoices.times IS NULL OR recurringinvoices.times > recurringinvoices.timesrepeated)"; 25 25 26 26 $queryresult = $this->db->query($querystatement); 27 27 28 28 while($therecord = $this->db->fetchArray($queryresult)){ 29 29 30 30 if($therecord["lastrepeat"]) 31 31 $startDate = stringToDate($therecord["lastrepeat"],"SQL"); 32 32 else 33 33 $startDate = stringToDate($therecord["invoicedate"],"SQL"); 34 34 35 35 $dateArray = $this->getValidInRange($startDate,$dateToCheck,$therecord); 36 36 37 37 if( in_array($dateToCheck, $dateArray)) 38 38 $invoiceList[] = $therecord["invoiceid"]; 39 39 40 40 }//end while 41 41 42 42 return $invoiceList; 43 43 44 44 }//end method 45 45 … … 50 50 //should pad the end date to make sure we get all weekly repeats 51 51 $endDate = strtotime("+7 days",$endDate); 52 52 53 53 $validDates = array(); 54 54 55 55 while($nextDate <= $endDate){ 56 56 57 57 switch($therecord["type"]){ 58 58 case "Daily": … … 61 61 $nextDate = strtotime("+".$therecord["every"]." days",$nextDate); 62 62 break; 63 64 case "Weekly": 63 64 case "Weekly": 65 65 //================================================================================== 66 66 $weekDayArray = explode("::",$therecord["eachlist"]); … … 69 69 $tempDate = strtotime(nl_langinfo( constant("DAY_1") ),$nextDate); 70 70 $tempDate = strtotime("-7 days",$tempDate); 71 71 72 72 foreach($weekDayArray as $weekday){ 73 73 if($weekday == 7) 74 74 $validDates[]=$tempDate; 75 75 else{ 76 $weekday++; 76 $weekday++; 77 77 $validDates[] = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 78 78 } 79 79 }// endforeach 80 81 80 81 82 82 $nextDate = strtotime("+".$therecord["every"]." week",$nextDate); 83 84 break; 85 83 84 break; 85 86 86 case "Monthly": 87 87 //================================================================================== 88 $dateArray = localtime($nextDate,true); 89 88 $dateArray = localtime($nextDate,true); 89 90 90 if($therecord["eachlist"]){ 91 91 $dayArray = explode("::",$therecord["eachlist"]); 92 92 93 93 foreach($dayArray as $theday) 94 $validDates[] = mktime(0,0,0,$dateArray["tm_mon"]+1,$theday,$dateArray["tm_year"]+1900); 95 94 $validDates[] = mktime(0,0,0,$dateArray["tm_mon"]+1,$theday,$dateArray["tm_year"]+1900); 95 96 96 } else{ 97 97 // check for things like second tuesday or last friday; 98 98 $tempDate = mktime(0,0,0,$dateArray["tm_mon"]+1,1,$dateArray["tm_year"]+1900); 99 99 $weekday = $therecord["ontheday"]; 100 $weekday = ($weekday == 7)? 1: ($weekday+1); 100 $weekday = ($weekday == 7)? 1: ($weekday+1); 101 101 if($therecord["ontheday"] != strftime("%u",$tempDate)); 102 102 $tempDate = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 103 103 104 104 while(date("n",$tempDate) == ($dateArray["tm_mon"]+1)){ 105 105 106 106 if($therecord["ontheweek"] == 5){ 107 107 // 5 is the "last" option, so we just need to see if … … 109 109 if($daysInMonth - date("d",$tempDate) < 7) 110 110 $validDates[] = $tempDate; 111 111 112 112 } else { 113 113 if( ceil(date("d",$tempDate)/7) == $therecord["ontheweek"]) 114 $validDates[] = $tempDate; 114 $validDates[] = $tempDate; 115 115 }// endif 116 116 … … 122 122 $nextDate = strtotime("+".$therecord["every"]." months",$nextDate); 123 123 break; 124 124 125 125 case "Yearly": 126 126 //================================================================================== 127 127 $monthArray = explode("::",$therecord["eachlist"]); 128 128 foreach($monthArray as $monthNum){ 129 $dateArray = localtime($nextDate,true); 129 $dateArray = localtime($nextDate,true); 130 130 $daysInMonth = date("d", mktime(0,0,0,$monthNum,0,$dateArray["tm_year"]+1900) ); 131 131 … … 137 137 // check for things like second tuesday or last friday; 138 138 $tempDate = mktime(0,0,0,$monthNum,1,$dateArray["tm_year"]+1900); 139 139 140 140 $weekday = $therecord["ontheday"]; 141 $weekday = ($weekday == 7)? 1: ($weekday+1); 141 $weekday = ($weekday == 7)? 1: ($weekday+1); 142 142 if($therecord["ontheday"] != strftime("%u",$tempDate)); 143 143 $tempDate = strtotime(nl_langinfo( constant("DAY_".$weekday) ),$tempDate); 144 145 144 145 146 146 while(date("n",$tempDate) == $monthNum){ 147 147 if($therecord["ontheweek"] == 5){ … … 150 150 if($daysInMonth - date("d",$tempDate) < 7) 151 151 $validDates[] = $tempDate; 152 152 153 153 } else { 154 154 if( ceil(date("d",$tempDate)/7) == $therecord["ontheweek"]) 155 $validDates[] = $tempDate; 155 $validDates[] = $tempDate; 156 156 }// endif 157 157 158 158 $tempDate = strtotime("+7 days",$tempDate); 159 159 160 160 }// endwhile 161 161 162 }//endif 162 }//endif 163 163 164 164 }//endforeach … … 168 168 break; 169 169 }//endswitch 170 170 171 171 }//end while 172 172 173 173 return $validDates; 174 175 }//end method 176 177 174 175 }//end method 176 177 178 178 function copyInvoice($invoiceid){ 179 179 $querystatement = " 180 SELECT 181 invoices.*, 182 firstrepeat, 183 includepaymenttype, 184 includepaymentdetails, 180 SELECT 181 invoices.*, 182 firstrepeat, 183 includepaymenttype, 184 includepaymentdetails, 185 185 recurringinvoices.id AS recurrid, 186 recurringinvoices.statusid AS newstatusid, 186 recurringinvoices.statusid AS newstatusid, 187 187 recurringinvoices.assignedtoid AS newassignedtoid, 188 188 notificationroleid 189 FROM 189 FROM 190 190 invoices INNER JOIN recurringinvoices ON invoices.id = recurringinvoices.invoiceid 191 WHERE 191 WHERE 192 192 invoices.id = ".$invoiceid; 193 193 194 194 $queryresult = $this->db->query($querystatement); 195 195 196 196 $therecord = $this->db->fetchArray($queryresult); 197 197 198 198 $fieldList = array(); 199 199 foreach($therecord as $name=>$value){ … … 206 206 case "modifieddate": 207 207 case "createdby": 208 case "creationdate": 208 case "creationdate": 209 209 case "newstatusid": 210 210 case "newassignedtoid": … … 212 212 case "recurrid": 213 213 break; 214 214 215 215 case "checkno": 216 216 case "webconfirmationno": … … 222 222 $therecord[$name] = NULL; 223 223 break; 224 224 225 225 case "statusdate": 226 226 case "orderdate": … … 250 250 $therecord[$name] = $therecord["newstatusid"]; 251 251 break; 252 252 253 253 case "assignedtoid": 254 254 $fieldlist[] = $name; … … 277 277 278 278 $insertstatement = $this->prepareInsert("invoices",$fieldlist,$therecord); 279 279 280 280 $this->db->query($insertstatement); 281 281 282 282 $theid = $this->db->insertId(); 283 283 284 284 $this->copyLineItems($therecord["id"],$theid); 285 285 $this->insertHistory($theid,$therecord["statusid"],$therecord["statusdate"],$therecord["assignedtoid"]); 286 286 287 287 $this->updateReccurence($therecord["recurrid"],$therecord["firstrepeat"]); 288 288 289 289 if($therecord["notificationroleid"]) 290 290 $this->sendNotification($therecord["notificationroleid"],$theid); 291 292 }//end method 293 294 291 292 }//end method 293 294 295 295 function copyLineItems($oldInvoiceID, $newInvoiceID){ 296 296 297 297 $querystatement = "SELECT * FROM lineitems WHERE invoiceid = ".$oldInvoiceID; 298 298 $queryresult = $this->db->query($querystatement); 299 299 300 300 while($therecord = $this->db->fetchArray($queryresult)){ 301 301 302 302 $fieldlist = array(); 303 303 304 304 foreach($therecord as $name=>$value){ 305 305 switch($name){ … … 308 308 case "modifieddate": 309 309 case "createdby": 310 case "creationdate": 310 case "creationdate": 311 311 break; 312 312 313 313 case "invoiceid": 314 314 $therecord[$name] = $newInvoiceID; 315 $fieldlist[] = $name; 315 $fieldlist[] = $name; 316 316 break; 317 317 318 318 default: 319 $fieldlist[] = $name; 319 $fieldlist[] = $name; 320 320 }// endswitch 321 321 }// endforeach 322 322 323 323 $insertstatement = $this->prepareInsert("lineitems",$fieldlist,$therecord); 324 324 325 325 $this->db->query($insertstatement); 326 326 327 327 }// endwhile 328 329 }//end method 330 331 328 329 }//end method 330 331 332 332 function prepareInsert($tablename, $fieldlist, $therecord){ 333 333 $insertstatement = "INSERT INTO ".$tablename." ("; 334 334 335 335 foreach($fieldlist as $name) 336 336 $insertstatement .= "`".$name."`, "; 337 337 338 338 $insertstatement .= " createdby,creationdate) VALUES ("; 339 339 340 340 foreach($fieldlist as $name) 341 341 if($therecord[$name] !== NULL) … … 343 343 else 344 344 $insertstatement .= "NULL, "; 345 345 346 346 $insertstatement .="-3, NOW());"; 347 347 348 348 return $insertstatement; 349 349 }//end method 350 351 350 351 352 352 function insertHistory($invoiceid, $statusid, $statusdate, $assignedtoid){ 353 353 $insertstatement = "INSERT INTO invoicestatushistory (invoiceid, invoicestatusid, statusdate, assignedtoid) VALUES ("; … … 356 356 $insertstatement .= "'".$statusdate."', "; 357 357 $insertstatement .= $assignedtoid.")"; 358 358 359 359 $this->db->query($insertstatement); 360 361 }//end method 362 363 360 361 }//end method 362 363 364 364 function updateReccurence($recurrid, $firstrepeat){ 365 365 $updatestatement = "UPDATE recurringinvoices SET timesrepeated = timesrepeated+1, lastrepeat=NOW()"; 366 366 if(!$firstrepeat) 367 367 $updatestatement .= ", firstrepeat=NOW()"; 368 368 369 369 $updatestatement .= " WHERE id = ".$recurrid; 370 370 371 371 $this->db->query($updatestatement); 372 372 373 373 } 374 375 374 375 376 376 function sendNotification($roleid, $newInvoiceID){ 377 377 if($roleid == -100) … … 379 379 else 380 380 $whereclause = "rolestousers.roleid = ".$roleid; 381 381 382 382 $querystatement = "SELECT email FROM rolestousers INNER JOIN users ON rolestousers.userid = users.id 383 383 WHERE email != '' AND ".$whereclause; 384 384 385 385 $queryresult = $this->db->query($querystatement); 386 386 387 387 $subject = APPLICATION_NAME." recurring invoice notification."; 388 388 $message = APPLICATION_NAME." has created a new order from a recurring invoice. The new order id is ".$newInvoiceID; … … 394 394 @ mail ($to,$subject,$message,$headers); 395 395 }// endwhile 396 396 397 397 }//end method 398 398 }//end class -
trunk/phpbms/modules/sample/install/install.php
r285 r485 1 1 <?php 2 /* 3 $Rev: 265 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-13 21:33:23 -0600 (Mon, 13 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2007, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 42 include("../../../install/install_include.php"); 43 include("../../../include/session.php"); 2 // The install proceess is typically simple, but if you have some complex 3 // installation procedures not covered by the installModuleAjax (located in the 4 // main install/installajax.php file) You can override the class. 5 // 6 // Just make sure your class has an 'install' method, and spits back JSON paired 7 // results 44 8 45 $phpbmsSession = new phpbmsSession; 46 $success = $phpbmsSession->loadDBSettings(false); 47 include_once("include/db.php"); 48 $db = new db(false); 49 $db->stopOnError = false; 50 $db->showError = false; 51 $db->logError = false; 9 // Always instanciate the class to the variable $theModule. include the 10 // encapsulating objects db and phpbmsSession variables as well 11 // as the path form the application to the modules's install folder 12 $theModule = new installModuleAjax($this->db, $this->phpbmsSession, "../modules/sample/install/"); 52 13 53 if($success !== false){ 54 55 if(!$db->connect()) 56 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 57 else { 58 if(!$db->selectSchema()) 59 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 60 else { 14 // by default the install class will try to run a createtables.sql file located 15 // in the modules install directory. In addition, it will run individual 16 // SQL files that match table name entries in the tables array (defined below) 17 // that should also be located in the module's install folder. 18 $theModule->tables = array( 19 "menu", 20 "modules", 21 "roles", 22 "scheduler", 23 "tabledefs", 24 "tablecolumns", 25 "tableoptions", 26 "tablefindoptions", 27 "tablesearchablefields", 28 "tabs", 29 "users", 30 ); 61 31 62 63 // ENTER YOUR MODULE NAME HERE 64 $thereturn = "Business Management System Installation\n"; 65 $thereturn .= "_______________________________________\n"; 66 67 //MAKE SURE THERE IS A createtables.sql FILE 68 //which houses all your SQL create statements 69 // for any tables you will create. 70 $tempreturn = createTables($db,"createtables.sql"); 71 72 if($tempreturn === true){ 73 74 $thereturn.= "Done Creating Tables \n"; 75 76 77 // NEXT, DEFINE AN ARRAY OF TABLE NAMES 78 // for any tables that need initial data populated. (including existing tables) 79 // for each table, make sure there 80 // is a corresponding SQL file 81 // with insert statements for all the records needing to be imported 82 $tables = array( 83 "choices", 84 "menu", 85 "tabs", 86 "modules", 87 "relationships", 88 "reports", 89 "tablecolumns", 90 "tabledefs", 91 "tablefindoptions", 92 "tableoptions", 93 "tablesearchablefields", 94 "usersearches", 95 "settings", 96 "shippingmethods", 97 "paymentmethods", 98 "invoicestatuses", 99 ); 100 foreach($tables as $table){ 101 102 $failure = false; 103 $tempreturn = importData($db,$table); 104 $thereturn .= $tempreturn; 105 if(!strpos($tempreturn,"complete.") === false){ 106 $failed = true; 107 } 108 109 }//end foreach 110 111 112 //MAKE SURE TO set the done message for your module. 113 if(!$failure){ 114 $thereturn .= "________________________\n"; 115 $thereturn .= "Done Installing BMS Data\n"; 116 } 117 } else 118 $thereturn = $tempreturn; 119 } 120 } 121 } else 122 $thereturn = "Could not access settings.php"; 123 124 125 header('Content-Type: text/xml'); 126 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 127 <response><?php echo $thereturn?></response> 32 ?> -
trunk/phpbms/modules/sample/install/update.php
r285 r485 1 1 <?php 2 /* 3 $Rev: 265 $ | $LastChangedBy: brieb $ 4 $LastChangedDate: 2007-08-13 21:33:23 -0600 (Mon, 13 Aug 2007) $ 5 +-------------------------------------------------------------------------+ 6 | Copyright (c) 2004 - 2007, Kreotek LLC | 7 | All rights reserved. | 8 +-------------------------------------------------------------------------+ 9 | | 10 | Redistribution and use in source and binary forms, with or without | 11 | modification, are permitted provided that the following conditions are | 12 | met: | 13 | | 14 | - Redistributions of source code must retain the above copyright | 15 | notice, this list of conditions and the following disclaimer. | 16 | | 17 | - Redistributions in binary form must reproduce the above copyright | 18 | notice, this list of conditions and the following disclaimer in the | 19 | documentation and/or other materials provided with the distribution. | 20 | | 21 | - Neither the name of Kreotek LLC nor the names of its contributore may | 22 | be used to endorse or promote products derived from this software | 23 | without specific prior written permission. | 24 | | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 26 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 27 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | 28 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 29 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 30 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 31 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 32 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 33 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 34 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 35 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 36 | | 37 +-------------------------------------------------------------------------+ 38 */ 39 error_reporting(E_ALL); 40 define("APP_DEBUG",false); 41 define("noStartup",true); 2 // The update proceess is typically simple, but if you have some complex 3 // update procedures (like the BMS module) not covered by the updateModuleAjax 4 // (located in the main install/installajax.php file) You can override the class. 5 // 6 // Just make sure your class has an 'update' method, and spits back JSON paired 7 // results 42 8 43 include("../../../install/install_include.php"); 44 include("../../../include/session.php"); 9 // Always instanciate the class to the variable $theModule. include the 10 // encapsulating objects db and phpbmsSession variables as well 11 // as the module name, and the path form the application to the modules's 12 // install folder 13 $theModule = new updateModuleAjax($this->db, $this->phpbmsSession, "recurringinvoices", "../modules/recurringinvoices/install/"); 45 14 46 function doUpdate($db) { 47 $thereturn="Updating Business Management System Module\n"; 48 49 if(!verifyAdminLogin($db,$_GET["u"],$_GET["p"])){ 50 $thereturn="Update Requires Administrative Access.\n\n"; 51 return $thereturn; 52 } 53 54 $newVersion = $_GET["v"]; 55 56 $querystatement="SELECT version FROM modules WHERE name=\"bms\""; 57 $queryresult=$db->query($querystatement); 58 if(!$queryresult) { 59 $thereturn="Error Accessing module table in database.\n\n"; 60 return $thereturn; 61 } 62 63 $ver=$db->fetchArray($queryresult); 15 // Next define all the updates that are possible. Each version 16 // corresponds to a sql file in the install folder named 'updatev[version].sql' 17 // that will be run while updating. 18 // 19 // List *all* the versions to update. The update process will ONLY run 20 // applicable upgrades, ignoring older versions not needed to upgrade. 21 $theModule->updateVersions = array( 22 1.01, 23 1.02, 24 1.03 25 ); 64 26 65 while($ver["version"] != $newVersion){ 66 switch($ver["version"]){ 67 // ================================================================================================ 68 case "0.5": 69 $thereturn.="Updating BMS Module to 0.51\n"; 70 71 //Updating Module Table 72 $querystatement="UPDATE modules SET version=\"0.51\" WHERE name=\"bms\";"; 73 $queryresult=$db->query($querystatement); 74 $thereturn.=" - modified bms record in modules table\n"; 75 76 $thereturn.="Update to 0.51 Finished\n\n"; 77 78 $ver["version"]="0.51"; 79 break; 80 // ================================================================================================ 81 case "0.51": 82 $thereturn.="Updating BMS Module to 0.6\n"; 83 84 $thereturn.=processSQLfile($db,"updatev0.6.sql"); 85 86 $thereturn.=importData($db,"choices"); 87 $thereturn.=importData($db,"menu"); 88 $thereturn.=importData($db,"reports"); 89 $thereturn.=importData($db,"tablecolumns"); 90 $thereturn.=importData($db,"tabledefs"); 91 $thereturn.=importData($db,"tablefindoptions"); 92 $thereturn.=importData($db,"tableoptions"); 93 $thereturn.=importData($db,"tablesearchablefields"); 94 95 $querystatement="SELECT clients.id,DATE_FORMAT(clients.creationdate,\"%Y-%m-%d\") as creationdate,max(invoices.orderdate) as orderdate 96 FROM `clients` LEFT JOIN invoices on clients.id=invoices.clientid 97 WHERE clients.type=\"client\" GROUP BY clients.id;"; 98 $queryresult=$db->query($querystatement); 99 100 while($therecord=$db->fetchArray($queryresult,$dblink)){ 101 $querystatement="UPDATE clients set becameclient=\""; 102 if($therecord["orderdate"]) 103 $querystatement.=$therecord["orderdate"]; 104 else 105 $querystatement.=$therecord["creationdate"]; 106 $querystatement.="\" WHERE id=".$therecord["id"]; 107 $updateresult=$db->query($querystatement); 108 } 109 $thereturn.=" - set intitial client becamclient field\n"; 110 111 112 //Updating Module Table 113 $querystatement="UPDATE modules SET version=\"0.6\" WHERE name=\"bms\";"; 114 $updateresult=$db->query($querystatement); 115 $thereturn.=" - modified bms record in modules table\n"; 116 117 $thereturn.="Update to 0.6 Finished\n\n"; 118 119 $ver["version"]="0.6"; 120 break; 121 // ================================================================================================ 122 case "0.6"; 123 $thereturn.="Updating BMS Module to 0.601\n"; 124 125 $querystatement="SELECT invoices.id,tax.percentage FROM invoices INNER JOIN tax on invoices.taxareaid=tax.id"; 126 $queryresult=$db->query($querystatement); 127 128 129 while($therecord=$db->fetchArray($queryresult)){ 130 $querystatement="UPDATE invoices SET taxpercentage=".$therecord["percentage"]."WHERE id=".$therecord["id"]; 131 $updateresult=$db->query($querystatement); 132 } 133 $thereturn.=" - set taxpercentage on invoices\n"; 134 135 //Updating Module Table 136 $querystatement="UPDATE modules SET version=\"0.601\" WHERE name=\"bms\";"; 137 $updateresult=$db->query($querystatement); 138 $thereturn.=" - modified bms record in modules table\n"; 139 140 141 $thereturn.="Update to 0.601 Finished\n\n"; 142 143 $ver["version"]="0.601"; 144 145 break; 146 // ================================================================================================ 147 case "0.601"; 148 $thereturn.="Updating BMS Module to 0.602\n"; 149 150 //Updating Module Table 151 $querystatement="UPDATE modules SET version=\"0.602\" WHERE name=\"bms\";"; 152 $updateresult=$db->query($querystatement); 153 $thereturn.=" - modified bms record in modules table\n"; 154 155 $thereturn.="Update to 0.602 Finished\n\n"; 156 157 $ver["version"]="0.602"; 158 // ================================================================================================ 159 case "0.602"; 160 $thereturn.="Updating BMS Module to 0.61\n"; 161 162 $thereturn.=processSQLfile($db,"updatev0.61.sql"); 163 164 //Updating Module Table 165 $querystatement="UPDATE modules SET version=\"0.61\" WHERE name=\"bms\";"; 166 $updateresult=$db->query($querystatement); 167 $thereturn.=" - modified bms record in modules table\n"; 168 169 $thereturn.="Update to 0.61 Finished\n\n"; 170 171 $ver["version"]="0.61"; 172 break; 173 // ================================================================================================ 174 case "0.61"; 175 $thereturn.="Updating BMS Module to 0.62\n"; 176 177 $thereturn.=processSQLfile($db,"updatev0.62.sql"); 178 179 //Updating Module Table 180 $querystatement="UPDATE modules SET version=\"0.62\" WHERE name=\"bms\";"; 181 $updateresult=$db->query($querystatement); 182 $thereturn.=" - modified bms record in modules table\n"; 183 184 $thereturn.="Update to 0.62 Finished\n\n"; 185 186 $ver["version"]="0.62"; 187 break; 188 // ================================================================================================ 189 case "0.62"; 190 $thereturn.="Updating BMS Module to 0.7\n"; 191 192 $thereturn.=processSQLfile($db,"updatev0.70.sql"); 193 194 //update to new status system 195 $result=updateInvoiceStatus($db); 196 if($result===true) 197 $thereturn.=" - Updated to new invoice status system\n"; 198 else 199 $thereturn.=" - Failed to updated to new invoice status system\n".$result."\n\n"; 200 201 //Update shipping from invoices 202 $result=moveShipping($db); 203 if($result===true) 204 $thereturn.=" - Created default Shipping Methods\n"; 205 else 206 $thereturn.=" - Failed to create default shipping methods\n".$result."\n\n"; 207 208 //update payment From invoices 209 $result=movePayments($db); 210 if($result===true) 211 $thereturn.=" - Created default payment methods\n"; 212 else 213 $thereturn.=" - Failed to create default payment Methods\n".$result."\n\n"; 214 215 //Updating Module Table 216 $querystatement="UPDATE modules SET version=\"0.7\" WHERE name=\"bms\";"; 217 $updateresult=$db->query($querystatement); 218 $thereturn.=" - Updated bms module record with new version\n"; 219 220 $thereturn.="Update to 0.7 Finished\n\n"; 221 222 $ver["version"]="0.7"; 223 break; 224 225 // ================================================================================================ 226 case "0.7"; 227 228 $thereturn.= processSQLfile($db,"updatev0.8.sql"); 229 230 //Updating Module Table 231 $querystatement="UPDATE modules SET version=\"0.8\" WHERE name=\"bms\";"; 232 $updateresult=$db->query($querystatement); 233 234 $thereturn.="Update of Business Management System Module to 0.8 Finished\n\n"; 235 $ver["version"]="0.8"; 236 break; 237 }//end switch 238 }//end while 239 return $thereturn; 240 241 }//end update 242 243 function moveShipping($db){ 244 $querystatement="SELECT DISTINCT shippingmethod FROM invoices WHERE shippingmethod!=\"\" ORDER BY shippingmethod"; 245 $queryresult=$db->query($querystatement); 246 247 while($therecord=$db->fetchArray($queryresult)){ 248 $querystatement="INSERT INTO `shippingmethods` (name,createdby,creationdate) VALUES (\"".$therecord["shippingmethod"]."\",1,NOW())"; 249 $updatequery=$db->query($querystatement); 250 } 251 252 $querystatement="SELECT id,name FROM shippingmethods"; 253 $queryresult=$db->query($querystatement); 254 255 while($therecord=$db->fetchArray($queryresult)){ 256 $querystatement="UPDATE invoices SET shippingmethodid=".$therecord["id"]." 257 WHERE shippingmethod=\"".$therecord["name"]."\""; 258 $updatequery=$db->query($querystatement); 259 } 260 $querystatement="ALTER TABLE invoices DROP shippingmethod"; 261 $updatequery=$db->query($querystatement); 262 263 return true; 264 } 265 266 function movePayments($db){ 267 $querystatement="SELECT DISTINCT paymentmethod FROM invoices WHERE paymentmethod!=\"\" ORDER BY paymentmethod"; 268 $queryresult=$db->query($querystatement); 269 270 while($therecord=$db->fetchArray($queryresult)){ 271 switch($therecord["paymentmethod"]){ 272 case "VISA": 273 case "VISA - Debit": 274 case "American Express": 275 case "Master Card": 276 case "MasterCard": 277 case "Discover Card": 278 $type="\"charge\""; 279 break; 280 281 case "Personal Check": 282 case "Check": 283 case "Cashiers Check": 284 case "check": 285 $type="\"draft\""; 286 break; 287 288 default: 289 $type="NULL"; 290 break; 291 } 292 293 $querystatement="INSERT INTO `paymentmethods` (name,`type`,createdby,creationdate) VALUES (\"".$therecord["paymentmethod"]."\",".$type.",1,NOW())"; 294 $updatequery=$db->query($querystatement); 295 } 296 297 $querystatement="SELECT id,name FROM paymentmethods"; 298 $queryresult=$db->query($querystatement); 299 while($therecord=$db->fetchArray($queryresult)){ 300 $querystatement="UPDATE invoices SET paymentmethodid=".$therecord["id"]." 301 WHERE paymentmethod=\"".$therecord["name"]."\""; 302 $updatequery=$db->query($querystatement); 303 } 304 $querystatement="ALTER TABLE invoices DROP paymentmethod"; 305 $updatequery=$db->query($querystatement); 306 307 return true; 308 } 309 310 function updateInvoiceStatus($db){ 311 $querystatement="SELECT id,status,statusdate,orderdate,invoicedate,type FROM invoices"; 312 $queryresult=$db->query($querystatement); 313 314 while($therecord=$db->fetchArray($queryresult)){ 315 $newstatus=1; 316 switch($therecord["status"]){ 317 case "Open": 318 $newstatus=1; 319 $statusdate=$therecord["orderdate"]; 320 break; 321 case "Committed": 322 $newstatus=2; 323 $statusdate=$therecord["orderdate"]; 324 break; 325 case "Packed": 326 $newstatus=3; 327 break; 328 case "Shipped": 329 $newstatus=4; 330 if($therecord["statusdate"]) 331 $statusdate=$therecord["statusdate"]; 332 elseif($therecord["invoicedate"]) 333 $statusdate=$therecord["invoicedate"]; 334 else 335 $statusdate=$therecord["orderdate"]; 336 break; 337 if($therecord["type"]=="Invoice") 338 $statusdate=$therecord["invoicedate"]; 339 } 340 $querystatement="UPDATE invoices SET statusid=".$newstatus.", statusdate=\"".$statusdate."\" WHERE id=".$therecord["id"]; 341 $updatequery=$db->query($querystatement); 342 343 //now create the history 344 $querystatement="INSERT INTO invoicestatushistory (invoiceid,invoicestatusid,statusdate)VALUES(".$therecord["id"].",".$newstatus.",\"".$statusdate."\")"; 345 $insertquery=$db->query($querystatement); 346 347 } 348 $querystatement="ALTER TABLE `invoices` DROP COLUMN `status`"; 349 $dropcolumnquery=$db->query($querystatement); 350 351 return true; 352 }//end funtion 353 354 355 $phpbmsSession = new phpbmsSession; 356 $success = $phpbmsSession->loadDBSettings(false); 357 358 include_once("include/db.php"); 359 $db = new db(false); 360 $db->stopOnError = false; 361 $db->showError = false; 362 $db->logError = false; 363 364 if($success !== false){ 365 366 if(!$db->connect()) 367 $thereturn = "Could Not Establish Connection To MySQL Server: Check server, user name, and password."; 368 else { 369 if(!$db->selectSchema()) 370 $thereturn = "Database (schema) ".MYSQL_DATABASE." could not be selected"; 371 else { 372 373 $phpbmsSession->db = $db; 374 $phpbmsSession->loadSettings(); 375 376 $thereturn=doUpdate($db); 377 378 } 379 } 380 } else 381 $thereturn = "Could not access settings.php"; 382 383 384 385 header('Content-Type: text/xml'); 386 ?><?php echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; ?> 387 <response><?php echo $thereturn?></response> 27 ?> -
trunk/phpbms/modules/sample/sampletable_addedit.php
r384 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev: 258 $ | $LastChangedBy: brieb $ … … 41 41 include("include/tables.php"); 42 42 include("include/fields.php"); 43 43 44 44 //if you need to ovveride the phpbmsTable class make sure to include the modules file 45 45 include("modules/[modulename]/include/[tablename].php"); 46 46 47 47 48 //If the addedit page will be accessd directly from a page other than the 48 //If the addedit page will be accessd directly from a page other than the 49 49 // basic search results page, you may want to grab and pass the previous URL 50 50 //with the following code 51 51 52 52 //=================================================== 53 if(!isset($_GET["backurl"])) 54 $backurl = NULL; 55 else{ 53 if(!isset($_GET["backurl"])) 54 $backurl = NULL; 55 else{ 56 56 $backurl = $_GET["backurl"]; 57 57 if(isset($_GET["refid"])) … … 63 63 //Here you invoke the table class. If you are going to use the standard phpbmsTable class 64 64 // for updates and the such you would access it like this 65 65 66 66 // $thetable = new phpbmsTable($db,[table definition id]); 67 68 // if you are going to overide the class you would instantiate69 // like this70 71 // $thetable = new [tablename]($db,[table definition id] ,$backurl);72 67 68 // if you are going to overide the class you would instantiate 69 // your overriden class like this 70 71 // $thetable = new [tablename]($db,[table definition id]); 72 73 73 //and if you are setting the backurl, make sure you pass that as well 74 74 // like this: 75 75 // $thetable = new [tablename]($db,[table definition id],$backurl); 76 77 78 // Next we process the form (if submitted) and76 77 78 // Next we process the form (if submitted) and 79 79 // return the current record as an array ($therecord) 80 80 // or if this is a new record, it returns the defaults … … 87 87 88 88 $pageTitle = "[tablename]"; 89 89 90 90 // Next, we set up to include any 91 91 // additional css or javascript files we will be using … … 93 93 // as they are automatically icluded when you define the special fields you 94 94 // will be using below. 95 $phpbms->cssIncludes[] = "pages/[ tablename].css";95 $phpbms->cssIncludes[] = "pages/[modulename]/[tablename].css"; 96 96 $phpbms->jsIncludes[] = "modules/[modulename]/javascript/[tablename].js"; 97 97 98 // DEPRECIATED: 98 99 // if you need to define a body onlload function, do so with the phpbms property 99 100 $phpbms->onload[] = "initializePage()"; … … 102 103 // Next we need to define any special fields that will be used in the form 103 104 // A list of field objects (with documentation)is available in the /include/fields.php 104 // file. 105 105 // file. 106 106 107 // We need to define them here in the head 107 108 // so that any necessay javascript is loaded appropriately. 108 109 109 110 //Form Elements 110 111 //============================================================== 111 112 112 113 // Create the form 113 114 $theform = new phpbmsForm(); 114 115 //if you need to set specific form vaiables (like enctype, or extra onsubmit 115 116 // you can set those form properties here. 116 117 // for each field we will use, create the field object and add it to 117 118 // for each field we will use, create the field object and add it to 118 119 // the forms list. 119 120 $theinput = new inputDatePicker("orderdate", $therecord["orderdate"], "order date"); 120 121 $theform->addField($theinput); 121 122 122 123 $theinput = new inputCheckBox("weborder",$therecord["weborder"],NULL, false, false); 123 124 $theform->addField($theinput); … … 136 137 $theform->jsMerge(); 137 138 //============================================================== 138 //End Form Elements 139 //End Form Elements 139 140 140 include("header.php"); 141 141 include("header.php"); 142 142 143 ?><div class="bodyline"> 143 <!-- 144 <!-- 144 145 Next we start the form. This also prints the H1 with title, and top save,cancel buttons 145 146 If you need to have other buttons, or need a specific top, you will need to create your form manually. … … 151 152 <p> 152 153 <label for="id">id</label><br /> 153 <input name="id" id="id" type="text" value="<?php echo $therecord["id"]; ?>" size="5" maxlength="5" readonly="readonly" class="uneditable" /> 154 <input name="id" id="id" type="text" value="<?php echo $therecord["id"]; ?>" size="5" maxlength="5" readonly="readonly" class="uneditable" /> 154 155 </p> 155 <p><?php $theform->showField("inactive");?></p> 156 <p><?php $theform->showField("inactive");?></p> 156 157 </fieldset> 157 158 … … 166 167 </fieldset> 167 168 </div> 168 <?php 169 <?php 169 170 //Last, we show the create/modifiy with the bottom save and cancel buttons 170 171 // and then close the form. -
trunk/phpbms/modules/sample/snapshot.php
r285 r485 40 40 /* 41 41 42 Here you can define and display information from your module that will show up on the snapshot43 (default) page.42 Here you can define and display information from your module that 43 will show up on the snapshot (default) page. 44 44 45 45 */ -
trunk/phpbms/requirements.php
r285 r485 1 <?php 1 <?php 2 2 /* 3 3 $Rev$ | $LastChangedBy$ … … 40 40 $loginNoDisplayError=true;; 41 41 require("include/session.php"); 42 42 43 43 $pageTitle = "phpBMS Browser Requirements"; 44 44 45 45 $phpbms->cssIncludes[] = "pages/requirements.css"; 46 46 47 47 $phpbms->showMenu = false; 48 48 $phpbms->showFooter = false; 49 49 50 50 include("header.php") 51 ?><div class="bodyline" id="container"> 52 <div class="box" id="logo" style=""><span>phpBMS</span></div> 51 ?><div class="bodyline" id="container"> 52 53 53 <h1>phpBMS Browser Requirements</h1> 54 <h2 id="cba">Client Browser Aplication</h2>55 54 56 <h3>JavaScript v2.0</h3> 57 <p>This application makes heavy use of newer JavaScript functions, including the paradigm known as AJAX. Without Javascript, enabled, phpBMS will not run correctly.</p> 55 <ul> 58 56 59 <h3>Window pop-ups:</h3> 60 <p>This application utilizes JavaScript to open new windows. If you disable Javascript window opening (like in Firefox or Opera) or are utilizing a 3rd-party application to stop Internet Explorer from opening unwanted windows, this application might not work correctly.</p> 57 <li> 58 <h3>Enabled JavaScript v2.0 or higher processing</h3> 59 <p> 60 phpBMS heavily uses JavaScript, including newer functions only found in version 2.0 or higher. 61 Most newer browsers support this, but make sure that JavaScript is enabled for this web application 62 </p> 63 </li> 61 64 62 <h3>Cookies</h3> 63 <p>A single cookie is set to identify the user during a session.</p> 65 <li> 66 <h3>Allow window pop-ups</h3> 67 <p> 68 This application sparingly uses JavaScript to open multiple windows when printing. If your browser 69 or third-party browser plug in prohibits pop-ups from this application, printing reports will not 70 be displayed. 71 </p> 72 </li> 64 73 65 <h3>Style Sheets (CSS) v1.1</h3> 66 <p>Your browser must support the rendering of Cascading Style Sheets. Without this support, the application will not work correctly.</p> 74 <li> 75 <h3>Cookie support</h3> 76 <p> 77 phpBMS sets a single cookie to track your login. Cookie suport for this site 78 must be enabled in order for the application to allow you to log in 79 </p> 80 </li> 81 82 <li> 83 <h3>Full Casscading Style Sheet (CSS) v1.2 support</h3> 84 <p> 85 phpBMS takes advantage of CSS v1.2 to render pages. Without this 86 support, the application may not look correct, and can even break some 87 functionality. 88 </p> 89 </li> 90 </ul> 67 91 68 92 <h2>Tested Browsers</h2> 69 <table border="0" cellpadding="0" cellspacing="0" class="querytable" id="browserTable"> 70 <tr> 71 <th class="queryheader" nowrap="nowrap">Browser Application</th> 72 <th class="queryheader">Version</th> 73 <th class="queryheader">Platform(s)</th> 74 <th align="center" class="queryheader">Compatibility</th> 75 </tr> 76 <tr class="row2"> 77 <td>Firefox</td> 78 <td>1.5.0.7</td> 79 <td>Windows/Macintosh</td> 80 <td align="center" class="important">X</td> 81 </tr> 82 <tr class="row1"> 83 <td>Internet Explorer</td> 84 <td>6.0.2900.2190</td> 85 <td>Windows</td> 86 <td align="center" class="important">X</td> 87 </tr> 88 <tr class="row2"> 89 <td>Opera</td> 90 <td>9.02</td> 91 <td>Windows</td> 92 <td align="center" class="important">X</td> 93 </tr> 94 <tr class="row1"> 95 <td>Internet Explorer</td> 96 <td>6.0.2900.2190</td> 97 <td>Windows</td> 98 <td align="center" class="important">X</td> 99 </tr> 100 <tr class="queryfooter"><td> </td><td> </td><td> </td><td> </td></tr> 101 </table> 93 94 <p> 95 This is a list of tested browsers known to work with the current version of phpBMS. If you successfully 96 test another browser with this version, please report it on our forums at <a href="http://phpbms.org">http://phpbms.org</a> 97 so we can add it to the list. Be sure to report the phpBMS version, browser name, browser version, and 98 operating system. 99 </p> 100 101 <ul> 102 <li>Firefox v3.07 for Macintosh</li> 103 <li>Firefox v3.07 for Windows</li> 104 <li>Safari v3.2.1 for Macintosh</li> 105 <li>Internet Explorer v7.0.5730.13 for Windows</li> 106 <li>Opera v9.64 for Windows</li> 107 </ul> 108 102 109 <p align="right"> 103 110 <input type="button" value="Log In" class="Buttons" onclick="document.location='./'" id="loginButton"/> -
trunk/phpbms/THANKS.txt
r396 r485 1 This file will contain all the people who have contributed to phpBMS 2 ==================================================================== 1 This file will contain all the people and companies who have contributed to 2 phpBMS 3 ================================================================================ 3 4 4 5 * Hauge Quality Water - http://haguekc.com/ 5 * Black Tie: Audio, Lighting & Video - http://blacktie.com.mx 6 * Black Tie: Audio, Lighting & Video - http://blacktie.com.mx/ 6 7 * Concept Z Performance - http://www.conceptzperformance.com/ 8 * Dahl Photography - http://www.dahlphotographers.com/