Giter Club home page Giter Club logo

code-base's Introduction

code-base

 public function DoProcessMessages()
        {
            try {
            $this->connectionFactory = PgConnectionFactory::getInstance();
            if ($_SERVER["REQUEST_METHOD"] == "GET") 
            {

                if (isset($_GET["action"]) && $_GET['action']=='getKeyNumber' ) {
                    echo $this->getKeyNumberRecords($_GET["cc"],$_GET["fn"],$_GET["table_name"]);
                    //echo 'response from page';
                    exit();
                }else {
                    $this->processResult = 'Invalid URL';
                }

                if (isset($_GET["action"]) && $_GET['action']=='getFigureNumber' ) {
                    echo $this->getFigureNumberRecords($_GET["cc"],$_GET["maf"],$_GET["table_name"]);
                    //echo 'response from page';
                    exit();
                }else {
                    $this->processResult = 'Invalid URL';
                }

                


                if (isset($_GET["action"]) && $_GET['action']=='getCheckBox' ) {
                    echo $this->getCheckBoxDetails($_GET["cc"],$_GET["fn"]);
                    //echo 'response from page';
                    exit();
                } 
                else {
                    $this->processResult = 'Invalid URL';
                }

                
               
                
            }
           
        }
        catch (Exception $e) {
            $this->processResult = $e->getFile().' -> '.$e->getLine().' -> '.$e->getTraceAsString();
        }
    
        }
    
    
        public function DoExecSQLWithParams($sql, $params) {
            return pg_query_params($this->connection->GetConnectionHandle(), $sql, $params);
        }
    
    
        private function getCheckBoxDetails($cc,$fn) {
            $d = array();
    
            $sql = "SELECT distinct modelcode, catalog_code, concat(modelcode,'-',description ) as display_value FROM bl.bl_na_illust_applmodel where catalog_code = '" . $cc . "' and fig_number = '". $fn . "'";
     
         
    
              $this->Connect();
              //$sql = str_replace('$1', $requestedStepId, $sql);
              $rows = $this->DoExecSQLWithParams($sql, array());
              $i=0;
              $data = array();
              if ($rows && pg_num_rows($rows) > 0) {
                while ($row = pg_fetch_array($rows, null, PGSQL_ASSOC )) {
                    $d = array();
                    $d['modelcode']= $row['modelcode'];
                    $d['catalog_code']= $row['catalog_code'];
                    $d['display_value']= $row['display_value'];
                    $data[$i]=$d;
                    $i=$i+1;
    
                }
                return json_encode($data);
            }
    
        }
    
        private function getKeyNumberRecords($cc,$fn,$table_name) {
            $d = array();
    
            $sql = "SELECT distinct key_number,concat(key_number,'-',part_name) as display_value
            FROM bl.".$table_name." where catalog_code = '" . $cc . "' and fig_number = '". $fn . "'";
     
         
    
              $this->Connect();
              //$sql = str_replace('$1', $requestedStepId, $sql);
              $rows = $this->DoExecSQLWithParams($sql, array());
              $i=0;
              $data = array();
              if ($rows && pg_num_rows($rows) > 0) {
                while ($row = pg_fetch_array($rows, null, PGSQL_ASSOC )) {
                    $d = array();
                    $d['key_number']= $row['key_number'];
                    $d['display_value']= $row['display_value'];
                    $data[$i]=$d;
                    $i=$i+1;
    
                }
                return json_encode($data);
            }
    
        }
       
        private function getFigureNumberRecords($cc,$maf,$table_name) {
            $d = array();
    
            $sql = "SELECT distinct fig_number, concat(fig_number,'-',fig_title) as display_value FROM  bl.".$table_name." where catalog_code = '" . $cc ."' and model_asm_flag = '". $maf . "' ";
     
         
    
              $this->Connect();
              //$sql = str_replace('$1', $requestedStepId, $sql);
              $rows = $this->DoExecSQLWithParams($sql, array());
              $i=0;
              $data = array();
              if ($rows && pg_num_rows($rows) > 0) {
                while ($row = pg_fetch_array($rows, null, PGSQL_ASSOC )) {
                    $d = array();
                    $d['fig_number']= $row['fig_number'];
                    $d['display_value']= $row['display_value'];
                    $data[$i]=$d;
                    $i=$i+1;
    
                }
                return json_encode($data);
            }
    
        }
    
    
    
        function GetConnectionOptions()
        {
            $result = GetGlobalConnectionOptions();
            $result['client_encoding'] = 'utf8';
            GetApplication()->GetUserAuthentication()->applyIdentityToConnectionOptions($result);
            return $result;
        }
    
    
        public function Connect() {
            if (!isset($this->connection)) {
                $this->connection = $this->connectionFactory->CreateConnection($this->GetConnectionOptions());
                $this->connection->Connect();
            }
        }

#PostBack Handler.js

function SendPostRequestSync(cc,fn) {
    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("GET", 'APIForFetchingPostbackData.php?action=getCheckBox&cc='+cc +'&fn='+fn,false);
    xmlhttp.send();
    if(xmlhttp.status ==200)
    {
        var resText = xmlhttp.responseText;
          return resText;
        
    }
    else{
        alert('Oops! Something went wrong. HTTP Status code: ' + xmlhttp.status + ', error text: ' + xmlhttp.responseText);
    }
    
}


function SendPostRequestForKeyNumberSync(cc,fn,table_name) {
    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("GET", 'APIForFetchingPostbackData.php?action=getKeyNumber&cc='+cc +'&fn='+fn+'&table_name='+table_name,false);
    xmlhttp.send();
    if(xmlhttp.status ==200)
    {
        var resText = xmlhttp.responseText;
          return resText;
        
    }
    else{
        alert('Oops! Something went wrong. HTTP Status code: ' + xmlhttp.status + ', error text: ' + xmlhttp.responseText);
    }
    
}


function SendPostRequestForFigureNumberSync(cc,maf,table_name) {
    var xmlhttp = new XMLHttpRequest();

    xmlhttp.open("GET", 'APIForFetchingPostbackData.php?action=getFigureNumber&cc='+cc +'&maf='+maf+'&table_name='+table_name,false);
    xmlhttp.send();
    if(xmlhttp.status ==200)
    {
        var resText = xmlhttp.responseText;
          return resText;
        
    }
    else{
        alert('Oops! Something went wrong. HTTP Status code: ' + xmlhttp.status + ', error text: ' + xmlhttp.responseText);
    }
    
}

code-base's People

Contributors

rohitrawatcse avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.