[ Index ]
 

Code source de SugarCRM 5.0.0beta1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> WebToLeadCapture.php (source)

   1  <?php
   2   if(!defined('sugarEntry'))define('sugarEntry', true);
   3  /*********************************************************************************

   4   * SugarCRM is a customer relationship management program developed by

   5   * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc.

   6   * 

   7   * This program is free software; you can redistribute it and/or modify it under

   8   * the terms of the GNU General Public License version 3 as published by the

   9   * Free Software Foundation.

  10   * 

  11   * This program is distributed in the hope that it will be useful, but WITHOUT

  12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

  13   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more

  14   * details.

  15   * 

  16   * You should have received a copy of the GNU General Public License along with

  17   * this program; if not, see http://www.gnu.org/licenses or write to the Free

  18   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

  19   * 02110-1301 USA.

  20   * 

  21   * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,

  22   * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.

  23   * 

  24   * The interactive user interfaces in modified source and object code versions

  25   * of this program must display Appropriate Legal Notices, as required under

  26   * Section 5 of the GNU General Public License version 3.

  27   * 

  28   * In accordance with Section 7(b) of the GNU General Public License version 3,

  29   * these Appropriate Legal Notices must retain the display of the "Powered by

  30   * SugarCRM" logo. If the display of the logo is not reasonably feasible for

  31   * technical reasons, the Appropriate Legal Notices must display the words

  32   * "Powered by SugarCRM".

  33   ********************************************************************************/
  34  require_once ('include/entryPoint.php');
  35  require_once ('include/formbase.php');
  36  require_once ('modules/Leads/LeadFormBase.php');
  37  require_once ('modules/Campaigns/Campaign.php');
  38  require_once ('modules/CampaignLog/CampaignLog.php');
  39  
  40  $app_strings = return_application_language($sugar_config['default_language']);
  41  $app_list_strings = return_app_list_strings_language($sugar_config['default_language']);
  42  $mod_strings = return_module_language($sugar_config['default_language'], 'Leads');
  43  
  44  $app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Lead'=>'Leads','Bug'=>'Bugs',
  45  
  46  
  47  
  48  
  49  );
  50  
  51  /**

  52   * To make your changes upgrade safe create a file called leadCapture_override.php and place the changes there

  53   */
  54  $users = array(
  55      'PUT A RANDOM KEY FROM THE WEBSITE HERE' => array('name'=>'PUT THE USER_NAME HERE', 'pass'=>'PUT THE USER_HASH FOR THE RESPECTIVE USER HERE'),
  56  );
  57  
  58  if (isset($_POST['campaign_id']) && !empty($_POST['campaign_id'])) {
  59          //adding the client ip address

  60          $_POST['client_id_address'] = query_client_ip();
  61          $campaign_id=$_POST['campaign_id'];            
  62          $campaign = new Campaign();
  63          $camp_query  = "select name,id from campaigns where id='$campaign_id'"; 
  64          $camp_query .= " and deleted=0";                                  
  65          $camp_result=$campaign->db->query($camp_query);              
  66          $camp_data=$campaign->db->fetchByAssoc($camp_result);
  67          //$current_user->user_name = $users[$_POST['user']]['name'];

  68          
  69          if(isset($camp_data) && $camp_data != null ){                                                                                                                      
  70                  $leadForm = new LeadFormBase();
  71                  $prefix = '';
  72                  if(!empty($_POST['prefix'])){
  73                      $prefix =     $_POST['prefix'];            
  74                  }
  75                 //$_POST['first_name'] = $name[0];  $_POST['last_name'] = $name[1];            

  76                  $lead = $leadForm->handleSave('', false, true);
  77                  if(!empty($lead)){
  78                  require_once ('modules/CampaignLog/CampaignLog.php');       
  79                  //create campaign log    

  80                  $camplog = new CampaignLog();        
  81                  $camplog->campaign_id  = $_POST['campaign_id'];
  82                  $camplog->related_id   = $lead->id;
  83                  $camplog->related_type = $lead->module_dir;
  84                  $camplog->activity_type = "lead";
  85                  $camplog->target_type = $lead->module_dir;
  86                  $campaign_log->activity_date=$timedate->to_display_date_time(gmdate("Y-m-d H:i:s"));
  87                  $camplog->target_id    = $lead->id;
  88                  $camplog->save();
  89                  
  90                  //link campaignlog and lead               

  91                  $lead->load_relationship('campaigns');
  92                  $lead->campaigns->add($camplog->id);
  93                  $lead->save();
  94                  } 
  95                  if(isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])){            
  96                      echo '<html><head><title>SugarCRM</title></head><body>';
  97                      echo '<form name="redirect" action="' .$_POST['redirect_url']. '" method="POST">';
  98          
  99                      foreach($_POST as $param => $value) {                 
 100                          if($param != 'redirect_url' ||$param != 'submit') {
 101                              echo '<input type="hidden" name="'.$param.'" value="'.$value.'">';
 102                              
 103                          }
 104          
 105                      }                  
 106                      if(empty($lead)) {
 107                          echo '<input type="hidden" name="error" value="1">';
 108                      }
 109                      echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
 110                      echo '</body></html>';
 111                  }
 112                  else{
 113                      echo $mod_strings['LBL_THANKS_FOR_SUBMITTING_LEAD'];
 114                  }
 115                  sugar_cleanup();
 116                  // die to keep code from running into redirect case below

 117                  die();
 118          }        
 119         else{
 120              echo $mod_strings['LBL_SERVER_IS_CURRENTLY_UNAVAILABLE'];
 121        }
 122  }
 123  
 124  echo $mod_strings['LBL_SERVER_IS_CURRENTLY_UNAVAILABLE'];
 125  if (!empty($_POST['redirect'])) {
 126      echo '<html><head><title>SugarCRM</title></head><body>';
 127      echo '<form name="redirect" action="' .$_POST['redirect']. '" method="POST">';
 128      echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
 129      echo '</body></html>';
 130  }
 131  ?>


Généré le : Tue Sep 11 10:48:47 2007 par Balluche grâce à PHPXref 0.7