navigation  interaction  search

 other resources

Changeset 439

Show
Ignore:
Timestamp:
10/30/08 15:26:37
Author:
nate
Message:
  • for nathan branch:
  • bug fixes
  • incorporated recent change to trunk
  • made import files for tables that use [tablename].php files with verification funcitons.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/nathan/include/imports.php

    r437 r439  
    465465                        }//end method --startForm-- 
    466466                         
    467                         function showButtons($ids = 1, $pageType = "main"){ 
     467                        function showButtons($ids = 1, $pageType = "main", $numberOfRecords = 0){ 
    468468                                ?> 
    469469                                <div class="importCancels"> 
     
    472472                                        <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)" /> 
    473473                                        <?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"') ?>/> 
    475475                                        <input type="submit" class="Buttons" value="cancel" name="command" id="cancelButton<?php echo $ids?>" title="rollback"/> 
    476476                                        <?php }//end if ?> 
  • branches/nathan/include/tables.php

    r437 r439  
    277277                         
    278278                        if(isset($variables["inactive"])) 
    279                                 if($variables["inactive"] && $variables["inactive"] !== 1) 
     279                                if($variables["inactive"] && $variables["inactive"] != 1) 
    280280                                        $this->verifyErrors[] = "The `inactive` field must be a boolean (equivalent to 0 or exactly 1)."; 
    281281                         
    282282                        if(isset($variables["webenabled"])) 
    283                                 if($variables["webenabled"] && $variables["webenabled"] !== 1) 
     283                                if($variables["webenabled"] && $variables["webenabled"] != 1) 
    284284                                        $this->verifyErrors[] = "The `webenabled` field must be a boolean (equivalent to 0 or exactly 1)."; 
    285285                         
  • branches/nathan/modules/base/general_import.php

    r432 r439  
    4949 
    5050 
    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"]; 
    5452 
    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"]); 
    6753         
    6854 
     
    7662        // like this 
    7763         
    78         //              $thetable = new [tablename]($db,[table definition id],$backurl); 
     64        //              $thetable = new [tablename]($db,[table definition id]); 
    7965        //              $import = new [importname]($thetable); 
    8066         
     
    126112                // you can set those form properties here. 
    127113                 
    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); 
    145114 
    146115                // lastly, use the jsMerge method to create the final Javascript formatting 
     
    219188                //Last, we show the create/modifiy with the bottom save and cancel buttons 
    220189                // and then close the form. 
    221                 $theform->showButtons(2, $import->pageType); 
     190                $theform->showButtons(2, $import->pageType, count($import->transactionRecords)); 
    222191                ?></div><?php 
    223192                $theform->endForm(); 
  • branches/nathan/modules/base/include/files.php

    r437 r439  
    9595                                        //equivalent to 0) is an acceptable role id. 
    9696                                        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."; 
    9898                                }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."; 
    100100                        }//end if 
    101101                         
     
    107107                function prepareVariables($variables){ 
    108108         
    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 
    119120                         
    120121                        return $variables;                       
  • branches/nathan/modules/base/include/menu.php

    r437 r439  
    120120                                        //check to see if the int typecast role id is in one of the available ones 
    121121                                        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."; 
    123123                                }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."; 
    125125                                 
    126126                        }//end if 
     
    142142                                        //Select run every time because `id` can be different 
    143143                                        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."; 
    145145                                         
    146146                                }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."; 
    148148                                 
    149149                        }//end if 
  • branches/nathan/modules/base/include/notes.php

    r437 r439  
    530530                        //check booleans 
    531531                        if(isset($variables["completed"])) 
    532                                 if($variables["completed"] && $variables["completed"] !== 1) 
     532                                if($variables["completed"] && $variables["completed"] != 1) 
    533533                                        $this->verifyErrors[] = "The `completed` field must be a boolean (equivalent to 0 or exactly 1)."; 
    534534                         
    535535                        if(isset($variables["private"])) 
    536                                 if($variables["private"] && $variables["private"] !== 1) 
     536                                if($variables["private"] && $variables["private"] != 1) 
    537537                                        $this->verifyErrors[] = "The `private` field must be a boolean (equivalent to 0 or exactly 1)."; 
    538538                         
    539539                        if(isset($variables["repeating"])) 
    540                                 if($variables["repeating"] && $variables["repeating"] !== 1) 
     540                                if($variables["repeating"] && $variables["repeating"] != 1) 
    541541                                        $this->verifyErrors[] = "The `repeating` field must be a boolean (equivalent to 0 or exactly 1)."; 
    542542                         
  • branches/nathan/modules/base/include/relationships.php

    r437 r439  
    6464                        $queryresult = $this->db->query($querystatement); 
    6565                         
    66                         if($this->db->numRow($queryresult)){ 
     66                        if($this->db->numRows($queryresult)){ 
    6767                                while($therecord = $this->db->fetchArray($queryresult)){ 
    6868                                         
     
    101101                                 
    102102                                //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 ){ 
    104104                                         
    105105                                        if(!count($this->availableTabledefIDs)) 
     
    118118                                 
    119119                                //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 ){ 
    121121                                 
    122122                                        if(!count($this->availableTabledefIDs)) 
     
    132132                        //check boolean 
    133133                        if(isset($variables["inherit"])) 
    134                                 if($variables["inherit"] && $variables["inherit"] !== 1) 
     134                                if($variables["inherit"] && $variables["inherit"] != 1) 
    135135                                        $this->verifyErrors[] = "The `inherit` field must be a boolean (equivalent to 0 or exactly 1)."; 
    136136                         
     
    143143                         
    144144                        if(!count($this->availableTabledefIDs) || !count($this->availableTabledefNames)) 
    145                                 $this->populateArrays(); 
     145                                $this->populateTabledefArrays(); 
    146146                         
    147147                        echo "<select id=\"".$fieldname."\" name=\"".$fieldname."\">\n"; 
  • branches/nathan/modules/base/include/reports.php

    r437 r439  
    155155                                         
    156156                                }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."; 
    158158                                 
    159159                        }//end if 
  • branches/nathan/modules/base/include/scheduler.php

    r437 r439  
    9494                        //be run. 
    9595                        if(isset($variables["job"])){ 
    96                                 if(!$variables["job"] === "" || $variables["job"] === NULL) ) 
     96                                if(!$variables["job"] === "" || $variables["job"] === NULL) 
    9797                                        $this->verifyErrors[] = "The `job` field must not be blank."; 
    9898                        }else 
     
    103103                                $explode = explode("::", $variables["crontab"]); 
    104104                                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."; 
    106106                        }//end if 
    107107                         
  • branches/nathan/modules/base/include/users.php

    r437 r439  
    4040        class users extends phpbmsTable{ 
    4141                 
     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                 
    4270                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."; 
    4389                         
    4490                        //---------[ check booleans ]--------------------------------- 
    4591                        if(isset($variables["revoked"])) 
    46                                 if($variables["revoked"] && $variables["revoked"] !== 1) 
     92                                if($variables["revoked"] && $variables["revoked"] != 1) 
    4793                                        $this->verifyErrors[] = "The `revoked` field must be a boolean (equivalent to 0 or exactly 1)."; 
    4894                         
    4995                        if(isset($variables["portalaccess"])) 
    50                                 if($variables["portalaccess"] && $variables["portalaccess"] !== 1) 
     96                                if($variables["portalaccess"] && $variables["portalaccess"] != 1) 
    5197                                        $this->verifyErrors[] = "The `portalaccess` field must be a boolean (equivalent to 0 or exactly 1)."; 
    5298                         
    5399                        if(isset($variables["admin"])) 
    54                                 if($variables["admin"] && $variables["admin"] !== 1) 
     100                                if($variables["admin"] && $variables["admin"] != 1) 
    55101                                        $this->verifyErrors[] = "The `admin` field must be a boolean (equivalent to 0 or exactly 1)."; 
    56102                         
  • branches/nathan/modules/base/include/usersearches.php

    r437 r439  
    136136                        if(isset($variables["userid"])){ 
    137137                                 
    138                                 if( (is_numeric($variables["userid"]) || !$variables["userid"]) && ((int) $variables["userid"] >= 0)
     138                                if( (is_numeric($variables["userid"]) || !$variables["userid"]) && ((int) $variables["userid"] >= 0) )
    139139                                         
    140140                                        if(!count($this->availableUserIDs)) 
     
    160160                                                $this->verifyErrors[] = "The `tabledefid` field does not give an existing/acceptable table definition id number."; 
    161161                                }else 
    162                                         $this->verifyErrors[] = "The `userid` field must be numeric."; 
     162                                        $this->verifyErrors[] = "The `tabledefid` field must be numeric."; 
    163163                        }else 
    164164                                $this->verifyErrors[] = "The `tabledefid` field must be set."; 
     
    172172                                                $this->populateRoleArray(); 
    173173                                         
    174                                         if(!in_array(((int)$variables["role"]), $this->availableRoleIDs)) 
     174                                        if(!in_array(((int)$variables["roleid"]), $this->availableRoleIDs)) 
    175175                                                $this->verifyErrors[] = "The `roleid` field does not give an existing/acceptable role id number."; 
    176176                                }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."; 
    178178                                 
    179179                        }//end if 
  • branches/nathan/modules/bms/include/addresstorecord.php

    r437 r439  
    146146                         
    147147                        if($this->db->numRows($queryresult)){ 
    148                                 while($therecord = $this->db->fetchArray($queryresult)
     148                                while($therecord = $this->db->fetchArray($queryresult))
    149149                                        $this->availableTabledefIDs[] = $therecord["id"]; 
    150                                         $this->availableTabledefNames[$therecord["id"] = $therecord["maintable"]; 
     150                                        $this->availableTabledefNames[$therecord["id"]] = $therecord["maintable"]; 
    151151                                }//end while 
    152152                        }else{ 
  • branches/nathan/modules/bms/include/clients.php

    r437 r439  
    292292                        //check bool on has credit 
    293293                        if(isset($variables["hascredit"])) 
    294                                 if($variables["hascredit"] && $variables["hascredit"] !== 1) 
     294                                if($variables["hascredit"] && $variables["hascredit"] != 1) 
    295295                                        $this->verifyErrors[] = "The `hascredit` field must be a boolean (equivalent to 0 or exactly 1)."; 
    296296                         
     
    972972                                                 
    973973                                                //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 
    977979                                                        $this->error .= '<li> incorrect amount of fields for line number '.$rowNum.'.</li>'; 
    978980                                                 
     
    987989                                                         
    988990                                                        //If it is a sugarcrm import, insert the shipping address as well 
     991                                                        $addressVerify = array(); 
    989992                                                        if($this->importType == "sugarcrm"){ 
    990993                                                                 
     
    10211024                                                                        $variables["primary"] = 0; 
    10221025                                                                         
    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 
    10241029                                                                         
    10251030                                                                }//end if 
     
    10281033                                                }else 
    10291034                                                        $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>'; 
    10301041                                                 
    10311042                                                $rowNum++; 
  • branches/nathan/modules/bms/include/invoices.php

    r437 r439  
    584584                                //readytopost 
    585585                                if(isset($variables["readytopost"])) 
    586                                         if($variables["readytopost"] && $variables["readytopost"] !== 1) 
     586                                        if($variables["readytopost"] && $variables["readytopost"] != 1) 
    587587                                                $this->verifyErrors[] = "The `readytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 
    588588                                                 
    589589                                //weborder 
    590590                                if(isset($variables["weborder"])) 
    591                                         if($variables["weborder"] && $variables["weborder"] !== 1) 
     591                                        if($variables["weborder"] && $variables["weborder"] != 1) 
    592592                                                $this->verifyErrors[] = "The `weborder` field must be a boolean (equivalent to 0 or exactly 1)."; 
    593593                                                 
    594594                                //shiptosameasbilling 
    595595                                if(isset($variables["shiptosameasbilling"])) 
    596                                         if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] !== 1) 
     596                                        if($variables["shiptosameasbilling"] && $variables["shiptosameasbilling"] != 1) 
    597597                                                $this->verifyErrors[] = "The `shiptosameasbilling` field must be a boolean (equivalent to 0 or exactly 1)."; 
    598598                        //check addresss ids 
  • branches/nathan/modules/bms/include/invoicestatuses.php

    r437 r439  
    6565                         
    6666                        if(isset($variables["setreadytopost"])) 
    67                                 if($variables["setreadytopost"] && $variables["setreadytopost"] !== 1) 
     67                                if($variables["setreadytopost"] && $variables["setreadytopost"] != 1) 
    6868                                        $this->verifyErrors[] = "The `setreadytopost` field must be a boolean (equivalent to 0 or exactly 1)."; 
    6969                         
    7070                        if(isset($variables["invoicedefault"])) 
    71                                 if($variables["invoicedefault"] && $variables["invoicedefault"] !== 1) 
     71                                if($variables["invoicedefault"] && $variables["invoicedefault"] != 1) 
    7272                                        $this->verifyErrors[] = "The `invoicedefault` field must be a boolean (equivalent to 0 or exactly 1)."; 
    7373                         
  • branches/nathan/modules/bms/include/products.php

    r437 r439  
    133133                                "; 
    134134                         
    135                         $queryresult = $this->db->query($querystatement) 
     135                        $queryresult = $this->db->query($querystatement); 
    136136                         
    137137                        if($this->db->numRows($queryresult)){ 
     
    179179                                        //can't have this partnumber already chosen 
    180180                                        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 
    182182                                        else 
    183                                                 $this->availablePartNumbers[] = $variables["partnumber"];//add new partnumber for future reference 
     183                                                $this->verifyErrors[] = "The `partnumber` field must give an unique part number."; 
    184184                                         
    185185                                }else 
     
    249249                        //check boolean 
    250250                        if(isset($variables["isoversized"])) 
    251                                 if($variables["isoversized"] && $variables["isoversized"] !==1) 
     251                                if($variables["isoversized"] && $variables["isoversized"] != 1) 
    252252                                        $this->verifyErrors[] = "The `isoversized` field must be a boolean (equivalent to 0 or exactly 1)."; 
    253253                         
    254254                        if(isset($variables["isprepackaged"])) 
    255                                 if($variables["isprepackaged"] && $variables["isprepackaged"] !==1) 
     255                                if($variables["isprepackaged"] && $variables["isprepackaged"] != 1) 
    256256                                        $this->verifyErrors[] = "The `isprepackaged` field must be a boolean (equivalent to 0 or exactly 1)."; 
    257257                         
    258258                        if(isset($variables["taxable"])) 
    259                                 if($variables["taxable"] && $variables["taxable"] !==1) 
     259                                if($variables["taxable"] && $variables["taxable"] != 1) 
    260260                                        $this->verifyErrors[] = "The `taxable` field must be a boolean (equivalent to 0 or exactly 1)."; 
    261261                         
  • branches/nathan/modules/bms/include/receipts.php

    <
    r437 r439  
    281281                        $queryresult = $this->db->query($querystatement); 
    282282                         
    283                         if($this->db->numRows9$queryresult){ 
     283                        if($this->db->numRows($queryresult)){ 
    284284                                while($therecord = $this->db->fetchArray($queryresult)) 
    285285                                        $this->availableClientIDs[] = $therecord["id"]; 
     
    317317                        if(isset($variables["clientid"])){ 
    318318                                 
    319                                 if(is_numeric($variables["clientid"]) && ((int) $variables["clientid") > 0){ 
     319                                if(is_numeric($variables["clientid"]) && ((int) $variables["clientid"]) > 0){ 
    320320                                         
    321321                                        if(!count($this->availableClientIDs)) 
     
    345345                                }//end switch 
    346346                        }else