Esempio n. 1
0
 public static function createUpdateScript(array $data)
 {
     $scriptID = 0;
     $scriptFormID = 0;
     #$scriptID = Model_Script::createUpdateScript($data);
     if (isset($data['form']['fields']) && count($data['form']['fields']) > 0) {
         $scriptFormID = ScriptForms::createForm($data['form']);
         #Model_Script::setScriptFormID($scriptFormID, $scriptID);
     }
     if ($scriptFormID > 0) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 2
0
 public function action_preview_script_form()
 {
     $Script = new ScriptForms(2);
     $this->template->title = "Scripts | Preview Script Form";
     $this->template->content = \View::forge('admin/script_form_preview', array('form' => $Script->generate()));
 }
Esempio n. 3
0
 public function post_load_products()
 {
     $results = array();
     $results = ScriptForms::loadProducts();
     $this->response(array('status' => 'SUCCESS', 'results' => $results));
 }
Esempio n. 4
0
 public function get_save($apiKey, $surveyID = 0)
 {
     // -- Check API Key
     // ----------------
     $apiCheck = \Crm\Portal\Portal_Check::api_key($apiKey);
     if ($apiCheck === false) {
         $this->response(array('status' => 'FAIL', 'message' => 'Invalid API Key has been used, please contact your IT support!'));
     } else {
         if ((int) $surveyID == 0) {
             $this->response(array('status' => 'FAIL', 'message' => 'Invalid Survey ID, please contact your IT support!'));
         } else {
             // -- Save the Lead Details
             // ------------------------
             $centerDetails = \Model_Call_Center::query()->where('api_key', $apiKey)->get_one();
             $Debtsolv = new Debtsolv();
             $Debtsolv->data(\Input::get());
             $Debtsolv->data(array('introducer_id' => $centerDetails->id));
             $leadpoolID = 0;
             $leadpoolID = $Debtsolv->addNewLead();
             if ((int) $leadpoolID > 0) {
                 $responseLogID = 0;
                 $responseLogID = ScriptForms::saveFormData($leadpoolID, 0, 0, 1, $surveyID, \Input::get('scriptForm'));
                 $Survey = new ScriptForms($surveyID);
                 // -- Save the Survey Results
                 // --------------------------
                 #if(ScriptForms::saveFormData($leadpoolID, 0, 0, 0, $surveyID, \Input::get('scriptForm')) === true)
                 // -- Save the Product Recommendations
                 // -----------------------------------
                 $Survey->saveResponseProducts((int) $responseLogID);
                 if ($responseLogID > 0) {
                     // -- All Saved and Done. Now send an email
                     // ----------------------------------------
                     $callCentre = \Model_Call_Center::query()->where('api_key', $apiKey)->get_one();
                     $Email = \Email::forge();
                     $Email->from('*****@*****.**', 'Money Management Services');
                     $Email->to('*****@*****.**');
                     $Email->subject($leadpoolID . ' - New Survey Result');
                     $Email->html_body(\View::forge('email', array('leadDetails' => \Input::get(), 'leadpoolID' => $leadpoolID, 'recommendedProducts' => $Survey->getProductsRecomendations((int) $responseLogID), 'scriptForm' => ScriptForms::loadResponse($leadpoolID, 0, 1), 'centre' => $callCentre->title, 'agent' => \Input::get('agent'), 'pitchScript' => \Input::get('surveyName'))));
                     $Email->send();
                     /*
                     try
                     {
                       $Email->send();
                     }
                     catch(\EmailSendingFailedException $e)
                     {
                       $this->response(array(
                         				  'status' => 'SUCCESS',
                         				  'message' => 'Survey Saved (Failed to send email)',
                         'results' => $Survey->getProductsRecomendations((int)$responseLogID),
                         'leadpoolID' => $leadpoolID,
                         			  ));
                     }
                     */
                     $this->response(array('status' => 'SUCCESS', 'message' => 'This Survey has been received.', 'results' => $Survey->getProductsRecomendations((int) $responseLogID), 'leadpoolID' => $leadpoolID));
                 } else {
                     $this->response(array('status' => 'FAIL', 'message' => 'Failed to save survey results. Debtsolv Lead ID is ' . $leadpoolID));
                 }
             } else {
                 $this->response(array('status' => 'FAIL', 'message' => 'Failed to save to Debtsolv'));
             }
         }
     }
 }