当前位置: 首页>>代码示例>>PHP>>正文


PHP DateTimeField::getDBInsertDateTimeValue方法代码示例

本文整理汇总了PHP中DateTimeField::getDBInsertDateTimeValue方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeField::getDBInsertDateTimeValue方法的具体用法?PHP DateTimeField::getDBInsertDateTimeValue怎么用?PHP DateTimeField::getDBInsertDateTimeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeField的用法示例。


在下文中一共展示了DateTimeField::getDBInsertDateTimeValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDBDateTimeValue

 /**
  * Function to get Date and Time value for Display
  * @param <type> $date
  * @return <String>
  */
 public static function getDBDateTimeValue($date)
 {
     global $log;
     $log->debug("Entering ./uitypes/Datetime.php::staticgetDBDateTimeValue");
     $date = new DateTimeField($date);
     return $date->getDBInsertDateTimeValue();
 }
开发者ID:cin-system,项目名称:cinrepo,代码行数:12,代码来源:Datetime.php

示例2: getConditionValue

 /**
  *
  * @param mixed $value
  * @param String $operator
  * @param WebserviceField $field
  */
 private function getConditionValue($value, $operator, $field)
 {
     $operator = strtolower($operator);
     $db = PearDatabase::getInstance();
     $inEqualityFieldTypes = ['currency', 'percentage', 'double', 'integer', 'number'];
     if (is_string($value) && $this->ignoreComma == false) {
         $commaSeparatedFieldTypes = ['picklist', 'multipicklist', 'owner', 'date', 'datetime', 'time', 'tree', 'sharedOwner', 'sharedOwner'];
         if (in_array($field->getFieldDataType(), $commaSeparatedFieldTypes)) {
             $valueArray = explode(',', $value);
             if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, ['e', 'n'])) {
                 $valueArray = getCombinations($valueArray);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = ltrim($value, ' |##| ');
                 }
             }
         } else {
             if ($field->getFieldDataType() == 'multiReferenceValue') {
                 $valueArray = explode(',', $value);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = '|#|' . $value . '|#|';
                 }
             } else {
                 $valueArray = [$value];
             }
         }
     } elseif (is_array($value)) {
         $valueArray = $value;
     } else {
         $valueArray = [$value];
     }
     $sql = array();
     if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
         if ($field->getFieldName() == 'birthday') {
             $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
             $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
             $sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
         } else {
             if ($this->isDateType($field->getFieldDataType())) {
                 $start = explode(' ', $valueArray[0]);
                 $end = explode(' ', $valueArray[1]);
                 if ($operator == 'between' && count($start) == 2 && count($end) == 2) {
                     $valueArray[0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]);
                     if ($start[0] == $end[0]) {
                         $dateTime = new DateTime($valueArray[0]);
                         $nextDay = $dateTime->modify('+1 days');
                         $nextDay = strtotime($nextDay->format('Y-m-d H:i:s')) - 1;
                         $nextDay = date('Y-m-d H:i:s', $nextDay);
                         $values = explode(' ', $nextDay);
                         $valueArray[1] = getValidDBInsertDateTimeValue($values[0]) . ' ' . $values[1];
                     } else {
                         $end = $valueArray[1];
                         $dateObject = new DateTimeField($end);
                         $valueArray[1] = $dateObject->getDBInsertDateTimeValue();
                     }
                 } else {
                     $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
                     $dateTimeStart = explode(' ', $valueArray[0]);
                     if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
                         $valueArray[0] = $dateTimeStart[0];
                     }
                     $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
                     $dateTimeEnd = explode(' ', $valueArray[1]);
                     if ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') {
                         $valueArray[1] = $dateTimeEnd[0];
                     }
                 }
             }
             if ($operator == 'notequal') {
                 $sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             } else {
                 $sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             }
         }
         return $sql;
     }
     foreach ($valueArray as $value) {
         if (!$this->isStringType($field->getFieldDataType())) {
             $value = trim($value);
         }
         if ($operator == 'empty' || $operator == 'y') {
             $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if ($operator == 'ny') {
             $sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
             if ($operator == 'e') {
                 $sql[] = "IS NULL";
                 continue;
             }
             $sql[] = "IS NOT NULL";
             continue;
//.........这里部分代码省略.........
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:101,代码来源:QueryGenerator.php

示例3: getActivityMailInfo

function getActivityMailInfo($return_id, $status, $activity_type)
{
    $mail_data = array();
    global $adb;
    $qry = "select * from vtiger_activity where activityid=?";
    $ary_res = $adb->pquery($qry, array($return_id));
    $send_notification = $adb->query_result($ary_res, 0, "sendnotification");
    $subject = $adb->query_result($ary_res, 0, "subject");
    $priority = $adb->query_result($ary_res, 0, "priority");
    $st_date = $adb->query_result($ary_res, 0, "date_start");
    $st_time = $adb->query_result($ary_res, 0, "time_start");
    $end_date = $adb->query_result($ary_res, 0, "due_date");
    $end_time = $adb->query_result($ary_res, 0, "time_end");
    $location = $adb->query_result($ary_res, 0, "location");
    if (!empty($st_time)) {
        $date = new DateTimeField($st_date . ' ' . $st_time);
        $st_date = $date->getDisplayDate();
        $st_time = $date->getDisplayTime();
    }
    if (!empty($end_time)) {
        $date = new DateTimeField($end_date . ' ' . $end_time);
        $end_date = $date->getDisplayDate();
        $end_time = $date->getDisplayTime();
    }
    $owner_qry = "select smownerid from vtiger_crmentity where crmid=?";
    $res = $adb->pquery($owner_qry, array($return_id));
    $owner_id = $adb->query_result($res, 0, "smownerid");
    $usr_res = $adb->pquery("select count(*) as count from vtiger_users where id=?", array($owner_id));
    if ($adb->query_result($usr_res, 0, 'count') > 0) {
        $assignType = "U";
        $usr_id = $owner_id;
    } else {
        $assignType = "T";
        $group_qry = "select groupname from vtiger_groups where groupid=?";
        $grp_res = $adb->pquery($group_qry, array($owner_id));
        $grp_name = $adb->query_result($grp_res, 0, "groupname");
    }
    $desc_qry = "select description from vtiger_crmentity where crmid=?";
    $des_res = $adb->pquery($desc_qry, array($return_id));
    $description = $adb->query_result($des_res, 0, "description");
    $rel_qry = "select case vtiger_crmentity.setype when 'Leads' then vtiger_leaddetails.lastname when 'Accounts' then vtiger_account.accountname when 'Potentials' then vtiger_potential.potentialname when 'Quotes' then vtiger_quotes.subject when 'PurchaseOrder' then vtiger_purchaseorder.subject when 'SalesOrder' then vtiger_salesorder.subject when 'Invoice' then vtiger_invoice.subject when 'Campaigns' then vtiger_campaign.campaignname when 'HelpDesk' then vtiger_troubletickets.title  end as relname from vtiger_seactivityrel inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_seactivityrel.crmid left join vtiger_leaddetails on vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid  left join vtiger_account on vtiger_account.accountid=vtiger_seactivityrel.crmid left join vtiger_potential on vtiger_potential.potentialid=vtiger_seactivityrel.crmid left join vtiger_quotes on vtiger_quotes.quoteid= vtiger_seactivityrel.crmid left join vtiger_purchaseorder on vtiger_purchaseorder.purchaseorderid = vtiger_seactivityrel.crmid  left join vtiger_salesorder on vtiger_salesorder.salesorderid = vtiger_seactivityrel.crmid left join vtiger_invoice on vtiger_invoice.invoiceid = vtiger_seactivityrel.crmid  left join vtiger_campaign on vtiger_campaign.campaignid = vtiger_seactivityrel.crmid left join vtiger_troubletickets on vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid where vtiger_seactivityrel.activityid=?";
    $rel_res = $adb->pquery($rel_qry, array($return_id));
    $rel_name = $adb->query_result($rel_res, 0, "relname");
    $relatedContacts = getActivityRelatedContacts($return_id);
    $mail_data['mode'] = "edit";
    $mail_data['activity_mode'] = $activity_type;
    $mail_data['sendnotification'] = $send_notification;
    $mail_data['user_id'] = $usr_id;
    $mail_data['subject'] = $subject;
    $mail_data['status'] = $status;
    $mail_data['taskpriority'] = $priority;
    $mail_data['relatedto'] = $rel_name;
    $mail_data['contact_name'] = implode(',', $relatedContacts);
    $mail_data['description'] = $description;
    $mail_data['assign_type'] = $assignType;
    $mail_data['group_name'] = $grp_name;
    $value = getaddEventPopupTime($st_time, $end_time, '24');
    $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
    if ($activity_type != 'Task') {
        $end_hour = $value['endhour'] . ':' . $value['endmin'] . '' . $value['endfmt'];
    }
    $date = new DateTimeField($st_date . " " . $start_hour);
    $endDate = new DateTimeField($end_date . " " . $end_hour);
    $mail_data['st_date_time'] = $date->getDBInsertDateTimeValue();
    $mail_data['end_date_time'] = $endDate->getDBInsertDateValue() . ' ' . $endDate->getDBInsertTimeValue();
    $mail_data['location'] = $location;
    return $mail_data;
}
开发者ID:mslokhat,项目名称:corebos,代码行数:68,代码来源:CalendarCommon.php

示例4: getPendingActivities

/**
 * Function to get Pending/Upcoming activities
 * @param integer  $mode     - number to differentiate upcoming and pending activities
 * return array    $values   - activities record in array format
 */
function getPendingActivities($mode, $view = '')
{
    global $log;
    $log->debug("Entering getPendingActivities() method ...");
    require_once 'data/Tracker.php';
    require_once 'include/utils/utils.php';
    require_once 'user_privileges/default_module_view.php';
    global $currentModule;
    global $singlepane_view;
    global $theme;
    global $focus;
    global $action;
    global $adb;
    global $app_strings;
    global $current_language;
    global $current_user;
    $current_module_strings = return_module_language($current_language, 'Calendar');
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    if ($_REQUEST['activity_view'] == '') {
        $activity_view = 'today';
    } else {
        $activity_view = vtlib_purify($_REQUEST['activity_view']);
    }
    $dbStartDateTime = new DateTimeField(date('Y-m-d H:i:s'));
    $userStartDate = $dbStartDateTime->getDisplayDate();
    $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00');
    $startDateTime = $userStartDateTime->getDBInsertDateTimeValue();
    $userEndDateTime = new DateTimeField($userStartDate . ' 23:59:00');
    $endDateTime = $userEndDateTime->getDBInsertDateTimeValue();
    if ($view == 'today') {
        $upcoming_condition = " AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}'\n\t\t\t\t\t\t\t\t\tOR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}')";
        $pending_condition = " AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}'\n\t\t\t\t\t\t\t\t\tOR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}')";
    } else {
        if ($view == 'all') {
            $upcoming_condition = " AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) >= '{$startDateTime}'\n\t\t\t\t\t\t\t\t\tOR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) >= '{$startDateTime}')";
            $pending_condition = " AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) <= '{$startDateTime}'\n\t\t\t\t\t\t\t\t\tOR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) <= '{$startDateTime}')";
        }
    }
    if ($mode != 1) {
        $list_query = " select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity." . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, " . "vtiger_activity.activitytype, vtiger_activity.date_start, vtiger_activity.due_date," . "from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=" . "vtiger_activity.activityid LEFT JOIN vtiger_groups ON vtiger_groups.groupid = " . "vtiger_crmentity.smownerid left outer join vtiger_recurringevents on " . "vtiger_recurringevents.activityid=vtiger_activity.activityid";
        $list_query .= getNonAdminAccessControlQuery('Calendar', $current_user);
        $list_query .= " WHERE vtiger_crmentity.deleted=0 and vtiger_activity.activitytype not in " . "('Emails') AND ( vtiger_activity.status is NULL OR vtiger_activity.status not in" . "('Completed','Deferred')) and ( vtiger_activity.eventstatus is NULL OR vtiger_activity." . "eventstatus not in ('Held','Not Held') )" . $upcoming_condition;
    } else {
        $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity" . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.activityid, vtiger_activity" . ".activitytype, vtiger_activity.date_start, vtiger_activity.due_date, from vtiger_activity" . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid " . "LEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid " . "left outer join vtiger_recurringevents on vtiger_recurringevents.activityid=" . "vtiger_activity.activityid";
        $list_query .= getNonAdminAccessControlQuery('Calendar', $current_user);
        $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity." . "activitytype not in ('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity." . "status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR " . "vtiger_activity.eventstatus not in ('Held','Not Held')) " . $pending_condition;
        $list_query .= " GROUP BY vtiger_activity.activityid";
        $list_query .= " ORDER BY date_start,time_start ASC";
        $res = $adb->query($list_query);
        $noofrecords = $adb->num_rows($res);
        $open_activity_list = array();
        $noofrows = $adb->num_rows($res);
        if (count($res) > 0) {
            for ($i = 0; $i < $noofrows; $i++) {
                $dateValue = $adb->query_result($res, $i, 'date_start') . ' ' . $adb->query_result($res, $i, 'time_start');
                $endDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_end');
                $recurringDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_start');
                $date = new DateTimeField($dateValue);
                $endDate = new DateTimeField($endDateValue);
                $recurringDate = new DateTimeField($recurringDateValue);
                $open_activity_list[] = array('name' => $adb->query_result($res, $i, 'subject'), 'id' => $adb->query_result($res, $i, 'activityid'), 'type' => $adb->query_result($res, $i, 'activitytype'), 'module' => $adb->query_result($res, $i, 'setype'), 'date_start' => $date->getDisplayDate(), 'due_date' => $endDate->getDisplayDate(), 'recurringdate' => $recurringDate->getDisplayDate(), 'priority' => $adb->query_result($res, $i, 'priority'));
            }
        }
        $title = array();
        $title[] = $view;
        $title[] = 'myUpcoPendAct.gif';
        $title[] = 'home_myact';
        $title[] = 'showActivityView';
        $title[] = 'MyUpcumingFrm';
        $title[] = 'activity_view';
        $header = array();
        $header[] = $current_module_strings['LBL_LIST_SUBJECT'];
        $header[] = 'Type';
        $return_url = "&return_module={$currentModule}&return_action=DetailView&return_id=" . (is_object($focus) ? $focus->id : "");
        $oddRow = true;
        $entries = array();
        foreach ($open_activity_list as $event) {
            $recur_date = preg_replace('/--/', '', $event['recurringdate']);
            if ($recur_date != "") {
                $event['date_start'] = $event['recurringdate'];
            }
            $font_color_high = "color:#00DD00;";
            $font_color_medium = "color:#DD00DD;";
            switch ($event['priority']) {
                case 'High':
                    $font_color = $font_color_high;
                    break;
                case 'Medium':
                    $font_color = $font_color_medium;
                    break;
                default:
                    $font_color = '';
            }
            if ($event['type'] != 'Task' && $event['type'] != 'Emails' && $event['type'] != '') {
//.........这里部分代码省略.........
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:101,代码来源:OpenListView.php

示例5: getValidDBInsertDateTimeValue

function getValidDBInsertDateTimeValue($value)
{
    $value = trim($value);
    $valueList = explode(' ', $value);
    if (count($valueList) == 2) {
        $dbDateValue = getValidDBInsertDateValue($valueList[0]);
        $dbTimeValue = $valueList[1];
        if (!empty($dbTimeValue) && strpos($dbTimeValue, ':') === false) {
            $dbTimeValue = $dbTimeValue . ':';
        }
        $timeValueLength = strlen($dbTimeValue);
        if (!empty($dbTimeValue) && strrpos($dbTimeValue, ':') == $timeValueLength - 1) {
            $dbTimeValue = $dbTimeValue . '00';
        }
        try {
            $dateTime = new DateTimeField($dbDateValue . ' ' . $dbTimeValue);
            return $dateTime->getDBInsertDateTimeValue();
        } catch (Exception $ex) {
            return '';
        }
    } elseif (count($valueList == 1)) {
        return getValidDBInsertDateValue($value);
    }
}
开发者ID:yunter,项目名称:crm,代码行数:24,代码来源:utils.php

示例6: RunTimeAdvFilter

 /** Function to get the RunTime Advanced filter conditions
  *  @ param $advft_criteria : Type Array
  *  @ param $advft_criteria_groups : Type Array
  *  This function returns  $advfiltersql
  *
  */
 function RunTimeAdvFilter($advft_criteria, $advft_criteria_groups)
 {
     $adb = PearDatabase::getInstance();
     $advfilterlist = array();
     $advfiltersql = '';
     if (!empty($advft_criteria)) {
         foreach ($advft_criteria as $column_index => $column_condition) {
             if (empty($column_condition)) {
                 continue;
             }
             $adv_filter_column = $column_condition["columnname"];
             $adv_filter_comparator = $column_condition["comparator"];
             $adv_filter_value = $column_condition["value"];
             $adv_filter_column_condition = $column_condition["columncondition"];
             $adv_filter_groupid = $column_condition["groupid"];
             $column_info = explode(":", $adv_filter_column);
             $moduleFieldLabel = $column_info[2];
             $fieldName = $column_info[3];
             list($module, $fieldLabel) = explode('__', $moduleFieldLabel, 2);
             $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
             $fieldType = null;
             if (!empty($fieldInfo)) {
                 $field = WebserviceField::fromArray($adb, $fieldInfo);
                 $fieldType = $field->getFieldDataType();
             }
             if ($fieldType == 'currency') {
                 // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                 if ($field->getUIType() == '72') {
                     $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value, null, true);
                 } else {
                     $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value);
                 }
             }
             $temp_val = explode(",", $adv_filter_value);
             if (($column_info[4] == 'D' || $column_info[4] == 'T' && $column_info[1] != 'time_start' && $column_info[1] != 'time_end' || $column_info[4] == 'DT') && ($column_info[4] != '' && $adv_filter_value != '')) {
                 $val = array();
                 for ($x = 0; $x < count($temp_val); $x++) {
                     if ($column_info[4] == 'D') {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertDateValue();
                     } elseif ($column_info[4] == 'DT') {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertDateTimeValue();
                     } else {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertTimeValue();
                     }
                 }
                 $adv_filter_value = implode(",", $val);
             }
             $criteria = array();
             $criteria['columnname'] = $adv_filter_column;
             $criteria['comparator'] = $adv_filter_comparator;
             $criteria['value'] = $adv_filter_value;
             $criteria['column_condition'] = $adv_filter_column_condition;
             $advfilterlist[$adv_filter_groupid]['columns'][] = $criteria;
         }
         foreach ($advft_criteria_groups as $group_index => $group_condition_info) {
             if (empty($group_condition_info)) {
                 continue;
             }
             if (empty($advfilterlist[$group_index])) {
                 continue;
             }
             $advfilterlist[$group_index]['condition'] = $group_condition_info["groupcondition"];
             $noOfGroupColumns = count($advfilterlist[$group_index]['columns']);
             if (!empty($advfilterlist[$group_index]['columns'][$noOfGroupColumns - 1]['column_condition'])) {
                 $advfilterlist[$group_index]['columns'][$noOfGroupColumns - 1]['column_condition'] = '';
             }
         }
         $noOfGroups = count($advfilterlist);
         if (!empty($advfilterlist[$noOfGroups]['condition'])) {
             $advfilterlist[$noOfGroups]['condition'] = '';
         }
         $advfiltersql = $this->generateAdvFilterSql($advfilterlist);
     }
     return $advfiltersql;
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:84,代码来源:ReportRun.php

示例7: getConditionValue

 /**
  *
  * @param mixed $value
  * @param String $operator
  * @param WebserviceField $field
  */
 private function getConditionValue($value, $operator, $field)
 {
     $operator = strtolower($operator);
     $db = PearDatabase::getInstance();
     $inEqualityFieldTypes = ['currency', 'percentage', 'double', 'integer', 'number'];
     if (is_string($value) && $this->ignoreComma == false) {
         $commaSeparatedFieldTypes = array('picklist', 'multipicklist', 'owner', 'date', 'datetime', 'time', 'tree');
         if (in_array($field->getFieldDataType(), $commaSeparatedFieldTypes)) {
             $valueArray = explode(',', $value);
             if ($field->getFieldDataType() == 'multipicklist' && in_array($operator, array('e', 'n'))) {
                 $valueArray = getCombinations($valueArray);
                 foreach ($valueArray as $key => $value) {
                     $valueArray[$key] = ltrim($value, ' |##| ');
                 }
             }
         } else {
             $valueArray = array($value);
         }
     } elseif (is_array($value)) {
         $valueArray = $value;
     } else {
         $valueArray = array($value);
     }
     $sql = array();
     if ($operator == 'between' || $operator == 'bw' || $operator == 'notequal') {
         if ($field->getFieldName() == 'birthday') {
             $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
             $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
             $sql[] = "BETWEEN DATE_FORMAT(" . $db->quote($valueArray[0]) . ", '%m%d') AND " . "DATE_FORMAT(" . $db->quote($valueArray[1]) . ", '%m%d')";
         } else {
             if ($this->isDateType($field->getFieldDataType())) {
                 $start = explode(' ', $valueArray[0]);
                 $end = explode(' ', $valueArray[1]);
                 if ($operator == 'between' && count($start) == 2 && count($end) == 2) {
                     $valueArray[0] = getValidDBInsertDateTimeValue($start[0] . ' ' . $start[1]);
                     if ($start[0] == $end[0]) {
                         $dateTime = new DateTime($valueArray[0]);
                         $nextDay = $dateTime->modify('+1 days');
                         $nextDay = strtotime($nextDay->format('Y-m-d H:i:s')) - 1;
                         $nextDay = date('Y-m-d H:i:s', $nextDay);
                         $values = explode(' ', $nextDay);
                         $valueArray[1] = getValidDBInsertDateTimeValue($values[0]) . ' ' . $values[1];
                     } else {
                         $end = $valueArray[1];
                         $dateObject = new DateTimeField($end);
                         $valueArray[1] = $dateObject->getDBInsertDateTimeValue();
                     }
                 } else {
                     $valueArray[0] = getValidDBInsertDateTimeValue($valueArray[0]);
                     $dateTimeStart = explode(' ', $valueArray[0]);
                     if ($dateTimeStart[1] == '00:00:00' && $operator != 'between') {
                         $valueArray[0] = $dateTimeStart[0];
                     }
                     $valueArray[1] = getValidDBInsertDateTimeValue($valueArray[1]);
                     $dateTimeEnd = explode(' ', $valueArray[1]);
                     if ($dateTimeEnd[1] == '00:00:00' || $dateTimeEnd[1] == '23:59:59') {
                         $valueArray[1] = $dateTimeEnd[0];
                     }
                 }
             }
             if ($operator == 'notequal') {
                 $sql[] = "NOT BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             } else {
                 $sql[] = "BETWEEN " . $db->quote($valueArray[0]) . " AND " . $db->quote($valueArray[1]);
             }
         }
         return $sql;
     }
     foreach ($valueArray as $value) {
         if (!$this->isStringType($field->getFieldDataType())) {
             $value = trim($value);
         }
         if ($operator == 'empty' || $operator == 'y') {
             $sql[] = sprintf("IS NULL OR %s = ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if ($operator == 'ny') {
             $sql[] = sprintf("IS NOT NULL AND %s != ''", $this->getSQLColumn($field->getFieldName()));
             continue;
         }
         if (strtolower(trim($value)) == 'null' || trim($value) == '' && !$this->isStringType($field->getFieldDataType()) && ($operator == 'e' || $operator == 'n')) {
             if ($operator == 'e') {
                 $sql[] = "IS NULL";
                 continue;
             }
             $sql[] = "IS NOT NULL";
             continue;
         } elseif ($field->getFieldDataType() == 'boolean') {
             $value = strtolower($value);
             if ($value == 'yes') {
                 $value = 1;
             } elseif ($value == 'no') {
                 $value = 0;
             }
//.........这里部分代码省略.........
开发者ID:artisan4710,项目名称:YetiForceCRM,代码行数:101,代码来源:QueryGenerator.php

示例8: RunTimeAdvFilter

 /** Function to get the RunTime Advanced filter conditions
  *  @ param $advft_criteria : Type Array
  *  @ param $advft_criteria_groups : Type Array
  *  This function returns  $advfiltersql
  */
 function RunTimeAdvFilter($advft_criteria, $advft_criteria_groups)
 {
     $adb = PearDatabase::getInstance();
     $advfilterlist = array();
     if (!empty($advft_criteria)) {
         foreach ($advft_criteria as $column_index => $column_condition) {
             if (empty($column_condition)) {
                 continue;
             }
             $adv_filter_column = $column_condition["columnname"];
             $adv_filter_comparator = $column_condition["comparator"];
             $adv_filter_value = $column_condition["value"];
             $adv_filter_column_condition = $column_condition["columncondition"];
             $adv_filter_groupid = $column_condition["groupid"];
             $column_info = explode(":", $adv_filter_column);
             $moduleFieldLabel = $column_info[2];
             $fieldName = $column_info[3];
             list($module, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
             $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
             $fieldType = null;
             if (!empty($fieldInfo)) {
                 $field = WebserviceField::fromArray($adb, $fieldInfo);
                 $fieldType = $field->getFieldDataType();
             }
             if ($fieldType == 'currency' or $fieldType == 'double') {
                 $flduitype = $fieldInfo['uitype'];
                 if ($flduitype == '72' or $flduitype == 9 or $flduitype == 7) {
                     $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value, null, true);
                 } else {
                     $adv_filter_value = CurrencyField::convertToDBFormat($adv_filter_value);
                 }
             }
             $temp_val = explode(",", $adv_filter_value);
             if (($column_info[4] == 'D' || $column_info[4] == 'T' && $column_info[1] != 'time_start' && $column_info[1] != 'time_end' || $column_info[4] == 'DT') && ($column_info[4] != '' && $adv_filter_value != '')) {
                 $val = array();
                 for ($x = 0; $x < count($temp_val); $x++) {
                     if ($column_info[4] == 'D') {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertDateValue();
                     } elseif ($column_info[4] == 'DT') {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertDateTimeValue();
                     } else {
                         $date = new DateTimeField(trim($temp_val[$x]));
                         $val[$x] = $date->getDBInsertTimeValue();
                     }
                 }
                 $adv_filter_value = implode(",", $val);
             }
             if ($fieldType == 'picklist' || $fieldType == 'multipicklist') {
                 if (!isValueInPicklist($adv_filter_value, $fieldName)) {
                     $adv_filter_value = getTranslationKeyFromTranslatedValue($module, $adv_filter_value);
                 }
             }
             $criteria = array();
             $criteria['columnname'] = $adv_filter_column;
             $criteria['comparator'] = $adv_filter_comparator;
             $criteria['value'] = $adv_filter_value;
             $criteria['column_condition'] = $adv_filter_column_condition;
             $advfilterlist[$adv_filter_groupid]['columns'][] = $criteria;
         }
         foreach ($advft_criteria_groups as $group_index => $group_condition_info) {
             if (empty($group_condition_info)) {
                 continue;
             }
             if (empty($advfilterlist[$group_index])) {
                 continue;
             }
             $advfilterlist[$group_index]['condition'] = $group_condition_info["groupcondition"];
             $noOfGroupColumns = count($advfilterlist[$group_index]['columns']);
             if (!empty($advfilterlist[$group_index]['columns'][$noOfGroupColumns - 1]['column_condition'])) {
                 $advfilterlist[$group_index]['columns'][$noOfGroupColumns - 1]['column_condition'] = '';
             }
         }
         $noOfGroups = count($advfilterlist);
         if (!empty($advfilterlist[$noOfGroups]['condition'])) {
             $advfilterlist[$noOfGroups]['condition'] = '';
         }
         $advfiltersql = $this->generateAdvFilterSql($advfilterlist);
     }
     return $advfiltersql;
 }
开发者ID:kikojover,项目名称:corebos,代码行数:87,代码来源:ReportRun.php

示例9: getRequestData

function getRequestData($return_id)
{
    global $adb;
    $cont_qry = "select * from vtiger_cntactivityrel where activityid=?";
    $cont_res = $adb->pquery($cont_qry, array($return_id));
    $noofrows = $adb->num_rows($cont_res);
    $cont_id = array();
    if ($noofrows > 0) {
        for ($i = 0; $i < $noofrows; $i++) {
            $cont_id[] = $adb->query_result($cont_res, $i, "contactid");
        }
    }
    $cont_name = '';
    foreach ($cont_id as $key => $id) {
        if ($id != '') {
            $displayValueArray = getEntityName('Contacts', $id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $field_value) {
                    $contact_name = $field_value;
                }
            }
            $cont_name .= $contact_name . ', ';
        }
    }
    $cont_name = trim($cont_name, ', ');
    $mail_data = array();
    $mail_data['user_id'] = $_REQUEST['assigned_user_id'];
    $mail_data['subject'] = $_REQUEST['subject'];
    $mail_data['status'] = $_REQUEST['activity_mode'] == 'Task' ? $_REQUEST['taskstatus'] : $_REQUEST['eventstatus'];
    $mail_data['activity_mode'] = $_REQUEST['activity_mode'];
    $mail_data['taskpriority'] = $_REQUEST['taskpriority'];
    $mail_data['relatedto'] = $_REQUEST['parent_name'];
    $mail_data['contact_name'] = $cont_name;
    $mail_data['description'] = $_REQUEST['description'];
    $mail_data['assign_type'] = $_REQUEST['assigntype'];
    $mail_data['group_name'] = getGroupName($_REQUEST['assigned_group_id']);
    $mail_data['mode'] = $_REQUEST['mode'];
    $value = getaddEventPopupTime($_REQUEST['time_start'], $_REQUEST['time_end'], '24');
    $start_hour = $value['starthour'] . ':' . $value['startmin'] . '' . $value['startfmt'];
    if ($_REQUEST['activity_mode'] != 'Task') {
        $end_hour = $value['endhour'] . ':' . $value['endmin'] . '' . $value['endfmt'];
    }
    $startDate = new DateTimeField($_REQUEST['date_start'] . " " . $start_hour);
    $endDate = new DateTimeField($_REQUEST['due_date'] . " " . $end_hour);
    $mail_data['st_date_time'] = $startDate->getDBInsertDateTimeValue();
    $mail_data['end_date_time'] = $endDate->getDBInsertDateTimeValue();
    $mail_data['location'] = vtlib_purify($_REQUEST['location']);
    return $mail_data;
}
开发者ID:mslokhat,项目名称:corebos,代码行数:49,代码来源:Save.php

示例10: homepage_getPendingActivities

/**
 * function to get pending activities for today
 * @param integer $maxval - the maximum number of records to display
 * @param integer $calCnt - returns the count query if this is set
 * return array    $values   - activities record in array format
 */
function homepage_getPendingActivities($maxval, $calCnt)
{
    require_once "data/Tracker.php";
    require_once "include/utils/utils.php";
    require_once 'include/utils/CommonUtils.php';
    global $adb;
    global $current_user;
    $dbStartDateTime = new DateTimeField(date('Y-m-d H:i:s'));
    $userStartDate = $dbStartDateTime->getDisplayDate();
    $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00');
    $startDateTime = $userStartDateTime->getDBInsertDateTimeValue();
    $userEndDateTime = new DateTimeField($userStartDate . ' 23:59:00');
    $endDateTime = $userEndDateTime->getDBInsertDateTimeValue();
    $pending_condition = " AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}'\n\t\t\t\t\t\t\t\t\tOR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) BETWEEN '{$startDateTime}' AND '{$endDateTime}')";
    $list_query = "select vtiger_crmentity.crmid,vtiger_crmentity.smownerid,vtiger_crmentity." . "setype, vtiger_recurringevents.recurringdate, vtiger_activity.* from vtiger_activity " . "inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid LEFT " . "JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid left outer join " . "vtiger_recurringevents on vtiger_recurringevents.activityid=vtiger_activity.activityid" . ($list_query .= getNonAdminAccessControlQuery('Calendar', $current_user));
    $list_query .= "WHERE vtiger_crmentity.deleted=0 and (vtiger_activity.activitytype not in " . "('Emails')) AND (vtiger_activity.status is NULL OR vtiger_activity.status not in " . "('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity." . "eventstatus not in ('Held','Not Held')) " . $pending_condition;
    $list_query .= " GROUP BY vtiger_activity.activityid";
    $list_query .= " ORDER BY date_start,time_start ASC";
    $list_query .= " limit {$maxval}";
    $res = $adb->query($list_query);
    $noofrecords = $adb->num_rows($res);
    if ($calCnt == 'calculateCnt') {
        return $noofrecords;
    }
    $open_activity_list = array();
    $noofrows = $adb->num_rows($res);
    if (count($res) > 0) {
        for ($i = 0; $i < $noofrows; $i++) {
            $dateValue = $adb->query_result($res, $i, 'date_start') . ' ' . $adb->query_result($res, $i, 'time_start');
            $endDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_end');
            $recurringDateValue = $adb->query_result($res, $i, 'due_date') . ' ' . $adb->query_result($res, $i, 'time_start');
            $date = new DateTimeField($dateValue);
            $endDate = new DateTimeField($endDateValue);
            $recurringDate = new DateTimeField($recurringDateValue);
            $open_activity_list[] = array('name' => $adb->query_result($res, $i, 'subject'), 'id' => $adb->query_result($res, $i, 'activityid'), 'type' => $adb->query_result($res, $i, 'activitytype'), 'module' => $adb->query_result($res, $i, 'setype'), 'date_start' => $date->getDisplayDate(), 'due_date' => $endDate->getDisplayDate(), 'recurringdate' => $recurringDate->getDisplayDate(), 'priority' => $adb->query_result($res, $i, 'priority'));
        }
    }
    $values = getActivityEntries($open_activity_list);
    $values['ModuleName'] = 'Calendar';
    $values['search_qry'] = "&action=ListView&from_homepage=pending_activities";
    return $values;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:48,代码来源:HomeUtils.php

示例11: saveAdvancedFilters

    /**
     * Function saves Reports Filter information
     */
    function saveAdvancedFilters()
    {
        $db = PearDatabase::getInstance();
        $reportId = $this->getId();
        $advancedFilter = $this->get('advancedFilter');
        if (!empty($advancedFilter)) {
            $db->pquery('DELETE FROM vtiger_relcriteria WHERE queryid = ?', array($reportId));
            $db->pquery('DELETE FROM vtiger_relcriteria_grouping WHERE queryid = ?', array($reportId));
            foreach ($advancedFilter as $groupIndex => $groupInfo) {
                if (empty($groupInfo)) {
                    continue;
                }
                $groupColumns = $groupInfo['columns'];
                $groupCondition = $groupInfo['condition'];
                foreach ($groupColumns as $columnIndex => $columnCondition) {
                    if (empty($columnCondition)) {
                        continue;
                    }
                    $advFilterColumn = $columnCondition["columnname"];
                    $advFilterComparator = $columnCondition["comparator"];
                    $advFilterValue = $columnCondition["value"];
                    $advFilterColumnCondition = $columnCondition["column_condition"];
                    $columnInfo = explode(":", $advFilterColumn);
                    $moduleFieldLabel = $columnInfo[2];
                    list($module, $fieldLabel) = explode('_', $moduleFieldLabel, 2);
                    $fieldInfo = getFieldByReportLabel($module, $fieldLabel);
                    $fieldType = null;
                    if (!empty($fieldInfo)) {
                        $field = WebserviceField::fromArray($db, $fieldInfo);
                        $fieldType = $field->getFieldDataType();
                    }
                    if ($fieldType == 'currency') {
                        if ($field->getUIType() == '71') {
                            $advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue, null, true);
                        } else {
                            $advFilterValue = Vtiger_Currency_UIType::convertToDBFormat($advFilterValue);
                        }
                    }
                    $tempVal = explode(",", $advFilterValue);
                    if (($columnInfo[4] == 'D' || $columnInfo[4] == 'T' && $columnInfo[1] != 'time_start' && $columnInfo[1] != 'time_end' || $columnInfo[4] == 'DT') && ($columnInfo[4] != '' && $advFilterValue != '')) {
                        $val = array();
                        for ($i = 0; $i < count($tempVal); $i++) {
                            if (trim($tempVal[$i]) != '') {
                                $date = new DateTimeField(trim($tempVal[$i]));
                                if ($columnInfo[4] == 'D') {
                                    $val[$i] = DateTimeField::convertToDBFormat(trim($tempVal[$i]));
                                } elseif ($columnInfo[4] == 'DT') {
                                    $val[$i] = $date->getDBInsertDateTimeValue();
                                } else {
                                    $val[$i] = $date->getDBInsertTimeValue();
                                }
                            }
                        }
                        $advFilterValue = implode(",", $val);
                    }
                    $db->pquery('INSERT INTO vtiger_relcriteria (queryid, columnindex, columnname, comparator, value,
						groupid, column_condition) VALUES (?,?,?,?,?,?,?)', array($reportId, $columnIndex, $advFilterColumn, $advFilterComparator, $advFilterValue, $groupIndex, $advFilterColumnCondition));
                    // Update the condition expression for the group to which the condition column belongs
                    $groupConditionExpression = '';
                    if (!empty($advancedFilter[$groupIndex]["conditionexpression"])) {
                        $groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
                    }
                    $groupConditionExpression = $groupConditionExpression . ' ' . $columnIndex . ' ' . $advFilterColumnCondition;
                    $advancedFilter[$groupIndex]["conditionexpression"] = $groupConditionExpression;
                }
                $groupConditionExpression = $advancedFilter[$groupIndex]["conditionexpression"];
                if (empty($groupConditionExpression)) {
                    continue;
                }
                // Case when the group doesn't have any column criteria
                $db->pquery("INSERT INTO vtiger_relcriteria_grouping(groupid, queryid, group_condition, condition_expression) VALUES (?,?,?,?)", array($groupIndex, $reportId, $groupCondition, $groupConditionExpression));
            }
        }
    }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:77,代码来源:Record.php

示例12: getValidDBInsertDateTimeValue

function getValidDBInsertDateTimeValue($value)
{
    $valueList = explode(' ', $value);
    $date = new DateTimeField($value);
    if (count($valueList) == 2) {
        $value = $date->getDBInsertDateTimeValue();
    } elseif (count($valueList == 1)) {
        $value = $date->getDBInsertDateValue();
    }
    return $value;
}
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:11,代码来源:utils.php

示例13: convertRecordToNativeFormat

 private function convertRecordToNativeFormat($module, $record)
 {
     if ($module == 'Events') {
         $record['start_time'] = $record['date_start'] . " " . $record['time_start'];
         $record['end_time'] = $record['due_date'] . " " . $record['time_end'];
     } else {
         if ($module == 'Calendar') {
             $dformat = "Y-m-d H:i:s";
             $record['start_time'] = date($dformat, strtotime($record['date_start']));
             $record['end_time'] = date($dformat, strtotime($record['due_date']));
             // convert the start time and end time to user time zone as outlook does not take the datetime in utc
             $oldDateFormat = $this->user->date_format;
             $this->user->date_format = 'yyyy-mm-dd';
             $startDateTimeField = new DateTimeField($record['start_time']);
             $record['start_time'] = $startDateTimeField->getDBInsertDateTimeValue($this->user);
             $endDateTimeField = new DateTimeField($record['end_time']);
             $record['end_time'] = $endDateTimeField->getDBInsertDateTimeValue($this->user);
             $this->user->date_format = $oldDateFormat;
         }
     }
     return $record;
 }
开发者ID:jmangarret,项目名称:vtigercrm,代码行数:22,代码来源:OutlookHandler.php

示例14: and

    $list_query = $oCustomView->getModifiedCvListQuery($viewid, $list_query, "Calendar");
}
if (isset($where) && $where != '') {
    if (isset($_REQUEST['from_homepagedb']) && $_REQUEST['from_homepagedb'] == 'true') {
        $list_query .= " and ((vtiger_activity.status!='Completed' and vtiger_activity.status!='Deferred') or vtiger_activity.status is null) and ((vtiger_activity.eventstatus!='Held' and vtiger_activity.eventstatus!='Not Held') or vtiger_activity.eventstatus is null) AND " . $where;
    } else {
        $list_query .= " AND " . $where;
    }
}
if (isset($_REQUEST['from_homepage'])) {
    $dbStartDateTime = new DateTimeField(date('Y-m-d H:i:s'));
    $userStartDate = $dbStartDateTime->getDisplayDate();
    $userStartDateTime = new DateTimeField($userStartDate . ' 00:00:00');
    $startDateTime = $userStartDateTime->getDBInsertDateTimeValue();
    $userEndDateTime = new DateTimeField($userStartDate . ' 23:59:00');
    $endDateTime = $userEndDateTime->getDBInsertDateTimeValue();
    if ($_REQUEST['from_homepage'] == 'upcoming_activities') {
        $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus not in ('Held','Not Held')) AND (CAST((CONCAT(date_start,' ',time_start)) AS DATETIME) >= '{$startDateTime}' OR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) >= '{$startDateTime}')";
    } elseif ($_REQUEST['from_homepage'] == 'pending_activities') {
        $list_query .= " AND (vtiger_activity.status is NULL OR vtiger_activity.status not in ('Completed','Deferred')) and (vtiger_activity.eventstatus is NULL OR  vtiger_activity.eventstatus not in ('Held','Not Held')) AND (CAST((CONCAT(due_date,' ',time_end)) AS DATETIME) <= '{$endDateTime}' OR CAST((CONCAT(vtiger_recurringevents.recurringdate,' ',time_start)) AS DATETIME) <= '{$endDateTime}')";
    }
}
if (isset($order_by) && $order_by != '') {
    if ($order_by == 'smownerid') {
        $list_query .= ' ORDER BY user_name ' . $sorder;
    } else {
        $tablename = getTableNameForField('Calendar', $order_by);
        $tablename = $tablename != '' ? $tablename . "." : '';
        if ($order_by == 'lastname') {
            $list_query .= ' ORDER BY vtiger_contactdetails.lastname ' . $sorder;
        } else {
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:31,代码来源:ListView.php

示例15: readAppointment

 /** To get the events of the specified user and shared events
  * @param $userid -- The user Id:: Type integer
  * @param $from_datetime -- The start date Obj :: Type Array
  * @param $to_datetime -- The end date Obj :: Type Array
  * @param $view -- The calendar view :: Type String
  * @returns $list :: Type Array
  */
 function readAppointment($userid, &$from_datetime, &$to_datetime, $view)
 {
     global $current_user, $adb;
     require 'user_privileges/user_privileges_' . $current_user->id . '.php';
     require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
     $and = "AND (\n\t\t\t\t\t(\n\t\t\t\t\t\t(\n\t\t\t\t\t\t\t(CAST(CONCAT(date_start,' ',time_start) AS DATETIME) >= ? AND CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ?)\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) <= ? )\n\t\t\t\t\t\t\tOR\t(CAST(CONCAT(date_start,' ',time_start) AS DATETIME) <= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ?)\n\t\t\t\t\t\t)\n\t\t\t\t\t\tAND vtiger_recurringevents.activityid is NULL\n\t\t\t\t\t)\n\t\t\t\tOR (\n\t\t\t\t\t\t(CAST(CONCAT(vtiger_recurringevents.recurringdate,' ',time_start) AS DATETIME) >= ?\n\t\t\t\t\t\t\tAND CAST(CONCAT(vtiger_recurringevents.recurringdate,' ',time_start) AS DATETIME) <= ?)\n\t\t\t\t\t\tOR\t(CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ? AND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) <= ?)\n\t\t\t\t\t\tOR\t(CAST(CONCAT(vtiger_recurringevents.recurringdate,' ',time_start) AS DATETIME) <= ?\n\t\t\t\t\t\t\tAND CAST(CONCAT(due_date,' ',time_end) AS DATETIME) >= ?)\n\t\t\t\t\t)\n\t\t\t\t)";
     $userNameSql = getSqlForNameInDisplayFormat(array('first_name' => 'vtiger_users.first_name', 'last_name' => 'vtiger_users.last_name'), 'Users');
     $q = "select vtiger_activity.*, vtiger_crmentity.*,\n\t\t\t\t\tcase when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name\n\t\t\t\t\tFROM vtiger_activity\n\t\t\t\t\t\tinner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid\n\t\t\t\t\t\tleft join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid\n\t\t\t\t\t\tleft join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\t\tWHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') {$and} ";
     // User Select Customization: Changes should made also in (calendayLaout getEventList) and one more BELOW
     $query_filter_prefix = calendarview_getSelectedUserFilterQuerySuffix();
     $q .= $query_filter_prefix;
     // END
     $h = $from_datetime->z_hour;
     $m = $from_datetime->min;
     if (empty($m)) {
         $m = '00';
     }
     $startDate = new DateTimeField($from_datetime->year . "-" . $from_datetime->z_month . "-" . $from_datetime->z_day . " {$h}:{$m}");
     $h = '23';
     $m = '59';
     $endDate = new DateTimeField($to_datetime->year . "-" . $to_datetime->z_month . "-" . $to_datetime->z_day . " {$h}:{$m}");
     $params = array($startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue(), $startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue());
     if ($is_admin == false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3) {
         //Added for User Based Custom View for Calendar
         $sec_parameter = getCalendarViewSecurityParameter();
         $q .= $sec_parameter;
     }
     $q .= " AND vtiger_recurringevents.activityid is NULL ";
     $q .= " group by vtiger_activity.activityid ORDER by vtiger_activity.date_start,vtiger_activity.time_start";
     $r = $adb->pquery($q, $params);
     $n = $adb->getRowCount($r);
     $a = 0;
     $list = array();
     while ($a < $n) {
         $result = $adb->fetchByAssoc($r);
         $from = strtotime($result['date_start']);
         $to = strtotime($result['due_date'] . ' ' . $result["time_end"]);
         $windowTo = strtotime($endDate->getDBInsertDateTimeValue());
         for ($j = $from; $j <= $to; $j = $j + 60 * 60 * 24) {
             $obj =& new Appointment();
             $temp_start = date("Y-m-d", $j);
             $endTime = strtotime($temp_start . ' ' . $result['time_start']);
             if ($endTime > $windowTo) {
                 break;
             }
             $result["date_start"] = $temp_start;
             list($obj->temphour, $obj->tempmin) = explode(":", $result["time_start"]);
             if ($start_timestamp != $end_timestamp && $view == 'day') {
                 if ($j == $start_timestamp) {
                     $result["duration_hours"] = 24 - $obj->temphour;
                 } elseif ($j > $start_timestamp && $j < $end_timestamp) {
                     list($obj->temphour, $obj->tempmin) = $current_user->start_hour != '' ? explode(":", $current_user->start_hour) : explode(":", "08:00");
                     $result["duration_hours"] = 24 - $obj->temphour;
                 } elseif ($j == $end_timestamp) {
                     list($obj->temphour, $obj->tempmin) = $current_user->start_hour != '' ? explode(":", $current_user->start_hour) : explode(":", "08:00");
                     list($ehr, $emin) = explode(":", $result["time_end"]);
                     $result["duration_hours"] = $ehr - $obj->temphour;
                 }
             }
             $obj->readResult($result, $view);
             $list[] = $obj;
             unset($obj);
         }
         $a++;
     }
     //Get Recurring events
     $q = "SELECT vtiger_activity.*, vtiger_crmentity.*, case when (vtiger_users.user_name not like '') then {$userNameSql} else vtiger_groups.groupname end as user_name , vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_groups.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left join vtiger_groups on vtiger_groups.groupid = vtiger_crmentity.smownerid LEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid";
     $q .= getNonAdminAccessControlQuery('Calendar', $current_user);
     $q .= " where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype not in ('Emails','Task') AND (cast(concat(recurringdate, ' ', time_start) as datetime) between ? and ?) ";
     // User Select Customization
     $q .= $query_filter_prefix;
     // END
     $params = array($startDate->getDBInsertDateTimeValue(), $endDate->getDBInsertDateTimeValue());
     $q .= " ORDER by vtiger_recurringevents.recurringid";
     $r = $adb->pquery($q, $params);
     $n = $adb->getRowCount($r);
     $a = 0;
     while ($a < $n) {
         $obj =& new Appointment();
         $result = $adb->fetchByAssoc($r);
         list($obj->temphour, $obj->tempmin) = explode(":", $result["time_start"]);
         $obj->readResult($result, $view);
         $a++;
         $list[] = $obj;
         unset($obj);
     }
     usort($list, 'compare');
     return $list;
 }
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:96,代码来源:Appointment.php


注:本文中的DateTimeField::getDBInsertDateTimeValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。