ContractConfig ausgebaut
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
|
||||
class ContractconfigValueModel {
|
||||
public $name;
|
||||
public $description;
|
||||
public $filename;
|
||||
public $store_filename;
|
||||
public $orig_filename;
|
||||
public $subfolder;
|
||||
public $contract_id;
|
||||
public $item_id;
|
||||
public $string;
|
||||
public $int;
|
||||
public $text;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
@@ -51,11 +50,11 @@ class ContractconfigValueModel {
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigValue", "*", "$where LIMIT 1");
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY item_id, contract_id LIMIT 1");
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new ContractconfigValue($data);
|
||||
@@ -73,7 +72,7 @@ class ContractconfigValueModel {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY name, filename");
|
||||
$res = $db->select("ContractconfigValue", "*", "$where ORDER BY item_id, contract_id");
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[] = new ContractconfigValue($data);
|
||||
@@ -86,24 +85,44 @@ class ContractconfigValueModel {
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if(array_key_exists("name", $filter)) {
|
||||
$name = FronkDB::singleton()->escape($filter['name']);
|
||||
if($name) {
|
||||
$where .= " AND name='$name'";
|
||||
if(array_key_exists("contract_id", $filter)) {
|
||||
$contract_id = $filter['contract_id'];
|
||||
if(is_numeric($contract_id)) {
|
||||
$where .= " AND contract_id=$contract_id";
|
||||
} elseif(is_array($contract_id) && count($contract_id)) {
|
||||
$where .= " AND contract_id IN (". implode(",", $contract_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("filename", $filter)) {
|
||||
$filename = FronkDB::singleton()->escape($filter['filename']);
|
||||
if($filename) {
|
||||
$where .= " AND filename='$filename'";
|
||||
if(array_key_exists("item_id", $filter)) {
|
||||
$item_id = $filter['item_id'];
|
||||
if(is_numeric($item_id)) {
|
||||
$where .= " AND item_id=$item_id";
|
||||
} elseif(is_array($item_id) && count($item_id)) {
|
||||
$where .= " AND item_id IN (". implode(",", $item_id).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("subfolder", $filter)) {
|
||||
$subfolder = FronkDB::singleton()->escape($filter['subfolder']);
|
||||
if($subfolder) {
|
||||
$where .= " AND subfolder='$subfolder'";
|
||||
if(array_key_exists("int", $filter)) {
|
||||
$int = $filter['int'];
|
||||
if(is_numeric($int)) {
|
||||
$where .= " AND int=$int";
|
||||
} elseif(is_array($int) && count($int)) {
|
||||
$where .= " AND `int` IN (". implode(",", $int).")";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("string", $filter)) {
|
||||
$string = FronkDB::singleton()->escape($filter['string']);
|
||||
if($string) {
|
||||
$where .= " AND `string`='$string'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("text", $filter)) {
|
||||
$text = FronkDB::singleton()->escape($filter['text']);
|
||||
if($text) {
|
||||
$where .= " AND `text`='$text'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user