phpBMS

Changeset 384 for trunk/phpbms/include

Show
Ignore:
Timestamp:
05/04/08 17:18:08 (4 years ago)
Author:
brieb
Message:

Pre v0.96 check in:

  • Added support for multiple addresses
  • Added link to google maps for addresses on client and sales order screens.
  • Added obfuscation ability to sensitive payment information when voiding/deleting or posting receipts and sales orders.
  • Replaced autofill fields with new smartsearch technologies
  • Fixed recurring invoice bug
  • Switched several sales order AJAX calls to use JSON
  • Reorganized quickView screens

Left to do:

  • Finish BMS update/install scripts with address and addressto record tabledef/table support information
  • Re-code delete prospect code
  • Finish BMS update/install scripts with new client/client dup tabledef/table support information.
Location:
trunk/phpbms/include
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/include/common_functions.php

    r370 r384  
    4747        var $topJS = array(); 
    4848        var $bottomJS = array(); 
    49          
    50         var $onload = ""; 
    51          
     49        var $onload = array(); 
     50                 
    5251        var $showFooter = true; 
    5352        var $showMenu = true; 
     
    8483                }//endid 
    8584        }//end method 
     85 
    8686         
    8787        function getModules(){ 
     
    579579                case "noencoding": 
    580580                        $value=$value; 
    581                 break; 
     581                        break; 
     582                 
     583                 
     584                case "bbcode": 
     585                        $value=htmlQuotes($value); 
     586                                                 
     587                        // This list needs to be expanded 
     588                        $bbcodelist["[b]"] = "<strong>"; 
     589                        $bbcodelist["[/b]"] = "</strong>"; 
     590                        $bbcodelist["[br]"] = "<br />"; 
     591                        $bbcodelist["[space]"] = "&nbsp;"; 
     592                         
     593                        foreach($bbcodelist as $bbcode => $translation) 
     594                                $value = str_replace($bbcode, $translation, $value); 
     595                                                         
     596                        break; 
     597                         
    582598                default: 
    583599                        $value=htmlQuotes($value); 
  • trunk/phpbms/include/fields.php

    r308 r384  
    5555        var $fields = array(); 
    5656         
     57        var $onload = array(); 
    5758         
    5859        function phpbmsForm($action = NULL, $method="post", $name="record", $onsubmit="return validateForm(this);", $dontSubmit = true){ 
     
    145146                $phpbms->topJS = array_merge($this->topJS,$phpbms->topJS); 
    146147                $phpbms->bottomJS = array_merge($this->bottomJS,$phpbms->bottomJS); 
     148                $phpbms->onload = array_merge($this->onload,$phpbms->onload); 
    147149                 
    148150                //next we go through the list of fields 
    149151                foreach($this->fields as $field){ 
     152 
    150153                        $toAdd = $field->getJSMods(); 
    151154                         
     
    156159                        $phpbms->topJS = array_merge($phpbms->topJS,$toAdd["topJS"]); 
    157160                        $phpbms->bottomJS = array_merge($phpbms->bottomJS,$toAdd["bottomJS"]);                   
    158                 } 
    159         } 
    160 } 
     161                        $phpbms->onload = array_merge($phpbms->onload,$toAdd["onload"]);                         
     162 
     163                }//endforeach 
     164                 
     165        }//end method - jsMerge 
     166}//end class 
    161167 
    162168 
     
    244250         
    245251        function getJSMods(){ 
    246                 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array()); 
     252                $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array(), "onload" => array()); 
    247253                 
    248254                foreach($this->jsIncludes as $theinclude) 
     
    709715 
    710716 
    711 //============================================================================================ 
    712 class inputAutofill extends inputField{ 
     717class inputSmartSearch extends inputField{ 
     718 
    713719/* 
    714            initialvalue =       Value for get field (usually and id) 
    715            tabledefid =                 id of table to pull information from 
    716            getfield =           Field to match value from 
    717            displayfield =       Field to display 
    718            extrafield =         Extra table information to display on drop down 
    719            whereclause =        SQL where clause (without WHERE) narrowing search lookup 
    720            blankout =           Wether to blank out invlaid entries 
     720                *db =                   (dbObj)         Database Object 
     721                *id =                   (string)        name of hidden field to be created 
     722                *searchName =   (string)        unique name of a stored search 
     723                initialvalue =  (var)           initial value for field (blank) 
     724                displayName =   (string)        Name to display (uses id by default) 
     725                displayName =   (string)        Name to display (uses id by default) 
     726                size =                  (int)           size attribute for displayed input tag (32) 
     727                maxlength =             (int)           max length attribute for displayed input tag (255) 
     728                displayLabel    (boolean)       Show label tag with displayName (true) 
     729                 
     730                The JS used by this field type requires that the field NOT be implemented inside a p tag,   
     731                inline element, or any tag that should not contain a div tag.  In IE, if the field placed  
     732                inside an element that should not be able to handle a DIV tag inside it (standards-wise),  
     733                IE will report a Javascript error. 
    721734*/ 
    722         function inputAutofill($db, $id, $initialvalue, $tabledefid, $getfield, $displayfield,  
    723                                                                                 $extrafield="", $whereclause="", $displayName = NULL, $required=false,  
    724                                                                                 $blankout=true, $displayLabel = true)  { 
    725                 $size = 32; 
    726                 $maxlength = 128; 
     735        function inputSmartSearch($db, $id, $searchName, $initialvalue = "", $displayName = NULL, $required=false,  
     736                                                                                $size = 32, $maxlength = 255, $displayLabel = true)  { 
     737                $this->db = $db; 
    727738                 
    728739                parent::inputField($id, $initialvalue, $displayName,$required, NULL, $size, $maxlength, $displayLabel); 
    729                  
    730                 $this->db = $db; 
    731                  
    732                 $this->tabledefid = $tabledefid; 
    733                 $this->getfield = $getfield; 
    734                 $this->displayfield = $displayfield; 
    735                 $this->extrafield = $extrafield; 
    736                 $this->whereclause = $whereclause; 
    737                  
    738                 $this->blankout = $blankout; 
    739                  
    740                 //First let's grab the Table information 
    741                 $querystatement = "SELECT maintable,querytable from tabledefs where id=".$tabledefid;    
     740 
     741                $this->searchName = $searchName; 
     742 
     743                //next I need to initialize and do the correct search 
     744                $this->searchInfo = $this->getSearchInfo($searchName); 
     745                 
     746                $this->displayValue = $this->getInitialDisplay(); 
     747 
     748        }//end method - init 
     749 
     750 
     751        function getSearchInfo($searchInfo){ 
     752         
     753                $querystatement = " 
     754                        SELECT 
     755                                * 
     756                        FROM 
     757                                smartsearches 
     758                        WHERE 
     759                                name = '".mysql_real_escape_string($searchInfo)."' 
     760                "; 
     761                 
     762                return  $this->db->fetchArray($this->db->query($querystatement)); 
     763 
     764        }//end method getInfo 
     765         
     766        function getInitialDisplay(){ 
     767         
     768                $querystatement = " 
     769                        SELECT 
     770                                ".$this->searchInfo["displayfield"]." AS display 
     771                        FROM 
     772                                ".$this->searchInfo["fromclause"]." 
     773                        WHERE 
     774                                ".$this->searchInfo["valuefield"]." = '".mysql_real_escape_string($this->value)."' 
     775                "; 
     776                 
    742777                $queryresult = $this->db->query($querystatement); 
    743                 $tableinfo = $this->db->fetchArray($queryresult); 
    744  
    745                 $querystatement = "SELECT ".$displayfield." AS display FROM ".$tableinfo["maintable"]." WHERE ".$getfield."=\"".$initialvalue."\" LIMIT 1;"; 
    746                 $queryresult = $this->db->query($querystatement); 
    747  
    748                 if($this->db->numRows($queryresult)) 
    749                         $displayresult = $this->db->fetchArray($queryresult); 
    750                 else 
    751                         $displayresult["display"]=""; 
    752                  
    753                 $this->displayValue = $displayresult["display"]; 
    754                  
    755         }//end method 
    756          
    757          
     778 
     779                if($this->db->numRows($queryresult)){ 
     780 
     781                        $therecord = $this->db->fetchArray($queryresult); 
     782                        return $therecord["display"]; 
     783                         
     784                } else 
     785                        return ''; 
     786         
     787        }//end method getInitialDisplay 
     788 
     789 
     790        // CLASS OVERIDES ================================================ 
    758791        function getJSMods(){ 
    759                 $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array()); 
    760                  
    761                 $thereturn["jsIncludes"][] = "common/javascript/autofill.js"; 
     792         
     793                $thereturn = array("jsIncludes" => array(), "topJS" => array(), "bottomJS" => array(), "onload" => array()); 
     794                 
     795                $thereturn["jsIncludes"][] = "common/javascript/smartsearch.js"; 
    762796 
    763797                if($this->required){ 
     798                 
    764799                        $message = $this->message; 
     800                         
    765801                        if($message == "") 
    766802                                $message = $this->displayName." cannot be blank."; 
    767                         $thereturn["topJS"][] = "requiredArray[requiredArray.length]=new Array(\"".$this->name."\",\"".$message."\");"; 
    768                 } 
    769                  
    770                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"] = new Array();'; 
    771                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["ch"] = "";'; 
    772                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["uh"] = "";'; 
    773                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["fl"] = "'.urlencode(stripslashes($this->displayfield)).'"'; 
    774                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["xt"] = "'.urlencode(stripslashes($this->extrafield)).'"'; 
    775                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["td"] = '.urlencode(stripslashes($this->tabledefid)).';'; 
    776                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["gf"] = "'.urlencode(stripslashes($this->getfield)).'"'; 
    777                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["wc"] = "'.urlencode(stripslashes($this->whereclause)).'"'; 
    778                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["bo"] = '.(($this->blankout) ? 'true' : 'false').''; 
    779                 $thereturn["topJS"][] = 'autofill["'.$this->id.'"]["vl"] = "'.htmlQuotes($this->displayValue).'"'; 
    780                 $thereturn["topJS"][] = 'appPath = "'.APP_PATH.'"'; 
    781  
    782                 $thereturn["bottomJS"][] = 'var display=getObjectFromID("ds-'.$this->id.'");'; 
    783                 $thereturn["bottomJS"][] = 'display.autocomplete="off";';                                                                
     803                        $thereturn["topJS"][] = "requiredArray[requiredArray.length]= [ '".$this->name."','".$message."' ];"; 
     804                         
     805                }//endif - required 
     806                 
     807                return $thereturn; 
    784808                                 
    785                 return $thereturn; 
    786         }//end if 
    787  
     809        }//end method - getJSMods 
     810         
    788811 
    789812        function showLabel(){ 
    790813                ?><label for="ds-<?php echo $this->id?>"><?php echo $this->displayName?></label><br /><?php 
    791         } 
     814        }//end method 
    792815 
    793816         
     
    802825                        $this->_attributes["class"] = " ".$this->_attributes["class"]; 
    803826                 
    804                 $this->_attributes["class"] = "autofillField".$this->_attributes["class"]; 
    805  
    806                          
     827                $this->_attributes["class"] = "inputSmartSearch".$this->_attributes["class"]; 
     828 
    807829                ?><input type="hidden" name="<?php echo $this->id?>" id="<?php echo $this->id?>" value="<?php echo $this->value?>" /> 
    808                         <input type="text" name="ds-<?php echo $this->id?>" id="ds-<?php echo $this->id?>"  title="Use % for wildcard searches." <?php  
    809                          
    810                         $this->displayAttributes(); 
    811                  
    812                         ?> value="<?php echo htmlQuotes($this->displayValue) ?>" onkeyup="autofillChange(this);return true;" onblur="setTimeout('blurAutofill(\'<?php echo $this->id ?>\')', 50)"  onkeydown="captureKey(event)" /> 
    813                         <?php  
    814                  
    815         }//end method                    
    816  
    817          
    818 }//end class 
    819  
     830                <input type="hidden" id="sdbid-<?php echo $this->id?>" value="<?php echo $this->searchInfo["id"]?>"/> 
     831                <input type="text" name="ds-<?php echo $this->id?>" id="ds-<?php echo $this->id?>"  title="Use % for wildcard searches." <?php  
     832                         
     833                $this->displayAttributes(); 
     834                 
     835                ?> value="<?php echo htmlQuotes($this->displayValue) ?>"/><?php  
     836 
     837        }//end method -display 
     838                 
     839}//end class - inputSmartSearch 
    820840?> 
  • trunk/phpbms/include/session.php

    r356 r384  
    248248                                                        $value=substr($value,$startpos+1,$endpos-$startpos-1); 
    249249                                                if(strpos($key,"mysql_")===0){ 
    250                                                         define(strtoupper($key),$value);                                                         
     250                                                        define(strtoupper($key),$value); 
    251251                                                } 
    252252                                        } 
     
    324324                                if(!defined(strtoupper($therecord["name"]))) 
    325325                                        define(strtoupper($therecord["name"]),$therecord["value"]); 
    326                                          
    327326                        }//end while 
    328327 
     
    350349                // This is in a function in case we want to do sessions differently in the future                
    351350                 
    352                 session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v08ID"); 
     351                session_name("phpBMS".preg_replace('/\W/',"",APPLICATION_NAME)."v096ID"); 
    353352                session_start(); 
    354353        } 
  • trunk/phpbms/include/tables.php

    r359 r384  
    303303                 
    304304                $updatestatement .= " WHERE `id`=".((int) $variables["id"]); 
    305                                  
     305 
    306306                $updateresult = $this->db->query($updatestatement); 
    307307                 
     
    310310         
    311311         
    312         function insertRecord($variables,$createdby = NULL){ 
     312        function insertRecord($variables,$createdby = NULL, $overrideID = false){ 
    313313         
    314314                if($createdby === NULL) 
     
    327327                                switch($fieldname){ 
    328328                                        case "id": 
    329                                         break; 
     329                                                if(isset($variables["id"])) 
     330                                                        if($overrideID && $variables["id"]){ 
     331                                                                $fieldlist .= "id, "; 
     332                                                                $insertvalues .= ((int) $variables["id"]).", "; 
     333                                                        }//endif 
     334                                                break; 
    330335                                         
    331336                                        case "createdby": 
     
    333338                                                $fieldlist .= $fieldname.", ";                                   
    334339                                                $insertvalues .= ((int) $createdby).", "; 
    335                                         break; 
     340                                                break; 
    336341         
    337342                                        case "creationdate": 
     
    339344                                                $fieldlist .= $fieldname.", "; 
    340345                                                $insertvalues .= "NOW(), "; 
    341                                         break; 
     346                                                break; 
    342347                                         
    343348                                        default: 
     
    348353                                                        $fieldlist .= "`".$fieldname."`, "; 
    349354                                                        $insertvalues .= $this->prepareFieldForSQL($variables[$fieldname],$thefield["type"],$thefield["flags"]).", "; 
    350                                                 } 
    351                                         break; 
     355                                                }//endif - fieldname 
     356                                                break; 
    352357                                }//end switch field name 
    353358                        }//end if 
     
    357362 
    358363                $insertstatement = "INSERT INTO ".$this->maintable." (".$fieldlist.") VALUES (".$insertvalues.")"; 
    359  
    360364                $insertresult = $this->db->query($insertstatement); 
    361365                 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.