예제 #1
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 Organization();
         $retrun_fields = $object->popup_selection_return_field;
         $retrun_field_list = explode(",", $retrun_fields);
         $object->query("select " . $retrun_fields . " from organization where idorganization = ?", 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;
 }
예제 #2
0
 /**
  * function to map the ralated to (organization) for potentials while importing
  * checks if the organization exists else will add a new one
  * @param string $organization_name
  * @return integer idorganization
  */
 public function map_related_to_organization($organization_name)
 {
     if (strlen($organization_name) > 2) {
         $organization_name = trim($organization_name);
         $do_organization = new Organization();
         $qry = "\n\t\t\tselect `idorganization` \n\t\t\tfrom `organization` \n\t\t\twhere \n\t\t\t`organization_name` = ?\n\t\t\tAND `deleted` = 0 \n\t\t\tAND `iduser` = " . $_SESSION["do_user"]->iduser;
         $do_organization->query($qry, array($organization_name));
         if ($do_organization->getNumRows() > 0) {
             $do_organization->next();
             return $do_organization->idorganization;
         } else {
             $do_organization->insert("organization", array("organization_name" => CommonUtils::purify_input($organization_name), "iduser" => $_SESSION["do_user"]->iduser));
             $idorganization = $do_organization->getInsertId();
             //adding the added_on
             $q_upd = "\n\t\t\t\tupdate `organization`\n\t\t\t\tset `added_on` = '" . date("Y-m-d H:i:s") . "'\n\t\t\t\twhere `idorganization` = " . $idorganization;
             $do_organization->query($q_upd);
             $do_organization->insert("organization_custom_fld", array("idorganization" => $idorganization));
             $do_organization->insert("organization_address", array("idorganization" => $idorganization));
             $do_data_history = new DataHistory();
             $do_data_history->add_history($idorganization, 6, 'add');
             $do_data_history->free();
             return $idorganization;
         }
     }
 }
예제 #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;
     }
 }