public function DeleteTemplate($extBruTypeId, $extTplName)
 {
     $bruTypeId = $extBruTypeId;
     $tplName = $extTplName;
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfoById($bruTypeId);
     $PSTTableName = $bruInfo['paramSetTemplateListTableName'];
     unset($Bru);
     $PSTempl = new PSTempl();
     $PSTempl->DeleteTemplate($PSTTableName, $tplName, $this->_user->username);
     unset($PSTempl);
     return "ok";
 }
 public function CreateTemplate($extFlightId, $extParamsToAdd, $extTplName)
 {
     $flightId = $extFlightId;
     $paramsToAdd = $extParamsToAdd;
     $tplName = $extTplName;
     $Fl = new Flight();
     $flightInfo = $Fl->GetFlightInfo($flightId);
     $bruType = $flightInfo['bruType'];
     $apTableName = $flightInfo['apTableName'];
     $bpTableName = $flightInfo['bpTableName'];
     unset($Fl);
     $Bru = new Bru();
     $bruInfo = $Bru->GetBruInfo($flightInfo['bruType']);
     $cycloApTableName = $bruInfo['gradiApTableName'];
     $cycloBpTableName = $bruInfo['gradiBpTableName'];
     $PSTTableName = $bruInfo['paramSetTemplateListTableName'];
     $paramsWithType = array();
     $Ch = new Channel();
     for ($i = 0; $i < count($paramsToAdd); $i++) {
         $paramInfo = $Bru->GetParamInfoByCode($cycloApTableName, $cycloBpTableName, $paramsToAdd[$i]);
         if (isset($paramInfo['paramType']) && $paramInfo['paramType'] == PARAM_TYPE_AP) {
             $apTableNameWithPrefix = $apTableName . "_" . $paramInfo['prefix'];
             $paramMinMax = $Ch->GetParamMinMax($apTableNameWithPrefix, $paramsToAdd[$i], $this->_user->username);
             $paramsWithType[PARAM_TYPE_AP][] = array('code' => $paramsToAdd[$i], 'min' => $paramMinMax['min'], 'max' => $paramMinMax['max']);
         } else {
             if (isset($paramInfo['paramType']) && $paramInfo['paramType'] == PARAM_TYPE_BP) {
                 $paramsWithType[PARAM_TYPE_BP][] = array('code' => $paramsToAdd[$i]);
             }
         }
     }
     unset($Bru);
     $PSTempl = new PSTempl();
     $PSTempl->DeleteTemplate($PSTTableName, $tplName, $this->_user->username);
     $PSTempl->CreateTplWithDistributedParams($PSTTableName, $tplName, $paramsWithType, $this->_user->username);
     unset($Ch);
     unset($PSTempl);
 }