/**
  * function to get the data history for an user
  * @param integer $iduser
  * @param integer $start
  * @param integer $max
  * @return array if found else false
  */
 public function get_data_history_user($iduser, $start = 0, $max = 0)
 {
     $return_array = array();
     $qry = "\n\t\tselect data_history.*, user.firstname, user.lastname , file_uploads.file_extension,\n\t\tuser.user_avatar from data_history \n\t\tinner join user on user.iduser = data_history.iduser\n\t\tleft join file_uploads on user.user_avatar = file_uploads.file_name\n\t\twhere data_history.iduser = ?\n\t\torder by data_history.iddata_history desc";
     if ($start == 0 && $max == 0) {
         $start = $this->sql_start;
         $max = $this->sql_max;
     }
     $qry .= " limit " . (int) $start . "," . (int) $max;
     $this->query($qry, array($iduser));
     $data_history_array = array();
     if ($this->getNumRows() > 0) {
         while ($this->next()) {
             $date_modified = TimeZoneUtil::convert_to_user_timezone($this->date_modified, true);
             $y = date("Y", strtotime($date_modified));
             $m = date("M", strtotime($date_modified));
             $data_history_array[$y][$m][] = $this->get_data_history_display_text($this, true, true);
         }
         $return_array["data"] = $data_history_array;
         if (isset($_REQUEST["last_year"]) && $_REQUEST["last_month"] && $_REQUEST["last_postition"]) {
             $return_array["last_details"] = array("last_year" => $_REQUEST["last_year"], "last_month" => $_REQUEST["last_month"], "last_postition" => $_REQUEST["last_postition"]);
         } else {
             $return_array["last_details"] = array("last_year" => '', "last_month" => '', "last_postition" => '');
         }
         return $return_array;
     } else {
         return false;
     }
 }
 public static function display_value($value)
 {
     $value = TimeZoneUtil::convert_to_user_timezone($value, true);
     $val = explode(" ", $value);
     $date = parent::display_value($val[0]);
     $time = i18nDate::i18n_time($val[1]);
     return $date . ' ' . $time;
 }
Beispiel #3
0
 /**
  * function to get the last update of a record
  * @param integer $idrecord
  * @param integer $idmodule
  * @param object $module_object
  * @param array
  */
 public function get_last_updates($idrecord, $idmodule, $module_object)
 {
     $updates = array();
     if ($module_object->last_modified_by > 0) {
         $qry = "\n\t\t\tselect user.firstname, user.lastname , file_uploads.file_extension,user.user_avatar \n\t\t\tfrom user\n\t\t\tleft join file_uploads on user.user_avatar = file_uploads.file_name \n\t\t\twhere user.iduser = ?";
         $stmt = $this->getDbConnection()->executeQuery($qry, array($module_object->last_modified_by));
         if ($stmt->rowCount() > 0) {
             $data = $stmt->fetch();
             $avatar = '';
             if ($data["user_avatar"] != '') {
                 $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
                 $avatar = $avatar_path . '/ths_' . $data["user_avatar"] . '.' . $data["file_extension"];
             }
             $updates["update"] = array("modified" => i18nDate::i18n_long_date(TimeZoneUtil::convert_to_user_timezone($module_object->last_modified, true), true), "user_name" => $data["firstname"] . ' ' . $data["lastname"], "user_avatar" => $avatar);
         }
     }
     $qry = "\n\t\tselect `data_history`.*, user.firstname, user.lastname , file_uploads.file_extension,user.user_avatar \n\t\tfrom `data_history`\n\t\tinner join `user` on `user`.`iduser` = `data_history`.`iduser`\n\t\tleft join file_uploads on user.user_avatar = file_uploads.file_name \n\t\twhere `data_history`.`idmodule` = ?\n\t\tAND `data_history`.`id_referrer` = ?\n\t\torder by `data_history`.`iddata_history` asc limit 1 ";
     $stmt = $this->getDbConnection()->executeQuery($qry, array($idmodule, $idrecord));
     if ($stmt->rowCount() > 0) {
         $data = $stmt->fetch();
         $avatar = '';
         if ($data["user_avatar"] != '') {
             $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
             $avatar = $avatar_path . '/ths_' . $data["user_avatar"] . '.' . $data["file_extension"];
         }
         $updates["add"] = array("modified" => i18nDate::i18n_long_date(TimeZoneUtil::convert_to_user_timezone($data["date_modified"], true), true), "user_name" => $data["firstname"] . ' ' . $data["lastname"], "user_avatar" => $avatar);
     }
     return $updates;
 }
