Advertisement
Guest User

Untitled

a guest
Aug 8th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.23 KB | None | 0 0
  1. //Store customer data in DB from sign-up form
  2. add_action('wp_ajax_bre_signup_preview_pdf', 'bre_signup_preview_pdf');
  3. add_action('wp_ajax_nopriv_bre_signup_preview_pdf', 'bre_signup_preview_pdf');
  4.  
  5. /**
  6. *
  7. * PROPOSED FUNCTION
  8. *
  9. * @The following functions are designed to replace the:
  10. * - breContractPDF()
  11. * - makePDF()
  12. *
  13. * breGetContractData($type=session|db, $id=contract_id){}
  14. * breGeneratePDF($data){}
  15. * breEmailPDF($data, $pdf_path){}
  16. *
  17. */
  18.  
  19. function bre_signup_preview_pdf(){
  20. if ( !wp_verify_nonce($_POST['nonce'], 'nebula_ajax_nonce') ){
  21. die('Permission Denied.');
  22. }
  23. breGetContractData('session');
  24. }
  25.  
  26. function breGetContractData($type, $id=false){
  27.  
  28. // echo 'This is action is saved within the LIVE theme!'; wp_die();
  29.  
  30. $type = ($type == 'db')? 'db': 'session';
  31.  
  32. #1- Determine if we should use DB
  33. if( $type == 'db' ){ //&& $id
  34.  
  35. //////////////////////////
  36. // @TODO: abstract this to remove the connection details and pull them from the wp-config
  37. //////////////////////////
  38. $servername = 'localhost';
  39. $username = 'bluerockenergy';
  40. $password = 'rgy572$BRE';
  41. $dbname = 'bluerock_wp';
  42.  
  43. // Create connection
  44. $conn = new mysqli($servername, $username, $password, $dbname);
  45. // Check connection
  46. if ($conn->connect_error) {
  47. die("Connection failed: " . $conn->connect_error);
  48. }
  49.  
  50. $sql = "SELECT id, service_type, first_name, last_name, company, emailaddress, electricplan, electric_utility, bre_electricplan, bre_electric_fixed_price_shown, bre_greenoptionpercentage, eletric_account_number_1, eletric_account_number_2, eletric_account_number_3, eletric_account_number_4, eletric_account_number_5, glasplan, gas_utility, bre_gasplan, bre_gas_fixed_price_shown, gas_account_number_1, gas_account_number_2, gas_account_number_3, gas_account_number_4, gas_account_number_5, contact_first_name, contact_last_name, contact_phone, contact_email, contact_fax, tax_exempt, tax_exempt_filename, mailing_address_1, mailing_address_2, mailing_city, mailing_state, mailing_zip, billing_address_1, billing_address_2, billing_city, billing_state, billing_zip, service_address_1, service_address_2, service_city, service_state, service_zip, industry, promo_code, electric_terms_accepted, gas_terms_accepted, hard_copy_requested, bill_of_rights_accepted, identity_validation_code, confirmation_number ga_cid, timestamp, contract_generated, confirmation_number_el, confirmation_number_gas
  51. FROM customer_signups
  52. ORDER BY `id` DESC LIMIT 0,1"; //WHERE?
  53.  
  54. $result = $conn->query($sql);
  55.  
  56. if ($result->num_rows > 0) {
  57. // output data of each row
  58. while($row = $result->fetch_assoc()) {
  59.  
  60. $PDFvalues = $row;
  61.  
  62. $customer_data = array(
  63. 'id' => $row["id"],
  64. 'service_type' => $row["service_type"],
  65. 'first_name' => $row["first_name"],
  66. 'last_name' => $row["last_name"],
  67. 'company' => $row["company"],
  68. 'emailaddress' => $row["emailaddress"],
  69. 'electricplan' => $row["electricplan"],
  70. 'electric_utility' => $row["electric_utility"],
  71. 'bre_electricplan' => $row["bre_electricplan"],
  72. 'bre_electric_fixed_price_shown' => $row["bre_electric_fixed_price_shown"],
  73. 'bre_greenoptionpercentage' => $row["bre_greenoptionpercentage"],
  74. 'eletric_account_number_1' => $row["eletric_account_number_1"],
  75. 'eletric_account_number_2' => $row["eletric_account_number_2"],
  76. 'eletric_account_number_3' => $row["eletric_account_number_3"],
  77. 'eletric_account_number_4' => $row["eletric_account_number_4"],
  78. 'eletric_account_number_5' => $row["eletric_account_number_5"],
  79. 'glasplan' => $row["glasplan"],
  80. 'gas_utility' => $row["gas_utility"],
  81. 'bre_gasplan' => $row["bre_gasplan"],
  82. 'bre_gas_fixed_price_shown' => $row["bre_gas_fixed_price_shown"],
  83. 'gas_account_number_1' => $row["gas_account_number_1"],
  84. 'gas_account_number_2' => $row["gas_account_number_2"],
  85. 'gas_account_number_3' => $row["gas_account_number_3"],
  86. 'gas_account_number_4' => $row["gas_account_number_4"],
  87. 'gas_account_number_5' => $row["gas_account_number_5"],
  88. 'contact_first_name' => $row["contact_first_name"],
  89. 'contact_last_name' => $row["contact_last_name"],
  90. 'contact_phone' => $row["contact_phone"],
  91. 'contact_email' => $row["contact_email"],
  92. 'contact_fax' => $row["contact_fax"],
  93. 'tax_exempt' => $row["tax_exempt"],
  94. 'tax_exempt_filename' => $row["tax_exempt_filename"],
  95. 'mailing_address_1' => $row["mailing_address_1"],
  96. 'mailing_address_2' => $row["mailing_address_2"],
  97. 'mailing_city' => $row["mailing_city"],
  98. 'mailing_state' => $row["mailing_state"],
  99. 'mailing_zip' => $row["mailing_zip"],
  100. 'billing_address_1' => $row["billing_address_1"],
  101. 'billing_address_2' => $row["billing_address_2"],
  102. 'billing_city' => $row["billing_city"],
  103. 'billing_state' => $row["billing_state"],
  104. 'billing_zip' => $row["billing_zip"],
  105. 'service_address_1' => $row["service_address_1"],
  106. 'service_address_2' => $row["service_address_2"],
  107. 'service_city' => $row["service_city"],
  108. 'service_state' => $row["service_state"],
  109. 'service_zip' => $row["service_zip"],
  110. 'industry' => $row["industry"],
  111. 'promo_code' => $row["promo_code"],
  112. 'electric_terms_accepted' => $row["electric_terms_accepted"],
  113. 'gas_terms_accepted' => $row["gas_terms_accepted"],
  114. 'hard_copy_requested' => $row["hard_copy_requested"],
  115. 'bill_of_rights_accepted' => $row["bill_of_rights_accepted"],
  116. 'identity_validation_code' => $row["identity_validation_code"],
  117. 'confirmation_number_el' => $row["confirmation_number_el"],
  118. 'confirmation_number_gas' => $row["confirmation_number_gas"],
  119. 'contract_generated' => $row["contract_generated"],
  120. 'ga_cid' => $row["ga_cid"],
  121. 'timestamp' => $row["timestamp"],
  122. );
  123.  
  124. } //endwhile
  125.  
  126. // @TODO: if we're doing the DB side of things, we should probably update DB like the current working function.
  127. // @TODO: COME BACK TO THIS!
  128. // ...
  129.  
  130. } //endif
  131.  
  132. } else{ #1- Or determine if we should just use the SESSION data
  133.  
  134. $customer_data = array(
  135. 'service_type' => sanitize_text_field($_POST['data']['service_type']),
  136. 'first_name' => sanitize_text_field($_POST['data']['first_name']),
  137. 'last_name' => sanitize_text_field($_POST['data']['last_name']),
  138. 'company' => sanitize_text_field($_POST['data']['company']),
  139. 'emailaddress' => sanitize_text_field($_POST['data']['emailaddress']),
  140. 'electricplan' => sanitize_text_field($_POST['data']['electricplan']),
  141. 'electric_utility' => sanitize_text_field($_POST['data']['electric_utility']),
  142. 'bre_electricplan' => sanitize_text_field($_POST['data']['bre_electricplan']),
  143. 'bre_electric_fixed_price_shown' => sanitize_text_field($_POST['data']['bre_electric_fixed_price_shown']),
  144. 'bre_greenoptionpercentage' => sanitize_text_field($_POST['data']['bre_greenoptionpercentage']),
  145. 'eletric_account_number_1' => sanitize_text_field($_POST['data']['eletric_account_number_1']),
  146. 'eletric_account_number_2' => sanitize_text_field($_POST['data']['eletric_account_number_2']),
  147. 'eletric_account_number_3' => sanitize_text_field($_POST['data']['eletric_account_number_3']),
  148. 'eletric_account_number_4' => sanitize_text_field($_POST['data']['eletric_account_number_4']),
  149. 'eletric_account_number_5' => sanitize_text_field($_POST['data']['eletric_account_number_5']),
  150. 'glasplan' => sanitize_text_field($_POST['data']['glasplan']),
  151. 'gas_utility' => sanitize_text_field($_POST['data']['gas_utility']),
  152. 'bre_gasplan' => sanitize_text_field($_POST['data']['bre_gasplan']),
  153. 'bre_gas_fixed_price_shown' => sanitize_text_field($_POST['data']['bre_gas_fixed_price_shown']),
  154. 'gas_account_number_1' => sanitize_text_field($_POST['data']['gas_account_number_1']),
  155. 'gas_account_number_2' => sanitize_text_field($_POST['data']['gas_account_number_2']),
  156. 'gas_account_number_3' => sanitize_text_field($_POST['data']['gas_account_number_3']),
  157. 'gas_account_number_4' => sanitize_text_field($_POST['data']['gas_account_number_4']),
  158. 'gas_account_number_5' => sanitize_text_field($_POST['data']['gas_account_number_5']),
  159. 'contact_first_name' => sanitize_text_field($_POST['data']['contact_first_name']),
  160. 'contact_last_name' => sanitize_text_field($_POST['data']['contact_last_name']),
  161. 'contact_phone' => sanitize_text_field($_POST['data']['contact_phone']),
  162. 'contact_email' => sanitize_text_field($_POST['data']['contact_email']),
  163. 'contact_fax' => sanitize_text_field($_POST['data']['contact_fax']),
  164. 'tax_exempt' => sanitize_text_field($_POST['data']['tax_exempt']),
  165. 'tax_exempt_filename' => sanitize_text_field($_POST['data']['tax_exempt_filename']),
  166. 'mailing_address_1' => sanitize_text_field($_POST['data']['mailing_address_1']),
  167. 'mailing_address_2' => sanitize_text_field($_POST['data']['mailing_address_2']),
  168. 'mailing_city' => sanitize_text_field($_POST['data']['mailing_city']),
  169. 'mailing_state' => sanitize_text_field($_POST['data']['mailing_state']),
  170. 'mailing_zip' => sanitize_text_field($_POST['data']['mailing_zip']),
  171. 'billing_address_1' => sanitize_text_field($_POST['data']['billing_address_1']),
  172. 'billing_address_2' => sanitize_text_field($_POST['data']['billing_address_2']),
  173. 'billing_city' => sanitize_text_field($_POST['data']['billing_city']),
  174. 'billing_state' => sanitize_text_field($_POST['data']['billing_state']),
  175. 'billing_zip' => sanitize_text_field($_POST['data']['billing_zip']),
  176. 'service_address_1' => sanitize_text_field($_POST['data']['service_address_1']),
  177. 'service_address_2' => sanitize_text_field($_POST['data']['service_address_2']),
  178. 'service_city' => sanitize_text_field($_POST['data']['service_city']),
  179. 'service_state' => sanitize_text_field($_POST['data']['service_state']),
  180. 'service_zip' => sanitize_text_field($_POST['data']['service_zip']),
  181. 'industry' => sanitize_text_field($_POST['data']['industry']),
  182. 'promo_code' => sanitize_text_field($_POST['data']['promo_code']),
  183. 'electric_terms_accepted' => sanitize_text_field($_POST['data']['electric_terms_accepted']),
  184. 'gas_terms_accepted' => sanitize_text_field($_POST['data']['gas_terms_accepted']),
  185. 'hard_copy_requested' => sanitize_text_field($_POST['data']['hard_copy_requested']),
  186. 'bill_of_rights_accepted' => sanitize_text_field($_POST['data']['bill_of_rights_accepted']),
  187. 'identity_validation_code' => sanitize_text_field($_POST['data']['identity_validation_code']),
  188. 'confirmation_number_el' => sanitize_text_field($_POST['data']['confirmation_number_el']),
  189. 'confirmation_number_gas' => sanitize_text_field($_POST['data']['confirmation_number_gas']),
  190. 'contract_generated' => '',
  191. 'ga_cid' => sanitize_text_field($_POST['data']['ga_cid']),
  192. 'timestamp' => sanitize_text_field(time()),
  193. );
  194.  
  195. } //endelse
  196.  
  197. // echo json_encode( $customer_data ); wp_die();
  198. breGeneratePDF($customer_data);
  199.  
  200. }
  201.  
  202. function breGeneratePDF($data){
  203. // echo json_encode( $customer_data ); wp_die();
  204. // echo 'Jef!';
  205.  
  206. ///////////////////////////// create contract number section end
  207. // @NOTE: HEREBLOCK should never be indented.
  208. // FDF header section
  209. $fdf_header = <<<FDF
  210. %FDF-1.2
  211.  
  212. 1 0 obj
  213. <<
  214. /FDF << /Fields [
  215. FDF;
  216.  
  217. // FDF footer section
  218. $fdf_footer = <<<FDF
  219. ] >> >>
  220. endobj
  221. trailer
  222. << /Root 1 0 R >>
  223. %%EOF;
  224. FDF;
  225. // @NOTE: HEREBLOCK should never be indented.
  226.  
  227. switch( $data['mailing_state'] ){ //@TODO: consider pulling the contact_state?
  228. case 'NY':
  229. $fdf_content = getNYcontractTemplate( $data );
  230. break;
  231. // @TODO: Commenting these out until we need them
  232. // case 'PA':
  233. // $fdf_content = getPAcontractTemplate( $data );
  234. // break;
  235. // case 'MA':
  236. // $fdf_content = getMAcontractTemplate( $data );
  237. // break;
  238. // case 'CT':
  239. // $fdf_content = getCTcontractTemplate( $data );
  240. // break;
  241. }
  242.  
  243. // Logic pushed into each template function
  244. // if ($electricplan == 1){
  245. // $resultE = makePDF("E", $PDFvalues, $electricContractNumber);
  246. // }
  247.  
  248. // if ($glasplan == 1){
  249. // $resultG = makePDF("G", $PDFvalues, $gasContractNumber);
  250. // }
  251.  
  252. }
  253.  
  254. function getNYcontractTemplate($data){
  255.  
  256. if($data['electric_utility']== "NatGrid-E"){
  257. $electric_utilityTxt = "National Grid - Upstate NY";
  258. } else if($data['electric_utility']== "ConEd-E"){
  259. $electric_utilityTxt = "Consolidated Edison";
  260. } else if($data['electric_utility']== "NYSEG-E"){
  261. $electric_utilityTxt = "NYSEG";
  262. } else if($data['electric_utility']== "NYSEG"){ // incase this value gets changed from NYSEG-E to NYSEG
  263. $electric_utilityTxt = "NYSEG";
  264. } else if($data['electric_utility']== "O&R-E"){
  265. $electric_utilityTxt = "Orange & Rockland";
  266. } else if($data['electric_utility']== "RGE-E"){
  267. $electric_utilityTxt = "Rochester Gas & Electric";
  268. } else if($data['electric_utility']== "CHGE-E"){
  269. $electric_utilityTxt = "Central Hudson Gas & Electric";
  270. }
  271.  
  272. if($data['gas_utility']== "NatGrid-G"){
  273. $gas_utilityTxt = "National Grid - Upstate NY";
  274. } else if($data['gas_utility']== "Keyspan-G"){
  275. $gas_utilityTxt = "National Grid - Metro NY";
  276. } else if($data['gas_utility']== "KeyspanLI-G"){
  277.  
  278. $gas_utilityTxt = "National Grid - Long Island NY";
  279. } else if($data['gas_utility']== "ConEd-G"){
  280. $gas_utilityTxt = "Consolidated Edison";
  281. } else if($data['gas_utility']== "NYSEG-G"){
  282. $gas_utilityTxt = "NYSEG";
  283. } else if($data['gas_utility']== "NYSEG"){// incase this value gets changed from NYSEG-E to NYSEG
  284. $gas_utilityTxt = "NYSEG";
  285. } else if($data['gas_utility']== "O&R-G"){
  286. $gas_utilityTxt = "Orange & Rockland";
  287. } else if($data['gas_utility']== "RGE-G"){
  288. $gas_utilityTxt = "Rochester Gas & Electric";
  289. } else if($data['gas_utility']== "CHGE-G"){
  290. $gas_utilityTxt = "Central Hudson Gas & Electric";
  291. } else if($data['gas_utility']== "NationalGas"){
  292. $gas_utilityTxt = "National Fuel Gas";
  293. }
  294.  
  295. //confirmation number field under logo
  296. if($data['electricplan'] == 1){
  297. $confirmation_number_el_top = "Confirmation #: BRE-" . $data['contractNumber']; //when called from an if then statemment where electic is true, an electric contract number is passed into ' $data[$ontractNumber']
  298. $fdf_content = "<< /T(confirmNumber)/V({$confirmation_number_el_top}) >>";
  299. }
  300.  
  301. if($data['glasplan'] == 1){
  302. $confirmation_number_gas_top = "Confirmation #: BRE-" . $data['contractNumber'];//when called from an if then statemment where gas is true, a gas contract number is passed into ' $data[$ontractNumber']
  303. $fdf_content .= "<< /T(gasConfirmNumber)/V({$confirmation_number_gas_top}) >>";
  304. }
  305.  
  306. //time and date field under logo
  307. $datetimeFormat = 'Y-m-d H:i:sa';
  308. $date = new \DateTime();
  309. $date->setTimestamp($timestamp);
  310. $dateTime = $date->format($datetimeFormat);
  311.  
  312. $customerName = $data['first_name'] . " " . $data['last_name'];
  313. $fdf_content .= "<< /T(customer)/V({$customerName}) >>";//page 2
  314. $fdf_content .= "<< /T(company)/V({$company}) >>";//page 1
  315. $fdf_content .= "<< /T(utilityName)/V({$electric_utilityTxt}) >>";
  316.  
  317. //electric utility rate ready radio buttons
  318. $NYSEG = 'NYSEG';
  319. $RGE = 'RGE';
  320.  
  321. //electric utility bill ready radio buttons
  322. $NationalGrid = 'NationalGrid';
  323. $ConEdison = 'ConEdison';
  324. $CentralHudson = 'CentralHudson';
  325. $OR = 'OR';
  326.  
  327. //bill ready buttons
  328. if ($data['electric_utility'] == 'NYSEG-E'){
  329. $fdf_content .= "<< /T(utility)/V({$NYSEG}) >>"; //bill ready page 1 radio button
  330. $fdf_content .= "<< /T(utility2)/V({$NYSEG}) >>"; //bill ready page 5 radio button
  331. } else if($data['electric_utility'] == 'RGE-E'){
  332. $fdf_content .= "<< /T(utility)/V({$RGE}) >>"; //bill ready page 1 radio button
  333. $fdf_content .= "<< /T(utility2)/V({$RGE}) >>"; //bill ready page 5 radio button
  334. //rate ready buttons
  335. } else if($data['electric_utility'] == 'NatGrid-E'){
  336. $fdf_content .= "<< /T(utilityName2)/V({$NationalGrid}) >>"; //rate ready page 5 radio button
  337. } else if($data['electric_utility'] == 'ConEd-E'){
  338. $fdf_content .= "<< /T(utilityName2)/V({$ConEdison}) >>";//rate ready page 5 radio button
  339. } else if($data['electric_utility'] == 'CHGE-E'){
  340. $fdf_content .= "<< /T(utilityName2)/V({$CentralHudson}) >>";//rate ready page 5 radio button
  341. } else if($data['electric_utility'] == 'O&R-E'){
  342. $fdf_content .= "<< /T(utilityName2)/V({$ORG}) >>";//rate ready page 5 radio button
  343. }
  344.  
  345. //gas utility text field
  346. $fdf_content .= "<< /T(gasUtilityName)/V({$gas_utilityTxt}) >>";
  347.  
  348. //the following is for Gas utility radio buttons if the utility is national grid
  349. $upstate = 'Upstate';
  350. $metro = 'Metro';
  351. $longIsland = 'LongIsland';
  352.  
  353. $NationalGridUpstate = 'NationalGridUpstate';
  354. $NationalGridMetro = 'NationalGridMetro';
  355. $NationalGridLongIsland = 'NationalGridLongIsland';
  356. $ConEdison = 'ConEdison';
  357. $NYSEG = 'NYSEG';
  358. $ORG = 'OR';
  359. $RGE = 'RGE';
  360. $CentralHudson = 'CentralHudson';
  361. $NationalFuel = 'NationalFuel';
  362.  
  363. if($data['gas_utility'] == 'NatGrid-G'){
  364. $fdf_content .= "<< /T(gasUtilityNG)/V({$upstate}) >>"; //gas utility radio button page 1
  365. $fdf_content .= "<< /T(gasUtility2)/V({$NationalGridUpstate}) >>"; //gas utility radio button page 5
  366. } else if($data['gas_utility'] == 'Keyspan-G'){
  367. $fdf_content .= "<< /T(gasUtilityNG)/V({$metro}) >>"; //gas utility radio button page 1
  368. $fdf_content .= "<< /T(gasUtility2)/V({$NationalGridMetro}) >>"; //gas utility radio button page 5
  369. } else if($data['gas_utility'] == 'KeyspanLI-G'){
  370. $fdf_content .= "<< /T(gasUtilityNG)/V({$longIsland}) >>"; //gas utility radio button page 1
  371. $fdf_content .= "<< /T(gasUtility2)/V({$NationalGridLongIsland}) >>"; //gas utility radio button page 5
  372. } else if($data['gas_utility'] == 'ConEd-G'){
  373. $fdf_content .= "<< /T(gasUtility2)/V({$ConEdison}) >>"; //gas utility radio button page 5
  374. } else if($data['gas_utility'] == 'NYSEG-G'){
  375. $fdf_content .= "<< /T(gasUtility2)/V({$NYSEG}) >>"; //gas utility radio button page 5
  376. } else if($data['gas_utility'] == 'O&R-G'){
  377. $fdf_content .= "<< /T(gasUtility2)/V({$ORG}) >>"; //gas utility radio button page 5
  378. } else if($data['gas_utility'] == 'RGE-G'){
  379. $fdf_content .= "<< /T(gasUtility2)/V({$RGE}) >>"; //gas utility radio button page 5
  380. } else if($data['gas_utility'] == 'CHGE-G'){
  381. $fdf_content .= "<< /T(gasUtility2)/V({$CentralHudson}) >>"; //gas utility radio button page 5
  382. } else if($data['gas_utility'] == 'NationalGas'){
  383. $fdf_content .= "<< /T(gasUtility2)/V({$NationalFuel}) >>"; //gas utility radio button page 5
  384. }
  385.  
  386. // @TODO: Start Testing Here! <jef@phg.com>
  387.  
  388. //electric account numbers
  389. $electricAccountNumbers2 = $eletric_account_number_1.", ".$eletric_account_number_2;
  390. $electricAccountNumbers3 = $eletric_account_number_1.", ".$eletric_account_number_2.", ".$eletric_account_number_3;
  391. $electricAccountNumbers4 = $eletric_account_number_1.", ".$eletric_account_number_2.", ".$eletric_account_number_3.", ".$eletric_account_number_4;
  392. $electricAccountNumbers5 = $eletric_account_number_1.", ".$eletric_account_number_2.", ".$eletric_account_number_3.", ".$eletric_account_number_4.", ".$eletric_account_number_5;
  393.  
  394. if(!$eletric_account_number_2){
  395. $fdf_content .= "<< /T(utilityAccNum)/V({$eletric_account_number_1}) >>";
  396. } else if(!$eletric_account_number_3){
  397. $fdf_content .= "<< /T(utilityAccNum)/V({$electricAccountNumbers2}) >>";
  398. } else if(!$eletric_account_number_4){
  399. $fdf_content .= "<< /T(utilityAccNum)/V({$electricAccountNumbers3}) >>";
  400. } else if(!$eletric_account_number_5){
  401. $fdf_content .= "<< /T(utilityAccNum)/V({$electricAccountNumbers4}) >>";
  402. } else{
  403. $fdf_content .= "<< /T(utilityAccNum)/V({$electricAccountNumbers5}) >>";
  404. }
  405.  
  406.  
  407. //gas account numbers
  408. $gasAccountNumbers2 = $gas_account_number_1.", ".$gas_account_number_2;
  409. $gasAccountNumbers3 = $gas_account_number_1.", ".$gas_account_number_2.", ".$gas_account_number_3;
  410. $gasAccountNumbers4 = $gas_account_number_1.", ".$gas_account_number_2.", ".$gas_account_number_3.", ".$gas_account_number_4;
  411. $gasAccountNumbers5 = $gas_account_number_1.", ".$gas_account_number_2.", ".$gas_account_number_3.", ".$gas_account_number_4.", ".$gas_account_number_5;
  412.  
  413. if(!$gas_account_number_2){
  414. $fdf_content .= "<< /T(gasUtilityAccNum)/V({$gas_account_number_1}) >>";
  415. } else if(!$gas_account_number_3){
  416. $fdf_content .= "<< /T(gasUtilityAccNum)/V({$gasAccountNumbers2}) >>";
  417. } else if(!$gas_account_number_4){
  418. $fdf_content .= "<< /T(gasUtilityAccNum)/V({$gasAccountNumbers3}) >>";
  419. } else if(!$gas_account_number_5){
  420. $fdf_content .= "<< /T(gasUtilityAccNum)/V({$gasAccountNumbers4}) >>";
  421. } else{
  422. $fdf_content .= "<< /T(gasUtilityAccNum)/V({$gasAccountNumbers5}) >>";
  423. }
  424.  
  425. $BlueLock100 = 'BlueLock100';
  426. $BluePremier = 'BluePremier';
  427. $Yes = 'Yes';
  428.  
  429. // electric fixed price (blueLock100) or variable price (BluePremier) option
  430. if ($bre_electricplan == "BlueLock100"){
  431. $fdf_content .= "<< /T(fixedPriceOptions)/V({$BlueLock100}) >>"; //commercial fixed price contracts
  432. $fdf_content .= "<< /T(managedPortfolioPlans)/V({$BlueLock100}) >>";//residential contracts
  433. $fdf_content .= "<< /T(fixedPrice)/V({$fixed_price_electric}) >>";
  434. } else if($bre_electricplan == "BluePremier"){
  435. $fdf_content .= "<< /T(fixedPriceOptions)/V({$BluePremier}) >>"; //commercial fixed price contracts
  436. $fdf_content .= "<< /T(managedPortfolioPlans)/V({$BluePremier}) >>";//residential contracts
  437. $fdf_content .= "<< /T(bluePremier)/V({$Yes}) >>";//commercial variable price contracts
  438. }
  439.  
  440. // gas fixed price (blueLock100) or variable price (BluePremier) option
  441. if ($bre_gasplan == "BlueLock100"){
  442. $fdf_content .= "<< /T(gasFixedPriceOptions)/V({$BlueLock100}) >>"; //commercial fixed price contracts
  443. $fdf_content .= "<< /T(gasManagedPortfolioPlans)/V({$BlueLock100}) >>";//residential contracts
  444. $fdf_content .= "<< /T(gasFixedPrice)/V({$fixed_price_gas}) >>";
  445. } else if($bre_gasplan == "BluePremier"){
  446. $fdf_content .= "<< /T(gasFixedPriceOptions)/V({$BluePremier}) >>"; //commercial fixed price contracts
  447. $fdf_content .= "<< /T(gasManagedPortfolioPlans)/V({$BluePremier}) >>";//residential contracts
  448. $fdf_content .= "<< /T(variablePriceOption)/V({$BluePremier}) >>";//commercial variable price contracts
  449. }
  450.  
  451.  
  452.  
  453.  
  454. $greenOption = $bre_greenoptionpercentage;
  455.  
  456. $greenUp30 = 'greenUp30';
  457. $greenUp50 = 'greenUp50';
  458. $greenUp75 = 'greenUp75';
  459. $greenUp100 = 'greenUp100';
  460.  
  461. if ($greenOption == "GREENUP30"){
  462. $fdf_content .= "<< /T(greenOption)/V({$greenUp30}) >>";
  463. } else if($greenOption == "GREENUP50"){
  464. $fdf_content .= "<< /T(greenOption)/V({$greenUp50}) >>";
  465. } else if($greenOption == "GREENUP75"){
  466. $fdf_content .= "<< /T(greenOption)/V({$greenUp75}) >>";
  467. } else if($greenOption == "GREENUP100"){
  468. $fdf_content .= "<< /T(greenOption)/V({$greenUp100}) >>";
  469. }
  470.  
  471. //$fdf_content .= "<< /T(startMonth)/V({}) >>"; no database table field for this
  472. //$fdf_content .= "<< /T(startYear)/V({}) >>"; no database table field for this
  473. $enrollmentTerm = 'twelve';
  474. $fdf_content .= "<< /T(enrollmentTerm)/V({$enrollmentTerm}) >>";//page 1
  475. $fdf_content .= "<< /T(gasEnrollmentTerm)/V({$enrollmentTerm}) >>";//page 1
  476.  
  477.  
  478. $contactFirstLastName = $contact_first_name." ".$contact_last_name;
  479. $fdf_content .= "<< /T(contactName)/V({$contactFirstLastName}) >>";//page 2
  480. //$fdf_content .= "<< /T(contactName2)/V({$contactFirstLastName}) >>";//page5 - this field name is now contactName
  481. $fdf_content .= "<< /T(contactPhone)/V({$contact_phone}) >>";//page 2
  482. //$fdf_content .= "<< /T(contactPhone2)/V({$contact_phone}) >>"; //page5 - this field name is now contactPhone
  483. $fdf_content .= "<< /T(contactFax)/V({$contact_fax}) >>"; //page 2
  484. $fdf_content .= "<< /T(contactEmail)/V({$contact_email}) >>";//page 2
  485.  
  486. $teNo = 'No';
  487. $teYes = 'Yes';
  488.  
  489. if($tax_exempt == "0"){
  490. $fdf_content .= "<< /T(taxExempt)/V({$teNo}) >>";
  491. } else if ($tax_exempt == "1"){ //what is the value for yes? is it one. No is 0
  492. $fdf_content .= "<< /T(taxExempt)/V({$teYes}) >>";
  493. }
  494.  
  495. $mailing_address = $mailing_address_1." ".$mailing_address_2;
  496. $mailingCityStateZip = $mailing_city.", ".$mailing_state." ".$mailing_zip;
  497. $fdf_content .= "<< /T(address)/V({$mailing_address}) >>";
  498. $fdf_content .= "<< /T(cityStateZip)/V({$mailingCityStateZip}) >>";
  499.  
  500.  
  501.  
  502. $billing_address = $billing_address_1." ".$billing_address_2;
  503. $billingCityStateZip = $billing_city.", ".$billing_state." ".$billing_zip;
  504. if($mailing_address != $billing_address){
  505. $fdf_content .= "<< /T(billingAddress)/V({$billing_address}) >>";
  506. $fdf_content .= "<< /T(billingCityStateZip)/V({$billingCityStateZip}) >>";
  507. }
  508.  
  509.  
  510.  
  511. $fdf_content .= "<< /T(organizationCode)/V({$industry}) >>";
  512. $fdf_content .= "<< /T(promoCode)/V({$promo_code}) >>";
  513.  
  514. $lastFourDigitsOfSS = "Last 4 digits of Social Security number of person submitting: ". $identity_validation_code;
  515. $fdf_content .= "<< /T(lastFourDigitsOfSS)/V({$lastFourDigitsOfSS}) >>";
  516.  
  517.  
  518. $breSignatureline = "Online Sign Up";
  519. $customerSignatureline = "Signed electronically on ". $dateTime;
  520. $fdf_content .= "<< /T(BlueRockSign)/V({$breSignatureline}) >>";
  521. $fdf_content .= "<< /T(CustomerSign)/V({$customerSignatureline}) >>";
  522.  
  523.  
  524.  
  525. if($eorg == "E"){
  526. $fdf_contentE = $fdf_content;
  527. return $fdf_contentE;
  528. }
  529. if($eorg == "G"){
  530. $fdf_contentG = $fdf_content;
  531. return $fdf_contentG;
  532. }
  533.  
  534. }
  535.  
  536. function breEmailPDF($data, $pdf_path){
  537. return false;
  538. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement