/p078_dealerd1/p108_Lead_Management/p108_Quick.php
PHP | 253 lines | 218 code | 31 blank | 4 comment | 23 complexity | 7800f5f067190ed4fa524fef607c120c MD5 | raw file
Possible License(s): GPL-2.0
- <?php
- include ("../../p093_includes/open_connection_database.php");
- include ("../../p093_includes/functions.inc.php");
-
- checkLogin();
-
- //get departments list
- $db->query("SELECT `cDepartment`.`cDepartment_ID`,
- `Department`
- FROM `cDepartment`
- INNER JOIN `cPeople_cDepartment`
- ON (`cPeople_cDepartment`.`cDepartment_ID`=`cDepartment`.`cDepartment_ID`)
- WHERE `cPeople_cDepartment`.`cPeople_ID`='%%1'
- ORDER BY `sort_code`,`DMS_DPT_Code`",
- $_SESSION['cPeople_ID']);
- $departments=$db->getList();
- $db->free();
-
- if (isset($_REQUEST['department'])) {
- $_SESSION['quick_department']=$_REQUEST['department'];
- }
-
- if (isset($_REQUEST['action']) && $_REQUEST['action']) {
- $data = array('p108_Lead_Status_ID'=>1,
- 'L_Day'=>date("Y-m-d H:i:s"),
- 'L_Details'=>$_REQUEST['note'],
- 'Lead_Summary'=>$_REQUEST['note'],
- 'DMS_Sync'=>'Y',
- 'EL_SP_cPeople_ID'=>$_REQUEST['cPeople_ID'],
- 'p108_Lead_Type_ID'=>$_REQUEST['lead_type'],
- 'L_cDepartment_ID'=>$_REQUEST['department']);
-
- $advertising = Advertising::findByCode($_REQUEST['source']);
- if ($advertising) {
- $data['EL_p108_Advertising_ID'] = $advertising->p108_Advertising_ID;
- }
-
- $db->insert('p108_Leads', $data);
-
- $db->query("SELECT CONCAT(`First_Name`,' ',`Last_Name`) FROM `cPeople` WHERE `cPeople_ID`='%%1'",$_REQUEST['cPeople_ID']);
- list($name)=$db->fetch();
- $db->free();
-
- $msg="Added Quick Enquiry for $name at ".date("d-m-Y h:ia");
- }
-
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <link rel="shortcut icon" href="/p093_includes/p078_dealerd/icon.ico" />
- <link rel="stylesheet" href="/p093_includes/css/p078_dealerd2.css" />
- <title>Llewellyn Motors - Lead Management System</title>
- <script type="text/javascript" src="/p093_includes/js/jquery.min.js"></script>
- </head>
- <body>
- <table cellpadding="5" height="100%" width="100%">
- <tr valign="top">
- <td width="1%">
- <div class="whitebox"><img alt="logo" src="/p093_includes/images/logo.jpg" /></div>
- <div class="vSpacer10"></div>
- <div class="whitebox"><?php include_once($dealerd_path.'menu.php')?></div>
- <div class="vSpacer10"></div>
- <div class="whitebox"><b>Welcome <?php echo $user?></b><br />View Deal Log</div>
- <div class="vSpacer10"></div>
-
- <div class="whitebox">
- <a href="javascript:window.print();">
- <img style="vertical-align:middle" alt="print" src="/p093_includes/images/print.jpg" />
- Print This Page
- </a>
- </div>
- </td>
- <td>
- <table class="whitebox" cellpadding="0" height="100%" width="100%">
- <tr valign="top">
- <td>
- <!-- start page -->
- <h1>Lead Management System</h1>
- <hr/>
-
- <p><a href="p108_Menu.php">Back to Lead Management</a></p>
-
- <h2>Quick Enquiry</h2>
- <p><b><?php if (isset($msg)) echo $msg; ?></b></p>
-
- <?php
- //get p108_Lead_Type
- $db->query("SELECT `p108_Lead_Type_ID`,
- `Lead_Code`
- FROM `p108_Lead_Type`
- WHERE 1
- ORDER BY `Lead_Sort_Code`");
- $lead_types=$db->getList();
- $lead_types=array(0=>'Select...')+$lead_types;
- $db->free();
-
- ?>
-
- <p>Enter in a quick note below which will be allocated to sale person to complete the enquiry register.</p>
- <p>An example might be "Man in Green hat on the yard" or "Guy from Brisbane on the Camry"</p>
-
- <table width="100%" border="0">
- <tr>
- <td width="440" valign="top">
- <form method="post" action="p108_Quick.php" onsubmit="return validate(this)">
- <input type="hidden" name="action" value="add" />
-
- <table cellpadding="0" cellspacing="0" class="list-table left-float" width="100%">
- <tr>
- <th>Enquiry</th>
- <th>Status</th>
- <th>Sales People</th>
- </tr>
- <tr>
- <td><textarea rows="5" cols="5" name="note" style="width:92%;height:70px"></textarea></td>
- <td valign="top">
- <select name="p108_Lead_Status_ID" style="width:100%">
- <option value=''>Select...</option>
- <?php
- $db->query("SELECT `p108_Lead_Status_ID`,
- `Lead_Status_Code`,
- `Status_Color`
- FROM `p108_Lead_Status`
- WHERE 1
- ORDER BY `Lead_Status_Sort_Code`");
-
- while ($row=$db->fetch()) {
- ?>
- <option value="<?php echo $row['p108_Lead_Status_ID']; ?>" <?php if($row['p108_Lead_Status_ID']=='1') echo 'selected="selected"'; ?>style="font-weight:bold;background-color:#<?php echo $row['Status_Color']; ?>"><?php echo $row['Lead_Status_Code']; ?></option>
- <?php
- }
- $db->free();
- ?>
- </select>
- </td>
-
- <td rowspan="5" style="width:390px" valign="top">
- <table class="no-background-table no-border-table" cellpadding="0" cellspacing="0" width="100%">
- <tr>
- <?php require('include/SP_List.php') ?>
- </tr>
- </table>
- </td>
- </tr>
-
- <tr>
- <th>Department</th>
- <th>Lead Type</th>
- </tr>
-
- <tr>
- <td>
- <?php
- $ctr=0;
- foreach ($departments as $id=>$name) {
- $ctr++;
- $rand_id='dpt_'.$id;
- ?>
- <input type="radio" id="<?php echo $rand_id; ?>" name="department" value="<?php echo $id; ?>"<?php if (isset($_SESSION['quick_department']) && $_SESSION['quick_department']==$id) echo ' checked'; ?>/>
- <label for="<?php echo $rand_id; ?>"><?php echo $name; ?></label><br/>
- <?php
- }
-
- ?>
- </td>
- <td valign="top">
- <select name="lead_type" id="lead_type" style="width:100%">
- <?php foreach ($lead_types as $id=>$name):?>
- <option value="<?php echo $id; ?>"<?php if ($id==!$id) echo ' selected'; ?>><?php echo $name; ?></option>
- <?php endforeach?>
- </select>
- </td>
- </tr>
-
- <tr>
- <th colspan="2">Source of Enquiry (what media do they use)</th>
- </tr>
- <tr>
- <td colspan="2"><?php require_once ($_SERVER['DOCUMENT_ROOT'] . '/p078_dealerd1/p108_Lead_Management/include/soeBox.php')?></td>
- </tr>
-
- <tr>
- <td colspan="3">
- <button type="submit">Submit »</button>
- </td>
- </tr>
- </table>
- </form>
- </td>
- </tr>
- </table>
-
- <p><a href="p108_Menu.php">Back to Lead Management</a></p>
-
- <script type="text/javascript">
- function validate(form) {
- if (!getRadioValue(form.cPeople_ID)) {
- alert("Please select a salesperson");
- return false;
- }
- if (!getRadioValue(form.department)) {
- alert("Please select a department");
- return false;
- }
- if (document.getElementById('lead_type').value=='0' || document.getElementById('lead_type').value=='') {
- alert("Please select a lead type");
- return false;
- }
-
-
- return true;
- }
-
- function getRadioValue(obj) {
- var val='';
- if (!obj.length && obj) {
- if (obj.checked) {
- val=obj.value;
- }
- } else {
- for (var i=0; i < obj.length; i++) {
- if (obj[i].checked) {
- val=obj[i].value;
- }
- }
- }
- return val;
- }
- </script>
- <!-- end page -->
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
- </html>
- <?php
- function getDirective($sort_code,$fields) {
- //returns a directive from $fields matching the $sort_code
- foreach ($fields as $id=>$field) {
- if ($field['sort_code']==$sort_code && $field['Type']=='R') {
- //matching directive
-
- return $field;
- }
- }
-
- return false;
- }
- ?>