Location: PHPKode > projects > Yoxel Systems > yoxel_v1.24beta/lms/lms_view.php
<?php
// $Header: /home/CVS/rps/lms/lms_view.php,v 1.11 2008/06/30 02:24:59 yoxel Exp $
/*
 * ----START-LICENCE----
 * Copyright 2002-2008 Yoxel Systems, Santa Clara, CA, USA (hide@address.com)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 * -----END-LICENCE-----
 */

 $hide_header = true;
 $hide_logo = true;
 require_once "../includes/db.inc";
 require_once "includes/lms/lms.inc";

 define('ACTION_NORMAL', 0x0000);
 define('ACTION_SYNC', 0x0001);
 define('ACTION_STARTIMP', 0x0002);
 define('ACTION_STOPIMP', 0x0003);
 define('ACTION_RESUMEIMP', 0x0004);
 define('ACTION_DELRID', 0x0005);

 $rts = new LicenseManager();
 $pqs_2d=&$rts->init_pqs();

 $rts->request_view_common_handler();

$prefix='view';
require_once('includes/lms/keys_server_inc.php');

if(isset($_GET['license'])){
	$id = ereg_replace("[^0-9]", "", $_GET['license']);
 	$xstr2uid=array();
	$RInfo=$rts->request_info($id,$xstr2uid);

	$only_wfstate_opt_mask=WFSTATE_OPT_FIXED;
	$auto_next_state=$rts->set_state_action($RInfo['class'], $RInfo['state'], $RInfo['prev_state'], FALSE, $xstr2uid,FALSE,$only_wfstate_opt_mask);

	$rw=FALSE;
	if($rts->is_rw_field('license'))
		$rw=TRUE;

	$on_load_str="addkey($id,".($rw?"true":"false").",0);";
	$on_resize_str="save_geom('geom_lms')";
	require_once "includes/header.inc";
	view_menu($id,RTS_VIEW_IS_EXTRA);

	$rts->request_view_frm_Start($RInfo,'lms_view');
?>

<tr class="lgray">
 	<th colspan="3">License File</th>
</tr>
<tr class='lgray' valign='top'>
 <td colspan=3>
<?php
	echo '<textarea name="license" class="textar" rows="16"'.($rw?'':' disabled').' style="width: 100%;">'.html_safe_text($RInfo['license'], true).'</textarea>';
?>
 </td>
</tr>
<tr class='separator'>
 	<td style='height: 1' colspan="3"></td>
</tr>
<tr class="lgray">
 	<th colspan="3"><?php echo $rw?'Construct a feature set from available license keys':'Current feature set'; ?></th>
 </tr>
<tr class="lgray">
 	<th colspan="3">
 	<select class="selec" style="width: 32em" name="pkid">
 <?php
 	 for($row=$rts->first_key();$row;$row=$rts->next_key())
			echo '
		<option value="'.$row['kid'].'">'.$pqs_2d['name'][$row['pid']].' - '.$row['summary'].'</option>';
?>

	</select>
	<input class="gbtn" type="button" value="Add Key" onClick="addkey(<?php echo $id.','.($rw?"true":"false"); ?>)"<?php echo $rw?'':' disabled'; ?>>
	<input class="sbtn" type="button" value="Recompute" onClick="recompute()">
	<input type="hidden" name="klist" value="" >
	</th>
</tr>
<tr class="lgray">
	<td colspan="3"><div id="keys_list"></div></td>
</tr>
<tr style="background:white">
	<td colspan="3" align="center">
<?php
	if($rw)
		echo '
	<input class="wbtn" type="submit" value="Save">';
?>
	</td>
</tr>
</form>
<iframe name="view_iframe" width="1" height="0" frameborder="0" src=""></iframe>
<?php
	$rts->request_view_frm_Close($RInfo,FALSE);
	require_once("includes/footer.inc");
	exit;
}

 if(isset($_POST['license'])){
 	$id = ereg_replace("[^0-9]", "", $_POST['id']);
 	$xstr2uid=array();
	$RInfo=$rts->request_info($id,$xstr2uid);

	$only_wfstate_opt_mask=WFSTATE_OPT_FIXED;
	$auto_next_state=$rts->set_state_action($RInfo['class'], $RInfo['state'], $RInfo['prev_state'], FALSE, $xstr2uid,FALSE,$only_wfstate_opt_mask);

 	if (!$rts->is_rw_field('license') || !isset($_POST['license'])){
 		header("Location: ".$_SERVER['PHP_SELF']."?license=$id");
		exit();
 	}

 	if(isset($_POST['klist']))
		$klist=explode(',',$_POST['klist']);

	if(count($klist)){
		$keys=array();
		foreach($klist as $kid){
			if(isset($_POST['kun'.$kid]))
				$keys[$kid]['kun']=$_POST['kun'.$kid];
			if(isset($_POST['kad'.$kid]))
				$keys[$kid]['kad']=$_POST['kad'.$kid];
			if(isset($_POST['kmn'.$kid]))
				$keys[$kid]['kmn']=$_POST['kmn'.$kid];
		}
		$rts->attach_keys($id,$keys);
	}

	$lic = str_replace("\r","",stripslashes($_POST['license']));
	if ($lic != $RInfo['license']){
		$SQLStr .= " license = '".escape_data($lic)."'";
		$comment .= "License file changed (skipped)\n";
		$rts->request_view_update($RInfo,$SQLStr);
		$rts->log_history($RInfo,$uid,$comment);
	}

	header("Location: ".$_SERVER['PHP_SELF']."?license=$id");
	exit();
 }

