コード例 #1
0
ファイル: sync.php プロジェクト: Terradex/sugar
function sync_events($one_user = false, $sel_user = "")
{
    global $beanList, $beanFiles, $path;
    $use_offset_time = true;
    $td = new TimeDate();
    $arr_modules[] = "Meetings";
    $arr_modules[] = "Calls";
    $arr_modules[] = "Tasks";
    global $timedate;
    global $beanList, $beanFiles, $path, $current_user;
    for ($tn = 0; $tn < count($arr_modules); $tn++) {
        ob_start();
        $module_name = $arr_modules[$tn];
        $class_name = $beanList[$module_name];
        require_once $beanFiles[$class_name];
        $seed = new $class_name();
        $tbn = $seed->table_name;
        $tablename = $tbn;
        $cstmtbname2 = $tablename . "_cstm";
        if ($one_user == true) {
            if ($_SESSION['authenticated_user_id'] == "" and 1 == 2) {
            } else {
                if ($sel_user != "") {
                    $cu = $sel_user;
                } else {
                    $cu = $_SESSION['authenticated_user_id'];
                }
                $tdus = new TimeDate();
                $cus = new User();
                $cus->retrieve($cu);
                ##############
                global $current_user;
                $current_user = $cus;
                ##############
                $calendar_priv_add = $cus->google_mcalendar_c;
                $crdatefilt = $cus->google_mafterdate_c;
                $crdatefilt = $tdus->swap_formats($crdatefilt, $td->get_date_format(true, $cus), "Y-m-d");
                unset($cus);
                $sql_user = "******";
                if ($crdatefilt != '') {
                    $sql_user .= "  and {$tbn}.date_entered>='{$crdatefilt}' ";
                }
                $query = $sql_user;
            }
        }
        $d1d = array();
        $s = array();
        $ch = array();
        $fd = array();
        $forexp = "";
        $fort1d = "";
        $t1d = "";
        $nt = "";
        $nt1 = "";
        $cm = date("m");
        $cy = date("Y");
        unset($response);
        global $max_events_upload_google;
        $response = $seed->get_list($order_by, $query, $offset, 10000, $max_events_upload_google, false);
        if ($tablename == "calls") {
        }
        $newdoc = $response['list'][$tn1];
        if (1 == 1) {
            $tablename = $tbn;
            echo "<br>****** Get events from {$tablename}";
            require_once 'modules/Calendar/DateTimeUtil.php';
            $cm = date("m");
            $cy = date("Y");
            for ($tn1 = 0; $tn1 < count($response['list']); $tn1++) {
                unset($a);
                unset($a1);
                unset($a2);
                unset($s);
                unset($current_user);
                unset($user);
                unset($td);
                $a1 = $response['list'][$tn1];
                $current_user = new User();
                $current_user->retrieve($a1->assigned_user_id);
                debugg("<br> current user for event " . $a1->assigned_user_id . "   " . $current_user->name);
                $user = $current_user;
                $td = new TimeDate();
                $user_google_mafterdate_c = $td->swap_formats($current_user->google_mafterdate_c, $td->get_date_format(true, $current_user), "Y-m-d");
                $add_notifications = $current_user->google_mnotifications_c;
                unset($a2);
                if ($tablename == 'meetings') {
                    $a2 = new Meeting();
                }
                if ($tablename == 'calls') {
                    $a2 = new Call();
                }
                if ($tablename == 'tasks') {
                    $a2 = new Task();
                }
                unset($a);
                $a = $a2->retrieve($a1->id);
                if ($a->old_id_c == "" or 1 == 1) {
                    global $calls_prefix;
                    global $meetings_prefix;
                    global $tasks_prefix;
                    $s = array();
                    $s["title"] = $a->name;
                    if ($tablename == 'meetings') {
                        $s["title"] = $meetings_prefix . $s["title"];
                    }
                    if ($tablename == 'calls') {
                        $s["title"] = $calls_prefix . $s["title"];
                    }
                    if ($tablename == 'tasks') {
                        $s["title"] = $tasks_prefix . $s["title"];
                    }
                    debugg("<br><br><br>**********Event ******* id={$a->id} ***** name={$a->name}" . "  number  " . $tn1 . " date " . $a->date_start);
                    if ($a->name == "gmt+1 start 23:30 end 00:15" or $a->name == "gmt+3 + dst start 23:30 end 00:15") {
                    }
                    $sq = "select * from {$tablename} where id='" . $a2->id . "' and deleted='0'";
                    $result = $a2->db->query($sq);
                    while ($row = $a2->db->fetchByAssoc($result)) {
                        $ro = $row;
                    }
                    $start = $ro['date_start'];
                    $end = $ro['date_due'];
                    #260608  $start_offset = $td->handle_offset($start, "Y-m-d H:i:s", true,$current_user);
                    #260608  $end_offset = $td->handle_offset($end, "Y-m-d H:i:s", true,$current_user);
                    $start_offset = $start;
                    $end_offset = $end;
                    if ($tablename == 'tasks') {
                        $a->date_start = $start;
                        $a->date_due = $end;
                    }
                    $s["content"] = $a->description;
                    $s["where"] = $a->location;
                    $s["startDay"] = $start_offset;
                    $s["startTime"] = $a->time_start;
                    $s["endDay"] = $end_offset;
                    $s["reminder_time"] = $a->reminder_time / 60;
                    if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) {
                        $s["reminder_time"] = 10;
                    }
                    if ($tablename == 'tasks') {
                        $s["startTime"] = "";
                        $a->time_start = "";
                    }
                    if ($a->date_start == '' and $a->date_due != "") {
                        $a->date_start = $end_offset;
                        #### for tsaks if no start date
                    } else {
                        $a->date_start = $start_offset;
                    }
                    $date_start_in_db_fmt = $start_offset;
                    $date_start_array = split(" ", trim($date_start_in_db_fmt));
                    $date_due_in_db_fmt = $end_offset;
                    $arr_ds = explode(" ", $start_offset);
                    $arr_de = explode(" ", $end_offset);
                    debugg("<br>current user " . $current_user->name);
                    $a->time_start = $arr_ds[1];
                    $a->time_due = $arr_de[1];
                    $s["startDay"] = $arr_ds[0];
                    $s["startTime"] = $a->time_start;
                    $s["endDay"] = $arr_de[0];
                    $s["endTime"] = $arr_de[1];
                    if ($tablename == "tasks" and $s["startDay"] == "" and $s["endDay"] !== "") {
                        $s["startDay"] = $s["endDay"];
                        $s["startTime"] = $s["endTime"];
                        $a->time_start = $s["endTime"];
                    }
                    debugg("<br>dst00 " . $date_start_in_db_fmt . "  a time start " . $a->time_start);
                    $fd = explode("/", $s["startDay"]);
                    if ($fd[2] == "") {
                        $fd = explode("-", $s["startDay"]);
                    }
                    $plugin_date_start = $fd[2] . "/" . $fd[1] . "/" . $fd[0] . " " . $s["startTime"];
                    if ($tablename != 'tasks') {
                        $plugin_date_due = $plugin_date_start;
                    } else {
                        $fd = explode("/", $s["endDay"]);
                        if ($fd[2] == "") {
                            $fd = explode("-", $s["endDay"]);
                        }
                        if ($fd[2] != "") {
                            $plugin_date_due = $fd[2] . "/" . $fd[1] . "/" . $fd[0] . " " . $s["dueTime"];
                        } else {
                            $plugin_date_due = $plugin_date_start;
                        }
                    }
                    $plugin_format = "d/m/Y H:i";
                    ######################################
                    $d1 = explode("/", $plugin_date_start);
                    global $current_user;
                    $d1[2] = explode(" ", $d1[2]);
                    $d1[2] = $d1[2][0];
                    $fort1 = explode(" ", $plugin_date_start);
                    $fort1 = $fort1[1];
                    $t1 = explode(":", $fort1);
                    $t1[1] = round($t1[1]);
                    $untill = mktime($t1[0] + $a->duration_hours, $t1[1] + $a->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]);
                    if ($tablename == 'tasks') {
                        if ($plugin_date_due == "" or $a->date_due == "") {
                            $forexp = $plugin_date_start;
                        } else {
                            $forexp = $plugin_date_due;
                        }
                    } else {
                        $forexp = $plugin_date_start;
                    }
                    $d1d = explode("/", $forexp);
                    if ($d1d[2] == "") {
                        $d1d = explode("-", $forexp);
                    }
                    $d1d[2] = explode(" ", $d1d[2]);
                    $d1d[2] = $d1d[2][0];
                    $fort1d = explode(" ", $forexp);
                    $fort1d = $fort1d[1];
                    $t1d = explode(":", $fort1d);
                    $untill = mktime($t1d[0] + $a->duration_hours, $t1d[1] + $a->duration_minutes, $t1d[2], $d1d[1], $d1d[0], $d1d[2]);
                    if ($tablename == 'tasks' and $a->date_due != "") {
                        $nt = explode(" ", $a->date_due);
                        $nt1 = explode(":", $nt[1]);
                        if ($nt[1] == "") {
                            $nt1 = explode(".", $nt[1]);
                        }
                        print_r($nt);
                        $untill = mktime($nt1[0], $nt1[1], 0, $d1d[1], $d1d[0], $d1d[2]);
                    }
                    $date_due = date("Y-m-d", $untill);
                    $time_due = date("H:i:s", $untill);
                    $s["endTime"] = $time_due;
                    $s["endDay"] = $date_due;
                    if ($a->date_start == '') {
                        $s["startTime"] = $s["endTime"];
                        $s["startDay"] = $s["endDay"];
                    }
                    if ($a->assigned_user_id == '') {
                        $user = $a->created_by;
                    } else {
                        $user = $a->assigned_user_id;
                    }
                    $user_data = get_user_email_pass1($user);
                    if ($user_data[0] != '' and $user_data[1] != '') {
                        debugg("<br>**Got user " . $user_data[0]);
                        $gc = new GoogleCalendarWrapper($user_data[0], $user_data[1], $current_user->google_mcalendar_c);
                        $_SESSION["called_from_sync"] = true;
                        $settings["reminder_checked"] = $a->reminder_checked;
                        if ($sel_user != "" and $calendar_priv_add != "" and $calendar_priv_add != "1") {
                            $gc->feed_url = $calendar_priv_add;
                        }
                        if ($s["startDay"] >= $user_google_mafterdate_c) {
                            $gc->add_event($s, $a->id, $tablename, $user_data, $add_notifications);
                        } else {
                        }
                        $_SESSION["called_from_sync"] = false;
                    }
                }
            }
        }
    }
}
コード例 #2
0
ファイル: model.php プロジェクト: jasondavis/sugarcrm
//подключение к базе
global $db;
//$bean->db
$r = $db->query('SELECT currency_code FROM px_exchangerates WHERE deleted=0 GROUP BY currency_code');
$load = array();
while ($a = $db->fetchByAssoc($r)) {
    $load[] = $a['currency_code'];
}
$datetime1 = new DateTime('2009-10-11');
$datetime2 = new DateTime('2009-10-13');
$interval = $datetime1->diff($datetime2);
$today = date("Y-m-d");
global $current_user;
$td = new TimeDate($current_user);
$date_my = $td->to_db_date(date($td->get_date_time_format()));
$date_my = $td->to_db_date(date($td->get_date_format()));
//только дата
$datetime1 = date($td->get_date_format());
$datetime2 = date_create_from_format($td->get_date_format(), $this->bean->px_status_study_date);
echo $interval->format('%R%a дней');
//%R плюс минус
echo $interval->format('%a дней');
$GLOBALS['timedate']->to_db_date();
$GLOBALS['timedate']->nowDbDate();
$GLOBALS['timedate']->nowDb();
//time
//debug_backtrace
$bcktrc = debug_backtrace();
$bcktrc = json_encode($bcktrc);
echo "<script> dbg_bcktrc = {$bcktrc}; </script>";
$debug_b = json_encode(debug_backtrace());
コード例 #3
0
 function display()
 {
     $ss = new Sugar_Smarty();
     $table = array('Leads' => 'Leads', 'Opportunities' => 'Opportunities', 'FITs' => 'Customer', 'Contacts' => 'Contacts', 'Accounts' => 'Company', 'Cases' => 'Cases', 'Notes' => 'Notes', 'Calls' => 'Calls', 'Emails' => 'Emails', 'Meetings' => 'Meetings', 'Tasks' => 'Tasks');
     $timedate = new TimeDate();
     global $db, $mod_strings, $app_list_strings, $current_user;
     $ss = new Sugar_Smarty();
     $ss->assign('MOD', $mod_strings);
     $focus = new C_Reports();
     $role = $focus->getUserRole('Reports', $current_user->id);
     $list_user = $focus->getUserForReportAsRole();
     $list_group = $focus->getAllSecuritySuite();
     $ss->assign('lst_group', get_select_options_with_id($app_list_strings['report_securitysuite_dom'], ''));
     $ss->assign('lst_user', get_select_options_with_id($app_list_strings['report_user_dom'], ''));
     if (isset($_REQUEST['submit'])) {
         $start_date = $_REQUEST['start_date'];
         $end_date = $_REQUEST['end_date'];
         $user_id = $_REQUEST['lst_user'];
         $list_user = $_REQUEST['user_id'];
         $time_range = $_REQUEST['time_range'];
         $start_end_yes = $_REQUEST['start_end_yes'];
         $report_option = $_REQUEST['report_option'];
         $type = $time_range ? $time_range : $start_end_yes;
         $ss->assign('TYPE', $type);
         $ss->assign('report_option', $report_option);
         $lst_user = get_select_options($app_list_strings['report_user_dom'], $user_id);
         $ss->assign('lst_user', $lst_user);
         if ($list_user) {
             $user_id = json_decode(base64_decode($list_user));
             if (count($user_id) > 0) {
                 $user_id = $user_id;
             }
         }
         if ($user_id) {
             $user_id = (array) $user_id;
         } else {
             unset($app_list_strings['report_user_dom']['0']);
             $user_id = array_keys($app_list_strings['report_user_dom']);
         }
         if ($group) {
             $group = (array) $group;
         } else {
             unset($app_list_strings['report_securitysuite_dom']['0']);
             $group = array_keys($app_list_strings['report_securitysuite_dom']);
         }
         $dateOp = new AdvancedDatetimeOperations($focus);
         $user_format = $timedate->get_date_format($current_user);
         $date_format = $_REQUEST['date_format'] != '' ? $_REQUEST['date_format'] : $user_format;
         if ($start_end_yes) {
             $time_range = '';
             $start_date = $timedate->to_display($_REQUEST['start_date'], $date_format, 'Y-m-d');
             $end_date = $timedate->to_display($_REQUEST['end_date'], $date_format, 'Y-m-d');
         } else {
             $start_date = date('Y-m-d');
             $end_date = date('Y-m-d');
             $dateOp->calc_date2($start_date, $end_date, $time_range);
         }
         $date_start = $timedate->to_display($start_date, 'Y-m-d', $user_format);
         $date_end = $timedate->to_display($end_date, 'Y-m-d', $user_format);
         $html = '';
         $html = '<br /><div style="color:red"><b>Note : (Created/Assigned/Modified)</b></div>';
         $html .= '<table class="h3Row" cellpadding="0" cellspacing="0" width="100%" border="1" style="border-collapse: collapse;"> ';
         $html .= '<thead>';
         $html .= '<td class="tb_border" style="background:#EBEBED"><b>User</b></td>';
         foreach ($table as $table_name) {
             $html .= '<td style="background:#EBEBED;text-align:center" class="tb_border" width="' . 100 / count($table) . '%"><b>' . $table_name . '</b></td>';
         }
         $html .= '</tr>';
         $html .= '</thead>';
         if (count($user_id) > 0 && $user_id[0] != '0') {
             foreach ($user_id as $value) {
                 $html .= '<tr height="20">';
                 $html .= '<td class="tb_border"> ' . translate('report_user_dom', '', $value) . ' </td>';
                 foreach ($table as $table_value => $table_name) {
                     $recordCreate = $focus->countRecordCreate(strtolower($table_value), $value, $start_date, $end_date);
                     $recordModify = $focus->countRecordAsignedTo(strtolower($table_value), $value, $start_date, $end_date);
                     $recordModified = $focus->countRecordModify(strtolower($table_value), $value, $start_date, $end_date);
                     if ($recordCreate > 0) {
                         $create_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&created_by_basic=' . $value . '&date_entered_basic_range_choice=between&start_range_date_entered_basic=' . $date_start . '&end_range_date_entered_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordCreate . '</a>';
                     } else {
                         $create_url = $recordCreate;
                     }
                     if ($recordModify > 0) {
                         $modify_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&assigned_user_id=' . $value . '&date_modified_basic_range_choice=between&start_range_date_modified_basic=' . $date_start . '&end_range_date_modified_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordModify . '</a>';
                     } else {
                         $modify_url = $recordModify;
                     }
                     if ($recordModified > 0) {
                         $modified_url = '<a target="blank" href="index.php?module=' . $table_value . '&action=index&query=true&modified_user_id_basic=' . $value . '&date_modified_basic_range_choice=between&start_range_date_modified_basic=' . $date_start . '&end_range_date_modified_basic=' . $date_end . '&searchFormTab=basic_search">' . $recordModified . '</a>';
                     } else {
                         $modified_url = $recordModified;
                     }
                     $html .= '<td style="text-align:center" class="tb_border">' . $create_url . ' / ' . $modify_url . ' / ' . $modified_url . ' </td>';
                 }
                 $html .= '</tr>';
             }
         }
         //$countACC = $focus->get_audit_table_name();
         $html .= '</table>';
         // $start_date = $timedate->to_display($_REQUEST['start_date'],$date_format,$user_format);
         //  $end_date = $timedate->to_display($_REQUEST['end_date'],$date_format,$user_format);
         $ss->assign('start_date', $_REQUEST['start_date']);
         $ss->assign('end_date', $_REQUEST['end_date']);
         $ss->assign('date_format', $user_format);
     }
     $html .= '<script type="text/javascript"> 
         jQuery(document).ready(function(){
            jQuery("table[class=\'h3Row\']").find("tbody").find("tr:even").addClass("evenListRowS1");
            jQuery("table[class=\'h3Row\']").find("tbody").find("tr:odd").addClass("oddListRowS1");
         });
         </script>';
     $ss->assign('CONTENT', $html);
     $ss->display("modules/C_Reports/tpls/Synthesis_Report.tpl");
 }
