New vlan column for subnet

Help
Bart
2014-01-17
2014-01-21
  • Bart
    Bart
    2014-01-17

    I am working on adding some extra columns into ipplan. So far I have :
    1. Added Integer column in base table
    2. Implemented new column into the view of subnets
    3. Added vlan field for createsubnet.php and pass value to database.

    The last part which I started to work with is modifysubnet.php. New Vlan field, which I added always shows 0 , however I am able to display vlan number as text on top of this website , just getting data into the text field does not seem to work. I am stuck with this one , anyone can have a look what can by wrong ?

    I have added comments at the part where it does and does not work.

    if (!$_POST || $formerror) {
    myError($w,$p, $formerror, FALSE);

    $result=$ds->GetBaseFromIndex($baseindex);
    if (!$row = $result->FetchRow()) {
       myError($w,$p, my_("Subnet cannot be found!"));
    }
    $size=$row["subnetsize"];
    $baseaddr=$row["baseaddr"];
    $baseip=inet_ntoa($row["baseaddr"]);
    $dhcp=$row["baseopt"] & 1;
    
    insert($w,block("<h3>"));
    insert($w,text(my_("Subnet:")." ".
                inet_ntoa($baseaddr)." ".my_("Mask:")." ".
                inet_ntoa(inet_aton(ALLNETS)+1 -
                    $size)."/".inet_bits($size)));
    insert($w,textbr());
    insert($w,text(my_("Description:")." ".$row["descrip"]));
    insert($w,textbr());
    

    // HERE IS THAT PART WHERE VLAN SHOWS CORRECTLY

    insert($w,text(my_("VLAN:")." ".$row["vlannr"]));
    insert($w,block("</h3>"));
    
    // start form
    insert($w, $f1 = form(array("name"=>"THISFORM",
                    "method"=>"get",
                    "action"=>$_SERVER["PHP_SELF"])));
    
    $cust=myCustomerDropDown($ds, $f1, $cust, $grps) or myError($w,$p, my_("No customers"));
    
    insert($f1,hidden(array("name"=>"vlannr",
                    "value"=>"$vlannr")));
    insert($f1,hidden(array("name"=>"descrip",
                    "value"=>"$descrip")));
    insert($f1,hidden(array("name"=>"search",
                    "value"=>"$search")));
    insert($f1,hidden(array("name"=>"ipaddr",
                    "value"=>"$ipaddr")));
    insert($f1,hidden(array("name"=>"areaindex",
                    "value"=>"$areaindex")));
    insert($f1,hidden(array("name"=>"rangeindex",
                    "value"=>"$rangeindex")));
    insert($f1,hidden(array("name"=>"baseindex",
                    "value"=>"$baseindex")));
    insert($f1,hidden(array("name"=>"grp",
                    "value"=>"$grp")));
    insert($f1,hidden(array("name"=>"origcust",
                    "value"=>"$origcust")));
    
    $result=$ds->GetGrps();
    
    $lst=array();
    while($row = $result->FetchRow()) {
        $col=$row["grp"];
        $lst["$col"]=$row["grpdescrip"];
    }
    if (empty($lst)) {
        myError($w,$p, my_("You first need to create some groups!"));
    }
    
    // start form
    insert($w, $f = form(array("name"=>"ENTRY",
                    "method"=>"post",
                    "action"=>$_SERVER["PHP_SELF"])));
    
    if ($origcust and $origcust != $cust) {
        insert($f,radio(array("name"=>"duplicatesubnet",
                        "value"=>"0"),
                    my_("Move subnet to new customer"), "checked"));
        insert($f,radio(array("name"=>"duplicatesubnet",
                        "value"=>"1"),
                    my_("Duplicate subnet on new customer")));
        insert($f,radio(array("name"=>"duplicatesubnet",
                        "value"=>"2"),
                    my_("Duplicate subnet on new customer without IP detail")));
        insert($f,generic("br"));
    }
    
    insert($f,textbrbr(my_("Subnet description")));
    insert($f,input_text(array("name"=>"descrip",
                    "value"=>"$descrip",
                    "size"=>"80",
                    "maxlength"=>"80")));
    insert($f,generic("br"));
    insert($f,textbrbr(my_("Vlan number")));
    

    // HERE IS THE PART WHERE IT ALWAYS SHOWS 0 in the textfield (if I replace $vlannr with $descrip then value is shown)

    insert($f,input_text(array("name"=>"vlannr",
                    "value"=>"$vlannr",
                    "size"=>"4",
                    "maxlength"=>"4")));
    insert($f,generic("br"));
    insert($f,checkbox(array("name"=>"dhcp",
                         "value"=>"1"),
                         my_("Is this a DHCP subnet?"), $dhcp));
    insert($f,generic("br"));
    
    insert($f,hidden(array("name"=>"baseindex",
                    "value"=>"$baseindex")));
    insert($f,hidden(array("name"=>"cust",
                    "value"=>"$cust")));
    insert($f,hidden(array("name"=>"search",
                    "value"=>"$search")));
    insert($f,hidden(array("name"=>"ipaddr",
                    "value"=>"$ipaddr")));
    insert($f,hidden(array("name"=>"areaindex",
                    "value"=>"$areaindex")));
    insert($f,hidden(array("name"=>"rangeindex",
                    "value"=>"$rangeindex")));
    insert($f,hidden(array("name"=>"origcust",
                    "value"=>"$origcust")));
    
    insert($f,textbrbr(my_("Admin Group")));
    insert($f,textbr(my_("WARNING: If you choose a group that you do not have access to, you will not be able to see or access the data")));
    insert($f,selectbox($lst,
                array("name"=>"grp"),
                $grp));
    
     
  • Bart
    Bart
    2014-01-21

    Ok never mind I have nailed it :D:

    This part was missing :
    $vlannr=$row["vlannr"];

    after this :

    $result=$ds->GetBaseFromIndex($baseindex);
    if (!$row = $result->FetchRow()) {
    myError($w,$p, my_("Subnet cannot be found!"));
    }
    $size=$row["subnetsize"];
    $baseaddr=$row["baseaddr"];
    $baseip=inet_ntoa($row["baseaddr"]);
    $dhcp=$row["baseopt"] & 1;

     
    Last edit: Bart 2014-01-21