예제 #1
0
파일: Main.php 프로젝트: somidex/tnf1002016
 public function processFreeReg($post, $request, $server, $cookie)
 {
     if (isset($post) && isset($server) && isset($request) && $server['REQUEST_METHOD'] == 'POST') {
         $db = new DBHandler();
         $db->connect();
         // Datas
         $u = new Utility();
         $coupon = $db->retrieveLeadLastId() . $u->generateCode();
         $request = array_merge($request, $cookie);
         $branch = isset($request['tnfbranch']) ? $request['tnfbranch'] : $request['branch'];
         $request['txn_id'] = $u->generateTransactionReceipt($branch, $coupon);
         $params = $u->processFreeData($request);
         $params['couponCode'] = $coupon;
         // Items
         $items = $u->processFreeItems($request);
         // End of Datas
         $ss = new SpreadsheetHandler();
         $duplicate = $ss->isEntryDuplicate($params['txnId']);
         if (!$duplicate) {
             $ss->addLeadToDocs($params);
             $ss->addPurchaseRegisterToDocs($items, $params);
         }
         $db->insertFreeLead($params, $items);
         $analytics = new Analytics();
         $analytics->ga($params, $items);
         $userfname = isset($request['userfname']) ? $request['userfname'] : "";
         $userlname = isset($request['userlname']) ? $request['userlname'] : "";
         $logparams = array("action" => "Special Rates", "module" => "TNF Microsite " . $branch, "content" => $userfname . " " . $userlname . " from " . $branch . " added a lead from the free registration promo with promo code " . $coupon, 'ip' => $server['REMOTE_ADDR']);
         $db->updateLogs(0, $logparams, $userfname, $userlname);
         $mail = new MailerHandler();
         $mail->sendMail($params);
         $sms = new SMS();
         $sms->sendSms($params['contact'], $params['txnId']);
         $bm = new BenchmarkHandler();
         $bm->addOnlineLeadToBenchmark($params);
         return $params;
     } else {
         return false;
     }
 }