[ Index ]
 

Code source de vtiger CRM 5.0.2

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

title

Body

[fermer]

/modules/Import/ -> ImportLead.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/modules/Import/ImportLead.php,v 1.3 2005/03/05 05:41:09 jack Exp $
  17   * Description:  Defines the Account SugarBean Account entity with the necessary
  18   * methods and variables.
  19   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
  20   * All Rights Reserved.
  21   * Contributor(s): ______________________________________..
  22   ********************************************************************************/
  23  
  24  
  25  include_once ('config.php');
  26  require_once ('include/logging.php');
  27  require_once ('include/database/PearDatabase.php');
  28  require_once ('data/SugarBean.php');
  29  require_once ('modules/Contacts/Contacts.php');
  30  require_once ('modules/Potentials/Potentials.php');
  31  require_once ('modules/Notes/Notes.php');
  32  require_once ('modules/Emails/Emails.php');
  33  require_once ('modules/Accounts/Accounts.php');
  34  require_once ('include/ComboUtil.php');
  35  require_once ('modules/Leads/Leads.php');
  36  
  37  
  38  class ImportLead extends Leads {
  39       var $db;
  40  
  41      // This is the list of the functions to run when importing
  42      var $special_functions =  array("assign_user");
  43  
  44      var $importable_fields = Array();
  45  
  46      /**    function used to set the assigned_user_id value in the column_fields when we map the username during import
  47       */
  48  	function assign_user()
  49      {
  50          global $current_user;
  51          $ass_user = $this->column_fields["assigned_user_id"];
  52          $this->db->println("assign_user ".$ass_user." cur_user=".$current_user->id);
  53          
  54          if( $ass_user != $current_user->id)
  55          {
  56              $this->db->println("searching and assigning ".$ass_user);
  57  
  58              //$result = $this->db->query("select id from vtiger_users where user_name = '".$ass_user."'");
  59              $result = $this->db->query("select id from vtiger_users where id = '".$ass_user."'");
  60              if($this->db->num_rows($result)!=1)
  61              {
  62                  $this->db->println("not exact records setting current userid");
  63                  $this->column_fields["assigned_user_id"] = $current_user->id;
  64              }
  65              else
  66              {
  67              
  68                  $row = $this->db->fetchByAssoc($result, -1, false);
  69                  if (isset($row['id']) && $row['id'] != -1)
  70                          {
  71                      $this->db->println("setting id as ".$row['id']);
  72                      $this->column_fields["assigned_user_id"] = $row['id'];
  73                  }
  74                  else
  75                  {
  76                      $this->db->println("setting current userid");
  77                      $this->column_fields["assigned_user_id"] = $current_user->id;
  78                  }
  79              }
  80          }
  81      }
  82  
  83      /** Constructor which will set the importable_fields as $this->importable_fields[$key]=1 in this object where key is the fieldname in the field table
  84       */
  85  	function ImportLead() {
  86          
  87          $this->log = LoggerManager::getLogger('import_lead');
  88          $this->db = new PearDatabase();
  89          $this->db->println("IMP ImportLead");
  90          $colf = getColumnFields("Leads");
  91          foreach($colf as $key=>$value)
  92              $this->importable_fields[$key]=1;
  93          
  94          $this->db->println($this->importable_fields);
  95      }
  96  
  97  }
  98  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7