if (isset($_GET['cc_add']) || isset($_GET['cc_del'])){
	require_once('includes/rts/cc_add_del_inc.php');
}

if (isset($_GET['history'])){	// Request ithistory ...
	$id = ereg_replace("[^0-9]", "", $_GET['history']);
	$xstr2uid=array();
	$RInfo=$rts->request_info($id,$xstr2uid);
	$ruid=$rts->request_owner($RInfo['class'],$RInfo['state'],$xstr2uid);

	// Read CC list
	$CCList = $rts->get_cc_list($id);
	$rts->add_to_cc_list($CCList,$ruid);
	$rts->add_to_cc_list($CCList,$RInfo['filed_by']);

	$Hist = &$rts->read_history($RInfo);

	$on_resize_str="save_geom('geom_lms')";
	require_once "includes/header.inc";

	// Output data from $Hist
	require_once "includes/rts/show_history_inc.php";

	require_once("includes/footer.inc");
	exit;
}	// isset($_GET['history'])

if (isset($_POST['id'])){
	$id = ereg_replace("[^0-9]", "", $_POST['id']);
	$xstr2uid=array();
	$RInfo=$rts->request_info($id,$xstr2uid);
	$rid_is_external=$rts->is_external($RInfo);

	$prev_state = $RInfo['prev_state'];
	$state		= $RInfo['state'];
	$class		= $RInfo['class'];
	$fixer		= $RInfo['fixer_uid'];
	$submitter	= $RInfo['filed_by'];

	$ism=$rts->inwork_state_mask[$class];
	$fsm=$rts->fixed_state_mask[$class];
	$vsm=$rts->verified_state_mask[$class];
	$lsm=$rts->last_state_mask($class);

	if (isset($_POST['just_comment'])){
		$comment = "\n".str_replace("\r", "", $_POST['just_comment']);
		$To = $rts->request_owner($class, $state, $xstr2uid);
		$rts->add_comment($RInfo, $comment, $To, $pqs_2d, isset($_POST['cc'])?$_POST['cc']:FALSE);
		header("Location: ".$_SERVER['PHP_SELF']."?history=$id");
		exit;
	}

	$a=explode(':',$_POST['actn']);
	$action = ereg_replace("[^0-9]", "", $a[0]);
	$wfaid = ereg_replace("[^0-9]", "", $a[1]);

	$SQL = array();
	$descr = "\n".str_replace("\r", "", $_POST['descr']);
	$SQLStr = ''; $comment = '';
	$Flags = $RInfo['options'];

	if($action!=ACTION_NORMAL)
		_quit_error('Unknown action ...');

	$rts->set_state_action($class, $state, $prev_state, $wfaid, $xstr2uid);
	$new_state=$rts->sa_next_state($wfaid);
	$action_name=$rts->sa_action_name($wfaid);
	$action_is_clone=$rts->sa_action_is_clone($wfaid);
	$comment = "Action: $action_name\n";
	$res=$rts->process_view_fields($RInfo,$xstr2uid,$action_is_clone);
	$SQLStr.=array_shift($res);
	$comment.=array_shift($res);

	// Each action comes with default updates
	$f2v=$rts->f2v_for_action($wfaid,$xstr2uid);
	//print_r($f2v);
	foreach($f2v as $f =>$v)
		$SQLStr.=", $f='".escape_data($v)."'";

	$RInfo['state']=$new_state;

	if($action_is_clone){
		$cloned_rid=$rts->clone_request($id);
		$sql_str=$rts->detect_state_change($cloned_rid,$new_state);
		$CRInfo=$RInfo;
		$CRInfo['rid']=$cloned_rid;
		$rts->log_history($CRInfo,$uid,$comment."Cloned from request: $id\n".$descr);

		$SQLStr = " state=$new_state $sql_str".($Flags!=$RInfo['options']?", options = {$RInfo['options']}":'')." $SQLStr";
		$RInfo['rid']=$cloned_rid;
		$RInfo['state']=$new_state;
		$rts->request_view_update($RInfo,$SQLStr);

		if($production_mode || !$at_isp)
			$rts->notify_by_email($cloned_rid, $uid, $_POST['descr'], $wfaid, false);

		header("Location: ".$_SERVER['PHP_SELF']."?id=$cloned_rid&reload=true");
	}else{
		$descr = "$comment$descr";
		$sql_str=$rts->detect_state_change($id,$new_state);
		$rts->log_history($RInfo,$uid,$descr);

		$SQLStr = " state=$new_state $sql_str".($Flags!=$RInfo['options']?", options = {$RInfo['options']}":'')." $SQLStr";

		$rts->request_view_update($RInfo,$SQLStr);

		if($production_mode || !$at_isp)
			$rts->notify_by_email($id, $uid, $_POST['descr'], $wfaid, false);

		header("Location: ".$_SERVER['PHP_SELF']."?id=$id&reload=true");
	}
	exit;
}	// isset($_POST['id'])


