Project

General

Profile

« Previous | Next » 

Revision 636a69e6

Added by Scott Dale over 18 years ago

more logic checks

View differences:

usr/local/www/firewall_schedule_edit.php
74 74
		$input_errors[] = "Reserved word used for schedule name.";
75 75
	} else {
76 76
		if (is_validaliasname($_POST['name']) == false)
77
			$input_errors[] = "The schedule name may only consist of the characters a-z, A-Z, 0-9, -";
77
			$input_errors[] = "The schedule name may only consist of the characters a-z, A-Z, 0-9";
78 78
	}
79 79
	
80 80
	if (!$_POST['schedule0'])
......
325 325
function checkForRanges(){
326 326
	if (daysSelected != "")
327 327
	{
328
		alert("You have not saved the specified time range. Please click 'Add Time' button to save the time range");
328
		alert("You have not saved the specified time range. Please click 'Add Time' button to save the time range.");
329 329
		return false;
330 330
	}
331 331
	else
......
547 547
		tr.appendChild(td);
548 548
		
549 549
		td = d.createElement("td");
550
		td.innerHTML = "<input type='image' src='/themes/" + theme + "/images/icons/icon_e.gif' onclick='editRow(\"" + tempTime + "\"); removeRow(this); return false;' value='Edit'>";
550
		td.innerHTML = "<input type='image' src='/themes/" + theme + "/images/icons/icon_e.gif' onclick='editRow(\"" + tempTime + "\",this); return false;' value='Edit'>";
551 551
		tr.appendChild(td);
552 552
			
553 553
		td = d.createElement("td");
......
597 597
	document.getElementById("timerangedescr").value = "";
598 598
}
599 599

  
600
function editRow(incTime) {
601
	//reset calendar and time
602
	clearCalendar();
603
	clearTime();
600
function editRow(incTime, el) {
601
	var check = checkForRanges();
604 602
	
605
	var starttimehour, descr, days, tempstr, starttimemin, hours, stoptimehour, stoptimemin = ""; 
606
	
607
	tempArray = incTime.split ("||");
608
	
609
	days = tempArray[0];
610
	hours = tempArray[1];
611
	descr = tempArray[2];
612
	
613
	var tempdayArray = days.split(",");
614
	var temphourArray = hours.split("-");
615
	tempstr = temphourArray[0];
616
	var temphourArray2 = tempstr.split(":");
617

  
618
	document.getElementById("starttimehour").value = temphourArray2[0];
619
	document.getElementById("starttimemin").value = temphourArray2[1];	
620
	
621
	tempstr = temphourArray[1];
622
	temphourArray2 = tempstr.split(":");
603
	if (check){  
604
		
605
		//reset calendar and time
606
		clearCalendar();
607
		clearTime();
608
		
609
		var starttimehour, descr, days, tempstr, starttimemin, hours, stoptimehour, stoptimemin = ""; 
610
		
611
		tempArray = incTime.split ("||");
612
		
613
		days = tempArray[0];
614
		hours = tempArray[1];
615
		descr = tempArray[2];
616
		
617
		var tempdayArray = days.split(",");
618
		var temphourArray = hours.split("-");
619
		tempstr = temphourArray[0];
620
		var temphourArray2 = tempstr.split(":");
623 621
	
624
	document.getElementById("stoptimehour").value = temphourArray2[0];
625
	document.getElementById("stoptimemin").value = temphourArray2[1];
622
		document.getElementById("starttimehour").value = temphourArray2[0];
623
		document.getElementById("starttimemin").value = temphourArray2[1];	
624
		
625
		tempstr = temphourArray[1];
626
		temphourArray2 = tempstr.split(":");
627
		
628
		document.getElementById("stoptimehour").value = temphourArray2[0];
629
		document.getElementById("stoptimemin").value = temphourArray2[1];
630
		
631
		document.getElementById("timerangedescr").value = descr;
626 632
	
627
	document.getElementById("timerangedescr").value = descr;
628

  
629
	//toggle the appropriate days
630
	for (i=0; i<tempdayArray.length; i++)
631
	{
632
		if (tempdayArray[i]){
633
			var tempweekstr = tempdayArray[i];
634
			dashpos = tempweekstr.search("-");			
635
					
636
			if (dashpos == "-1")
637
			{
638
				tempstr = "w2p" + tempdayArray[i];
639
			}
640
			else
641
			{
642
				tempstr = tempdayArray[i];
633
		//toggle the appropriate days
634
		for (i=0; i<tempdayArray.length; i++)
635
		{
636
			if (tempdayArray[i]){
637
				var tempweekstr = tempdayArray[i];
638
				dashpos = tempweekstr.search("-");			
639
						
640
				if (dashpos == "-1")
641
				{
642
					tempstr = "w2p" + tempdayArray[i];
643
				}
644
				else
645
				{
646
					tempstr = tempdayArray[i];
647
				}
648
				daytoggle(tempstr);
643 649
			}
644
			daytoggle(tempstr);
645 650
		}
651
		removeRownoprompt(el);
646 652
	}
647 653
}
648 654

  
649
function removeRow(el) {
655
function removeRownoprompt(el) {
650 656
    var cel;
651 657
    while (el && el.nodeName.toLowerCase() != "tr")
652 658
	    el = el.parentNode;
......
657 663
    }
658 664
}
659 665

  
666

  
667
function removeRow(el) {
668
	var check = confirm ("Do you really want to delete this time range?");
669
	if (check){
670
	    var cel;
671
	    while (el && el.nodeName.toLowerCase() != "tr")
672
		    el = el.parentNode;
673
	
674
	    if (el && el.parentNode) {
675
		cel = el.getElementsByTagName("td").item(0);
676
		el.parentNode.removeChild(el);
677
	    }
678
	}
679
}
680

  
660 681
</script>
661 682
EOD;
662 683
?>
......
679 700
               	<tr>
680 701
				  <td width="15%" valign="top" class="vncellreq">Schedule Name</td>
681 702
				  <td width="85%" class="vtable">
682
				  <input name="name" type="text" id="name" size="40" class="formfld" value="<?=htmlspecialchars($pconfig['name']);?>"><br>
703
				  <?php if(is_schedule_inuse($pconfig['name']) == true): ?>
704
				  			<input name="name" type="hidden" id="name" size="40"  value="<?=htmlspecialchars($pconfig['name']);?>" />
705
						  <?php echo $pconfig['name']; ?>
706
						      <p>
707
						        <span class="vexpl">NOTE: This schedule is in use so the name may not be modified!</span>
708
						      </p>
709
				<?php else: ?>
710
				  <input name="name" type="text" id="name" size="40" maxlength="40" class="formfld" value="<?=htmlspecialchars($pconfig['name']);?>"><br>
683 711
				      	<span class="vexpl">
684
     					   The name of the alias may only consist of the characters a-z, A-Z and 0-9, -, _
685
      					</span>					
712
     					   The name of the alias may only consist of the characters a-z, A-Z and 0-9
713
      					</span>
714
      			<?php endif; ?>   					
686 715
				  </td>
687 716
				</tr>
688 717
				<tr>
689 718
					<td width="15%" valign="top" class="vncell">Description</td>
690
					<td width="85%" class="vtable"><input name="descr" type="text" id="descr" size="40" class="formfld" value="<?=htmlspecialchars($pconfig['descr']);?>"><br>
719
					<td width="85%" class="vtable"><input name="descr" type="text" id="descr" size="40" maxlength="40" class="formfld" value="<?=htmlspecialchars($pconfig['descr']);?>"><br>
691 720
 						<span class="vexpl">
692 721
				        	You may enter a description here for your reference (not parsed).
693
				      	</span>     
694
				      </td>
722
				      	</span>
723
				  
724
					</td>
695 725
				</tr>
696 726
				<tr>
697 727
				</tr>
......
860 890
				</tr>
861 891
				<tr>
862 892
					<td width="15%" valign="top" class="vncell">Time Range Description</td>
863
					<td width="85%" class="vtable"><input name="timerangedescr" type="text" class="formfld" id="timerangedescr" size="40" maxlength="40" value=""><br>
893
					<td width="85%" class="vtable"><input name="timerangedescr" type="text" class="formfld" id="timerangedescr" size="40" maxlength="40"><br>
864 894
 						<span class="vexpl">
865 895
				        	You may enter a description here for your reference (not parsed).
866 896
				      	</span>     
......
997 1027
							        	<input type='text' readonly class='formfld' name='timedescr<?php echo $counter; ?>' id='timedescr<?php echo $counter; ?>' style=' word-wrap:break-word; width:100%; border:0px solid;' value='<?php echo $timedescr; ?>'>
998 1028
							        </td>
999 1029
							        <td>
1000
							        	<input type='image' src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_e.gif' onclick='editRow("<?php echo $tempTime; ?>"); removeRow(this); return false;' value='Edit'>
1030
							        	<input type='image' src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_e.gif' onclick='editRow("<?php echo $tempTime; ?>",this); return false;' value='Edit'>
1001 1031
							        </td>
1002 1032
							        <td>
1003 1033
							        	<input type='image' src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' onclick='removeRow(this); return false;' value='Delete'>

Also available in: Unified diff