Example #1
0
 /**
  * function to map related to (contacts) for potentials while importing
  * checks if the contact exists else adds a new contact
  * @param string $contact_name
  * @return integer idcontacts
  */
 public function map_related_to_contacts($contact_name)
 {
     if (strlen($contact_name) > 2) {
         $contact_name = trim($contact_name);
         $do_contact = new Contacts();
         $qry = "\n\t\t\tselect `idcontacts`\n\t\t\tfrom  `contacts`\n\t\t\twhere `deleted` = 0 \n\t\t\tAND iduser = "******"do_user"]->iduser . "\n\t\t\tAND \n\t\t\t(\n\t\t\t\tconcat(firstname,' ',lastname) = ?\n\t\t\t\tor\n\t\t\t\tconcat(lastname,' ',firstname) = ?\n\t\t\t)\n\t\t\t";
         $do_contact->query($qry, array($contact_name, $contact_name));
         if ($do_contact->getNumRows() > 0) {
             $do_contact->next();
             return $do_contact->idcontacts;
         } else {
             $contact_name_explode = explode(" ", $contact_name);
             $do_contact->insert("contacts", array("firstname" => CommonUtils::purify_input($contact_name_explode[0]), "lastname" => CommonUtils::purify_input($contact_name_explode[1]), "iduser" => $_SESSION["do_user"]->iduser));
             $idcontacts = $do_contact->getInsertId();
             //adding the added_on
             $q_upd = "\n\t\t\t\tupdate `contacts` \n\t\t\t\tset `added_on` = '" . date("Y-m-d H:i:s") . "'\n\t\t\t\twhere `idcontacts` = " . $idcontacts;
             $do_contact->query($q_upd);
             $do_contact->insert("contacts_custom_fld", array("idcontacts" => $idcontacts));
             $do_contact->insert("contacts_address", array("idcontacts" => $idcontacts));
             $do_data_history = new DataHistory();
             $do_data_history->add_history($idcontacts, 4, 'add');
             $do_data_history->free();
             return $idcontacts;
         }
     }
 }
Example #2
0
 /**
  * Function to get the value of the entity 
  * @param integer $value
  * @return string $retval
  */
 public static function get_value($value)
 {
     $retval = '';
     if ((int) $value > 0) {
         $object = new Contacts();
         $retrun_fields = $object->popup_selection_return_field;
         $retrun_field_list = explode(",", $retrun_fields);
         $object->query("select " . $retrun_fields . " from contacts where idcontacts = ?", array($value));
         if ($object->getNumRows() > 0) {
             $object->next();
             $cnt_return_fields = 0;
             foreach ($retrun_field_list as $retrun_fields) {
                 if ($cnt_return_fields > 0) {
                     $retval .= ' ';
                 }
                 $retval .= $object->{$retrun_fields};
                 $cnt_return_fields++;
             }
         }
     }
     return $retval;
 }
Example #3
0
 /**
  * function to get the complete conversion information
  * @param integer $idleads
  * @return array if data found else false
  */
 public function get_conversion_matrix($idleads)
 {
     $qry = "select * from `leads_conversion_matrix` where `idleads` = ?";
     $this->query($qry, array($idleads));
     if ($this->getNumRows() > 0) {
         $this->next();
         if ((int) $this->idpotentials > 0) {
             $do_potentials = new Potentials();
             $q_p = "\n\t\t\t\tselect `potential_name` \n\t\t\t\tfrom `" . $do_potentials->getTable() . "` \n\t\t\t\twhere `idpotentials` = ?";
             $do_potentials->query($q_p, array($this->idpotentials));
             if ($do_potentials->getNumRows() > 0) {
                 $do_potentials->next();
                 $return_array["potential"] = array("idpotentials" => (int) $this->idpotentials, "potential_name" => $do_potentials->potential_name);
             }
         }
         if ((int) $this->idorganization > 0) {
             $do_organization = new Organization();
             $q_o = "\n\t\t\t\tselect `organization_name` \n\t\t\t\tfrom `" . $do_organization->getTable() . "` \n\t\t\t\twhere `idorganization` = ?";
             $do_organization->query($q_o, array($this->idorganization));
             if ($do_organization->getNumRows() > 0) {
                 $do_organization->next();
                 $return_array["organization"] = array("idorganization" => (int) $this->idorganization, "organization_name" => $do_organization->organization_name);
             }
         }
         if ((int) $this->idcontacts > 0) {
             $do_contacts = new Contacts();
             $q_c = "\n\t\t\t\tselect `firstname`,`lastname` \n\t\t\t\tfrom `" . $do_contacts->getTable() . "` where `idcontacts` = ?";
             $do_contacts->query($q_c, array($this->idcontacts));
             if ($do_contacts->getNumRows() > 0) {
                 $do_contacts->next();
                 $return_array["contact"] = array("idcontacts" => (int) $this->idcontacts, "contact_name" => $do_contacts->firstname . ' ' . $do_contacts->lastname);
             }
         }
         $do_user = new User();
         $do_user->getId((int) $this->iduser);
         $return_array["user"] = array("user_name" => $do_user->user_name, "fullname" => $do_user->firstname . ' ' . $do_user->lastname);
         $return_array["conversion_date"] = array("conversion_date" => i18nDate::i18n_long_date(TimeZoneUtil::convert_to_user_timezone($this->conversion_date, true), true));
         return $return_array;
     } else {
         return false;
     }
 }