function get_info()
 {
     $post_code = isset($_POST['post_code']) ? $_POST['post_code'] : '';
     $class_id = isset($_POST['class_id']) ? $_POST['class_id'] : '';
     if (!$post_code == get_post_code()) {
         return show(501, '无权限访问');
     }
     if ($class_id == '') {
         return show(103, 'class_id不能为空');
     }
     $class_info = M('answer_info');
     $class_info->where("class_id='{$class_id}'")->getField();
 }
示例#2
0
function import_manifest($manifest_reg, $manifest_counter_result, $site_result, $site_has_cat_result, $delivery_result)
{
    global $GME;
    echo "In import manifest";
    connect_tablet();
    //here we for the last time ask tavblet before connectin to root
    //check manifest unq number
    $GME .= new_line(" In import manifest ");
    //
    //extract manifest reg
    $id_manifest = $manifest_reg[0];
    $manifest_unq_num = $manifest_reg[1];
    $manifest_date = $manifest_reg[2];
    $manifest_driver = $manifest_reg[3];
    $manifest_closed = $manifest_reg[4];
    //write a standard origin conversion function that
    //$manifest_siteid=$manifest_reg[5]; //converst tablet origin into dbs3 origin using post code as constanse
    $manifest_start_dbs = $manifest_reg[6];
    //do it each time
    $manifest_end_dbs = $manifest_reg[7];
    //site for site conversion
    //asssuming only one site
    $GME .= new_line(" Manifest array " . $manifest_reg[0] . " - " . $manifest_reg[1] . " - " . $manifest_reg[2] . " - " . $manifest_reg[3] . " - " . $manifest_reg[4] . " - " . $manifest_reg[5]);
    $site = mysql_fetch_array($site_result);
    $site_id = $site[0];
    $site_origin_origin_id = $site[1];
    //here a problem cince it may be with root system origin converted. Means that origins must be converted from tablet to root
    $site_ref_number = $site[2];
    $site_rep_auth = $site[3];
    $site_dest_location = $site[4];
    $site_batch_date = $site[5];
    $site_batch_id = $site[6];
    $site_closed = $site[7];
    ###
    //get post code from tablet
    $tablet_tmp_post_code = get_post_code($site_origin_origin_id);
    //get origin from tablet
    //checktabletpostcode
    echo "NEW CONV Ori:" . ($new_converted_origin = root_system_origin_from_post($tablet_tmp_post_code));
    $GME .= new_line("NEW Conv ori:" . $new_converted_origin);
    $tablet_tmp_post_code = $new_converted_origin;
    /*
    $site_origin_tab=mysql_fetch_array($site_result);
         //get post code from tablet
    $tablet_tmp_post_code=get_post_code($site_origin_tab[1]); //get origin from tablet
                        //checktabletpostcode
                    echo "NEW CONV Ori:".$new_converted_origin= root_system_origin_post_code($tablet_tmp_post_code);                
    */
    //root_system_origin($origin_id);                    //check pos code root return origin id
    //Manifest reg id is taken from manifest, than is inserted into root system with conversion
    //we gona insert this to root system as AI. But we chcack manifest unq number
    //extract site -stage 2
    /*
    
    $site_id=$site[0];
    $site_origin_origin_id=$site[1];
    $site_ref_number=$site[2];
    $site_rep_auth=$site[3];
    $site_dest_location=$site[4];
    $site_batch_date=$site[5];
    $site_batch_id=$site[6];
    $site_closed=$site[7];
    */
    //variables for module conversion
    $stack_trace_manifest_reg_id;
    $stack_trace_manifest_reg_unq_number;
    $stack_trace_fresh_site_id;
    connect_dbs3();
    //here we connect to main root system
    //check root system
    $sql = "SELECT * FROM manifest_reg WHERE manifest_unq_num='{$manifest_unq_num}'";
    $result = query_select($sql);
    if ($num = mysql_num_rows($result) > 0) {
        return "manifest already exist in the system";
    }
    /*
            //Checking if origins id is adjusted to coonversion module
            $conversion_post_code=get_post_code($site_origin_origin_id=$site[1]); //take tablet origin_id and compare to local
            
             echo $sql="SELECT origin_id FROM origin WHERE post_code='$conversion_post_code'";
             $result=query_select($sql) or die(mysql_error());
             $rek=mysql_fetch_array($result);
             $origin_in_root=$rek[0];
             echo "NEW conversion id".$origin_in_root;
    */
    connect_dbs3();
    mysql_query("START TRANSACTION");
    $flag = true;
    //here we insert as it goes manifest reg, but we need to keeptrace of it to update
    $manifest_siteid = 0;
    //we use blank one
    echo $query_manifest = "INSERT INTO manifest_reg(manifest_unq_num,date_manifest,driver_num,hash_serial,group1,closed,siteid,start_dbs,end_dbs) " . "VALUES ('{$manifest_unq_num}','{$manifest_date}','{$manifest_driver}','0','0','{$manifest_closed}','{$manifest_siteid}','{$manifest_start_dbs}','{$manifest_end_dbs}')";
    $result = mysql_query($query_manifest) or trigger_error(mysql_error(), E_USER_ERROR);
    if (!$result) {
        $flag = false;
    } else {
        echo "Result manifest register done";
        $GME .= new_line("Result manifest register done");
        //if inserted correctly we take last insert id
        $stack_trace_manifest_reg_id = mysql_insert_id();
        $stack_trace_manifest_reg_unq_number = $manifest_unq_num;
    }
    //manifest counter extract
    while ($manifest_counter = mysql_fetch_array($manifest_counter_result)) {
        echo "executing mysql counter";
        //here we will be unsing manifest stack trace for manifest_reg
        echo $manifest_counter_id = $manifest_counter[0];
        echo $manifest_counter_manifest_counter = $manifest_counter[1];
        $manifest_counter_sub_cat = $manifest_counter[2];
        $manifest_counter_manifest_sub_cat = $manifest_counter[3];
        echo "reg:" . ($manifest_counter_manifest_reg_idmanifest_reg = $stack_trace_manifest_reg_id);
        //$manifest_counter[4]; deprecated
        $manifest_counter_finished = $manifest_counter[5];
        echo $query_manifest_counter = "INSERT INTO manifest_counter(manifest_counter,sub_cat,manifest_sub_cat,manifest_reg_idmanifest_reg,finished) " . "VALUES ('{$manifest_counter_manifest_counter}','{$manifest_counter_sub_cat}','{$manifest_counter_manifest_sub_cat}','{$manifest_counter_manifest_reg_idmanifest_reg}','{$manifest_counter_finished}')";
        $result = mysql_query($query_manifest_counter) or trigger_error(mysql_error(), E_USER_ERROR);
        if (!$result) {
            $flag = false;
        } else {
            echo "Result insert counter done";
            //here we need a fresh site id not the old one from system. Its generated on level of adding site id
        }
    }
    echo "Done manifest counters successfult";
    //IF FIRST STAGE DONE GO THROUGH SECOND ONE
    //SITE
    //asssuming only one site
    /*         
            $site=mysql_fetch_array($site_result);      
            $site_id=$site[0];
            $site_origin_origin_id=$site[1];  //here a problem cince it may be with root system origin converted. Means that origins must be converted from tablet to root
            $site_ref_number=$site[2];
            $site_rep_auth=$site[3];
            $site_dest_location=$site[4];
            $site_batch_date=$site[5];
            $site_batch_id=$site[6];
            $site_closed=$site[7];
    */
    $site_origin_origin_id = $tablet_tmp_post_code;
    //add one site
    echo $query_site = "INSERT INTO site(Origin_origin_id,site_ref_number,Rep_Auth,Dest_location,batch_date,batch_id,closed) " . "VALUES ('{$site_origin_origin_id}','{$site_ref_number}','{$site_rep_auth}','{$site_dest_location}','{$site_batch_date}','{$site_batch_id}','{$site_closed}')";
    $result = mysql_query($query_site) or trigger_error(mysql_error(), E_USER_ERROR);
    if (!$result) {
        $flag = false;
    } else {
        echo "Done site";
        echo $stack_trace_fresh_site_id = mysql_insert_id();
    }
    //SITE HAS CATEGORY INSERT
    while ($site_has_cat = mysql_fetch_array($site_has_cat_result)) {
        $i++;
        $site_has_cat_id = $site_has_cat[0];
        //$site_has_cat_site_site_id=$site_has_cat[1];
        $site_has_cat_sub_cat_id = $site_has_cat[1];
        $site_has_cat_quantity = $site_has_cat[3];
        $site_has_cat_sum_weight = $site_has_cat[4];
        $site_has_cat_site_site_id = $stack_trace_fresh_site_id;
        //$site_has_cat_sum_weight=0;
        //only adds few
        echo "</BR>" . $i;
        echo $query_site_has_cat = "INSERT INTO site_has_cat(Sub_cat_id_c,Site_site_id,Quantity,sum_weight) " . "VALUES ('{$site_has_cat_sub_cat_id}','{$site_has_cat_site_site_id}','{$site_has_cat_quantity}','{$site_has_cat_sum_weight}')";
        $result = mysql_query($query_site_has_cat) or trigger_error(mysql_error(), E_USER_ERROR);
        if (!$result) {
            $flag = false;
        } else {
            echo "result site_has_cat Done";
        }
    }
    //deliveries
    while ($delivery = mysql_fetch_array($delivery_result)) {
        $delivery_delivery_id = $delivery[0];
        $delivery_trans_category = $delivery[1];
        //$delivery_site_site_id=$delivery[2];
        $delivery_date = $delivery[3];
        $delivery_qtty_picked_up = $delivery[4];
        $delivery_picker1 = $delivery[5];
        $delivery_trans_ref_number = $delivery[6];
        $delivery_closed = $delivery[7];
        $delivery_qnum = $delivery[8];
        $delivery_att_num = $delivery[9];
        $delivery_site_site_id = $stack_trace_fresh_site_id;
        echo $query_delivery = "INSERT INTO delivery(Trans_Category_Category_id,Site_site_id,date,QtyPickedUp,picker1,trans_ref_num,closed,QNum,att_num)" . "VALUES ('{$delivery_trans_category}','{$delivery_site_site_id}','{$delivery_date}','{$delivery_qtty_picked_up}','{$delivery_picker1}','{$delivery_trans_ref_number}'," . "'{$delivery_closed}','{$delivery_qnum}','{$delivery_att_num}')";
        $result = mysql_query($query_delivery) or trigger_error(mysql_error(), E_USER_ERROR);
        if (!$result) {
            $flag = false;
        } else {
            echo "result succesfully done deliveries";
        }
    }
    //here we update site id in both manifest_reg and manifest_counter
    $update_manifest_reg = "UPDATE manifest_reg SET siteid='{$stack_trace_fresh_site_id}' WHERE idmanifest_reg='{$stack_trace_manifest_reg_id}'";
    $result = query_select($update_manifest_reg);
    if (!$result) {
        $flag = false;
    } else {
        echo "result succesfully updated manifest reg siteid";
    }
    if ($flag) {
        echo "Cimmited";
        mysql_query("COMMIT");
    } else {
        echo "Rolled backed";
        mysql_query("ROLLBACK");
    }
    //update manifest on table for cloas 1
    if ($flag) {
        connect_tablet();
        //the last one is to reove from tablet. make it unvisible
        $update_closed = "UPDATE manifest_reg SET closed=1 WHERE idmanifest_reg='{$id_manifest}'";
        $rek = mysql_query($update_closed) or die(mysql_error());
    }
}