/**
  * function to get the detailed forcasting data 
  * @param string $where
  * @param integer $iduser
  * @return void
  */
 public function get_detailed_forecast_data($where = '', $iduser = 0)
 {
     $do_potentials = new Potentials();
     $do_potentials->get_list_query();
     if ($where == '') {
         $user_where = $this->get_report_where($iduser, 'potentials', 'pot_to_grp_rel');
     }
     $date_where = '';
     $start_date = TimeZoneUtil::get_user_timezone_date();
     $date_obj = new DateTime($start_date);
     $add_89 = $date_obj->modify('+89 day');
     $end_date = $add_89->format('Y-m-d');
     $date_where = " and `potentials`.`expected_closing_date` >= '{$start_date}' \n\t\tand `potentials`.`expected_closing_date` <= '{$end_date}' \n\t\t";
     $qry = $do_potentials->getSqlQuery();
     $qry .= $user_where . $date_where . " order by `potentials`.`expected_closing_date`";
     $this->query($qry);
 }
Exemple #2
0
    function testWeirdSystemVLICs()
    {
        $vobj = <<<HI
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Ximian//NONSGML Evolution Calendar//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:/freeassociation.sourceforge.net/Tzfile/SystemV/EST5EDT
X-LIC-LOCATION:SystemV/EST5EDT
BEGIN:STANDARD
TZNAME:EST
DTSTART:19701104T020000
RRULE:FREQ=YEARLY;BYDAY=1SU;BYMONTH=11
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:EDT
DTSTART:19700311T020000
RRULE:FREQ=YEARLY;BYDAY=2SU;BYMONTH=3
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
UID:20121026T021107Z-6301-1000-1-0@chAir
DTSTAMP:20120905T172126Z
DTSTART;TZID=/freeassociation.sourceforge.net/Tzfile/SystemV/EST5EDT:
 20121026T153000
DTEND;TZID=/freeassociation.sourceforge.net/Tzfile/SystemV/EST5EDT:
 20121026T160000
TRANSP:OPAQUE
SEQUENCE:5
SUMMARY:pick up Ibby
CLASS:PUBLIC
CREATED:20121026T021108Z
LAST-MODIFIED:20121026T021118Z
X-EVOLUTION-MOVE-CALENDAR:1
END:VEVENT
END:VCALENDAR
HI;
        $tz = TimeZoneUtil::getTimeZone('/freeassociation.sourceforge.net/Tzfile/SystemV/EST5EDT', Reader::read($vobj), true);
        $ex = new \DateTimeZone('America/New_York');
        $this->assertEquals($ex->getName(), $tz->getName());
    }
 /**
  * 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;
     }
 }
Exemple #4
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;
 }
 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;
 }
Exemple #6
0
 /**
  * event function to add an entity to queue
  * @param object $evctl
  * @return string
  */
 public function eventAjaxAddQueue(EventControler $evctl)
 {
     if (trim($evctl->date) != '' && (int) $evctl->related_module_id > 0 && (int) $evctl->related_record_id > 0) {
         $user_timezone = $_SESSION['do_user']->user_timezone;
         $date = FieldType9::convert_before_save($evctl->date);
         $today = TimeZoneUtil::get_user_timezone_date($user_timezone);
         $todayDateObj = new DateTime($today);
         $queueDateObj = new DateTime($date);
         $diff = $todayDateObj->diff($queueDateObj);
         $day_diff = $diff->format('%R%a');
         if ($day_diff < 0) {
             echo _('Older date for queue is not allowed !');
         } else {
             $this->addNew();
             $this->sqcrm_record_id = (int) $evctl->related_record_id;
             $this->related_module_id = (int) $evctl->related_module_id;
             $this->iduser = $_SESSION['do_user']->iduser;
             $this->queue_date = $date;
             $this->add();
             echo '1';
         }
     } else {
         echo _('Missing module id , date or record id to be added in queue !');
     }
 }
Exemple #7
0
    $related_to_id = (int) $_GET["related_to"];
    $related_to_module_id = (int) $_GET["related_to_module"];
    $module_info = $_SESSION["do_module"]->get_modules_with_full_info();
    $related_module_name = $module_info[$related_to_module_id]["name"];
    $cancel_return = NavigationControl::getNavigationLink($related_module_name, "detail", $related_to_id);
    if ($_SESSION["do_crm_action_permission"]->action_permitted('view', $related_to_module_id, $related_to_id) === true) {
        $add_from_related = true;
    } else {
        $show_add_page = false;
    }
} else {
    $cancel_return = NavigationControl::getNavigationLink($module, "list");
}
// set event start/end date time
$start_end_date = TimeZoneUtil::get_user_timezone_date();
$start_time = TimeZoneUtil::get_user_timezone_time();
$end_time = date("H:i:s", strtotime("+1 hour", strtotime($start_time)));
//Recurrent event info
$recurrent_events = new RecurrentEvents();
$text_options = $recurrent_events->get_text_options();
$days_in_week = $recurrent_events->get_days_in_week();
if ($show_add_page === true) {
    require_once 'view/calendar_add_view.php';
} else {
    echo '<div class="alert alert-danger" style="height:100px;margin-top:100px;margin-left:200px;margin-right:200px;">';
    echo '<h4>';
    echo _('Access Denied ! ');
    echo '</h4>';
    echo _('You are not authorized to perform this operation.');
    echo '</div>';
}
 /**
  * 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);
 }
Exemple #9
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;
     }
 }
Exemple #10
0
<?php 
// Copyright SQCRM. For licensing, reuse, modification and distribution see license.txt  

/**
* Home page call and events
* @author Abhik Chakraborty
*/ 
?>
<link rel="stylesheet" href="/themes/custom-css/eventcal/eventCalendar.css">
<link rel="stylesheet" href="/themes/custom-css/eventcal/eventCalendar_theme_responsive.css">
<?php
include_once(BASE_PATH.'/widgets/CallsAndEvents/CallsAndEvents.class.php') ;
$current_date = TimeZoneUtil::get_user_timezone_date();
$current_date_exploded = explode("-",$current_date);
$current_year = $current_date_exploded[0];
$current_month = $current_date_exploded[1];

if (isset($_REQUEST["y"]) && isset($_REQUEST["m"])) {
	$year = (int)$_REQUEST["y"];
	$month = (int)$_REQUEST["m"];
	if (isset($_REQUEST["c"])) {
		$change_type = $_REQUEST["c"] ;
		if ($change_type == 'p') {
			$ym = date("Y-m-d",strtotime("- 1 month",strtotime($year.'-'.$month.'-01')));
		} elseif ($change_type == 'n') {
			$ym = date("Y-m-d",strtotime("+ 1 month",strtotime($year.'-'.$month.'-01')));
		}
		$year = date("Y",strtotime($ym));
		$month = date("m",strtotime($ym));
	}
} else {
Exemple #11
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;
    }
    function testFallBack()
    {
        $vobj = <<<HI
BEGIN:VCALENDAR
METHOD:REQUEST
VERSION:2.0
BEGIN:VTIMEZONE
TZID:foo
BEGIN:STANDARD
DTSTART:16010101T030000
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=10;BYDAY=-1SU
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T020000
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
RRULE:FREQ=YEARLY;WKST=MO;INTERVAL=1;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20120416T092149Z
DTSTART;TZID="foo":20120418T1
 00000
SUMMARY:Begin Unterhaltsreinigung
UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000
 0100000008FECD2E607780649BE5A4C9EE6418CBC
 000
END:VEVENT
END:VCALENDAR
HI;
        $tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj));
        $this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz);
    }