Changeset 720 for trunk/phpbms
- Timestamp:
- 01/06/10 17:04:26 (2 years ago)
- Location:
- trunk/phpbms
- Files:
-
- 6 modified
-
checkunique.php (modified) (1 diff)
-
common/javascript/fields.js (modified) (1 diff)
-
include/search_class.php (modified) (1 diff)
-
modules/bms/include/invoices.php (modified) (4 diffs)
-
modules/bms/javascript/product.js (modified) (1 diff)
-
search.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/checkunique.php
r702 r720 37 37 +-------------------------------------------------------------------------+ 38 38 */ 39 require ("include/session.php");40 39 41 function isUnique($tablename,$column,$value,$excludeid,$db){ 42 43 $thereturn=false; 44 45 $querystatement="SELECT count(id) AS thecount FROM ".$tablename." WHERE ".$column."=\"".$value."\" AND id!=".$excludeid; 46 $queryresult=$db->query($querystatement); 47 if($queryresult){ 48 $therecord=$db->fetchArray($queryresult); 49 if($therecord["thecount"]==0) 50 $thereturn=true; 51 } 52 53 return $thereturn; 54 } 55 56 57 $isunique=false; 58 59 if(isset($_GET["tdid"]) && isset($_GET["c"]) && isset($_GET["val"]) && isset($_GET["xid"])) { 60 $_GET["tdid"]=((int) $_GET["tdid"]); 61 $_GET["xid"]=((int) $_GET["xid"]); 62 63 $querystatement="SELECT maintable FROM tabledefs WHERE id=".$_GET["tdid"]; 64 $queryresult=$db->query($querystatement); 65 if($queryresult) 66 if($therecord=$db->fetchArray($queryresult)) 67 $isunique=isUnique($therecord["maintable"],$_GET["c"],$_GET["val"],$_GET["xid"],$db); 68 } 69 70 header('Content-Type: text/xml'); 71 echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; 72 ?> 73 <response> 74 <isunique><?php echo ((int) $isunique) ?></isunique> 75 </response> 40 41 class uniqueChecker{ 42 43 var $db; 44 45 function uniqueChecker($db){ 46 47 $this->db = $db; 48 $this->db->errorFormat = "json"; 49 50 }//end function init 51 52 53 function check($tabledefuuid, $columname, $value, $excludeid = NULL){ 54 55 $querystatement = " 56 SELECT 57 `maintable` 58 FROM 59 `tabledefs` 60 WHERE 61 `uuid` = '".mysql_real_escape_string($tabledefuuid)."'"; 62 63 $queryresult = $this->db->query($querystatement); 64 65 if($this->db->numRows($queryresult) === 0) 66 return "error"; 67 68 $therecord = $this->db->fetchArray($queryresult); 69 70 $table = $therecord["maintable"]; 71 72 $columname = mysql_real_escape_string(str_replace("`","", $columname)); 73 $value = mysql_real_escape_string($value); 74 75 $querystatement = " 76 SELECT 77 count(id) AS thecount 78 FROM 79 `".$table."` 80 WHERE 81 `".$columname."` = '".$value."'"; 82 83 if($excludeid){ 84 85 $querystatement .= " AND `uuid` != '".mysql_real_escape_string($excludeid)."'"; 86 87 }//endif 88 89 $queryresult = $this->db->query($querystatement); 90 91 $therecord = $this->db->fetchArray($queryresult); 92 93 return ($therecord["thecount"] == 0); 94 95 }//end function check 96 97 }//end class 98 99 100 /** 101 * PROCESSING ================================================================== 102 */ 103 if(!isset($noOutput)){ 104 105 require_once("include/session.php"); 106 107 if(!isset($_GET["tduuid"]) || !isset($_GET["cname"]) || !isset($_GET["value"])) 108 $error = new appError(200, "passed parameters not set"); 109 110 if(!isset($_GET["xuuid"])) 111 $_GET["xuuid"] = ""; 112 113 $checker = new uniqueChecker($db); 114 115 echo json_encode($checker->check($_GET["tduuid"], $_GET["cname"], $_GET["value"], $_GET["xuuid"])); 116 117 }//endif -
trunk/phpbms/common/javascript/fields.js
r703 r720 237 237 } 238 238 239 function checkUnique(tabledef id,column,checkvalue,excludeid){240 241 var theurl= APP_PATH+"checkunique.php?tdid="+parseInt(tabledefid);242 theurl=theurl+"&c="+encodeURIComponent(column); 243 theurl=theurl+"& val="+encodeURIComponent(checkvalue);244 theurl=theurl+"& xid="+parseInt(excludeid);245 239 function checkUnique(tabledefuuid , columnName, value, excludeuuid){ 240 241 var theurl= APP_PATH + "checkunique.php?tduuid=" + encodeURIComponent(tabledefuuid); 242 243 theurl=theurl+"&cname="+encodeURIComponent(columnName); 244 theurl=theurl+"&value="+encodeURIComponent(value); 245 theurl=theurl+"&xuuid="+encodeURIComponent(excludeuuid); 246 246 247 247 loadXMLDoc(theurl,null,false); 248 248 249 response = req.responseXML.documentElement; 250 thevalue = response.getElementsByTagName('isunique')[0].firstChild.data; 251 252 if(thevalue==1) return true; else return false; 253 } 249 var isUnique = false; 250 251 try { 252 253 isUnique = eval("(" + req.responseText + ")") 254 255 } catch(err) { 256 257 isUnique = false; 258 259 } 260 261 return isUnique; 262 263 } -
trunk/phpbms/include/search_class.php
r711 r720 671 671 672 672 <label for="startswith">starts with</label><br /> 673 <input id="startswith" name="startswith" type="text" value="<?php if($this->querytype=="search" and isset($this->savedstartswith)) echo formatVariable( $this->savedstartswith) ?>" size="35" maxlength="128" tabindex="1"/>673 <input id="startswith" name="startswith" type="text" value="<?php if($this->querytype=="search" and isset($this->savedstartswith)) echo formatVariable(stripslashes(stripslashes($this->savedstartswith))) ?>" size="35" maxlength="128" tabindex="1"/> 674 674 675 675 </p> -
trunk/phpbms/modules/bms/include/invoices.php
r703 r720 816 816 }//end if 817 817 818 if(!in_array(((string)$variables["assignedtoid"]), $this->_availableUserUUIDs))818 if(!in_array(((string)$variables["assignedtoid"]), $this->_availableUserUUIDs)) 819 819 $this->verifyErrors[] = "The `assignedtoid` field does not give an existing/acceptable user id number."; 820 820 … … 1556 1556 1557 1557 if($therecord["defaultassignedtoid"]!="") 1558 $assignedtoid = $therecord["defaultassignedtoid"];1558 $assignedtoid = "'".$therecord["defaultassignedtoid"]."'"; 1559 1559 else 1560 1560 $assignedtoid="NULL"; … … 1595 1595 SET 1596 1596 invoices.statusdate=NOW(), 1597 assignedtoid= '".$assignedtoid."',1597 assignedtoid=".$assignedtoid.", 1598 1598 modifiedby=".$_SESSION["userinfo"]["id"].", "; 1599 1599 … … 1627 1627 $querystatement="INSERT INTO invoicestatushistory (invoiceid,invoicestatusid,statusdate,assignedtoid) values ("; 1628 1628 $querystatement.="'".$therecord["uuid"]."','".$statusid."',NOW(),"; 1629 $querystatement.= "'".$assignedtoid."'";1629 $querystatement.= $assignedtoid; 1630 1630 $querystatement.=")"; 1631 1631 $insertresult = $this->db->query($querystatement); -
trunk/phpbms/modules/bms/javascript/product.js
r703 r720 81 81 82 82 var partnumber = getObjectFromID("partnumber"); 83 var excludeid = getObjectFromID(" id");84 85 if(!checkUnique( 4, "partnumber", partnumber.value, parseInt(excludeid.value))){83 var excludeid = getObjectFromID("uuid"); 84 85 if(!checkUnique('tbld:7a9e87ed-d165-c4a4-d9b9-0a4adc3c5a34', "partnumber", partnumber.value, excludeid.value)){ 86 86 87 87 alert("Part number must be unique."); -
trunk/phpbms/search.php
r702 r720 49 49 //initialize the object 50 50 $displayTable->initialize($_GET["id"]); 51 52 if (isset($passedjoinclause)) $_SESSION["passedjoinclause"] = $passedjoinclause; 53 if (isset($passedjoinwhere)) $_SESSION["passedjoinwhere"] = $passedjoinwhere; 51 52 if (isset($passedjoinclause)) $_SESSION["passedjoinclause"] = $passedjoinclause; 53 if (isset($passedjoinwhere)) $_SESSION["passedjoinwhere"] = $passedjoinwhere; 54 54 55 55 … … 121 121 122 122 }//endif 123 123 124 124 /** 125 * If the command is a push command, include tables.php 125 * If the command is a push command, include tables.php 126 126 */ 127 127 if(strpos($functionname, ":") !== false) 128 128 include("include/tables.php"); 129 129 130 130 //try to include table specific functions 131 131 if(file_exists("modules/".$displayTable->thetabledef["name"]."/include/".$displayTable->thetabledef["maintable"].".php")) … … 142 142 143 143 if(!preg_match("/\:/", $functionname)){ 144 144 145 145 if(method_exists($searchFunctions,$functionname)) 146 146 $statusmessage = $searchFunctions->$functionname(); 147 147 else 148 148 $statusmessage = "Function ".$functionname." not defined"; 149 149 150 150 }else{ 151 151 152 152 if(moduleExists("mod:b2d42220-443b-fe74-dbdb-ed2c0968c38c", $phpbms->modules)) 153 153 $statusmessage = $searchFunctions->runPush($therecord["name"]); 154 154 155 155 }//end if 156 156 break;