Changeset 439
- Timestamp:
- 10/30/08 15:26:37
- Files:
-
- branches/nathan/include/imports.php (modified) (2 diffs)
- branches/nathan/include/tables.php (modified) (1 diff)
- branches/nathan/modules/base/files_import.php (added)
- branches/nathan/modules/base/general_import.php (modified) (4 diffs)
- branches/nathan/modules/base/include/files.php (modified) (2 diffs)
- branches/nathan/modules/base/include/menu.php (modified) (2 diffs)
- branches/nathan/modules/base/include/notes.php (modified) (1 diff)
- branches/nathan/modules/base/include/relationships.php (modified) (5 diffs)
- branches/nathan/modules/base/include/reports.php (modified) (1 diff)
- branches/nathan/modules/base/include/scheduler.php (modified) (2 diffs)
- branches/nathan/modules/base/include/users.php (modified) (1 diff)
- branches/nathan/modules/base/include/usersearches.php (modified) (3 diffs)
- branches/nathan/modules/base/menu_import.php (added)
- branches/nathan/modules/base/notes_import.php (added)
- branches/nathan/modules/base/relationships_import.php (added)
- branches/nathan/modules/base/reports_import.php (added)
- branches/nathan/modules/base/roles_import.php (added)
- branches/nathan/modules/base/scheduler_import.php (added)
- branches/nathan/modules/base/tabledefs_import.php (added)
- branches/nathan/modules/base/usersearches_import.php (added)
- branches/nathan/modules/bms/discounts_import.php (added)
- branches/nathan/modules/bms/include/addresstorecord.php (modified) (1 diff)
- branches/nathan/modules/bms/include/clients.php (modified) (5 diffs)
- branches/nathan/modules/bms/include/invoices.php (modified) (1 diff)
- branches/nathan/modules/bms/include/invoicestatuses.php (modified) (1 diff)
- branches/nathan/modules/bms/include/products.php (modified) (3 diffs)
- branches/nathan/modules/bms/include/receipts.php (modified) (4 diffs)
- branches/nathan/modules/bms/install/createtables.sql (modified) (1 diff)
- branches/nathan/modules/bms/install/tablecolumns.sql (modified) (1 diff)
- branches/nathan/modules/bms/install/updatev0.98.sql (modified) (1 diff)
- branches/nathan/modules/bms/invoicestatuses_import.php (added)
- branches/nathan/modules/bms/receipts_import.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/nathan/include/imports.php
r437 r439 465 465 }//end method --startForm-- 466 466 467 function showButtons($ids = 1, $pageType = "main" ){467 function showButtons($ids = 1, $pageType = "main", $numberOfRecords = 0){ 468 468 ?> 469 469 <div class="importCancels"> … … 472 472 <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)" /> 473 473 <?php }else{?> 474 <input type="submit" class="Buttons" value="import" name="command" id="import<?php echo $ids?>" title="commit" />474 <input type="submit" class="Buttons" value="import" name="command" id="import<?php echo $ids?>" title="commit" <?php echo ($numberOfRecords? '':'disabled="disabled"') ?>/> 475 475 <input type="submit" class="Buttons" value="cancel" name="command" id="cancelButton<?php echo $ids?>" title="rollback"/> 476 476 <?php }//end if ?> branches/nathan/include/tables.php
r437 r439 277 277 278 278 if(isset($variables["inactive"])) 279 if($variables["inactive"] && $variables["inactive"] != =1)279 if($variables["inactive"] && $variables["inactive"] != 1) 280 280 $this->verifyErrors[] = "The `inactive` field must be a boolean (equivalent to 0 or exactly 1)."; 281 281 282 282 if(isset($variables["webenabled"])) 283 if($variables["webenabled"] && $variables["webenabled"] != =1)283 if($variables["webenabled"] && $variables["webenabled"] != 1) 284 284 $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1)."; 285 285 branches/nathan/modules/base/general_import.php
r432 r439 49 49 50 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 51 $tabledefid = (int) $_GET["id"]; 54 52 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 53 68 54 … … 76 62 // like this 77 63 78 // $thetable = new [tablename]($db,[table definition id] ,$backurl);64 // $thetable = new [tablename]($db,[table definition id]); 79 65 // $import = new [importname]($thetable); 80 66 … … 126 112 // you can set those form properties here. 127 113 128 // for each field we will use, create the field object and add it to129 // 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);145 114 146 115 // lastly, use the jsMerge method to create the final Javascript formatting … … 219 188 //Last, we show the create/modifiy with the bottom save and cancel buttons 220 189 // and then close the form. 221 $theform->showButtons(2, $import->pageType );190 $theform->showButtons(2, $import->pageType, count($import->transactionRecords)); 222 191 ?></div><?php 223 192 $theform->endForm(); branches/nathan/modules/base/include/files.php
r437 r439 95 95 //equivalent to 0) is an acceptable role id. 96 96 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 97 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number." 97 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 98 98 }else 99 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0." 99 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 100 100 }//end if 101 101 … … 107 107 function prepareVariables($variables){ 108 108 109 if($_FILES['upload']["name"]){ 110 111 $variables["name"] = $_FILES['upload']["name"]; 112 $variables["type"] = $_FILES['upload']['type']; 113 $variables["file"] = $this->getPicture("upload"); 114 115 } else { 116 unset($this->fields["type"]); 117 unset($this->fields["file"]); 118 }//end if 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 119 120 120 121 return $variables; branches/nathan/modules/base/include/menu.php
r437 r439 120 120 //check to see if the int typecast role id is in one of the available ones 121 121 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 122 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number." 122 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 123 123 }else 124 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0." 124 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 125 125 126 126 }//end if … … 142 142 //Select run every time because `id` can be different 143 143 if( !$this->checkParentMenuIDs($id, ((int) $variables["parentid"])) ) 144 $this->verifyErrors[] = "The `parentid` field does not give an existing/acceptable parent id number." 144 $this->verifyErrors[] = "The `parentid` field does not give an existing/acceptable parent id number."; 145 145 146 146 }else 147 $this->verifyErrors[] = "The `roleid` field must be a non-negative number or equivalent to 0." 147 $this->verifyErrors[] = "The `roleid` field must be a non-negative number or equivalent to 0."; 148 148 149 149 }//end if branches/nathan/modules/base/include/notes.php
r437 r439 530 530 //check booleans 531 531 if(isset($variables["completed"])) 532 if($variables["completed"] && $variables["completed"] != =1)532 if($variables["completed"] && $variables["completed"] != 1) 533 533 $this->verifyErrors[] = "The `completed` field must be a boolean (equivalent to 0 or exactly 1)."; 534 534 535 535 if(isset($variables["private"])) 536 if($variables["private"] && $variables["private"] != =1)536 if($variables["private"] && $variables["private"] != 1) 537 537 $this->verifyErrors[] = "The `private` field must be a boolean (equivalent to 0 or exactly 1)."; 538 538 539 539 if(isset($variables["repeating"])) 540 if($variables["repeating"] && $variables["repeating"] != =1)540 if($variables["repeating"] && $variables["repeating"] != 1) 541 541 $this->verifyErrors[] = "The `repeating` field must be a boolean (equivalent to 0 or exactly 1)."; 542 542 branches/nathan/modules/base/include/relationships.php
r437 r439 64 64 $queryresult = $this->db->query($querystatement); 65 65 66 if($this->db->numRow ($queryresult)){66 if($this->db->numRows($queryresult)){ 67 67 while($therecord = $this->db->fetchArray($queryresult)){ 68 68 … … 101 101 102 102 //must be a positive number 103 if( is_numeric($variables["fromtableid" ) && ((int) $variables["fromtableid"]) > 0 ){103 if( is_numeric($variables["fromtableid"]) && ((int) $variables["fromtableid"]) > 0 ){ 104 104 105 105 if(!count($this->availableTabledefIDs)) … … 118 118 119 119 //must be a positive number 120 if( is_numeric($variables["totableid" ) && ((int) $variables["totableid"]) > 0 ){120 if( is_numeric($variables["totableid"]) && ((int) $variables["totableid"]) > 0 ){ 121 121 122 122 if(!count($this->availableTabledefIDs)) … … 132 132 //check boolean 133 133 if(isset($variables["inherit"])) 134 if($variables["inherit"] && $variables["inherit"] != =1)134 if($variables["inherit"] && $variables["inherit"] != 1) 135 135 $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1)."; 136 136 … … 143 143 144 144 if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 145 $this->populate Arrays();145 $this->populateTabledefArrays(); 146 146 147 147 echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; branches/nathan/modules/base/include/reports.php
r437 r439 155 155 156 156 }else 157 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0." 157 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 158 158 159 159 }//end if branches/nathan/modules/base/include/scheduler.php
r437 r439 94 94 //be run. 95 95 if(isset($variables["job"])){ 96 if(!$variables["job"] === "" || $variables["job"] === NULL) )96 if(!$variables["job"] === "" || $variables["job"] === NULL) 97 97 $this->verifyErrors[] = "The `job` field must not be blank."; 98 98 }else … … 103 103 $explode = explode("::", $variables["crontab"]); 104 104 if(count($explode) != 4) 105 $this->verifyErrors[] = "The `crontab` field is not of the proper form. There must be four pairs of '::' in the field's value." 105 $this->verifyErrors[] = "The `crontab` field is not of the proper form. There must be four pairs of '::' in the field's value."; 106 106 }//end if 107 107 branches/nathan/modules/base/include/users.php
r437 r439 40 40 class users extends phpbmsTable{ 41 41 42 var $usedLoginNames = array(); 43 44 function populateLoginNameArray(){ 45 46 $querystatement=" 47 SELECT 48 `login` 49 FROM 50 `users`; 51 "; 52 53 $queryresult = $this->db->query($querystatement); 54 55 if($this->db->numRows($queryresult)){ 56 while($therecord = $this->db->fetchArray($queryresult)){ 57 58 $this->usedLoginNames[] = $therecord["login"]; 59 60 }//end while 61 }else{ 62 //if no valid login names, I put in a value that will 63 //give the arrays a count but not actually match any realistic login names 64 $this->usedLoginNames[] = "THIS is @ ve|2`/ D|_||\/|B |_0GI|\| and stupid too."; 65 }//end if 66 67 }//end method 68 69 42 70 function verifyVariables($variables){ 71 //---------[ check login names ]------------------------------ 72 73 if(isset($variables["login"])){ 74 if( $variables["login"] !== "" || $variables["login"] !== NULL ){ 75 76 if(!count($this->usedLoginNames)) 77 $this->populateLoginNameArray(); 78 79 //check to see new login name is taken 80 if(!in_array($variables["login"], $this->usedLoginNames)) 81 $this->usedLoginNames[] = $variables["login"];//add to name used 82 else 83 $this->verifyErrors[] = "The `login` field must give an unique login name."; 84 85 }else 86 $this->verifyErrors[] = "The `login` field must not be blank."; 87 }else 88 $this->verifyErrors[] = "The `login` field must be set."; 43 89 44 90 //---------[ check booleans ]--------------------------------- 45 91 if(isset($variables["revoked"])) 46 if($variables["revoked"] && $variables["revoked"] != =1)92 if($variables["revoked"] && $variables["revoked"] != 1) 47 93 $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1)."; 48 94 49 95 if(isset($variables["portalaccess"])) 50 if($variables["portalaccess"] && $variables["portalaccess"] != =1)96 if($variables["portalaccess"] && $variables["portalaccess"] != 1) 51 97 $this->verifyErrors[] = "The `portalaccess` field must be a boolean (equivalent to 0 or exactly 1)."; 52 98 53 99 if(isset($variables["admin"])) 54 if($variables["admin"] && $variables["admin"] != =1)100 if($variables["admin"] && $variables["admin"] != 1) 55 101 $this->verifyErrors[] = "The `admin` field must be a boolean (equivalent to 0 or exactly 1)."; 56 102 branches/nathan/modules/base/include/usersearches.php
r437 r439 136 136 if(isset($variables["userid"])){ 137 137 138 if( (is_numeric($variables["userid"]) || !$variables["userid"]) && ((int) $variables["userid"] >= 0) {138 if( (is_numeric($variables["userid"]) || !$variables["userid"]) && ((int) $variables["userid"] >= 0) ){ 139 139 140 140 if(!count($this->availableUserIDs)) … … 160 160 $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition id number."; 161 161 }else 162 $this->verifyErrors[] = "The ` userid` field must be numeric.";162 $this->verifyErrors[] = "The `tabledefid` field must be numeric."; 163 163 }else 164 164 $this->verifyErrors[] = "The `tabledefid` field must be set."; … … 172 172 $this->populateRoleArray(); 173 173 174 if(!in_array(((int)$variables["role "]), $this->availableRoleIDs))174 if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 175 175 $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 176 176 }else 177 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0." 177 $this->verifyErrors[] = "The `roleid` field must be numeric or equivalent to 0."; 178 178 179 179 }//end if branches/nathan/modules/bms/include/addresstorecord.php
r437 r439 146 146 147 147 if($this->db->numRows($queryresult)){ 148 while($therecord = $this->db->fetchArray($queryresult) {148 while($therecord = $this->db->fetchArray($queryresult)){ 149 149 $this->availableTabledefIDs[] = $therecord["id"]; 150 $this->availableTabledefNames[$therecord["id"] = $therecord["maintable"];150 $this->availableTabledefNames[$therecord["id"]] = $therecord["maintable"]; 151 151 }//end while 152 152 }else{ branches/nathan/modules/bms/include/clients.php
r437 r439 292 292 //check bool on has credit 293 293 if(isset($variables["hascredit"])) 294 if($variables["hascredit"] && $variables["hascredit"] != =1)294 if($variables["hascredit"] && $variables["hascredit"] != 1) 295 295 $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1)."; 296 296 … … 972 972 973 973 //if valid, insert, if not, log error and don't insert. 974 if($rowFieldNum == $fieldNum) 975 $theid = $this->table->insertRecord($trimmedRowData); 976 else 974 if($rowFieldNum == $fieldNum){ 975 $verify = $this->table->verifyVariables($trimmedRowData); 976 if(!count($verify["error"])) 977 $theid = $this->table->insertRecord($trimmedRowData); 978 }else 977 979 $this->error .= '<li> incorrect amount of fields for line number '.$rowNum.'.</li>'; 978 980 … … 987 989 988 990 //If it is a sugarcrm import, insert the shipping address as well 991 $addressVerify = array(); 989 992 if($this->importType == "sugarcrm"){ 990 993 … … 1021 1024 $variables["primary"] = 0; 1022 1025 1023 $this->table->address->insertRecord($variables); 1026 $addressVerify = $this->table->address->verifyVariables($variables);//verify address 1027 if(!count($addressVerify["error"]))//check for errors 1028 $this->table->address->insertRecord($variables);//insert if no errors 1024 1029 1025 1030 }//end if … … 1028 1033 }else 1029 1034 $this->error .= '<li> failed insert for line number '.$rowNum.'.</li>'; 1035 foreach($verify["error"] as $error)//log verify errors for display 1036 $this->error .= '<li class="subError">'.$error.'</li>'; 1037 1038 if(isset($addressVerify["error"])) 1039 foreach($addressVerify["error"] as $error)//log address verify errors for display 1040 $this->error .= '<li class="subError">'.$error.'</li>'; 1030 1041 1031 1042 $rowNum++; branches/nathan/modules/bms/include/invoices.php
r437 r439 584 584 //readytopost 585 585 if(isset($variables["readytopost"])) 586 if($variables["readytopost"] && $variables["readytopost"] != =1)586 if($variables["readytopost"] && $variables["readytopost"] != 1) 587 587 $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 588 588 589 589 //weborder 590 590 if(isset($variables["weborder"])) 591 if($variables["weborder"] && $variables["weborder"] != =1)591 if($variables["weborder"] && $variables["weborder"] != 1) 592 592 $this->verifyErrors[] = "The `weborder` field must be a boolean (equivalent to 0 or exactly 1)."; 593 593 594 594 //shiptosameasbilling 595 595 if(isset($variables["shiptosameasbilling"])) 596 if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != =1)596 if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != 1) 597 597 $this->verifyErrors[] = "The `shiptosameasbilling` field must be a boolean (equivalent to 0 or exactly 1)."; 598 598 //check addresss ids branches/nathan/modules/bms/include/invoicestatuses.php
r437 r439 65 65 66 66 if(isset($variables["setreadytopost"])) 67 if($variables["setreadytopost"] && $variables["setreadytopost"] != =1)67 if($variables["setreadytopost"] && $variables["setreadytopost"] != 1) 68 68 $this->verifyErrors[] = "The `setreadytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 69 69 70 70 if(isset($variables["invoicedefault"])) 71 if($variables["invoicedefault"] && $variables["invoicedefault"] != =1)71 if($variables["invoicedefault"] && $variables["invoicedefault"] != 1) 72 72 $this->verifyErrors[] = "The `invoicedefault` field must be a boolean (equivalent to 0 or exactly 1)."; 73 73 branches/nathan/modules/bms/include/products.php
r437 r439 133 133 "; 134 134 135 $queryresult = $this->db->query($querystatement) 135 $queryresult = $this->db->query($querystatement); 136 136 137 137 if($this->db->numRows($queryresult)){ … … 179 179 //can't have this partnumber already chosen 180 180 if( !in_array($variables["partnumber"], $this->availablePartNumbers) ) 181 $this-> verifyErrors[] = "The `partnumber` field does not give an existing/acceptable part number.";181 $this->availablePartNumbers[] = $variables["partnumber"];//add new partnumber for future reference 182 182 else 183 $this-> availablePartNumbers[] = $variables["partnumber"];//add new partnumber for future reference183 $this->verifyErrors[] = "The `partnumber` field must give an unique part number."; 184 184 185 185 }else … … 249 249 //check boolean 250 250 if(isset($variables["isoversized"])) 251 if($variables["isoversized"] && $variables["isoversized"] != =1)251 if($variables["isoversized"] && $variables["isoversized"] != 1) 252 252 $this->verifyErrors[] = "The `isoversized` field must be a boolean (equivalent to 0 or exactly 1)."; 253 253 254 254 if(isset($variables["isprepackaged"])) 255 if($variables["isprepackaged"] && $variables["isprepackaged"] != =1)255 if($variables["isprepackaged"] && $variables["isprepackaged"] != 1) 256 256 $this->verifyErrors[] = "The `isprepackaged` field must be a boolean (equivalent to 0 or exactly 1)."; 257 257 258 258 if(isset($variables["taxable"])) 259 if($variables["taxable"] && $variables["taxable"] != =1)259 if($variables["taxable"] && $variables["taxable"] != 1) 260 260 $this->verifyErrors[] = "The `taxable` field must be a boolean (equivalent to 0 or exactly 1)."; 261 261 branches/nathan/modules/bms/include/receipts.php
r437 r439 281 281 $queryresult = $this->db->query($querystatement); 282 282 283 if($this->db->numRows 9$queryresult){283 if($this->db->numRows($queryresult)){ 284 284 while($therecord = $this->db->fetchArray($queryresult)) 285 285 $this->availableClientIDs[] = $therecord["id"]; … … 317 317 if(isset($variables["clientid"])){ 318 318 319 if(is_numeric($variables["clientid"]) && ((int) $variables["clientid" ) > 0){319 if(is_numeric($variables["clientid"]) && ((int) $variables["clientid"]) > 0){ 320 320 321 321 if(!count($this->availableClientIDs)) … … 345 345 }//end switch 346 346 }else <