From d051f21a7f507bac2f563e312c09855688f217c4 Mon Sep 17 00:00:00 2001 From: Bjverde Date: Sat, 7 Oct 2023 15:38:09 -0300 Subject: [PATCH] :hammer: #104 create addFilterFields --- .../controllers/TCreateFormList.class.php | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/app/control/controllers/TCreateFormList.class.php b/app/control/controllers/TCreateFormList.class.php index 896d78e..ef9dcc9 100644 --- a/app/control/controllers/TCreateFormList.class.php +++ b/app/control/controllers/TCreateFormList.class.php @@ -84,13 +84,41 @@ public function addGetWhereGridParametersFields($qtdTabs) $this->addGetWhereGridParameters_fied(false, $value, $qtdTabs); } } + //-------------------------------------------------------------------------------------- + public function getSqlOperatorsByType($formDinType) + { + $restult = null; + switch ($formDinType) { + case TCreateFormGeneric::FORMDIN_TYPE_DATE: + $restult = '='; + break; + case TCreateFormGeneric::FORMDIN_TYPE_DATETIME: + $restult = '='; + break; + case TCreateFormGeneric::FORMDIN_TYPE_NUMBER: + $restult = '='; + break; + case TCreateFormGeneric::FORMDIN_TYPE_TEXT: + $restult = 'like'; + break; + default: + $restult = '='; + } + return $restult; + } + public function addFilterFieldType($qtdTabs,$key, $fieldName, $notPK = true) + { + $formDinType = $this->getColumnsPropertieFormDinType($key); + $conector = $this->getSqlOperatorsByType($formDinType); + $this->addLine($qtdTabs.'$this->addFilterField(\''.$fieldName.'\', \''.$conector.'\', \''.$fieldName.'\'); //campo, operador, campo do form'); + } public function addFilterFields($qtdTabs) { $this->addLine($qtdTabs.'$this->filter_criteria = new TCriteria;'); $this->addLine($qtdTabs.'$this->addFilterField(self::$primaryKey, \'=\', self::$primaryKey); //campo, operador, campo do form'); $listColumnsName = $this->getListColunnsName(); foreach ($listColumnsName as $key => $value) { - $this->addGetWhereGridParameters_fied(false, $value, $qtdTabs); + $this->addGetWhereGridParameters_fied($qtdTabs,$key, $value); } } //--------------------------------------------------------------------------------------