if (isset($_GET['id'])){
// Request view ...

	require_once('includes/rts/view_get_start_inc.php');

	$aList=array();
	$ExtPRList=array();
	$a2f=array();
	foreach($rts->state_actions['frequency'] as $wfaid => $f){
		$n=$rts->sa_action_name($wfaid);
		if($n)
			array_push($aList,ACTION_NORMAL.':'.$wfaid.':'.($f>0?'* ':'').$n);
		$a2f[$wfaid]=$rts->get_rw_fields($wfaid);
	}

	//if (($state&$lsm) && ($user_is&USER_IS_MU))
        //	array_push($aList, ACTION_DELRID.':0:Delete request');

	$on_resize_str="save_geom('geom_lms')";
	$on_load_str="rts_view_init(".isset($_GET['reload']).");";
	require_once("includes/header.inc");
	if($asp_mode)
		if(($licn=check_out_license(LIC_LMS))>-1){
                	if($licn>0)
                     	   _quit_error('License checkout failed. Licensed number of users ('.$licn.') for LMS already reached.');
               		else
                      	  _quit_error('License checkout failed. No license to use this part of LMS.');
		}

  require_once("includes/rts/js_view_filter_inc.php");
  view_menu($id,RTS_VIEW_IS_MAIN);

  $rts->request_view_frm_Start($RInfo);
  $rts->request_view_tr_Action($RInfo,$aList);
  $rts->request_view_tr_IDnDon($RInfo);
  $rts->request_view_tr_Submitter($RInfo);
  $rts->request_view_tr_State($RInfo);
  $rts->request_view_tr_Class($RInfo);
  $rts->request_view_tr_Synopsis($RInfo);
  $rts->request_view_tr_Fixer($RInfo,$xstr2uid,'Owner',FALSE);
  $rts->request_view_tr_AddRemoveCC($RInfo,$CCList,$inCCList);
  $rts->request_view_tr_Customer($RInfo,TRUE);
  $rts->request_view_tr_VBC($RInfo);
  $rts->request_view_tr_Amount($RInfo,'booking','Booking Amount','$');
  //$rts->request_view_tr_Amount($RInfo,'maintenance','Monthly Maintenance','$');
  $rts->request_view_tr_Platform($RInfo);
  $rts->request_view_tr_Hostid($RInfo);
  $rts->request_view_tr_Description($RInfo);
  $rts->request_view_frm_Close($RInfo);
?>


<script language='JavaScript'>
<!--
	filter_fields(document.view_frm<?php echo $aList?'':',true'; ?>);
//-->
</script>

<?php
	require_once("includes/footer.inc");
	exit;
} // isset($_GET['id'])

_quit_error("Unknown mode: ".$_SERVER['QUERY_STRING']." ...");


  function view_menu($id,$rts_view_menu=LMS_VIEW_IS_MAIN){
	global $dir_name;
	global $is_customer;
	global $help_msg;
	global $top_nav_menu;

	$main_here	= ($rts_view_menu == RTS_VIEW_IS_MAIN)   ? 'class="here"' : '';
	$history_here	= ($rts_view_menu == RTS_VIEW_IS_HISTORY)? 'class="here"' : '';
	$lic_here	= ($rts_view_menu == RTS_VIEW_IS_EXTRA)? 'class="here"' : '';
	if(isset($help_msg))
		$help_here = ($rts_view_menu == RTS_VIEW_IS_HELP)? 'class="here"' : '';

	$phrase_param = isset($_GET['phrase'])?'&phrase='.$_GET['phrase']:'';

	echo '
         <ul id="topnav">
            <li>'.yxl_gen_link('/lms/lms_view.php?id='.$id.$phrase_param,'main view',$main_here).'</li>
            <li>'.yxl_gen_link('/lms/lms_view.php?history='.$id.$phrase_param,'history',$history_here).'</li>
            <li>'.yxl_gen_link('/lms/lms_view.php?license='.$id.$phrase_param,'license',$lic_here).'</li>';
//	if(isset($help_msg)){
//		echo '
//	    <li><a href="'.$dir_name.'/lms/lms_view.php?help='.$id.$phrase_param.'" '.$help_here.'>help</a></li>';
//	}

	echo '
	</ul>';
  }
?>





Return current item: Yoxel Systems