Example #1
0
function addServiceForm($services)
{
    //global all variables and make the tool bar
    global $tool, $serviceForm, $headings, $titles, $serviceKey, $serviceTypes, $location, $status_array;
    //create the tools if this is not in Ajax mode
    /*Taken out for usability issues
    	if (!isset($_GET['mode']))
    	{
    		$toolNames = array("All Services", "All Archived Services");
    		$toolIcons = array("services", "services");
    		$toolHandlers = array("handleEvent('services.php')", "handleEvent('services.php?action=showArchived')");
    		echo $tool->createNewTools($toolNames, $toolIcons, $toolHandlers);
    	}*/
    $serviceForm->setCols(2);
    $serviceType;
    $value = $_GET['mode'];
    /*switch ($value)
    	{
    		case 0: $serviceType = 'commodity'; break;
    		case 1: $serviceType = 'oran'; break;
    		case 2: $serviceType = 'ix'; break;
    		case 3: $serviceType = 'undefined'; break;
    		case 4: $serviceType = 'l2_vlan'; break;
    		case 5: $serviceType = 'l2_transparant_p2p'; break;
    		case 6: $serviceType = 'l2_tranparant_multipoint'; break;
    		case 7: $serviceType = 'CU_ALL'; break;
    	}*/
    //gives the headings titles and service keyes to the corresponding layer
    if ($_GET['layer'] == 3) {
        $headings = array("Service Information", "*<break>*", "Port Specific Information", "*<break>*", "Routing Specific Information", "*<break>*", "IPv4 Information", "*<break>*", "IPv6 Information");
        $titles = array("Customer name", "Service type", "Include statistics in portal?.tip.If YES is selected the user will be able to see the statistics for this particular service in the wiki portal. If this is not selected, traffic stats for this service will not be available in the wiki portal", "Service description (name).tip.A useful description for this service", "Notes.tip.Here you can add generic notes for this service, for example: This is a tempory backup connection.", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Device for Service", "Interface.tip.Name of the physical interface, for example ge-2/0/1<br>Do not use subinterface format no ge-2/0/1.10", "Interface MTU Size.tip.Default for ORAN and CU_ALL is 9000 bytes, the commodity and IX instance use 1500", "Interface tagged", "Vlan number.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration", "*<break>*", "Logical router", "Routing type", "AS number", "Traffic Policing", "*<break>*", "IPv4 unicast", "IPv4 multicast", "BCNET router address.tip.IPv4 address of the BCNET side of this link. Please include masklenght. Format: x.x.x.x/30", "Customer router address.tip.IPv4 address of the Customer side of this link. Please include masklenght. Format: x.x.x.x/30", "IPv4 prefix", "*<break>*", "IPv6 unicast", "IPv6 multicast", "BCNET router address", "Customer router address", "IPv6 prefix");
        $serviceKey = array("cusName", "serviceType", "stats", "description", "notes", "status", "in_production", "out_production", "device", "interface", "interfaceMTU", "tagged", "vlanNum", "logiRout", "routType", "ASNum", "trafPolice", "ipv4Uni", "ipv4Multi", "pRoutAd4", "cRoutAd4", "prefix4", "ipv6Uni", "ipv6Multi", "pRoutAd6", "cRoutAd6", "prefix6");
        $layer3Service = new Layer3_service($services->get_service_id());
        $fieldType = array("drop_down", "drop_down", "radio", "", "text_area", "drop_down", "date_picker", "date_picker", "drop_down", "", "drop_down", "radio", "", "", "drop_down", "", "", "radio", "radio", "custom", "custom", "text_area.width:150px.height:100px", "radio", "radio", "custom", "custom", "text_area.width:200px.height:100px");
        $customKeys = array("pRoutAd4", "cRoutAd4", "pRoutAd6", "cRoutAd6");
        $custom = array();
        foreach ($customKeys as $id => $value) {
            $custom[$id] = "<input name=\"" . $customKeys[$id] . "\" id=\"" . $customKeys[$id] . "\" value=\"\" type=\"text\" maxChar=\"250\" style='width: 30%;'> / <input name=\"" . $customKeys[$id] . "-length\" id=\"" . $customKeys[$id] . "-length\" value=\"\" type=\"text\" maxChar=\"2\" style='width: 2%;'>";
        }
        //store the values in the info
        $fieldInfo = array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", $custom[0], $custom[1], "", "", "", $custom[2], $custom[3], "");
        $contact = new Contact();
        $customers = $contact->get_groups();
        $MTU = array(1500 => '1500', 9000 => '9000');
        $routingType = array('BGP' => 'BGP', 'Static' => 'Static');
        $allServiceTypes = ServiceType::get_service_types();
        $lay3Types = array();
        foreach ($allServiceTypes as $id => $value) {
            $curServiceType = new ServiceType($id);
            if ($curServiceType->get_service_layer() == 3) {
                $lay3Types[$id] = $curServiceType->get_name();
            }
        }
        $types = array($customers, $lay3Types, $status_array, Device::get_devices(), $MTU, $routingType);
        $serviceForm->setData($fieldInfo);
        $serviceForm->setFieldType($fieldType);
        //WEIRD BUG THAT I DUN GET BCNET ROUTER ADDRESS NOT WORKING
        //store all the contact information values into an array
        echo $serviceForm->newServiceForm($headings, $titles, $serviceKey, $types);
    } else {
        if ($_GET['layer'] == 2) {
            $serviceKey = array("cusName", "serviceType", "stats", "description", "notes", "status", "in_production", "out_production", "vlanNum");
            $headings = array("Service Information", "*<break>*", "Layer 2 Specific Information");
            $titles = array("Customer name", "Service type", "Include statistics in portal?.tip.If YES is selected the user will be able to see the statistics for this particular service in the wiki portal. If this is not selected, traffic stats for this service will not be available in the wiki portal", "Service description (name).tip.A useful description for this service", "Notes.tip.Here you can add generic notes for this service, for example: This is a tempory backup connection.", "Status.tip.Specify the production status of this Service", "In production date", "Out of production date", "*<break>*", "Vlan number.tip.Please enter a vlan number. If this is an untagged routed port and has no vlan, than please use 0. This means no vlan configuration");
            $types = "";
            $contact = new Contact();
            $allServiceTypes = ServiceType::get_service_types();
            $lay2Types = array();
            foreach ($allServiceTypes as $id => $value) {
                $curServiceType = new ServiceType($id);
                if ($curServiceType->get_service_layer() == 2) {
                    $lay2Types[$id] = $curServiceType->get_name();
                }
            }
            $customers = $contact->get_groups();
            $types = array($customers, $lay2Types, $status_array);
            $fieldType = array("drop_down", "drop_down", "radio", "", "text_area", "drop_down", "date_picker", "date_picker", "");
            //$fieldInfo = array("", $serviceType, "", "", "", "");
            $serviceForm->setFieldType($fieldType);
            //$serviceForm->setData($fieldInfo);
            //store all the service information values into an array
            echo $serviceForm->newServiceForm($headings, $titles, $serviceKey, $types);
        } else {
            $handler2 = "return LoadPage('services.php?action=add&layer=2&mode='+this.value, 'addLayerForm');";
            $handler3 = "return LoadPage('services.php?action=add&layer=3&mode='+this.value, 'addLayerForm');";
            // Change that... for some reason the above doesn't load the ajax scripts properly....
            // Specificaly the datepicker scripts.
            $handler2 = "window.location='services.php?action=add&layer=2';";
            $handler3 = "window.location='services.php?action=add&layer=3';";
            echo "\r\n\t\t<div style='margin-bottom:10px; clear:left;'>\r\n\t\t<form method='post'>\r\n\t\t<input type='radio' name='serviceType' value='2' onclick=\"{$handler2}\">Layer 2</input>\r\n\t\t<input type='radio' name='serviceType' value='3' onclick=\"{$handler3}\">Layer 3</input>\r\n\t\t</form></div>\r\n\t\t<div id='addLayerForm'></div>";
        }
    }
}