Example #1
0
         $att_num = $rek_att['att_num'];
         mysql_connect($host_in, $username, $password);
         mysql_select_db($dbs_in);
         $sql_insert = "INSERT INTO delivery(Trans_Category_Category_id,Site_site_id,date,QtyPickedUp,picker1,trans_ref_num,closed,QNum,att_num) " . "VALUES('{$trans}','{$site_id_root_converted}','{$date}','{$qtty}','{$picker1}','{$trans_ref_num}','{$closed}','{$qnum}','{$att_num}')";
         $result_att_in = mysql_query($sql_insert);
         if ($result_att_in) {
             echo "<BR/>Import #" . $i . " Done successfuly";
             $convert_site = "UPDATE manifest_reg SET siteid='{$site_id_root_converted}' WHERE idmanifest_reg='{$last_inserted_mani}'";
             mysql_query($convert_site) or die(mysql_error());
             echo "<BR/>LAsT INSERTED MANI" . $last_inserted_mani . "Import details " . $import_details;
             $convert_site = "UPDATE manifest_counter SET manifest_reg_idmanifest_reg='{$last_inserted_mani}' WHERE manifest_reg_idmanifest_reg='{$mani_reg}='";
             //mysql_query($convert_site) or die(mysql_error());
             //than do the callculations for site id
             //echo $start_dbs-$end_dbs;
             if (isset($start_dbs) and isset($end_dbs)) {
                 $space = split_barcode($start_dbs, $end_dbs);
                 $update_site_space = "UPDATE site SET closed='{$space}' WHERE site_id='{$site_id_root_converted}'";
                 $result_space = mysql_query($update_site_space);
                 //$rek_space=mysql_fetch_array($result_space);
             } else {
                 echo "Ending barcode not set. Not calculated";
             }
         } else {
             echo mysql_error();
         }
     }
 } else {
     echo "<BR />Rolling_back :" . ($manifest_id = $import_details);
     echo "<BR />Rolled backed. " . roll_back_manifest($manifest_id);
     roll_back_insert_manifest_details_root($last_inserted_mani);
     //rolling back site,sitecat and delivery
Example #2
0
function get_barcodes_from_db($barcode)
{
    echo "Przekazany bar" . $barcode;
    //echo split_barcode($barcode);
    //get barcode, search whole database, serialize and compare if ok return site place
    echo "<BR/><BR/><BR/>inside get_barcodes;";
    //$siteid=$_SESSION['site_id_s'];
    $host = '127.0.0.1';
    $username = '******';
    $password = '******';
    $NEW_CALCULATION = 1;
    $dbs3 = 'dbs3';
    mysql_connect($host, $username, $password);
    mysql_select_db($dbs3);
    echo "get_bar " . $siteid;
    $query = "SELECT * FROM manifest_reg";
    $result = mysql_query($query);
    echo "<BR/>Interpreter: " . mysql_error();
    $check_buffor_register = array();
    $z_counter = 0;
    $return_flag = 0;
    while ($rek = mysql_fetch_array($result)) {
        // echo "<BR/>Starting Barcode From manifest Register ";
        $start_dbs = $rek['start_dbs'];
        $end_dbs = $rek['end_dbs'];
        echo $idmanifest_reg = $rek['idmanifest_reg'];
        //echo " !!Siteid ";
        // $siteid=$rek['siteid'];
        //echo " Start DBS is: ";
        $start_dbs;
        //echo " End DBS is: ";
        $end_dbs;
        //here we go for taking a preset number of items collected from site place
        if ($NEW_CALCULATION == 0) {
            $query = "SELECT COUNT(manifest_counter) as ile, SUM(manifest_counter) as suma FROM manifest_counter WHERE manifest_reg_idmanifest_reg='{$idmanifest_reg}'";
            $result_count = mysql_query($query) or die(mysql_error());
            while ($rek_count = mysql_fetch_array($result_count)) {
                $ile = $rek_count['ile'];
                $suma = $rek_count['suma'];
            }
        } else {
            //take from site table
            $query = "SELECT siteid FROM manifest_reg WHERE idmanifest_reg='{$idmanifest_reg}'";
            $result_count = mysql_query($query) or die(mysql_error());
            while ($rek_count = mysql_fetch_array($result_count)) {
                echo "Site id" . ($site_id_tmp = $rek_count['siteid']);
                $query = "SELECT * FROM site WHERE site_id='{$site_id_tmp}'";
                $result_count = mysql_query($query) or die(mysql_error());
                if (mysql_num_rows($result_count) > 1) {
                    die(mysql_error());
                }
                while ($rek_site = mysql_fetch_array($result_count)) {
                    echo "Size calc " . ($size_calculation_site = $rek_site['closed']);
                    // return $site_id_tmp;
                }
            }
        }
        $barcode = strtolower($barcode);
        $dbs_set = array();
        global $error_factor;
        echo " <BR/>PROB set" . ($dbs_prob_set = $suma + $error_factor);
        //echo $barcode;
        //echo $barcode;
        if ($NEW_CALCULATION == 1) {
            echo "Second serialisation cicrut active";
            $dbs_prob_set = $size_calculation_site;
        } else {
        }
        $next_dbs = $start_dbs;
        for ($i = 0; $i < $dbs_prob_set; $i++) {
            $dbs_set[$i] = $next_dbs;
            $next_dbs = split_barcode($next_dbs);
            //echo $dbs_set[$i]."<BR />";
            //echo "First : ".$dbs_set[$i]."Second : ".$barcode;
            $result_cmp = strcmp($dbs_set[$i], $barcode);
            if ($result_cmp == 0) {
                echo "<BR/><BR/>Detected Comparison: " . $dbs_set[$i] . " AND " . $barcode;
                echo " Sum: " . $suma;
                echo " Result " . $barcode;
                echo " Range " . $dbs_set[0] . " " . $dbs_set[$dbs_prob_set];
                echo " ~Result " . $barcode;
                echo $siteid = $rek['siteid'];
                //echo $start_dbs;
                $return_flag += 1;
                echo "<BR/><BR/>";
                while ($rek_count['ile'] > 40) {
                    echo "<BR/>Critical System Error: SYSTEM NOT COHERENT";
                    break;
                }
            }
        }
        //   echo "<BR /><BR/>";
    }
    echo "<BR/><BR/> ";
    echo "Return flag: " . $return_flag;
    /* if($z_counter>1)
       {
          echo "Z Buffor size abnormal ".$z_counter; 
          return -2;
       }*/
    if ($return_flag == 1) {
        //echo "SESSION SET ".$_SESSION['site_id_s']=$siteid;
        echo "Siteid " . $siteid;
        return $siteid;
    } else {
        $_SESSION['site_id_s'] = 0;
        echo "<BR/>";
        echo "<BR/>Braekin Bad";
        return 0;
    }
}
Example #3
0
function get_barcodes_from_db($barcode)
{
    //echo "Przekazany bar".$barcode;
    //echo split_barcode($barcode);
    //get barcode, search whole database, serialize and compare if ok return site place
    //echo "<BR/><BR/><BR/>inside get_barcodes;";
    //$siteid=$_SESSION['site_id_s'];
    // echo "s";
    global $COUNTER_BREAK;
    global $host;
    global $username;
    global $password;
    global $NEW_CALCULATION;
    global $dbs3;
    $con = mysql_connect($host, $username, $password);
    mysql_select_db($dbs3);
    // print "con".$con;
    //echo "get_bar ".$siteid;
    $query = "SELECT * FROM manifest_reg ORDER BY idmanifest_reg DESC";
    //changing order for bigggest/ most recent first gives amazing efficency rise from 0,46 ms to 0,046. ten times better
    $result = mysql_query($query) or die(mysql_error());
    // echo "qud".$result;
    //echo "<BR/>Interpreter: ".mysql_error();
    $check_buffor_register = array();
    $z_counter = 0;
    $return_flag = 0;
    while ($rek = mysql_fetch_array($result)) {
        // echo "<BR/>Starting Barcode From manifest Register ";
        $start_dbs = $rek['start_dbs'];
        $end_dbs = $rek['end_dbs'];
        $idmanifest_reg = $rek['idmanifest_reg'];
        //echo " !!Siteid ";
        // $siteid=$rek['siteid'];
        //echo " Start DBS is: ";
        $start_dbs;
        //echo " End DBS is: ";
        $end_dbs;
        //here we go for taking a preset number of items collected from site place
        if ($NEW_CALCULATION == 0) {
            $query = "SELECT COUNT(manifest_counter) as ile, SUM(manifest_counter) as suma FROM manifest_counter WHERE manifest_reg_idmanifest_reg='{$idmanifest_reg}'";
            $result_count = mysql_query($query) or die(mysql_error());
            while ($rek_count = mysql_fetch_array($result_count)) {
                $ile = $rek_count['ile'];
                $suma = $rek_count['suma'];
            }
        } else {
            //do for each of manifest registy take a siteid and process individualy
            //take from site table
            $query = "SELECT siteid FROM manifest_reg WHERE idmanifest_reg='{$idmanifest_reg}'";
            $result_count = mysql_query($query) or die(mysql_error());
            while ($rek_count = mysql_fetch_array($result_count)) {
                // echo "ssi";
                $site_id_tmp = $rek_count['siteid'];
                $query = "SELECT * FROM site WHERE site_id='{$site_id_tmp}'";
                $result_count = mysql_query($query) or die(mysql_error());
                if (mysql_num_rows($result_count) > 1) {
                    die(mysql_error());
                }
                while ($rek_site = mysql_fetch_array($result_count)) {
                    $size_calculation_site = $rek_site['closed'];
                    //get a set of range
                }
                //get sites ends here
            }
            //end else
        }
        //standard code
        $barcode = strtolower($barcode);
        $dbs_set = array();
        global $error_factor;
        $suma = 0;
        $dbs_prob_set = $suma + $error_factor;
        //echo $barcode;
        //echo $barcode;
        if ($NEW_CALCULATION == 1) {
            // "Second serialisation cicrut active";
            $dbs_prob_set = $size_calculation_site;
            //initialise given manifest id by its reall range
        } else {
        }
        //echo "1";
        $next_dbs = $start_dbs;
        //this shall solve unset value
        $initializer = 0;
        for ($i = 0; $i < $dbs_prob_set; $i++) {
            /**
             * Optimisation method using so called initialiser initializing it with 1 while detected one site id, than carrying on untill 100 more barcodes than quits with
             * successs. Or if met the overlapped set, that means if another flag returned during this 100 hunders than gives value -5 error message
             */
            $initializer++;
            if ($initializer == 100 and $return_flag == 1) {
                return $siteid;
            }
            $dbs_set[$i] = strtolower($next_dbs);
            //first is start dbs
            $next_dbs = split_barcode($next_dbs);
            //echo $dbs_set[$i]."<BR />";
            //echo "First : ".$dbs_set[$i]."Second : ".$barcode;
            $result_cmp = strcmp($dbs_set[$i], $barcode);
            if ($result_cmp == 0) {
                // echo "cmp";
                // echo "<BR/><BR/>Detected Comparison: ".$dbs_set[$i]." AND ".$barcode;
                //   echo " Sum: ".$suma;
                //   echo " Result ".$barcode;
                //   echo " Range ".$dbs_set[0]." ".$dbs_set[$dbs_prob_set];
                //    echo " ~Result ".$barcode;
                $siteid = $rek['siteid'];
                //     echo $start_dbs;
                $return_flag += 1;
                //optimisation way
                if ($return_flag == 1) {
                    $initializer = 1;
                }
                if ($return_flag > 1) {
                    return -5;
                }
                //      echo "<BR/><BR/>";
                while ($rek_count['ile'] > 40) {
                    echo "<BR/>Critical System Error: SYSTEM NOT COHERENT";
                    //break;
                    return -2;
                }
                //return $siteid;
                // echo "el";
            }
        }
        //   echo "<BR /><BR/>";
    }
    //  echo "<BR/><BR/> ";
    //echo "Return flag: ".$return_flag;
    /* if($z_counter>1)
       {
          echo "Z Buffor size abnormal ".$z_counter; 
          return -2;
       }*/
    // echo "end";
    mysql_close($con);
    if ($return_flag > 1) {
        return -5;
    }
    if ($return_flag == 1) {
        $_SESSION['site_id_s'] = $siteid;
        return strtoupper($siteid);
    } else {
        $COUNTER_BREAK += 1;
        $_SESSION['site_id_s'] = 0;
        //echo "<BR/>";
        echo "<BR/>Braekin Bad";
        return 0;
    }
}