コード例 #4
0
require_once "include/TimeDate.php";
require_once 'include/entryPoint.php';
global $db, $current_user;
$first_name = trim($_POST['first_name']);
$last_name = trim($_POST['last_name']);
$birthday = trim($_POST['birthday']);
$phone_mobile = trim($_POST['phone_mobile']);
$identy_card = trim($_POST['identy_card']);
$where = "deleted = 0 AND last_name = '" . $last_name . "'";
if ($first_name) {
    $where .= " AND first_name = '" . $first_name . "'";
}
if ($birthday) {
    // Xu ly chuoi ngay sinh
    $date_time = new TimeDate();
    $user_date_format = $date_time->get_date_format($current_user);
    $birdthday = $date_time->to_display($birthday, $user_date_format, 'Y-m-d');
    $where .= " AND birthday = '" . $birdthday . "'";
}
if ($phone_mobile) {
    $where .= " AND phone_mobile = '" . $phone_mobile . "'";
}
if ($identy_card) {
    $where .= " AND identy_card = '" . $identy_card . "'";
}
$sql = "SELECT id, first_name, last_name, birthday, phone_mobile, identy_card, assigned_user_id FROM fits WHERE {$where}";
$result = $db->query($sql);
//display
$n = $db->getRowCount($result);
$error = '';
if ($n > 0) {