Location: PHPKode > projects > Yoxel Systems > yoxel_v1.24beta/sfs/sfs_file.php
<?php
// $Header: /home/CVS/rps/sfs/sfs_file.php,v 1.12 2008/09/23 05:26:35 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-----
 */

	require_once('../includes/db.inc');
	require_once('includes/sfs/sfs.inc');

	$page_title='Sales Forecasting System';
	include_once('includes/header.inc');

	if($is_customer)
                _quit_error("You are not allowed to use this part of the site.");

        $rts = new ForecastTracker();
        $opt=0;

        $pqs_2d=&$rts->pqs_2d;
        $pqid=$user_params->pget('sfs_file_pqid');
        $class=SFS_REQ_CLASS_STD;
        if(!isset($pqs_2d['name'][$pqid]))
                $pqid=0;
        init_users();
        $first_cust=init_customers();
        $pcid=$user_params->pget('sfs_file_cust');
        if(!isset($customers_2d['name'][$pcid]))
                $pcid=0;

	if(isset($_POST['customer_id'])){

		$xok=TRUE;
		$fields=array();

		if(is_synopsis(stripslashes(trim($_POST['synop'])))){
                        $fields['synopsis'] = stripslashes(trim($_POST['synop']));
                }else{
                        $xok=FALSE;
                        _live_error('Please enter valid opportunity name (more than 4 characters long).');
                }

		if(isset($_POST['customer_id'])){
			$pcid=$_POST['customer_id'];
			if($pcid)
				$fields['customer_id']=$pcid;
			else{
				$xok=FALSE;
				_live_error('Please select an account.');
			}
		}else
			_die('No customer_id specified.');

		if(isset($_POST['lead_source'])){
			$fields['lead_source']=$_POST['lead_source'];
		}else
			_die('No lead_source specified.');

		if(isset($_POST['pid'])){
			$pid=$_POST['pid'];
			if($pid)
				$fields['pid']=$pid;
			else{
				$xok=FALSE;
				_live_error('Please select a product.');
			}
		}else
			_die('No pid specified.');

		if(isset($_POST['cc_list'])){
			$cc_list=$_POST['cc_list'];
			//echo "$cc_list <br>";
		}else
			$cc_list=FALSE;

		if(is_date(stripslashes(trim($_POST['ecd'])))){
			$fields['expected_close_date']=date_norm2sql(stripslashes(trim($_POST['ecd'])));

		}else{
			$xok=FALSE;
			_live_error('Please enter correct Expected Close Date.');
		}

		if(is_num(stripslashes(trim($_POST['eba'])))){
			$fields['booking_amount']=stripslashes(trim($_POST['eba']));
		}else{
			$xok=FALSE;
			_live_error('Please enter correct estimated booking amount.');
		}

		$d_orig = str_replace("\r","",stripslashes($_POST['descr']));
                if(is_description($d_orig)){
                        $fields['description'] = escape_data($d_orig);
                }else{
                        $xok=FALSE;
                        _live_error('Your description uses forbiden characters.');
                }

		if($xok){
			$rts->file_request($fields,$cc_list);
			$user_params->pset('sfs_file_pqid',$pid);
                	$user_params->pset('sfs_file_cust',$pcid);
                	$user_params->save();
                        _warning('Thank you for registering your forecast.');
                        header('Refresh: 2; '.$_SERVER['PHP_SELF']);
                        //header("Location: ".$_SERVER['PHP_SELF']);
                        exit();
                        $_POST=array();
                }
	}

        $cc_select=array();
        $cc_select[$uid]=TRUE;
        $allowed_cc=array();
        foreach($active_users as $u => $un){
        	if(YxlUsers::user_is($u)&USER_IS_CUSTOMER)
        		continue;
        	if(!in_array($u,$rts->get_user_options('fixer_uid')))
        		continue;
		arr_push($allowed_cc,$u);
	}
?>

<script>
<!--

  function go(form){

	if (text_check(form.synop))
                return alert('Please, enter opportunity name!');

	if (sel_check(form.customer_id))
                return alert('Please, select an account!');

        if (sel_check(form.pid))
                return alert('Please, select a product!');

	if (date_check(form.ecd))
                return alert('Please, enter expected close date!');

	if (int_check(form.eba))
                return alert('Please, enter estimated booking amount!');

        if (text_check(form.descr))
                return alert('Please, enter description!');

	collect_all(form);
	form.submit();
	disable_form(form);
  }

