PageRenderTime 41ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/p078_dealerd1/p108_Lead_Management/p108_Quick.php

https://bitbucket.org/rlm3/rlm3
PHP | 253 lines | 218 code | 31 blank | 4 comment | 23 complexity | 7800f5f067190ed4fa524fef607c120c MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. include ("../../p093_includes/open_connection_database.php");
  3. include ("../../p093_includes/functions.inc.php");
  4. checkLogin();
  5. //get departments list
  6. $db->query("SELECT `cDepartment`.`cDepartment_ID`,
  7. `Department`
  8. FROM `cDepartment`
  9. INNER JOIN `cPeople_cDepartment`
  10. ON (`cPeople_cDepartment`.`cDepartment_ID`=`cDepartment`.`cDepartment_ID`)
  11. WHERE `cPeople_cDepartment`.`cPeople_ID`='%%1'
  12. ORDER BY `sort_code`,`DMS_DPT_Code`",
  13. $_SESSION['cPeople_ID']);
  14. $departments=$db->getList();
  15. $db->free();
  16. if (isset($_REQUEST['department'])) {
  17. $_SESSION['quick_department']=$_REQUEST['department'];
  18. }
  19. if (isset($_REQUEST['action']) && $_REQUEST['action']) {
  20. $data = array('p108_Lead_Status_ID'=>1,
  21. 'L_Day'=>date("Y-m-d H:i:s"),
  22. 'L_Details'=>$_REQUEST['note'],
  23. 'Lead_Summary'=>$_REQUEST['note'],
  24. 'DMS_Sync'=>'Y',
  25. 'EL_SP_cPeople_ID'=>$_REQUEST['cPeople_ID'],
  26. 'p108_Lead_Type_ID'=>$_REQUEST['lead_type'],
  27. 'L_cDepartment_ID'=>$_REQUEST['department']);
  28. $advertising = Advertising::findByCode($_REQUEST['source']);
  29. if ($advertising) {
  30. $data['EL_p108_Advertising_ID'] = $advertising->p108_Advertising_ID;
  31. }
  32. $db->insert('p108_Leads', $data);
  33. $db->query("SELECT CONCAT(`First_Name`,' ',`Last_Name`) FROM `cPeople` WHERE `cPeople_ID`='%%1'",$_REQUEST['cPeople_ID']);
  34. list($name)=$db->fetch();
  35. $db->free();
  36. $msg="Added Quick Enquiry for $name at ".date("d-m-Y h:ia");
  37. }
  38. ?>
  39. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  40. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  41. <head>
  42. <link rel="shortcut icon" href="/p093_includes/p078_dealerd/icon.ico" />
  43. <link rel="stylesheet" href="/p093_includes/css/p078_dealerd2.css" />
  44. <title>Llewellyn Motors - Lead Management System</title>
  45. <script type="text/javascript" src="/p093_includes/js/jquery.min.js"></script>
  46. </head>
  47. <body>
  48. <table cellpadding="5" height="100%" width="100%">
  49. <tr valign="top">
  50. <td width="1%">
  51. <div class="whitebox"><img alt="logo" src="/p093_includes/images/logo.jpg" /></div>
  52. <div class="vSpacer10"></div>
  53. <div class="whitebox"><?php include_once($dealerd_path.'menu.php')?></div>
  54. <div class="vSpacer10"></div>
  55. <div class="whitebox"><b>Welcome <?php echo $user?></b><br />View Deal Log</div>
  56. <div class="vSpacer10"></div>
  57. <div class="whitebox">
  58. <a href="javascript:window.print();">
  59. <img style="vertical-align:middle" alt="print" src="/p093_includes/images/print.jpg" />
  60. Print This Page
  61. </a>
  62. </div>
  63. </td>
  64. <td>
  65. <table class="whitebox" cellpadding="0" height="100%" width="100%">
  66. <tr valign="top">
  67. <td>
  68. <!-- start page -->
  69. <h1>Lead Management System</h1>
  70. <hr/>
  71. <p><a href="p108_Menu.php">Back to Lead Management</a></p>
  72. <h2>Quick Enquiry</h2>
  73. <p><b><?php if (isset($msg)) echo $msg; ?></b></p>
  74. <?php
  75. //get p108_Lead_Type
  76. $db->query("SELECT `p108_Lead_Type_ID`,
  77. `Lead_Code`
  78. FROM `p108_Lead_Type`
  79. WHERE 1
  80. ORDER BY `Lead_Sort_Code`");
  81. $lead_types=$db->getList();
  82. $lead_types=array(0=>'Select...')+$lead_types;
  83. $db->free();
  84. ?>
  85. <p>Enter in a quick note below which will be allocated to sale person to complete the enquiry register.</p>
  86. <p>An example might be "Man in Green hat on the yard" or "Guy from Brisbane on the Camry"</p>
  87. <table width="100%" border="0">
  88. <tr>
  89. <td width="440" valign="top">
  90. <form method="post" action="p108_Quick.php" onsubmit="return validate(this)">
  91. <input type="hidden" name="action" value="add" />
  92. <table cellpadding="0" cellspacing="0" class="list-table left-float" width="100%">
  93. <tr>
  94. <th>Enquiry</th>
  95. <th>Status</th>
  96. <th>Sales People</th>
  97. </tr>
  98. <tr>
  99. <td><textarea rows="5" cols="5" name="note" style="width:92%;height:70px"></textarea></td>
  100. <td valign="top">
  101. <select name="p108_Lead_Status_ID" style="width:100%">
  102. <option value=''>Select...</option>
  103. <?php
  104. $db->query("SELECT `p108_Lead_Status_ID`,
  105. `Lead_Status_Code`,
  106. `Status_Color`
  107. FROM `p108_Lead_Status`
  108. WHERE 1
  109. ORDER BY `Lead_Status_Sort_Code`");
  110. while ($row=$db->fetch()) {
  111. ?>
  112. <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>
  113. <?php
  114. }
  115. $db->free();
  116. ?>
  117. </select>
  118. </td>
  119. <td rowspan="5" style="width:390px" valign="top">
  120. <table class="no-background-table no-border-table" cellpadding="0" cellspacing="0" width="100%">
  121. <tr>
  122. <?php require('include/SP_List.php') ?>
  123. </tr>
  124. </table>
  125. </td>
  126. </tr>
  127. <tr>
  128. <th>Department</th>
  129. <th>Lead Type</th>
  130. </tr>
  131. <tr>
  132. <td>
  133. <?php
  134. $ctr=0;
  135. foreach ($departments as $id=>$name) {
  136. $ctr++;
  137. $rand_id='dpt_'.$id;
  138. ?>
  139. <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'; ?>/>
  140. <label for="<?php echo $rand_id; ?>"><?php echo $name; ?></label><br/>
  141. <?php
  142. }
  143. ?>
  144. </td>
  145. <td valign="top">
  146. <select name="lead_type" id="lead_type" style="width:100%">
  147. <?php foreach ($lead_types as $id=>$name):?>
  148. <option value="<?php echo $id; ?>"<?php if ($id==!$id) echo ' selected'; ?>><?php echo $name; ?></option>
  149. <?php endforeach?>
  150. </select>
  151. </td>
  152. </tr>
  153. <tr>
  154. <th colspan="2">Source of Enquiry (what media do they use)</th>
  155. </tr>
  156. <tr>
  157. <td colspan="2"><?php require_once ($_SERVER['DOCUMENT_ROOT'] . '/p078_dealerd1/p108_Lead_Management/include/soeBox.php')?></td>
  158. </tr>
  159. <tr>
  160. <td colspan="3">
  161. <button type="submit">Submit &raquo;</button>
  162. </td>
  163. </tr>
  164. </table>
  165. </form>
  166. </td>
  167. </tr>
  168. </table>
  169. <p><a href="p108_Menu.php">Back to Lead Management</a></p>
  170. <script type="text/javascript">
  171. function validate(form) {
  172. if (!getRadioValue(form.cPeople_ID)) {
  173. alert("Please select a salesperson");
  174. return false;
  175. }
  176. if (!getRadioValue(form.department)) {
  177. alert("Please select a department");
  178. return false;
  179. }
  180. if (document.getElementById('lead_type').value=='0' || document.getElementById('lead_type').value=='') {
  181. alert("Please select a lead type");
  182. return false;
  183. }
  184. return true;
  185. }
  186. function getRadioValue(obj) {
  187. var val='';
  188. if (!obj.length && obj) {
  189. if (obj.checked) {
  190. val=obj.value;
  191. }
  192. } else {
  193. for (var i=0; i < obj.length; i++) {
  194. if (obj[i].checked) {
  195. val=obj[i].value;
  196. }
  197. }
  198. }
  199. return val;
  200. }
  201. </script>
  202. <!-- end page -->
  203. </td>
  204. </tr>
  205. </table>
  206. </td>
  207. </tr>
  208. </table>
  209. </body>
  210. </html>
  211. <?php
  212. function getDirective($sort_code,$fields) {
  213. //returns a directive from $fields matching the $sort_code
  214. foreach ($fields as $id=>$field) {
  215. if ($field['sort_code']==$sort_code && $field['Type']=='R') {
  216. //matching directive
  217. return $field;
  218. }
  219. }
  220. return false;
  221. }
  222. ?>