Beispiel #4
0
 /**
  * function to construct the live feed text to display
  * @param object $obj
  * @return array
  */
 public function construct_feed_text($obj)
 {
     $action_user = $obj->firstname . ' ' . $obj->lastname;
     $thumb = '';
     if ($obj->user_avatar != '') {
         $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
         $thumb = $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension;
     }
     $date_added = i18nDate::i18n_long_date(TimeZoneUtil::convert_to_user_timezone($obj->date_added, true), true);
     $module_name = CommonUtils::get_module_name_as_text($obj->idmodule);
     $link_identifier = true;
     $related_identifer_text = '';
     $link_related_identifier = true;
     $mentions = false;
     switch ($obj->action) {
         case 'add':
             $content = _('Added') . ' ' . $module_name;
             break;
         case 'edit':
             $content = _('Updated') . ' ' . $module_name;
             break;
         case 'delete':
             $content = _('Deleted') . ' ' . $module_name . ' - ';
             $link_identifier = false;
             break;
         case 'lead_covert':
             $content = _('Converted') . ' ' . $module_name;
             break;
         case 'add_contact_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'add_organization_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'add_potential_lead_convert':
             $content = _('Added') . ' ' . $module_name;
             $related_identifer_text = _('during converting the lead');
             break;
         case 'changed_assigned_to':
             $content = _('Changed assigned to ') . ' ' . $module_name;
             break;
         case 'note_mention':
             $content = _('Mentions you in note on ') . ' ' . $module_name;
             $mentions = true;
             break;
     }
     if ($link_identifier === true) {
         if (true === $mentions) {
             $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], 'detail', $obj->idrecord, '#note' . $obj->related_identifier_idrecord);
             $identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $obj->identifier . '</a>';
         } else {
             $detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->idmodule]["name"], "detail", $obj->idrecord);
             $identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $detail_url . '">' . $obj->identifier . '</a>';
         }
     } else {
         $identifier = $obj->identifier;
     }
     $content .= ' ' . $identifier;
     if (strlen($related_identifer_text) > 5) {
         if ($link_related_identifier === true) {
             $related_detail_url = NavigationControl::getNavigationLink($_SESSION["do_module"]->modules_full_details[$obj->related_identifier_idmodule]["name"], "detail", $obj->related_identifier_idrecord);
             $related_identifier = '&nbsp;<a href="' . $GLOBALS['SITE_URL'] . $related_detail_url . '">' . $obj->related_identifier . '</a>';
         } else {
             $related_identifier = $obj->related_identifier;
         }
         $content .= ' ' . $related_identifer_text . $related_identifier;
     }
     return array("user_name" => $action_user, "avatar" => $thumb, "content" => $content, "action_date" => $date_added);
 }
Beispiel #5
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;
     }
 }
Beispiel #6
0
    /**
     * function to display each note
     * @param object $obj
     */
    function display_note($obj, $active_users)
    {
        $note_documents = '';
        $avatar_path = $GLOBALS['AVATAR_DISPLAY_PATH'];
        $note_by = '';
        if ((int) $obj->iduser > 0) {
            $note_by = $obj->firstname . ' ' . $obj->lastname;
            if ($obj->user_avatar != '') {
                $thumb = '<img src="' . $avatar_path . '/ths_' . $obj->user_avatar . '.' . $obj->file_extension_user_avatar . '" style="width:20px;height:20px;" />';
            } else {
                $thumb = '<span class="add-on"><i class="icon-user"></i></span>';
            }
        } elseif ((int) $obj->idcpanel_user > 0) {
            $note_by = $obj->c_firstname . ' ' . $obj->c_lastname;
            if ($obj->contact_avatar != '') {
                $thumb = '<img src="' . $avatar_path . '/ths_' . $obj->contact_avatar . '.' . $obj->file_extension_contact_avatar . '" style="width:20px;height:20px;" />';
            } else {
                $thumb = '<span class="add-on"><i class="icon-user"></i></span>';
            }
        }
        $note_content = $obj->notes;
        $note_content = \CommonUtils::format_display_text($note_content);
        $note_content = \FieldType200::display_value($note_content);
        $do_files_and_attachment = new \CRMFilesAndAttachments();
        $do_files_and_attachment->get_uploaded_files(8, $obj->idnotes);
        if ($do_files_and_attachment->getNumRows() > 0) {
            $e_download = new Event("CRMFilesAndAttachments->eventDownloadFiles");
            $e_download->setEventControler("/eventcontroler.php");
            $note_documents = '<p>';
            while ($do_files_and_attachment->next()) {
                $e_download->addParam("fileid", $do_files_and_attachment->idfile_uploads);
                $download_link = $e_download->getLink($do_files_and_attachment->file_description);
                $note_documents .= $download_link . '<br />';
            }
            $note_documents .= '</p>';
        }
        $date_added = \i18nDate::i18n_long_date(\TimeZoneUtil::convert_to_user_timezone($obj->date_added, true), true);
        $html = <<<html
\t\t<div class="notes_content" id="note{$obj->idnotes}">{$thumb}
\t\t\t<strong>{$note_by}</strong>
\t\t\t<span class="notes_content_right" style="display:none;">
\t\t\t\t<a href="#" onclick="display_edit_notes('{$obj->idnotes}'); return false;">edit</a> | 
\t\t\t\t<a href="#" onclick="delete_notes('{$obj->idnotes}'); return false;">delete</a>
\t\t\t</span>
\t\t\t<p id="content_{$obj->idnotes}">
\t\t\t\t{$note_content}
\t\t\t</p>
\t\t\t{$note_documents}
\t\t\t<p id="content_hidden_{$obj->idnotes}" style="display:none;"></p>
\t\t\t<a href="#note-content-{$obj->idnotes}" onclick="return false ;" id="note-content-{$obj->idnotes}"><span class="notes_date_added">{$date_added}</span></a>
      </div>
      <hr class="form_hr" id="note_separator_{$obj->idnotes}">
html;
        $do_files_and_attachment->free();
        echo $html;
    }