//-->
</script>

	<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"
		enctype="multipart/form-data">
	<input type="hidden" name="MAX_FILE_SIZE" value="3000000">
	<table width="100%" border=0 cellpadding=1 cellspacing=1>
	<tr class="column_header">
		 <th colspan=2 class="dgray">Sales Forecast</th>
	</tr>
	<tr style='height: 1' class='separator'>
		<td></td>
		<td></td>
        </tr>
	<tr class="lgray">
		<th width=30%>Opportunity Name</th>
		<td width=70%>
			<input class="inp" type="text" name="synop" size=48 maxlength=127 value="<?php if(isset($_POST['synop'])) echo $_POST['synop']; ?>" />
		</td>
	</tr>
	<tr class="lgray">
		<th width=30%>Account</th>
		<td width=70%>
		<select class="selec" name="customer_id">
			<option value="0">=Pick Account=</option>
<?php
	foreach ($customers_2d['name'] as $k => $v) {
		if(!$k) continue;
		if($customers_2d['options'][$k]&CUST_OPT_INTERNAL) continue;
		echo "<option value='$k'".($k == $pcid?' selected':'').">$v</option>";
	}
?>
		</select>
		</td>
	</tr>
	<tr class=lgray>
		<th width=30%>Lead Source</th>
		<td width=70%>
<?php
	if(isset($_POST['lead_source']))
		$cs=$_POST['lead_source'];
	else
		$cs=0;
?>
		<select class="selec" name="lead_source">
<?php
			foreach($lead_source as $k => $v)
				echo '
			<option value="'.$k.'"'.($k==$cs?' selected':'').'>'.$v.'</option>';
?>
		</select>
		</td>
	</tr>
	<tr class="lgray">
		<th width=30%>Product</th>
		<td width=70%>
		<select class="selec" name="pid">
			<option value="0">=Pick Product=</option>
<?php
		if(isset($_POST['pid']))
			$cs=$_POST['pid'];
		else
			$cs=$pid;
		foreach ($pqs_2d['name'] as $k => $v)
			echo "<option value='$k'".($k == $cs?' selected':'').">$v</option>";
?>
		</select>
		</td>
	</tr>
	<tr class="lgray" align='left'>
                        <th align='center'>CC List</th>
			<td colspan="2"><table>
			<TR>
                        	<td>
                                <input type='hidden' name='cc_list' value=''>
                                <select name='_cc_list' size=5 class='selec' onChange='sel_add(this)' width="100%">
<?php
                foreach($allowed_cc as $i => $u){
                        $n=$all_users_2d['name'][$u];
                        echo '<option value="'.$u.'">'.$n."</option>\n";
                }
?>
                                </select>
                        	</td>
                        	<td>
        				<input type='button' class='btn_small' value='Add >>' disabled><br>
        				<input type='button' name='_cc_list' class='btn_small' value='<< Delete' onClick='sel_del(this)'>
        			</td>
                        	<td>
                                <select name='__cc_list' size=5 class='selec' width="100%">
<?php
                foreach($allowed_cc as $i => $u){
                        if(!isset($cc_select[$u])) continue;
                        $n=$all_users_2d['name'][$u];
                        echo "<option value='$u'>".$n."</option>\n";
                }
?>
                                        </select>
                        	</td>
                        </tr>
                        </table></td>
                </tr>
	<tr class="lgray">
		<th width=30%>Expected Close Date</th>
		<td width=70%><input class="inp" type="text" name="ecd" value="
<?php
		if(isset($_POST['ecd']))
			echo $_POST['ecd'];
?>" size=10 maxlength=10>mm/dd/yyyy</td>
	</tr>
	<tr class="lgray">
		<th width=30%>Estimated Booking Amount $</th>
		<td width=70%><input class="inp" type="text" name="eba" size=7 maxlength=10 value="<?php if(isset($_POST['eba'])) echo $_POST['eba']; ?>" />
		</td>
	</tr>
	<tr class="lgray">
		<th width=30%>Description</th>
		<td width=70%>
			<textarea name="descr" rows=6 style="width: 100%">
<?php
		if(isset($_POST['descr'])) echo $_POST['descr'];
?></textarea>
		</td>
	</tr>
	<tr style='height: 1' class='separator'>
		<td></td>
		<td></td>
        </tr>
	<tr class="dgray">
		<td align=left colspan=2>
			<input class="btn_small" type="button" name="" value="File The Forecast" onClick="go(this.form)">
		</td>
	</tr>
	</table>
	</form>

<?php include_once("includes/footer.inc"); ?>
Return current item: Yoxel Systems