Exemplo n.º 1
0
 public function create_contact($r)
 {
     global $OUTPUT;
     $mail = $r['record']['email'];
     require_once dirname(__FILE__) . '/epesi_contacts_addressbook_backend.php';
     $contacts = new epesi_contacts_addressbook_backend('CRM Contacts');
     $ret = $contacts->search('email', $mail, true, false);
     if (count($ret->records)) {
         $OUTPUT->show_message('contactexists', 'warning');
     } else {
         require_once dirname(__FILE__) . '/epesi_companies_addressbook_backend.php';
         $companies = new epesi_companies_addressbook_backend('CRM Companies');
         $ret = $companies->search('email', $mail, true, false);
         if (count($ret->records)) {
             $OUTPUT->show_message('contactexists', 'warning');
         } else {
             if (isset($r['record']['firstname']) && $r['record']['firstname'] !== "" && isset($r['record']['surname']) && $r['record']['surname'] !== "") {
                 $name = array($r['record']['firstname'], $r['record']['surname']);
             } else {
                 $name = explode(' ', $r['record']['name'], 2);
             }
             if (count($name) < 2) {
                 $OUTPUT->show_message('errorsavingcontact', 'warning');
             } else {
                 $loc = Base_RegionalSettingsCommon::get_default_location();
                 Utils_RecordBrowserCommon::new_record('contact', array('first_name' => $name[0], 'last_name' => $name[1], 'email' => $mail, 'permission' => 0, 'country' => $loc['country']));
                 $OUTPUT->show_message('addedsuccessfully', 'confirmation');
             }
         }
     }
     $OUTPUT->send();
     //    return array('abort'=>true);
 }
Exemplo n.º 2
0
 public function month_array($date, $mark = array())
 {
     $first_day_of_month = strtotime(date('Y-m-', $date) . '01');
     $diff = date('w', $first_day_of_month) - Utils_PopupCalendarCommon::get_first_day_of_week();
     if ($diff < 0) {
         $diff += 7;
     }
     $currday = strtotime("-{$diff} days", $first_day_of_month);
     $curmonth = date('m', $date);
     $month = array();
     $today = date('Y-m-d', strtotime(Base_RegionalSettingsCommon::time2reg(null, false, true, true, false)));
     $colors = CRM_Calendar_EventCommon::get_available_colors();
     while (date('m', $currday) != $curmonth % 12 + 1) {
         $week = array();
         $weekno = date('W', $currday);
         $link = Base_BoxCommon::create_href($this, 'CRM_Calendar', null, null, null, array('jump_to_date' => $currday, 'switch_to_tab' => 'Week'));
         for ($i = 0; $i < 7; $i++) {
             $main_month = date('m', $currday) == $curmonth;
             $next = array('day' => date('j', $currday), 'day_link' => Base_BoxCommon::create_href($this, 'CRM_Calendar', null, null, null, array('jump_to_date' => $currday, 'switch_to_tab' => 'Day')), 'style' => ($main_month ? date('Y-m-d', $currday) == $today ? 'today' : 'current' : 'other') . (date('N', $currday) >= 6 ? '_weekend' : ''), 'time' => $currday);
             if ($main_month && isset($mark[date('Y-m-d', $currday)])) {
                 $next['style'] .= ' event-' . $colors[$mark[date('Y-m-d', $currday)]];
             }
             $week[] = $next;
             $currday = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $currday)) + 3600 * 24) . ' ' . date('H:i:s', $currday));
         }
         $month[] = array('week_label' => $weekno, 'week_link' => $link, 'days' => $week);
     }
     return $month;
 }
Exemplo n.º 3
0
 public static function format_time($time)
 {
     static $base_unix_time = null;
     if ($base_unix_time === null) {
         $base_unix_time = strtotime('1970-01-01 00:00');
     }
     return Base_RegionalSettingsCommon::time2reg($base_unix_time + $time, 'without_seconds', false, false);
 }
Exemplo n.º 4
0
 public function body()
 {
     if (!Base_AclCommon::i_am_user()) {
         print __('First log in to the system.');
         return;
     }
     $form = $this->init_module(Libs_QuickForm::module_name(), __('Saving settings'));
     //pass
     $form->addElement('header', null, __('Change password'));
     $form->addElement('html', '<tr><td colspan=2>' . __('Leave password boxes empty if you prefer your current password') . '</td></tr>');
     $form->addElement('password', 'new_pass', __('New password'));
     $form->addElement('password', 'new_pass_c', __('Confirm new password'));
     $form->addRule(array('new_pass', 'new_pass_c'), __('Your passwords don\'t match'), 'compare');
     $form->addRule('new_pass', __('Your password must be longer then 5 chars'), 'minlength', 6);
     //mail
     $form->addElement('header', null, __('Change e-mail'));
     $form->addElement('text', 'mail', __('New e-mail address'));
     $form->addRule('mail', __('Field required'), 'required');
     $form->addRule('mail', __('Invalid e-mail address'), 'email');
     //autologin
     $ret = DB::GetAll('SELECT autologin_id,description,last_log FROM user_autologin WHERE user_login_id=%d', array(Acl::get_user()));
     if ($ret) {
         $form->addElement('header', null, __('Delete autologin'));
     }
     foreach ($ret as $row) {
         $form->addElement('checkbox', 'delete_autologin[' . $row['autologin_id'] . ']', $row['description'], Base_RegionalSettingsCommon::time2reg($row['last_log']));
     }
     //confirmation
     $form->addElement('header', null, __('Confirmation'));
     $form->addElement('password', 'old_pass', __('Old password'));
     $form->registerRule('check_old_pass', 'callback', 'check_old_pass', $this);
     $form->addRule('old_pass', __('Old password incorrect'), 'check_old_pass');
     $form->addRule('old_pass', __('Field required'), 'required');
     if (Base_AclCommon::check_permission('Advanced User Settings')) {
         Base_ActionBarCommon::add('back', __('Back'), $this->create_main_href('Base_User_Settings'));
     }
     Base_ActionBarCommon::add('save', __('Save'), $form->get_submit_form_href());
     #$form->addElement('submit', 'submit_button', __('OK'));
     if ($form->validate_with_message('Setting saved', __('Problem encountered'))) {
         if ($form->process(array(&$this, 'submit_user_preferences'))) {
             if (Base_AclCommon::check_permission('Advanced User Settings')) {
                 Base_BoxCommon::location('Base_User_Settings');
             }
         }
     } else {
         //defaults
         $ret = DB::Execute('SELECT p.mail FROM user_password p  WHERE p.user_login_id=%d', Acl::get_user());
         if ($row = $ret->FetchRow()) {
             $form->setDefaults(array('mail' => $row[0]));
         }
         $form->display();
     }
 }
Exemplo n.º 5
0
 public function body($skin, $size = 200)
 {
     print '<center' . ($skin == 'chunkySwissOnBlack' ? ' style="background-color:black; color:white;"' : '') . '>';
     $browser = stripos($_SERVER['HTTP_USER_AGENT'], 'msie');
     if ($browser !== false || $skin == 'flash') {
         $size *= 2;
         //clock taken from http://www.kirupa.com/developer/actionscript/clock.htm
         $clock = $this->get_module_dir() . 'clock.swf';
         print '<center><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" height="' . $size . '" width="' . $size . '">' . '<param name="movie" value="' . $clock . '">' . '<param name="quality" value="high">' . '<param name="wmode" value="transparent">' . '<param name="menu" value="false">' . '<embed src="' . $clock . '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" height="' . $size . '" width="' . $size . '">' . '</object></center>';
     } else {
         load_js($this->get_module_dir() . 'coolclock.js');
         eval_js('CoolClock.findAndCreateClocks()');
         print '<canvas id="' . $this->get_path() . 'canvas" class="CoolClock:' . $skin . ':' . $size . '"></canvas>';
     }
     print '<BR>' . Base_RegionalSettingsCommon::time2reg(null, false) . '</center>';
 }
Exemplo n.º 6
0
 public function init()
 {
     $d = getcwd();
     chdir('../../../../');
     require_once 'include/epesi.php';
     require_once 'include/cache.php';
     require_once 'include/variables.php';
     require_once 'include/misc.php';
     require_once 'include/module_primitive.php';
     require_once 'include/module_install.php';
     require_once 'include/module_common.php';
     require_once 'include/module.php';
     require_once 'include/module_manager.php';
     require_once 'include/autoloader.php';
     ModuleManager::load_modules();
     chdir($d);
     global $E_SESSION;
     $_SESSION['user'] = $E_SESSION['user'];
     if (Base_RegionalSettingsCommon::time_12h()) {
         $time = 'h:i a';
     } else {
         $time = 'H:i';
     }
     $date = Base_RegionalSettingsCommon::date_format();
     switch ($date) {
         case '%Y-%m-%d':
             $date = 'Y-m-d';
             break;
         case '%m/%d/%Y':
             $date = 'm/d/Y';
             break;
         case '%d %B %Y':
             $date = 'd F Y';
             break;
         case '%d %b %Y':
             $date = 'd M Y';
             break;
         case '%b %d, %Y':
             $date = 'M d, Y';
             break;
     }
     rcmail::get_instance()->config->set('date_short', 'D ' . $time);
     rcmail::get_instance()->config->set('date_long', $date . ' ' . $time);
     rcmail::get_instance()->config->set('date_today', $time);
     $this->add_hook('message_outgoing_body', array($this, 'add_signature'));
     $this->add_hook('user_create', array($this, 'lookup_user_name'));
 }
Exemplo n.º 7
0
 public function applet($conf, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     $opts['go'] = false;
     // enable/disable full screen
     $opts['title'] = $conf['title'];
     $title = __('Birthdays upcoming in the next: %d days.', array($conf['no_of_days']));
     $sort_order = 'ASC';
     // initialize the recordset
     $rb = $this->init_module(Utils_RecordBrowser::module_name(), 'contact', 'contact');
     // $conds - parameters for the applet
     // 1st - table field names, width, truncate
     // 2nd - criteria (filter)
     // 3rd - sorting
     // 4th - function to return tooltip
     // 5th - limit how many records are returned, null = no limit
     // 6th - Actions icons - default are view + info (with tooltip)
     // 1st - table field names
     $cols = array(array('field' => 'last_name', 'width' => 15), array('field' => 'first_name', 'width' => 15), array('field' => 'birth_date', 'width' => 15));
     // 2nd - criteria (filter)
     if ($conf['no_of_days'] < 0) {
         $title = __('Birthdays from the last %d days.', array(-$conf['no_of_days']));
         $sort_order = 'DESC';
     }
     $dates = array();
     $now = strtotime(Base_RegionalSettingsCommon::time2reg(null, false, true, true, false));
     foreach (range(0, $conf['no_of_days']) as $day) {
         $dates[] = date('%%-%m-%d', strtotime("+{$day} days", $now));
     }
     $crits = array("~birth_date" => $dates);
     if (isset($conf['cont_type']) && $conf['cont_type'] == 'f') {
         $crits[':Fav'] = true;
     }
     // 3rd - sorting
     $sorting = array('birth_date' => $sort_order);
     // 4th - function to return tooltip
     $tooltip = null;
     // 5th - limit how many records are returned, null = no limit
     $limit = null;
     // 6th - Actions icons - default are view + info (with tooltip)
     $conds = array($cols, $crits, $sorting, $tooltip, $limit, $conf, &$opts);
     // initialize miniview
     print $title;
     $this->display_module($rb, $conds, 'mini_view');
 }
Exemplo n.º 8
0
 public static function notification()
 {
     $time = time() - 24 * 3600;
     $arr = DB::GetAll('SELECT ul.login, ul.id as user_id, asm.id, asm.message, asm.posted_on, asm.to_user_login_id FROM apps_shoutbox_messages asm LEFT JOIN user_login ul ON ul.id=asm.base_user_login_id WHERE asm.posted_on>=%T AND asm.base_user_login_id!=%d AND (asm.to_user_login_id=%d OR asm.to_user_login_id is null) ORDER BY asm.posted_on DESC LIMIT 10', array($time, Base_AclCommon::get_user(), Base_AclCommon::get_user()));
     if (empty($arr)) {
         return array();
     }
     //print it out
     $ret = array();
     $tray = array();
     foreach ($arr as $row) {
         if (!$row['login']) {
             $row['login'] = '******';
         }
         $ret['shoutbox_' . $row['id']] = vsprintf('<font color="gray">[%s]</font><font color="blue">%s</font>: %s', array(Base_RegionalSettingsCommon::time2reg($row['posted_on']), $row['login'], $row['message']));
         $tray['shoutbox_' . $row['id']] = array('title' => __('Shoutbox Message'), 'body' => $row['to_user_login_id'] ? __('%s wrote to you: %s', array(Base_UserCommon::get_user_label($row['user_id'], true), $row['message'])) : __('%s wrote to all: %s', array(Base_UserCommon::get_user_label($row['user_id'], true), $row['message'])));
     }
     return array('notifications' => $ret, 'tray' => $tray);
 }
Exemplo n.º 9
0
 public function applet($conf, &$opts)
 {
     //available applet options: toggle,href,title,go,go_function,go_arguments,go_contruct_arguments
     $opts['go'] = false;
     // enable/disable full screen
     $opts['title'] = $conf['title'];
     // initialize the recordset
     $rb = $this->init_module('Utils/RecordBrowser', 'contact', 'contact');
     $me = CRM_ContactsCommon::get_my_record();
     // $conds - parameters for the applet
     // 1st - table field names, width, truncate
     // 2nd - criteria (filter)
     // 3rd - sorting
     // 4th - function to return tooltip
     // 5th - limit how many records are returned, null = no limit
     // 6th - Actions icons - default are view + info (with tooltip)
     // 1st - table field names
     $cols = array(array('field' => 'last_name', 'width' => 15), array('field' => 'first_name', 'width' => 15), array('field' => 'birth_date', 'width' => 15));
     // 2nd - criteria (filter)
     // TO DO - filter date - today through today+2 weeks
     $dates = array();
     for ($i = 0; $i < $conf['no_of_days']; $i++) {
         $dates[] = DB::Concat(DB::qstr('%'), DB::qstr(date('-m-d', strtotime(Base_RegionalSettingsCommon::time2reg(strtotime('+' . $i . ' days'), false, true, true, false)))));
     }
     if (isset($conf['cont_type']) && $conf['cont_type'] == 'f') {
         $crits = array(':Fav' => true, '"~birth_date' => $dates);
     } else {
         $crits = array('"~birth_date' => $dates);
     }
     // 3rd - sorting
     $sorting = array('last_name' => 'ASC');
     // 4th - function to return tooltip
     $tooltip = 'test';
     // 5th - limit how many records are returned, null = no limit
     $limit = null;
     // 6th - Actions icons - default are view + info (with tooltip)
     $conds = array($cols, $crits, $sorting, $tooltip, $limit, $conf, &$opts);
     // initialize miniview
     print __('Birthdays upcoming in the next: %d days.', array($conf['no_of_days']));
     $this->display_module($rb, $conds, 'mini_view');
 }
Exemplo n.º 10
0
 public function admin()
 {
     if ($this->is_back()) {
         $this->parent->reset();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $theme = $this->init_module(Base_Theme::module_name());
     $new_token_href = $this->create_confirm_callback_href(__('Are you sure?'), array($this, 'new_token'));
     $theme->assign('new_token_href', $new_token_href);
     $theme->assign('wiki_url', 'http://www.epesi.org/Cron');
     $theme->assign('cron_url', Base_CronCommon::get_cron_url());
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'cron');
     $m->set_table_columns(array(array('name' => 'Description', 'width' => 65), array('name' => 'Last Run', 'width' => 20), array('name' => 'Running', 'width' => 15)));
     $ret = DB::Execute('SELECT description,last,running FROM cron ORDER BY last DESC');
     while ($row = $ret->FetchRow()) {
         $m->add_row($row['description'] ? $row['description'] : '???', $row['last'] ? Base_RegionalSettingsCommon::time2reg($row['last']) : '---', $row['running'] ? '<span style="color:red">' . __('Yes') . '</span>' : '<span style="color:green">' . __('No') . '</span>');
     }
     $html = $this->get_html_of_module($m);
     $theme->assign('history', $html);
     $theme->display();
 }
Exemplo n.º 11
0
 public static function post_install()
 {
     $loc = Base_RegionalSettingsCommon::get_default_location();
     $ret = array(array('type' => 'text', 'name' => 'cname', 'label' => __('Company Name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))), array('type' => 'text', 'name' => 'sname', 'label' => __('Short company name'), 'default' => '', 'param' => array('maxlength' => 64)));
     if (Acl::is_user()) {
         $ret[] = array('type' => 'text', 'name' => 'fname', 'label' => __('Your first name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required'))));
         $ret[] = array('type' => 'text', 'name' => 'lname', 'label' => __('Your last name'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required'))));
     }
     return array_merge($ret, array(array('type' => 'text', 'name' => 'address1', 'label' => __('Address 1'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'address2', 'label' => __('Address 2'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'callback', 'name' => 'country', 'func' => array('CRM_ContactsInstall', 'country_element'), 'default' => $loc['country']), array('type' => 'callback', 'name' => 'state', 'func' => array('CRM_ContactsInstall', 'state_element'), 'default' => $loc['state']), array('type' => 'text', 'name' => 'city', 'label' => __('City'), 'default' => '', 'param' => array('maxlength' => 64), 'rule' => array(array('type' => 'required', 'message' => __('Field required')))), array('type' => 'text', 'name' => 'postal', 'label' => __('Postal Code'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'phone', 'label' => __('Phone'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'fax', 'label' => __('Fax'), 'default' => '', 'param' => array('maxlength' => 64)), array('type' => 'text', 'name' => 'web', 'label' => __('Web address'), 'default' => '', 'param' => array('maxlength' => 64))));
 }
Exemplo n.º 12
0
 public function display_activities($events, $tasks, $phonecalls)
 {
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), 'activities', 'activities');
     $gb->set_table_columns(array(array('name' => __('Type'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Subject'), 'width' => 20), array('name' => __('Date/Deadline'), 'wrapmode' => 'nowrap', 'width' => 8), array('name' => __('Employees'), 'width' => 11), array('name' => __('Customers'), 'width' => 11), array('name' => __('Attachments'), 'width' => 4)));
     $amount = 0;
     if ($this->display['events']) {
         $amount += count($events);
     }
     if ($this->display['tasks']) {
         $amount += count($tasks);
     }
     if ($this->display['phonecalls']) {
         $amount += count($phonecalls);
     }
     $limit = $gb->get_limit($amount);
     for ($i = 0; $i < $limit['offset'] + $limit['numrows'] && $i < $amount; $i++) {
         if ($this->display['events'] && count($events)) {
             $ev = current($events);
         } else {
             $ev = array('start' => -1);
         }
         if ($this->display['tasks'] && count($tasks)) {
             $t = current($tasks);
             if (!$t['deadline']) {
                 $t['deadline'] = 0;
             } else {
                 $t['deadline'] = strtotime($t['deadline']);
             }
         } else {
             $t = array('deadline' => -1);
         }
         if ($this->display['phonecalls'] && count($phonecalls)) {
             $ph = current($phonecalls);
             $ph['date_and_time'] = strtotime($ph['date_and_time']);
         } else {
             $ph = array('date_and_time' => -1);
         }
         $maxt = max($ev['start'], $t['deadline'], $ph['date_and_time']);
         $gb_row = $gb->get_new_row();
         if ($ev['start'] == $maxt) {
             $v = array_shift($events);
             if ($i >= $limit['offset'] && $v) {
                 if (isset($v['view_action'])) {
                     $view_href = $v['view_action'];
                 } else {
                     $view_href = $this->create_callback_href(array($this, 'view_event'), array($v['id']));
                 }
                 $title = '<a ' . $view_href . '>' . $v['title'] . '</a>';
                 if (isset($v['description']) && $v['description'] != '') {
                     $title = '<span ' . Utils_TooltipCommon::open_tag_attrs($v['description'], false) . '>' . $title . '</span>';
                 }
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('crm_meeting', $v['id']));
                 $gb_row->add_data(__('Meeting'), $title, Base_RegionalSettingsCommon::time2reg($v['start'], $v['duration'] == -1 ? false : 2), CRM_ContactsCommon::display_contact(array('employees' => $v['employees']), false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact(array('customers' => $v['customers']), false, array('id' => 'customers', 'param' => ';::')), Utils_AttachmentCommon::count('crm_meeting/' . $v['id']));
             }
         } elseif ($t['deadline'] == $maxt) {
             $v = array_shift($tasks);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('task', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('task', $v['id']));
                 $gb_row->add_data(__('Task'), CRM_TasksCommon::display_title($v, false), !isset($v['deadline']) || !$v['deadline'] ? __('No deadline') : Base_RegionalSettingsCommon::time2reg($v['deadline'], false, true, false), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_ContactsCommon::display_company_contact($v, false, array('id' => 'customers')), Utils_AttachmentCommon::count('task/' . $v['id']));
             }
         } else {
             $v = array_shift($phonecalls);
             $v = Utils_RecordBrowserCommon::filter_record_by_access('phonecall', $v);
             if ($i >= $limit['offset'] && $v) {
                 $gb_row->add_info(Utils_RecordBrowserCommon::get_html_record_info('phonecall', $v['id']));
                 $gb_row->add_data(__('Phonecall'), CRM_PhoneCallCommon::display_subject($v), Base_RegionalSettingsCommon::time2reg($v['date_and_time'], 2), CRM_ContactsCommon::display_contact($v, false, array('id' => 'employees', 'param' => ';CRM_ContactsCommon::contact_format_no_company')), CRM_PhoneCallCommon::display_contact_name($v, false), Utils_AttachmentCommon::count('phonecall/' . $v['id']));
             }
         }
     }
     $this->display_module($gb);
 }
Exemplo n.º 13
0
 public function history($uid = null)
 {
     $th = $this->init_module(Base_Theme::module_name());
     $th->assign('header', __('Shoutbox History'));
     $qf = $this->init_module(Libs_QuickForm::module_name());
     if (ModuleManager::is_installed('CRM_Contacts') >= 0) {
         $emps = DB::GetAssoc('SELECT l.id,' . DB::ifelse('cd.f_last_name!=\'\'', DB::concat('cd.f_last_name', DB::qstr(' '), 'cd.f_first_name'), 'l.login') . ' as name FROM user_login l LEFT JOIN contact_data_1 cd ON (cd.f_login=l.id AND cd.active=1) WHERE l.active=1 ORDER BY name');
     } else {
         $emps = DB::GetAssoc('SELECT id,login FROM user_login WHERE active=1 ORDER BY login');
     }
     $qf->addElement('select', 'user', __('User'), array('all' => '[' . __('All') . ']') + $emps);
     $qf->addElement('datepicker', 'from_date', __('From'));
     $qf->addElement('datepicker', 'to_date', __('To'));
     $qf->addElement('text', 'search', __('Search for'));
     $qf->addElement('submit', 'submit_button', __('Filter'));
     $to_date =& $this->get_module_variable('to_date');
     $from_date =& $this->get_module_variable('from_date');
     $user =& $this->get_module_variable('to', "all");
     $qf->setDefaults(array('from_date' => $from_date, 'to_date' => $to_date, 'user' => $uid));
     //if submited
     if ($qf->validate()) {
         $from_date = $qf->exportValue('from_date');
         $to_date = $qf->exportValue('to_date');
         $user = $qf->exportValue('user');
         $search_word = $qf->exportValue('search');
     }
     $qf->assign_theme('form', $th);
     $uid = is_numeric($user) ? $user : null;
     $date_where = '';
     if ($from_date) {
         $date_where .= 'AND posted_on>=' . DB::DBDate($from_date);
     }
     if ($to_date) {
         $date_where .= 'AND posted_on<=' . DB::DBDate($to_date);
     }
     if (isset($search_word) && $search_word) {
         $search_word = explode(' ', $search_word);
         foreach ($search_word as $word) {
             if ($word) {
                 $date_where .= ' AND message ' . DB::like() . ' ' . DB::Concat(DB::qstr('%'), DB::qstr(htmlspecialchars($word, ENT_QUOTES, 'UTF-8')), DB::qstr('%'));
             }
         }
     }
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'shoutbox_history');
     $gb->set_table_columns(array(array('name' => __('From'), 'width' => 10), array('name' => __('To'), 'width' => 10), array('name' => __('Message'), 'width' => 64), array('name' => __('Date'), 'width' => 16)));
     // $gb->set_default_order(array(__('Date')=>'DESC'));
     $myid = Base_AclCommon::get_user();
     $where = '(' . ($uid ? '(base_user_login_id=' . $myid . ' AND to_user_login_id=' . $uid . ') OR (base_user_login_id=' . $uid . ' AND to_user_login_id=' . $myid . ') OR (to_user_login_id is null AND base_user_login_id=' . $uid . ')' : 'to_user_login_id is null OR to_user_login_id=' . $myid . ' OR base_user_login_id=' . $myid) . ')' . $date_where;
     $query = 'SELECT base_user_login_id, to_user_login_id, message, posted_on FROM apps_shoutbox_messages WHERE ' . $where . ' ORDER BY posted_on DESC';
     $query_qty = 'SELECT count(id) FROM apps_shoutbox_messages WHERE ' . $where;
     $ret = $gb->query_order_limit($query, $query_qty);
     if ($ret) {
         while ($row = $ret->FetchRow()) {
             $ulogin = Base_UserCommon::get_user_label($row['base_user_login_id']);
             if ($row['to_user_login_id'] !== null) {
                 $tologin = Base_UserCommon::get_user_label($row['to_user_login_id']);
             } else {
                 $tologin = '******' . __('All') . ']';
             }
             $gb->add_row('<span class="author">' . $ulogin . '</span>', '<span class="author">' . $tologin . '</span>', array('value' => Utils_BBCodeCommon::parse($row['message']), 'overflow_box' => false), Base_RegionalSettingsCommon::time2reg($row['posted_on']));
         }
     }
     $gb->set_inline_display(true);
     $th->assign('messages', $this->get_html_of_module($gb));
     $th->display();
     return true;
 }
Exemplo n.º 14
0
    public function view_edit_history($id){
		load_js('modules/Utils/RecordBrowser/edit_history.js');
        if ($this->is_back())
            return $this->back();
        $this->init();
		$tb = $this->init_module('Utils_TabbedBrowser');		
        $gb_cha = $this->init_module('Utils/GenericBrowser', null, $this->tab.'__changes');
		$form = $this->init_module('Libs_QuickForm');

        $table_columns_changes = array( array('name'=>__('Date'), 'width'=>10, 'wrapmode'=>'nowrap'),
                                        array('name'=>__('Username'), 'width'=>10, 'wrapmode'=>'nowrap'),
                                        array('name'=>__('Field'), 'width'=>10, 'wrapmode'=>'nowrap'),
                                        array('name'=>__('Old value'), 'width'=>10, 'wrapmode'=>'nowrap'),
                                        array('name'=>__('New value'), 'width'=>10, 'wrapmode'=>'nowrap'));

        $gb_cha->set_table_columns( $table_columns_changes );

        $gb_cha->set_inline_display();

        $created = Utils_RecordBrowserCommon::get_record($this->tab, $id, true);
        $access = $this->get_access('view', $created);
        $field_hash = array();
        $edited = DB::GetRow('SELECT ul.login, c.edited_on FROM '.$this->tab.'_edit_history AS c LEFT JOIN user_login AS ul ON ul.id=c.edited_by WHERE c.'.$this->tab.'_id=%d ORDER BY edited_on DESC',array($id));
        foreach($this->table_rows as $field => $args)
            $field_hash[$args['id']] = $field;

        $ret = DB::Execute('SELECT ul.login, c.id, c.edited_on, c.edited_by FROM '.$this->tab.'_edit_history AS c LEFT JOIN user_login AS ul ON ul.id=c.edited_by WHERE c.'.$this->tab.'_id=%d ORDER BY edited_on DESC, id DESC',array($id));
		$dates_select = array();
		$tb_path = escapeJS($tb->get_path());
        while ($row = $ret->FetchRow()) {
			$user = Base_UserCommon::get_user_label($row['edited_by']);
			$date_and_time = Base_RegionalSettingsCommon::time2reg($row['edited_on']);
            $changed = array();
            $ret2 = DB::Execute('SELECT * FROM '.$this->tab.'_edit_history_data WHERE edit_id=%d',array($row['id']));
            while($row2 = $ret2->FetchRow()) {
                if ($row2['field']!='id' && (!isset($access[$row2['field']]) || !$access[$row2['field']])) continue;
                $changed[$row2['field']] = $row2['old_value'];
                $last_row = $row2;
                $dates_select[$row['edited_on']] = $date_and_time;
            }
            foreach($changed as $k=>$v) {
                if ($k=='id') {
					$gb_cha->add_row(
						$date_and_time, 
						$user, 
						array('value'=>_V($last_row['old_value']), 'attrs'=>'colspan="3" style="text-align:center;font-weight:bold;"'),
						array('value'=>'', 'dummy'=>true),
						array('value'=>'', 'dummy'=>true)
					);
                } else {
                    if (!isset($field_hash[$k])) continue;
                    $new = $this->get_val($field_hash[$k], $created, false, $this->table_rows[$field_hash[$k]]);
                    if ($this->table_rows[$field_hash[$k]]['type']=='multiselect') $v = Utils_RecordBrowserCommon::decode_multi($v);
                    $created[$k] = $v;
                    $old = $this->get_val($field_hash[$k], $created, false, $this->table_rows[$field_hash[$k]]);
					$gb_row = $gb_cha->get_new_row();
					$gb_row->add_action('href="javascript:void(0);" onclick="recordbrowser_edit_history_jump(\''.$row['edited_on'].'\',\''.$this->tab.'\','.$created['id'].',\''.$form->get_name().'\');tabbed_browser_switch(1,2,null,\''.$tb_path.'\')"','View');
                    $gb_row->add_data(
                        $date_and_time,
                        $row['edited_by']!==null?$user:'',
                        _V($this->table_rows[$field_hash[$k]]['name']), // TRSL
                        $old,
                        $new
                    );
                }
            }
        }

		$gb_row = $gb_cha->get_new_row();
		$gb_row->add_data(
			Base_RegionalSettingsCommon::time2reg($created['created_on']),
			$created['created_by']!==null?Base_UserCommon::get_user_label($created['created_by']):'',
			array('value'=>__('RECORD CREATED'), 'attrs'=>'colspan="3" style="text-align:center;font-weight:bold;"'),
			array('value'=>'', 'dummy'=>true),
			array('value'=>'', 'dummy'=>true)
		);


//		$tb->set_tab(__('Record historical view'), array($this, 'record_historical_view'), array($created, $access, $form, $dates_select), true);
		$tb->start_tab(__('Changes History'));
		$this->display_module($gb_cha);
		$tb->end_tab();

		$tb->start_tab(__('Record historical view'));
		$dates_select[$created['created_on']] = Base_RegionalSettingsCommon::time2reg($created['created_on']);
        foreach($this->table_rows as $field => $args) {
            if (!$access[$args['id']]) continue;
            $val = $this->get_val($field, $created, false, $args);
        }
		$form->addElement('select', 'historical_view_pick_date', __('View the record as of'), $dates_select, array('onChange'=>'recordbrowser_edit_history("'.$this->tab.'",'.$created['id'].',"'.$form->get_name().'");', 'id'=>'historical_view_pick_date'));
		$form->setDefaults(array('historical_view_pick_date'=>$created['created_on']));
		$form->display();
		$this->view_entry('history', $created);
		$tb->end_tab();

		
		$this->display_module($tb);
        Base_ActionBarCommon::add('back',__('Back'),$this->create_back_href());
        return true;
    }
Exemplo n.º 15
0
 public static function get_alarm($id)
 {
     $a = self::get_meeting($id);
     if (!$a) {
         return __('Private record');
     }
     if ($a['duration'] < 0) {
         $date = __('Timeless event: %s', array(Base_RegionalSettingsCommon::time2reg($a['date'], false)));
     } else {
         $date = __('Date: %s', array(Base_RegionalSettingsCommon::time2reg($a['date'] . ' ' . date('H:i:s', strtotime($a['time'])), 2)));
     }
     return $date . "\n" . __('Title: %s', array($a['title']));
 }
Exemplo n.º 16
0
 public static function get_html_record_info($created_by, $created_on, $edited_by = null, $edited_on = null, $id = null)
 {
     if ($created_by !== null) {
         $contact = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact_by_user_id($created_by), true);
         if ($contact != '') {
             $created_by = $contact;
         } else {
             $created_by = Base_UserCommon::get_user_login($created_by);
         }
     } else {
         $created_by = '';
     }
     // If the record was edited get user contact info
     if ($edited_by != null) {
         if ($edited_by != $created_by) {
             $contact = CRM_ContactsCommon::contact_format_no_company(CRM_ContactsCommon::get_contact_by_user_id($edited_by), true);
         }
         if ($contact != '') {
             $edited_by = $contact;
         } else {
             $edited_by = Base_UserCommon::get_user_login($edited_by);
         }
     }
     $htmlinfo = array();
     if ($id) {
         $htmlinfo[__('Record ID') . ':'] = $id;
     }
     $htmlinfo[__('Created by') . ':'] = $created_by;
     $htmlinfo[__('Created on') . ':'] = Base_RegionalSettingsCommon::time2reg($created_on);
     if ($edited_by != null) {
         $htmlinfo = $htmlinfo + array(__('Edited by') . ':' => $edited_by, __('Edited on') . ':' => Base_RegionalSettingsCommon::time2reg($edited_on));
     }
     return Utils_TooltipCommon::format_info_tooltip($htmlinfo);
 }
Exemplo n.º 17
0
 public function applet($conf, &$opts)
 {
     $opts['go'] = true;
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'agendaX');
     $columns = array(array('name' => __('Start'), 'order' => 'e.starts', 'width' => 25, 'wrapmode' => 'nowrap'), array('name' => __('Title'), 'order' => 'e.title', 'width' => 50));
     $gb->set_table_columns($columns);
     $start = date('Y-m-d', time());
     $end = date('Y-m-d', time() + $conf['days'] * 24 * 60 * 60);
     $gb->set_default_order(array(__('Start') => 'ASC'));
     CRM_Calendar_EventCommon::$filter = '(' . CRM_FiltersCommon::get_my_profile() . ')';
     $data = array();
     Base_ThemeCommon::load_css('CRM_Calendar', 'agenda');
     $custom_events = DB::GetAssoc('SELECT id, handler_callback FROM crm_calendar_custom_events_handlers ORDER BY group_name');
     $ret = array();
     if (!empty($custom_events)) {
         $c = 0;
         foreach ($custom_events as $id => $cb) {
             if ($conf['events_handlers__' . $id]) {
                 $cb = explode('::', $cb);
                 if (!is_callable($cb)) {
                     continue;
                 }
                 $add = call_user_func($cb, 'get_all', $start, $end, CRM_Calendar_EventCommon::$filter);
                 foreach ($add as $v) {
                     $ret[str_pad($v['start'], 16, '0', STR_PAD_LEFT) . '__' . $c] = $v;
                     $c++;
                 }
             }
         }
     }
     ksort($ret);
     foreach ($ret as $row) {
         if (isset($row['status']) && $row['status'] == 'closed') {
             continue;
         }
         if (!isset($row['view_action'])) {
             $ex = Utils_CalendarCommon::process_event($row);
             $view_action = '<a ' . $this->create_callback_href(array($this, 'view_event'), $row['id']) . '>';
             $ev_id = explode('_', $row['id'], 2);
             $ev_id = $ev_id[0];
         } else {
             $tmp = Utils_CalendarCommon::process_event($row);
             $ex = $row;
             $ex['start'] = $tmp['start'];
             $view_action = '<a ' . $row['view_action'] . '>';
         }
         //////////////////////////
         // left column
         $date = $ex['start'];
         ///////////////////
         // right column
         $title = Utils_TooltipCommon::create($row['title'], $row['custom_tooltip']);
         $day = isset($row['timeless']) && $row['timeless'] ? $row['timeless'] : Base_RegionalSettingsCommon::time2reg($row['start'], false, true, true, false);
         if ($day < date('Y-m-d')) {
             $class = 'past';
         } elseif ($day == date('Y-m-d')) {
             $class = 'today';
         } elseif ($day == date('Y-m-d', strtotime('+1 day'))) {
             $class = 'tomorrow';
         } else {
             $class = 'other';
         }
         $gb_row = $gb->get_new_row();
         $gb_row->set_attrs('class="CRM_Calendar_applet__' . $class . '"');
         $gb_row->add_data(array('value' => $date, 'order_value' => isset($row['timeless']) && $row['timeless'] ? strtotime($row['timeless']) : $row['start']), array('value' => $view_action . $title . '</a>'));
     }
     $this->display_module($gb, array(false), 'automatic_display');
 }
Exemplo n.º 18
0
 public function queue_tab($count_f, $get_f, $statuses)
 {
     $t = time();
     $status =& $this->get_module_variable('queue_status', current(array_keys($statuses)));
     $offset =& $this->get_module_variable('queue_offset', 0);
     $form = $this->init_module(Libs_QuickForm::module_name());
     $theme = $this->pack_module(Base_Theme::module_name());
     $form->addElement('select', 'status', __('Status'), $statuses);
     $form->addElement('submit', 'submit_button', __('Show'));
     $form->addRule('status', 'Field required', 'required');
     $form->setDefaults(array('status' => $status));
     if ($form->validate()) {
         $data = $form->exportValues();
         if (array_key_exists($data['status'], $statuses)) {
             $status = $data['status'];
         }
         $offset = 0;
     }
     $form->assign_theme('form', $theme);
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'queue');
     $m->set_table_columns(array(array('name' => 'To', 'width' => 30, 'order' => 'toNumber'), array('name' => 'Status', 'width' => 10), array('name' => 'Date', 'width' => 10, 'order' => 'creationDate'), array('name' => 'File', 'width' => 30, 'order' => 'fileName')));
     $m->set_default_order(array('Date' => 'DESC'));
     $count = call_user_func($count_f, $status);
     if ($count === false) {
         $count = 0;
     }
     $limits = $m->get_limit($count);
     $order = $m->get_order();
     if ($count != 0) {
         $data = call_user_func($get_f, $status, $order[0]['order'], $order[0]['direction'], $limits['numrows'], (string) ($limits['offset'] + 1));
     }
     if ($count == 0 || $data === false) {
         $data = array();
     }
     foreach ($data as $row) {
         $from_rec = CRM_ContactsCommon::get_contacts(array('fax' => $row['toNumber']));
         foreach ($from_rec as &$rec) {
             $rec = CRM_ContactsCommon::contact_format_default($rec);
         }
         $from_rec_comp = CRM_ContactsCommon::get_companies(array('fax' => $row['toNumber']));
         foreach ($from_rec_comp as $rec) {
             $from_rec[] = Utils_RecordBrowserCommon::create_linked_label('company', 'Company Name', $rec);
         }
         $m->add_row(empty($from_rec) ? $row['toNumber'] : ' (' . implode(', ', $from_rec) . ')', $statuses[$row['faxStatus']], Base_RegionalSettingsCommon::time2reg($row['creationDate']), '<a href="' . $row['fileUrl'] . '" target="_blank">' . $row['fileName'] . '</a>');
     }
     $theme->assign('table_data', $this->get_html_of_module($m));
     $theme->display();
 }
Exemplo n.º 19
0
//print it out
foreach ($arr as $row) {
    $daydiff = floor((time() - strtotime($row['posted_on'])) / 86400);
    switch (true) {
        case $daydiff < 1:
            $fcolor = '#000000';
            break;
        case $daydiff < 3:
            $fcolor = '#444444';
            break;
        case $daydiff < 7:
            $fcolor = '#888888';
            break;
        default:
            $fcolor = '#AAAAAA';
    }
    $user_label = Apps_ShoutboxCommon::create_write_to_link($row['from_login_id']);
    if ($row['to_login_id']) {
        $user_label .= ' -> ' . Apps_ShoutboxCommon::create_write_to_link($row['to_login_id']);
    }
    print '<span class="author border_radius_3px dark_blue_gradient">' . $user_label . '</span><span class="time"> [' . Base_RegionalSettingsCommon::time2reg($row['posted_on'], 2) . ']</span><br/><span class="shoutbox_textbox"style="color:' . $fcolor . ';">' . ($row['to_login_id'] == $myid && $uid === null ? '<b>' : '') . Utils_BBCodeCommon::parse($row['message']) . ($row['to_login_id'] == $myid && $uid === null ? '</b>' : '') . '</span><hr/>';
}
$content = ob_get_contents();
ob_end_clean();
require_once 'libs/minify/HTTP/Encoder.php';
$he = new HTTP_Encoder(array('content' => $content));
if (MINIFY_ENCODE) {
    $he->encode();
}
$he->sendAll();
exit;
Exemplo n.º 20
0
	public function month() {
		$theme = $this->pack_module('Base/Theme');
		Base_ThemeCommon::load_css('Utils_Calendar', 'common');

		$theme->assign('trash_label', __('Drag and drop to delete'));
		$theme->assign('nextyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)+1).date('-m-d',$this->date))));
		$theme->assign('nextyear_label',__('Next year'));
		$theme->assign('nextmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date+86400*date('t',$this->date)))));
		$theme->assign('nextmonth_label',__('Next month'));
		$theme->assign('today_href', $this->create_unique_href(array('date'=>date('Y-m-d'))));
		$theme->assign('today_label', __('Today'));
		$theme->assign('prevmonth_href', $this->create_unique_href(array('date'=>date('Y-m-d',$this->date-86400*date('t',$this->date-86400*(date('d', $this->date)+1))))));
		$theme->assign('prevmonth_label', __('Previous month'));
		$theme->assign('prevyear_href', $this->create_unique_href(array('date'=>(date('Y',$this->date)-1).date('-m-d',$this->date))));
		$theme->assign('prevyear_label', __('Previous year'));
		$theme->assign('info', __('Double&nbsp;click&nbsp;on&nbsp;cell&nbsp;to&nbsp;add&nbsp;event'));

		if ($this->isset_unique_href_variable('date'))
			$this->set_date($this->get_unique_href_variable('date'));

		$link_text = $this->create_unique_href_js(array('date'=>'__YEAR__-__MONTH__-__DAY__'));
		$theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text,'month'));

		$month = $this->month_array($this->date);
		$dnd = array();
		foreach($month as & $week) {
			foreach($week['days'] as & $cday) {
				$cday['id'] = 'UCcell_'.$cday['time'];
				$dnd[] = $cday['time'];
			}
		}

		$day_headers = array();
		$day = strtotime('Sun');
		$day = strtotime('+'.Utils_PopupCalendarCommon::get_first_day_of_week().' days', $day);
		for ($i=0; $i<7; $i++) {
			$day_headers[] = array('class'=>(date('N',$day)>=6?'weekend_day_header':'day_header'), 'label'=>__date('D', $day));
			$day = strtotime('+1 day', $day);
		}

		$theme->assign('month_view_label', __('Month calendar'));

		$theme->assign('day_headers', $day_headers);
		$theme->assign('month', $month);
		$theme->assign('month_label', __date('F', $this->date));
		$theme->assign('year_label', date('Y', $this->date));
		$theme->assign('year_link', $this->create_unique_href(array('time'=>$this->date, 'tab'=>'Year','action'=>'switch')));
		$theme->assign('trash_id','UCtrash');

		$navigation_bar_additions = '';
		if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) {
			$event_module_instance = $this->init_module($this->event_module);
			$navigation_bar_additions = call_user_func(array($event_module_instance,'get_navigation_bar_additions'), '', '');
		}
		$theme->assign('navigation_bar_additions', $navigation_bar_additions);

		$theme->display('month');


		//data
		$start_t = date('Y-m-d',$month[0]['days'][0]['time']);
		//$start_t = Base_RegionalSettingsCommon::reg2time($start_t);
		$end_t = date('Y-m-d',$month[count($month)-1]['days'][6]['time']+86400);
		//$end_t = Base_RegionalSettingsCommon::reg2time($end_t);
		$ret = $this->get_events($start_t,$end_t);
		$this->displayed_events = array('start'=>$start_t, 'end'=>$end_t,'events'=>$ret);
		$this->js('Utils_Calendar.page_type=\'month\'');
		$ev_out = 'function() {';
		foreach($ret as $ev) {
			$this->print_event($ev);
			if(!isset($ev['timeless']) || !$ev['timeless'])
				$ev_start = strtotime(Base_RegionalSettingsCommon::time2reg($ev['start'],true,true,true,false));
			else
				$ev_start = strtotime($ev['timeless']);
			$ev_start = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$ev_start).' 00:00:00');
			$dest_id = 'UCcell_'.$ev_start;
			$ev_out .= 'Utils_Calendar.add_event(\''.Epesi::escapeJS($dest_id,false).'\', \''.$ev['id'].'\', '.((!isset($ev['draggable']) || $ev['draggable']==true)?1:0).', 1);';
		}
		$ev_out.='}';
		$this->js('Utils_Calendar.add_events_f = '.$ev_out);
		$this->js('Utils_Calendar.add_events("Utils%2FCalendar%2Fmonth.css")');
		if ($this->custom_new_event_href_js!==null)
			$jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__');
		else
			$jshref = $this->create_unique_href_js(array('action'=>'add','time'=>'__TIME__','timeless'=>'__TIMELESS__'));
		eval_js('Utils_Calendar.activate_dnd(\''.Epesi::escapeJS(json_encode($dnd),false).'\','.
				'\''.Epesi::escapeJS($jshref,false).'\','.
				'\''.Epesi::escapeJS($this->get_path(),false).'\','.
				'\''.CID.'\')');
	}
Exemplo n.º 21
0
 protected function hf_timestamp($field, $operator, $value, $raw_sql_val)
 {
     if ($raw_sql_val) {
         return array("{$field} {$operator} {$value}", array());
     }
     if ($operator == DB::like()) {
         if (DB::is_postgresql()) {
             $field .= '::varchar';
         }
         return array("{$field} {$operator} %s", array($value));
     }
     $vals = array();
     if (!$value) {
         $sql = "{$field} IS NULL";
     } else {
         $null_part = $operator == '<' || $operator == '<=' ? " OR {$field} IS NULL" : " AND {$field} IS NOT NULL";
         $value = Base_RegionalSettingsCommon::reg2time($value, false);
         $sql = "({$field} {$operator} %T {$null_part})";
         $vals[] = $value;
     }
     return array($sql, $vals);
 }
Exemplo n.º 22
0
 public function mail_addresses_addon($arg, $rb)
 {
     $type = $rb->tab;
     $loc = Base_RegionalSettingsCommon::get_default_location();
     $rb = $this->init_module('Utils/RecordBrowser', 'rc_multiple_emails');
     $order = array(array('record_type' => $type, 'record_id' => $arg['id']), array('record_type' => false, 'record_id' => false), array());
     $rb->set_defaults(array('record_type' => $type, 'record_id' => $arg['id']));
     $rb->enable_quick_new_records();
     $this->display_module($rb, $order, 'show_data');
 }
Exemplo n.º 23
0
 public static function mobile_rb_edit($tab, $id)
 {
     if ($id === false) {
         $rec = array();
     } else {
         $rec = self::get_record($tab, $id);
     }
     $cols = Utils_RecordBrowserCommon::init($tab);
     $defaults = array();
     if ($id === false) {
         $mode = 'add';
         $access = array();
         $defaults = self::record_processing($tab, $defaults, 'adding');
     } else {
         $mode = 'edit';
         $access = Utils_RecordBrowserCommon::get_access($tab, 'view', $rec);
         if (is_array($access)) {
             foreach ($access as $k => $v) {
                 if (!$v) {
                     unset($rec[$k]);
                 }
             }
         }
         $defaults = $rec = self::record_processing($tab, $rec, 'editing');
     }
     $QFfield_callback_table = array();
     $ret = DB::Execute('SELECT * FROM ' . $tab . '_callback WHERE freezed=0');
     while ($row = $ret->FetchRow()) {
         $QFfield_callback_table[$row['field']] = $row['callback'];
     }
     $defaults = array_merge($defaults, $_SESSION['rb_' . $tab . '_defaults']);
     $qf = new HTML_QuickForm('rb_edit', 'post', 'mobile.php?' . http_build_query($_GET));
     foreach ($cols as $field => $args) {
         if (isset($access[$args['id']]) && !$access[$args['id']]) {
             continue;
         }
         if (isset($rec[$args['id']])) {
             $val = $rec[$args['id']];
         } elseif (isset($defaults[$args['id']])) {
             $val = $defaults[$args['id']];
         } else {
             $val = null;
         }
         $label = _V($args['name']);
         // TRSL
         if (isset($QFfield_callback_table[$field])) {
             $mobile_rb = new Utils_RecordBrowserMobile($tab, $rec);
             self::call_QFfield_callback($QFfield_callback_table[$field], $qf, $args['id'], $label, $mode, $val, $args, $mobile_rb, null);
             if ($mode == 'edit') {
                 unset($defaults[$args['id']]);
             }
             continue;
         }
         switch ($args['type']) {
             case 'calculated':
                 $qf->addElement('static', $args['id'], $label);
                 if (!is_array($rec)) {
                     $values = $defaults;
                 } else {
                     $values = $rec;
                     if (is_array($defaults)) {
                         $values = $values + $defaults;
                     }
                 }
                 if (!isset($values[$args['id']])) {
                     $values[$args['id']] = '';
                 }
                 $val = Utils_RecordBrowserCommon::get_val($tab, $field, $values, true, $args);
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'integer':
             case 'float':
                 $qf->addElement('text', $args['id'], $label);
                 if ($args['type'] == 'integer') {
                     $qf->addRule($args['id'], __('Only integer numbers are allowed.'), 'regex', '/^[0-9]*$/');
                 } else {
                     $qf->addRule($args['id'], __('Only numbers are allowed.'), 'numeric');
                 }
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'checkbox':
                 $qf->addElement('checkbox', $args['id'], $label, '');
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'currency':
                 $qf->addElement('currency', $args['id'], $label);
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'text':
                 $qf->addElement('text', $args['id'], $label, array('maxlength' => $args['param']));
                 $qf->addRule($args['id'], __('Maximum length for this field is %s characters.', array($args['param'])), 'maxlength', $args['param']);
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'long text':
                 $qf->addElement('textarea', $args['id'], $label, array('maxlength' => 200));
                 $qf->addRule($args['id'], __('Maximum length for this field in mobile edition is 200 chars.'), 'maxlengt', 200);
                 if ($val !== null) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'commondata':
                 $param = explode('::', $args['param']['array_id']);
                 foreach ($param as $k => $v) {
                     if ($k != 0) {
                         $param[$k] = self::get_field_id($v);
                     }
                 }
                 if (count($param) == 1) {
                     $qf->addElement($args['type'], $args['id'], $label, $param, array('empty_option' => true, 'id' => $args['id'], 'order_by_key' => $args['param']['order_by_key']));
                     if ($val !== null) {
                         $qf->setDefaults(array($args['id'] => $val));
                     }
                 }
                 break;
             case 'select':
                 $comp = array();
                 $ref = explode(';', $args['param']);
                 if (isset($ref[1])) {
                     $crits_callback = $ref[1];
                 } else {
                     $crits_callback = null;
                 }
                 if (isset($ref[2])) {
                     $multi_adv_params = call_user_func(explode('::', $ref[2]));
                 } else {
                     $multi_adv_params = null;
                 }
                 if (!isset($multi_adv_params) || !is_array($multi_adv_params)) {
                     $multi_adv_params = array();
                 }
                 if (!isset($multi_adv_params['order'])) {
                     $multi_adv_params['order'] = array();
                 }
                 if (!isset($multi_adv_params['cols'])) {
                     $multi_adv_params['cols'] = array();
                 }
                 if (!isset($multi_adv_params['format_callback'])) {
                     $multi_adv_params['format_callback'] = array();
                 }
                 $ref = $ref[0];
                 @(list($tab2, $col) = explode('::', $ref));
                 if (!isset($col)) {
                     trigger_error($field);
                 }
                 if ($tab2 == '__RECORDSETS__') {
                     continue;
                 }
                 //skip multi recordsets chained selector
                 if ($tab2 == '__COMMON__') {
                     $data = Utils_CommonDataCommon::get_translated_tree($col);
                     if (!is_array($data)) {
                         $data = array();
                     }
                     $comp = $comp + $data;
                 } else {
                     if (isset($crits_callback)) {
                         $crit_callback = explode('::', $crits_callback);
                         if (is_callable($crit_callback)) {
                             $crits = call_user_func($crit_callback, false, $rec);
                             $adv_crits = call_user_func($crit_callback, true, $rec);
                         } else {
                             $crits = $adv_crits = array();
                         }
                         if ($adv_crits === $crits) {
                             $adv_crits = null;
                         }
                         if ($adv_crits !== null) {
                             continue;
                             //skip record picker
                         }
                     } else {
                         $crits = array();
                     }
                     $col = explode('|', $col);
                     $col_id = array();
                     foreach ($col as $c) {
                         $col_id[] = self::get_field_id($c);
                     }
                     $records = Utils_RecordBrowserCommon::get_records($tab2, $crits, empty($multi_adv_params['format_callback']) ? $col_id : array(), !empty($multi_adv_params['order']) ? $multi_adv_params['order'] : array());
                     $ext_rec = array();
                     if (isset($rec[$args['id']])) {
                         if (!is_array($rec[$args['id']])) {
                             if ($rec[$args['id']] != '') {
                                 $rec[$args['id']] = array($rec[$args['id']] => $rec[$args['id']]);
                             } else {
                                 $rec[$args['id']] = array();
                             }
                         }
                     }
                     if (isset($defaults[$args['id']])) {
                         if (!is_array($defaults[$args['id']])) {
                             $rec[$args['id']][$defaults[$args['id']]] = $defaults[$args['id']];
                         } else {
                             foreach ($defaults[$args['id']] as $v) {
                                 $rec[$args['id']][$v] = $v;
                             }
                         }
                     }
                     $single_column = count($col_id) == 1;
                     if (isset($rec[$args['id']])) {
                         $ext_rec = array_flip($rec[$args['id']]);
                         foreach ($ext_rec as $k => $v) {
                             $c = Utils_RecordBrowserCommon::get_record($tab2, $k);
                             if (!empty($multi_adv_params['format_callback'])) {
                                 $n = call_user_func($multi_adv_params['format_callback'], $c);
                             } else {
                                 if ($single_column) {
                                     $n = $c[$col_id[0]];
                                 } else {
                                     $n = array();
                                     foreach ($col_id as $cid) {
                                         $n[] = $c[$cid];
                                     }
                                     $n = implode(' ', $n);
                                 }
                             }
                             $comp[$k] = $n;
                         }
                     }
                     if (!empty($multi_adv_params['order'])) {
                         natcasesort($comp);
                     }
                     foreach ($records as $k => $v) {
                         if (!empty($multi_adv_params['format_callback'])) {
                             $n = call_user_func($multi_adv_params['format_callback'], $v);
                         } else {
                             //                                      $n = $v[$col_id];
                             if ($single_column) {
                                 $n = $v[$col_id[0]];
                             } else {
                                 $n = array();
                                 foreach ($col_id as $cid) {
                                     $n[] = $v[$cid];
                                 }
                                 $n = implode(' ', $n);
                             }
                         }
                         $comp[$k] = $n;
                         unset($ext_rec[$v['id']]);
                     }
                     if (empty($multi_adv_params['order'])) {
                         natcasesort($comp);
                     }
                 }
                 if ($args['type'] === 'select') {
                     $comp = array('' => '---') + $comp;
                 }
                 $qf->addElement($args['type'], $args['id'], $label, $comp, array('id' => $args['id']));
                 if ($id !== false) {
                     $qf->setDefaults(array($args['id'] => $rec[$args['id']]));
                 }
                 break;
             case 'date':
                 $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--'));
                 if ($val) {
                     $qf->setDefaults(array($args['id'] => $val));
                 }
                 break;
             case 'timestamp':
                 $qf->addElement('date', $args['id'], $label, array('format' => 'd M Y H:i', 'minYear' => date('Y') - 95, 'maxYear' => date('Y') + 5, 'addEmptyOption' => true, 'emptyOptionText' => '--'));
                 if ($val) {
                     $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false);
                     $qf->setDefaults(array($args['id'] => $default));
                 }
                 break;
             case 'time':
                 $qf->addElement('date', $args['id'], $label, array('format' => 'H:i', 'addEmptyOption' => true, 'emptyOptionText' => '--'));
                 if ($val) {
                     $default = Base_RegionalSettingsCommon::time2reg($val, true, true, true, false);
                     $qf->setDefaults(array($args['id'] => $default));
                 }
                 break;
             case 'multiselect':
                 //ignore
                 if ($id === false) {
                     continue;
                 }
                 $val = Utils_RecordBrowserCommon::get_val($tab, $field, $rec, true, $args);
                 if ($val === '') {
                     continue;
                 }
                 $qf->addElement('static', $args['id'], $label);
                 $qf->setDefaults(array($args['id'] => $val));
                 unset($defaults[$args['id']]);
                 break;
         }
         if ($args['required']) {
             $qf->addRule($args['id'], __('Field required'), 'required');
         }
     }
     $qf->addElement('submit', 'submit_button', __('Save'), IPHONE ? 'class="button white"' : '');
     if ($qf->validate()) {
         $values = $qf->exportValues();
         foreach ($cols as $v) {
             if ($v['type'] == 'checkbox' && !isset($values[$v['id']])) {
                 $values[$v['id']] = 0;
             } elseif ($v['type'] == 'date') {
                 if (is_array($values[$v['id']]) && $values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '') {
                     $values[$v['id']] = sprintf("%d-%02d-%02d", $values[$v['id']]['Y'], $values[$v['id']]['M'], $values[$v['id']]['d']);
                 } else {
                     $values[$v['id']] = '';
                 }
             } elseif ($v['type'] == 'timestamp') {
                 if ($values[$v['id']]['Y'] !== '' && $values[$v['id']]['M'] !== '' && $values[$v['id']]['d'] !== '' && $values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') {
                     $timestamp = $values[$v['id']]['Y'] . '-' . $values[$v['id']]['M'] . '-' . $values[$v['id']]['d'] . ' ' . $values[$v['id']]['H'] . ':' . $values[$v['id']]['i'];
                     $values[$v['id']] = Base_RegionalSettingsCommon::reg2time($timestamp, true);
                 } else {
                     $values[$v['id']] = '';
                 }
             } elseif ($v['type'] == 'time') {
                 if ($values[$v['id']]['H'] !== '' && $values[$v['id']]['i'] !== '') {
                     $time = recalculate_time(date('Y-m-d'), $values[$v['id']]);
                     $timestamp = Base_RegionalSettingsCommon::reg2time(date('1970-01-01 H:i:s', $time), true);
                     $values[$v['id']] = date('1970-01-01 H:i:s', $timestamp);
                 } else {
                     $values[$v['id']] = '';
                 }
             }
         }
         foreach ($defaults as $k => $v) {
             if (!isset($values[$k])) {
                 $values[$k] = $v;
             }
         }
         if ($id !== false) {
             $values['id'] = $id;
             Utils_RecordBrowserCommon::update_record($tab, $id, $values);
         } else {
             $id = Utils_RecordBrowserCommon::new_record($tab, $values);
         }
         return false;
     }
     $renderer =& $qf->defaultRenderer();
     $qf->accept($renderer);
     print $renderer->toHtml();
 }
Exemplo n.º 24
0
 protected function validate_single(Utils_RecordBrowser_CritsSingle $crits, $record)
 {
     $id = isset($record['id']) ? $record['id'] : '';
     list($field, $subfield) = Utils_RecordBrowser_CritsSingle::parse_subfield($crits->get_field());
     $field = ltrim(Utils_RecordBrowserCommon::get_field_id($field), '_');
     $subfield = ltrim(Utils_RecordBrowserCommon::get_field_id($subfield), '_');
     $r_val = isset($record[$field]) ? $record[$field] : '';
     $crit_value = $crits->get_value();
     $field_definition = $this->get_field_definition($field);
     if ($subfield && $field_definition) {
         $sub_tab = isset($field_definition['ref_table']) ? $field_definition['ref_table'] : false;
         if ($sub_tab) {
             if (is_array($r_val)) {
                 foreach ($r_val as $k => $v) {
                     $r_val[$k] = Utils_RecordBrowserCommon::get_value($sub_tab, $v, $subfield);
                 }
             } else {
                 if ($r_val) {
                     $r_val = Utils_RecordBrowserCommon::get_value($sub_tab, $r_val, $subfield);
                 } else {
                     $r_val = '';
                 }
                 if (substr($r_val, 0, 2) == '__') {
                     $r_val = Utils_RecordBrowserCommon::decode_multi($r_val);
                 }
                 // FIXME need better check
             }
         }
     }
     $k = strtolower($field);
     $record[$k] = $r_val;
     $result = false;
     $transform_date = false;
     if ($k == 'created_on') {
         $transform_date = 'timestamp';
     } elseif ($k == 'edited_on') {
         $details = Utils_RecordBrowserCommon::get_record_info($this->tab, $id);
         $record[$k] = $details['edited_on'];
         $transform_date = 'timestamp';
     } elseif ($field_definition) {
         $type = $field_definition['type'];
         if ($type == 'timestamp') {
             $transform_date = 'timestamp';
         } elseif ($type == 'date') {
             $transform_date = 'date';
         }
     }
     if ($transform_date == 'timestamp' && $crit_value) {
         $crit_value = Base_RegionalSettingsCommon::reg2time($crit_value, false);
         $crit_value = date('Y-m-d H:i:s', $crit_value);
     } else {
         if ($transform_date == 'date' && $crit_value) {
             $crit_value = Base_RegionalSettingsCommon::reg2time($crit_value, false);
             $crit_value = date('Y-m-d', $crit_value);
         }
     }
     $vv = explode('::', $crit_value, 2);
     if (isset($vv[1]) && is_callable($vv)) {
         $result = call_user_func_array($vv, array($this->tab, &$record, $k, $crits));
     } else {
         if (is_array($record[$k])) {
             if ($crit_value) {
                 $result = in_array($crit_value, $record[$k]);
             } else {
                 $result = empty($record[$k]);
             }
             if ($crits->get_operator() == '!=') {
                 $result = !$result;
             }
         } else {
             switch ($crits->get_operator()) {
                 case '>':
                     $result = $record[$k] > $crit_value;
                     break;
                 case '>=':
                     $result = $record[$k] >= $crit_value;
                     break;
                 case '<':
                     $result = $record[$k] < $crit_value;
                     break;
                 case '<=':
                     $result = $record[$k] <= $crit_value;
                     break;
                 case '!=':
                     $result = $record[$k] != $crit_value;
                     break;
                 case '=':
                     $result = $record[$k] == $crit_value;
                     break;
                 case 'LIKE':
                     $result = self::check_like_match($record[$k], $crit_value);
                     break;
                 case 'NOT LIKE':
                     $result = !self::check_like_match($record[$k], $crit_value);
                     break;
             }
         }
     }
     if ($crits->get_negation()) {
         $result = !$result;
     }
     if (!$result) {
         $this->issues[] = $k;
     }
     return $result;
 }
Exemplo n.º 25
0
	public function body(){
		if (empty($this->grid)) {
			print('Time grid not defined, aborting');
			return;
		}
		load_js('modules/Utils/Planner/planner.js');
		eval_js('disableSelection($("Utils_Planner__grid"))');
		eval_js('Event.observe(window,"mouseup",time_grid_mouse_up)');
		$theme = $this->init_module('Base/Theme');

		/* HEADERS */
		$fdow = Utils_PopupCalendarCommon::get_first_day_of_week();
		$headers = array();
		$select_all = array();
		if ($this->date===null) {
			$days_of_week = array(0=>__('Sunday'), 1=>__('Monday'), 2=>__('Tuesday'), 3=>__('Wednesday'), 4=>__('Thursday'), 5=>__('Friday'), 6=>__('Saturday'));
			while (count($headers)<7) {
				$headers[$fdow] = $days_of_week[$fdow];
				$fdow++;
				if ($fdow>6) $fdow -= 7;
			}
		} else {
//			while (date('w',$this->date)!=$fdow) $this->date = strtotime('-1 day', $this->date);
			$_SESSION['client']['utils_planner']['date'] = $this->date;
			$days_of_week = array(0=>__('Sun'), 1=>__('Mon'), 2=>__('Tue'), 3=>__('Wed'), 4=>__('Thu'), 5=>__('Fri'), 6=>__('Sat'));
			$curr = $this->date;
			while (count($headers)<7) {
				$headers[$curr] = Base_RegionalSettingsCommon::time2reg($curr, false, true, false).' '.$days_of_week[date('w',$curr)];
				$curr = strtotime('+1 day', $curr);
			}
		}
		$theme->assign('headers',$headers);

		foreach ($headers as $k1=>$v1)
			$select_all[$k1] = '';
		/* GRID LEGEND */
		$grid_legend = array();
		$grid_attrs = array();
		foreach ($this->grid as $k=>$v) {
			if (!isset($this->grid[$k+1])) break;
			foreach ($headers as $k1=>$v1)
				$select_all[$k1] .= ($select_all[$k1]?'time_grid_mouse_move':'time_grid_mouse_down').'('.$v.','.$k1.');';
			$grid_legend[$v] = Utils_PlannerCommon::format_time($v*60);
			$grid_legend[$v] .= ' - '.Utils_PlannerCommon::format_time($this->grid[$k+1]*60);
			$grid_attrs[$v] = array(); 
			foreach ($headers as $k2=>$v2) $grid_attrs[$v][$k2] = 'class="noconflict unused" id="'.$k2.'__'.$v.'" onmousedown="time_grid_mouse_down('.$v.','.$k2.')" onmousemove="if(typeof(time_grid_mouse_move)!=\'undefined\')time_grid_mouse_move('.$v.','.$k2.')"';
		}
		foreach ($headers as $k1=>$v1)
			$select_all[$k1] .= 'time_grid_mouse_up();';
		/* GRID LEGEND END */
		
		$theme->assign('select_all',$select_all);
		$theme->assign('select_all_label',__('Select all'));

		$theme->assign('grid_legend',$grid_legend);
		$theme->assign('grid_attrs',$grid_attrs);
		$theme->assign('time_frames',array('label'=>__('Time frames'), 'html'=>'<div id="Utils_Planner__time_frames" />'));
		$_SESSION['client']['utils_planner']['grid']=array(
			'timetable'=>$this->grid,
			'days'=>$headers,
			);
		if ($this->date!==null) {
			$this->form->addElement('submit', 'next_day', __('Next day'), array('onclick'=>'$("planner_navigation").value="next_day";'));
			$this->form->addElement('submit', 'prev_day', __('Previous day'), array('onclick'=>'$("planner_navigation").value="prev_day";'));
			$this->form->addElement('submit', 'next_week', __('Next week'), array('onclick'=>'$("planner_navigation").value="next_week";'));
			$this->form->addElement('submit', 'prev_week', __('Previous week'), array('onclick'=>'$("planner_navigation").value="prev_week";'));
			$this->form->addElement('submit', 'today', __('Today'), array('onclick'=>'$("planner_navigation").value="today";'));
			$this->form->addElement('hidden', 'navigation', '', array('id'=>'planner_navigation'));
			$link_text = '$(\'planner_navigation\').value=\'__YEAR__-__MONTH__-__DAY__\';'.$this->form->get_submit_form_js().';';
			$theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text,'day',$fdow,null,null,$this->date));
			eval_js('$("planner_navigation").value="";');
		}

		$values = $this->get_module_variable('preserve_values', null);
		if ($values===null)
			$values = $this->form->exportValues();
		else
			$this->unset_module_variable('preserve_values');
		$this->form->setDefaults($values);

		$validate = false;
		if ($this->form->validate()) {
			$validate = true;
			foreach ($values as $k=>$v)
				$this->values[$k] = $v;
		}
			
		$this->form->assign_theme('form', $theme);
		$theme->display();
		Base_ActionBarCommon::add('save',__('Save'),$this->form->get_submit_form_href());
		Base_ActionBarCommon::add('back',__('Back'),$this->create_back_href());
		
		$time_frames = explode(';',$values['grid_selected_frames']);
		if (!empty($time_frames) && $time_frames[0]) {
			foreach ($time_frames as $k=>$v) {
				$x = explode('::',$v);
				if (!isset($x[2])) trigger_error(print_r($time_frames, true));
				list($day, $s, $e) = explode('::',$v);
				foreach ($this->grid as $v) {
					if ($v>=$s && $v<$e) {
						eval_js('time_grid_mouse_down('.$v.','.$day.',"used");');
					}
				}
			}
			eval_js('time_grid_mouse_up();');
		}
		if (isset($values['navigation']) && $values['navigation']) {
			switch ($values['navigation']) {
				case 'next_day': $ch = strtotime('+1 day', $this->date); break;
				case 'prev_day': $ch = strtotime('-1 day', $this->date); break;
				case 'next_week': $ch = strtotime('+7 days', $this->date); break;
				case 'prev_week': $ch = strtotime('-7 days', $this->date); break;
				case 'today': $ch = strtotime(date('Y-m-d')); break;
				default: $ch = strtotime($values['navigation']);
			}
			if ($ch) {
				$values['navigation'] = '';
				$this->set_module_variable('fixed_date', $ch);
				$this->set_module_variable('preserve_values', $values);
				location(array());
				return;
			}
		}
		if ($validate) {
			unset($values['grid_selected_frames']);
			foreach ($time_frames as $k=>$v) {
				if (!$v) {
					unset($time_frames[$k]);
					break;
				}
				list($day, $s, $e) = explode('::',$v);
				$time_frames[$k] = array('day'=>$day, 'start'=>$s, 'end'=>$e);
			}
			call_user_func($_SESSION['client']['utils_planner']['processing_callback'], $values, $time_frames);
			$this->set_back_location();
			location(array());
		}
		foreach ($this->values as $k=>$v) {
			$_SESSION['client']['utils_planner']['resources'][$k]['value'] = $v;
			$_SESSION['client']['utils_planner']['resources'][$k]['in_use'] = array();
		}
		foreach ($this->values as $k=>$v) {
			eval_js(Utils_PlannerCommon::resource_changed($k, $v));
		}
	}
Exemplo n.º 26
0
 public function week()
 {
     $theme = $this->pack_module(Base_Theme::module_name());
     Base_ThemeCommon::load_css('Utils_CalendarBusyReport', 'common');
     $theme->assign('next7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date + 604800))));
     $theme->assign('next7_label', __('Next week'));
     $theme->assign('next_href', $this->create_unique_href(array('shift_week_day' => 1)));
     $theme->assign('next_label', __('Next day'));
     $theme->assign('today_href', $this->create_unique_href(array('date' => date('Y-m-d'))));
     $theme->assign('today_label', __('Today'));
     $theme->assign('prev_href', $this->create_unique_href(array('shift_week_day' => 0)));
     $theme->assign('prev_label', __('Previous day'));
     $theme->assign('prev7_href', $this->create_unique_href(array('date' => date('Y-m-d', $this->date - 604800))));
     $theme->assign('prev7_label', __('Previous week'));
     $link_text = $this->create_unique_href_js(array('week_date' => '__YEAR__-__MONTH__-__DAY__'));
     $theme->assign('popup_calendar', Utils_PopupCalendarCommon::show('week_selector', $link_text, 'day', $this->settings['first_day_of_week']));
     $week_shift = $this->get_module_variable('week_shift', 0);
     $first_day_of_displayed_week = date('w', $this->date) - $this->settings['first_day_of_week'];
     if ($first_day_of_displayed_week < 0) {
         $first_day_of_displayed_week += 7;
     }
     $diff = $week_shift - $first_day_of_displayed_week;
     $dis_week_from = strtotime(($diff < 0 ? $diff : '+' . $diff) . ' days', $this->date);
     //headers
     $day_headers = array();
     $today = Base_RegionalSettingsCommon::time2reg(null, false, true, true, false);
     if (date('m', $dis_week_from) != date('m', $dis_week_from + 518400)) {
         $second_span_width = date('d', $dis_week_from + 518400);
         $header_month = array('first_span' => array('colspan' => 7 - $second_span_width, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))), 'second_span' => array('colspan' => $second_span_width, 'month' => __date('M', $dis_week_from + 518400), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from + 518400), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from + 518400, 'tab' => 'Year'))));
     } else {
         $header_month = array('first_span' => array('colspan' => 7, 'month' => __date('M', $dis_week_from), 'month_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Month')), 'year' => date('Y', $dis_week_from), 'year_link' => $this->create_unique_href(array('action' => 'switch', 'time' => $dis_week_from, 'tab' => 'Year'))));
     }
     for ($i = 0; $i < 7; $i++) {
         $that_day = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from));
         $day_headers[] = array('date' => date('d', $that_day) . ' ' . __date('D', $that_day), 'style' => (date('Y-m-d', $that_day) == $today ? 'today' : 'other') . (date('N', $that_day) >= 6 ? '_weekend' : ''), 'link' => $this->create_unique_href(array('action' => 'switch', 'time' => $that_day, 'tab' => 'Day')));
     }
     $theme->assign('header_month', $header_month);
     $theme->assign('day_headers', $day_headers);
     $theme->assign('head_col_width', $this->settings['head_col_width']);
     $report = array();
     //timeline and ids
     $time_ids = array();
     $timeline = array();
     for ($i = 0; $i < 7; $i++) {
         $time_ids[$i] = array();
         $today_t_timeless = strtotime(date('Y-m-d', strtotime(date('Y-m-d 12:00:00', $dis_week_from)) + 3600 * 24 * $i) . ' ' . date('H:i:s', $dis_week_from));
         $today_t = Base_RegionalSettingsCommon::reg2time(date('Y-m-d', $today_t_timeless));
         $today_date = date('Y-m-d', $today_t_timeless);
         $timeline[$today_date] = $this->get_timeline($today_date);
         $prev = null;
         foreach ($timeline[$today_date] as &$v) {
             if ($v['time'] === false) {
                 $time_ids[$i][] = false;
             } elseif (is_string($v['time'])) {
                 $ii = $today_t_timeless . '_' . $v['time'];
                 $time_ids[$i][] = $ii;
                 $report[$ii] = array();
                 //					eval_js('$("UCcell_'.$ii.'").innerHTML="'.$ii.'";'); // *DEBUG*
             } else {
                 $ii = $today_t + $v['time'];
                 $time_ids[$i][] = $ii;
                 $report[$ii] = array();
                 //					eval_js('$("UCcell_'.$ii.'").innerHTML="'.Base_RegionalSettingsCommon::time2reg($ii).'";'); // *DEBUG*
             }
             $prev = $v;
         }
     }
     $navigation_bar_additions = '';
     if (is_callable(array($this->event_module, 'get_navigation_bar_additions'))) {
         $event_module_instance = $this->init_module($this->event_module);
         $navigation_bar_additions = call_user_func(array($event_module_instance, 'get_navigation_bar_additions'), '', '');
     }
     $theme->assign('navigation_bar_additions', $navigation_bar_additions);
     $theme->assign('time_ids', $time_ids);
     $theme->assign('timeline', reset($timeline));
     $theme->assign('week_view_label', __('Week calendar'));
     //data
     //$dis_week_from = Base_RegionalSettingsCommon::reg2time($dis_week_from);
     //$dis_week_to = $dis_week_from+7*86400-1;
     $dis_week_to = date('Y-m-d', $dis_week_from + 7.5 * 86400);
     $dis_week_from = date('Y-m-d', $dis_week_from);
     $ret = $this->get_events($dis_week_from, $dis_week_to);
     $this->displayed_events = array('start' => $dis_week_from, 'end' => $dis_week_to, 'events' => $ret);
     $custom_keys = $this->settings['custom_rows'];
     $busy_labels = $this->settings['busy_labels'];
     foreach ($ret as $k => $ev) {
         if (!isset($ev['busy_label'])) {
             continue;
         }
         if (!is_array($ev['busy_label'])) {
             $ev['busy_label'] = array($ev['busy_label']);
         }
         ob_start();
         Utils_CalendarBusyReportCommon::print_event($ev);
         $ev_print = ob_get_clean();
         $day_start = explode(':', $this->settings['start_day']);
         $day_start = ($day_start[0] * 60 + $day_start[1]) * 60;
         if (!isset($ev['start'])) {
             $diff = 1;
         } else {
             $diff = ($day_start - ($ev['start'] - $today_t)) / 3600;
         }
         $dur = ceil($ev['duration'] / (strtotime($this->settings['interval']) - strtotime('0:00')));
         if (isset($ev['timeless']) && $ev['timeless']) {
             if (!isset($ev['custom_row_key'])) {
                 $ev['custom_row_key'] = 'timeless';
             }
             $today_t_timeless = strtotime($ev['timeless']);
             if (isset($custom_keys[$ev['custom_row_key']])) {
                 $dest_id = $today_t_timeless . '_' . $ev['custom_row_key'];
                 if (isset($report[$dest_id])) {
                     foreach ($ev['busy_label'] as $busy_label) {
                         if (!isset($busy_labels[$busy_label])) {
                             $busy_labels[$busy_label] = $busy_label;
                         }
                         if (!isset($report[$dest_id][$busy_label])) {
                             $report[$dest_id][$busy_label] = '';
                         }
                         $report[$dest_id][$busy_label] .= $ev_print;
                     }
                 }
             } else {
                 //					trigger_error('Invalid custom_row_key:'.$ev['custom_row_key'],E_USER_ERROR);
                 continue;
             }
         } else {
             $today_t = Base_RegionalSettingsCommon::time2reg($ev['start'], true, true, true, false);
             $today_date = date('Y-m-d', strtotime($today_t));
             $today_t = strtotime(date('Y-m-d H:i:s', Base_RegionalSettingsCommon::reg2time($today_date)));
             $ev_start = $ev['start'] - $today_t;
             if (!isset($timeline[$today_date])) {
                 continue;
             }
             $ct = count($timeline[$today_date]);
             for ($i = 1, $j = 2; $j < $ct; $i++, $j++) {
                 while ($timeline[$today_date][$i]['time'] === false) {
                     $i++;
                 }
                 while (($timeline[$today_date][$j]['time'] === false || $i >= $j) && $j < $ct) {
                     $j++;
                 }
                 if ($j == $ct) {
                     break;
                 }
                 if ($timeline[$today_date][$i]['time'] <= $ev_start && $ev_start < $timeline[$today_date][$j]['time']) {
                     break;
                 }
             }
             for ($k = $i; $k < $i + $dur; $k++) {
                 $dest_id = $today_t + $timeline[$today_date][$k]['time'];
                 if (isset($report[$dest_id])) {
                     foreach ($ev['busy_label'] as $busy_label) {
                         if (!isset($busy_labels[$busy_label])) {
                             $busy_labels[$busy_label] = $busy_label;
                         }
                         if (!isset($report[$dest_id][$busy_label])) {
                             $report[$dest_id][$busy_label] = '';
                         }
                         $report[$dest_id][$busy_label] .= $ev_print;
                     }
                 }
             }
         }
     }
     $theme->assign('report', $report);
     $theme->assign('busy_labels', $busy_labels);
     //ok, display
     $theme->display('week');
     if ($this->custom_new_event_href_js !== null) {
         $jshref = call_user_func($this->custom_new_event_href_js, '__TIME__', '__TIMELESS__', '__OBJECT__');
     } else {
         $jshref = $this->create_unique_href_js(array('action' => 'add', 'time' => '__TIME__', 'timeless' => '__TIMELESS__', 'object' => '__OBJECT__'));
     }
     eval_js('Utils_CalendarBusyReport.activate_dclick(\'' . Epesi::escapeJS($jshref, false) . '\')');
 }
Exemplo n.º 27
0
 public static function crm_event_get($id)
 {
     if (!is_array($id)) {
         $r = Utils_RecordBrowserCommon::get_record('task', $id);
     } else {
         $r = $id;
         $id = $r['id'];
     }
     $r = Utils_RecordBrowserCommon::filter_record_by_access('task', $r);
     if (!$r) {
         return null;
     }
     $next = array('type' => __('Task'));
     $day = $r['deadline'];
     $iday = strtotime($day);
     $next['id'] = $r['id'];
     $base_unix_time = strtotime(date('1970-01-01 00:00:00'));
     $next['start'] = $iday;
     $next['timeless'] = $day;
     $next['duration'] = -1;
     $next['title'] = (string) $r['title'];
     $next['description'] = (string) $r['description'];
     $next['color'] = 'gray';
     if ($r['status'] == 0 || $r['status'] == 1) {
         switch ($r['priority']) {
             case 0:
                 $next['color'] = 'green';
                 break;
             case 1:
                 $next['color'] = 'yellow';
                 break;
             case 2:
                 $next['color'] = 'red';
                 break;
         }
     }
     if ($r['status'] == 2) {
         $next['color'] = 'blue';
     }
     if ($r['status'] == 3) {
         $next['color'] = 'gray';
     }
     $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'view');
     if (Utils_RecordBrowserCommon::get_access('task', 'edit', $r) !== false) {
         $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('task', $r['id'], 'edit');
     } else {
         $next['edit_action'] = false;
         $next['move_action'] = false;
     }
     if (Utils_RecordBrowserCommon::get_access('task', 'delete', $r) == false) {
         $next['delete_action'] = false;
     }
     /*		$r_new = $r;
     		if ($r['status']==0) $r_new['status'] = 1;
     		if ($r['status']<=1) $next['actions'] = array(
     			array('icon'=>Base_ThemeCommon::get_template_file('CRM/Meeting', 'close_event.png'), 'href'=>self::get_status_change_leightbox_href($r_new, false, array('id'=>'status')))
     		);*/
     $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, false);
     $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, false);
     $inf2 = array(__('Date') => '<b>' . $event_date . '</b>');
     $emps = array();
     foreach ($r['employees'] as $e) {
         $e = CRM_ContactsCommon::contact_format_no_company($e, true);
         $e = str_replace('&nbsp;', ' ', $e);
         if (mb_strlen($e, 'UTF-8') > 33) {
             $e = mb_substr($e, 0, 30, 'UTF-8') . '...';
         }
         $emps[] = $e;
     }
     $next['busy_label'] = $r['employees'];
     $cuss = array();
     foreach ($r['customers'] as $c) {
         $c = CRM_ContactsCommon::display_company_contact(array('customers' => $c), true, array('id' => 'customers'));
         $cuss[] = str_replace('&nbsp;', ' ', $c);
     }
     $inf2 += array(__('Task') => '<b>' . $next['title'] . '</b>', __('Description') => $next['description'], __('Assigned to') => implode('<br>', $emps), __('Contacts') => implode('<br>', $cuss), __('Status') => Utils_CommonDataCommon::get_value('CRM/Status/' . $r['status'], true), __('Access') => Utils_CommonDataCommon::get_value('CRM/Access/' . $r['permission'], true), __('Priority') => Utils_CommonDataCommon::get_value('CRM/Priority/' . $r['priority'], true), __('Notes') => Utils_AttachmentCommon::count('task/' . $r['id']));
     $next['employees'] = $r['employees'];
     $next['customers'] = $r['customers'];
     $next['status'] = $r['status'] <= 2 ? 'active' : 'closed';
     $next['custom_tooltip'] = '<center><b>' . __('Task') . '</b></center><br>' . Utils_TooltipCommon::format_info_tooltip($inf2) . '<hr>' . CRM_ContactsCommon::get_html_record_info($r['created_by'], $r['created_on'], null, null);
     return $next;
 }
Exemplo n.º 28
0
 public function make_event_PDF($pdf, $id, $no_details = false, $type = 'Event')
 {
     $custom_event = false;
     if (!is_array($id)) {
         $check = explode('#', $id);
         if (isset($check[1])) {
             $callback = DB::GetOne('SELECT handler_callback FROM crm_calendar_custom_events_handlers WHERE id=%d', $check[0]);
             $callback = explode('::', $callback);
             $ev = call_user_func($callback, 'get', $check[1]);
             $no_details = true;
             $custom_event = true;
         } else {
             trigger_error('Invalid event id: ' . $id, E_USER_ERROR);
         }
     } else {
         $ev = $id;
         $id = $ev['id'];
         $id = explode('_', $id);
         $id = $id[0];
         /*			$ev_details = DB::GetRow('SELECT *, starts AS start, ends AS end FROM crm_calendar_event WHERE id=%d', array($id));
         			foreach ($ev_details as $k=>$v)
         				if (!isset($ev[$k])) $ev[$k] = $v;*/
         $ev['title'] = strip_tags($ev['title']);
         $check = explode('#', $id);
         if (isset($check[1])) {
             $no_details = true;
             $custom_event = true;
         }
     }
     $pdf_theme = $this->pack_module('Base/Theme');
     $pdf_theme->assign('description', array('label' => __('Description'), 'value' => str_replace("\n", '<br/>', htmlspecialchars($ev['description']))));
     if (!$no_details) {
         $ev['status'] = Utils_CommonDataCommon::get_value('CRM/Status/' . $ev['status'], true);
         $ev['access'] = self::$access[$ev['access']];
         $ev['priority'] = self::$priority[$ev['priority']];
         foreach (array('access' => __('Access'), 'priority' => __('Priority'), 'status' => __('Status')) as $v => $label) {
             $pdf_theme->assign($v, array('label' => $label, 'value' => $ev[$v]));
         }
         $created_by = CRM_ContactsCommon::get_contact_by_user_id($ev['created_by']);
         if ($created_by !== null) {
             $created_by = $created_by['last_name'] . ' ' . $created_by['first_name'];
         } else {
             $created_by = Base_UserCommon::get_user_login($ev['created_by']);
         }
         $created_on = Base_RegionalSettingsCommon::time2reg($ev['created_on'], false);
         $pdf_theme->assign('created_on', array('label' => __('Created on'), 'value' => $created_on));
         $pdf_theme->assign('created_by', array('label' => __('Created by'), 'value' => $created_by));
         if ($ev['edited_by'] != null) {
             $edited_by = CRM_ContactsCommon::get_contact_by_user_id($ev['edited_by']);
             if ($edited_by !== null) {
                 $edited_by = $edited_by['last_name'] . ' ' . $edited_by['first_name'];
             } else {
                 $edited_by = Base_UserCommon::get_user_login($ev['edited_by']);
             }
             $edited_on = Base_RegionalSettingsCommon::time2reg($ev['edited_on'], false);
         } else {
             $edited_by = '--';
             $edited_on = '--';
         }
         $pdf_theme->assign('edited_on', array('label' => __('Edited on'), 'value' => $edited_on));
         $pdf_theme->assign('edited_by', array('label' => __('Edited by'), 'value' => $edited_by));
         $pdf_theme->assign('printed_on', array('label' => __('Printed on'), 'value' => Base_RegionalSettingsCommon::time2reg(time())));
     }
     $emps = array();
     $cuss = array();
     $cus_cmps = array();
     if (isset($ev['employees']) && !empty($ev['employees'])) {
         foreach ($ev['employees'] as $v) {
             $c = CRM_ContactsCommon::get_contact($v);
             $emps[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone']);
         }
     }
     if (isset($ev['customers']) && !empty($ev['customers'])) {
         foreach ($ev['customers'] as $v) {
             $det = explode(':', $v);
             if (isset($det[1])) {
                 $v = $det[1];
             } else {
                 $v = $det[0];
                 $det[0] = 'P';
             }
             if ($det[0] == 'P') {
                 $c = CRM_ContactsCommon::get_contact($v);
                 $company_name = isset($c['company_name']) && is_numeric($c['company_name']) ? array(Utils_RecordBrowserCommon::get_value('company', $c['company_name'], 'Company Name')) : '---';
                 $cuss[] = array('name' => $c['last_name'] . ' ' . $c['first_name'], 'mphone' => $c['mobile_phone'], 'wphone' => $c['work_phone'], 'hphone' => $c['home_phone'], 'company_name' => $company_name);
             }
             if ($det[0] == 'C') {
                 $c = array('company_name' => array($v));
             }
             if (is_array($c['company_name'])) {
                 foreach ($c['company_name'] as $v2) {
                     if (!isset($cus_cmps[$v2])) {
                         $cus_cmps[$v2] = CRM_ContactsCommon::get_company($v2);
                     }
                 }
             }
         }
     }
     $pdf_theme->assign('employees', array('main_label' => __('Employees'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'lp_label' => __('Lp'), 'data' => $emps));
     $pdf_theme->assign('customers', array('main_label' => __('Customers'), 'name_label' => __('Name'), 'mphone_label' => __('Mobile Phone'), 'wphone_label' => __('Work Phone'), 'hphone_label' => __('Home Phone'), 'company_name' => __('Company Name'), 'lp_label' => __('Lp'), 'data' => $cuss));
     $pdf_theme->assign('customers_companies', array('main_label' => __('Customers Companies'), 'name_label' => __('Company Name'), 'phone_label' => __('Phone'), 'fax_label' => __('Fax'), 'address_label' => __('Address'), 'city_label' => __('City'), 'lp_label' => __('Lp'), 'data' => $cus_cmps));
     $pdf_theme->assign('title', array('label' => __('Title'), 'value' => $ev['title']));
     $start = Base_RegionalSettingsCommon::time2reg($ev['start'], false);
     $pdf_theme->assign('start_date', array('label' => __('Start Date'), 'value' => $start, 'details' => array('weekday' => __date('l', strtotime($start)))));
     if (!isset($ev['timeless'])) {
         $pdf_theme->assign('start_time', array('label' => __('Start Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['start'], true, false)));
         if (!isset($ev['end'])) {
             trigger_error(print_r($ev, true));
         }
         $pdf_theme->assign('end_time', array('label' => __('End Time'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], true, false)));
         $hours = floor(($ev['end'] - $ev['start']) / 3600);
         $format = __('%d hours', array($hours));
         $minutes = ($ev['end'] - $ev['start']) % 3600;
         if ($minutes != 0) {
             if ($hours == 0) {
                 $format = '';
             } else {
                 $format .= ', ';
             }
             $format .= __('%d minutes', array($minutes / 60));
         }
         $pdf_theme->assign('duration', array('label' => __('Duration'), 'value' => $format));
         if (date('Y-m-d', $ev['start']) != date('Y-m-d', $ev['end'])) {
             $pdf_theme->assign('end_date', array('label' => __('End Date'), 'value' => Base_RegionalSettingsCommon::time2reg($ev['end'], false)));
         }
     } else {
         $pdf_theme->assign('timeless', array('label' => __('Timeless'), 'value' => __('Yes')));
     }
     $pdf_theme->assign('type', $type);
     ob_start();
     $pdf_theme->display('pdf_version');
     $cont = ob_get_clean();
     $pdf->writeHTML($cont);
 }
Exemplo n.º 29
0
 public function file_history($attachment)
 {
     if ($this->is_back()) {
         $x = ModuleManager::get_instance('/Base_Box|0');
         if (!$x) {
             trigger_error('There is no base box module instance', E_USER_ERROR);
         }
         return $x->pop_main();
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     $id = $attachment['id'];
     $tb =& $this->init_module(Utils_TabbedBrowser::module_name());
     $tb->start_tab('File history');
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hua' . $id);
     $gb->set_inline_display();
     $gb->set_table_columns(array(array('name' => __('Deleted'), 'order' => 'deleted', 'width' => 10), array('name' => __('Date'), 'order' => 'upload_on', 'width' => 25), array('name' => __('Who'), 'order' => 'upload_by', 'width' => 25), array('name' => __('Attachment'), 'order' => 'uaf.original')));
     $gb->set_default_order(array(__('Date') => 'DESC'));
     $ret = $gb->query_order_limit('SELECT uaf.id,uaf.deleted,uaf.filestorage_id,uaf.created_on as upload_on,uaf.created_by as upload_by,uaf.original FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id, 'SELECT count(*) FROM utils_attachment_file uaf WHERE uaf.attach_id=' . $id);
     while ($row = $ret->FetchRow()) {
         $r = $gb->get_new_row();
         if ($row['deleted']) {
             $r->add_action($this->create_confirm_callback_href(__('Are you sure you want to restore attached file?'), array($this, 'restore_file'), array($row['id'])), 'restore', __('Restore'));
         }
         $view_link = '';
         $lb = array();
         $lb['aid'] = $id;
         $lb['crypted'] = $attachment['crypted'];
         $lb['original'] = $row['original'];
         $lb['id'] = $row['id'];
         $lb['filestorage_id'] = $row['filestorage_id'];
         $file = '<a ' . Utils_AttachmentCommon::get_file_leightbox($lb, $view_link) . '>' . $row['original'] . '</a>';
         $r->add_data($row['deleted'] ? __('Yes') : __('No'), Base_RegionalSettingsCommon::time2reg($row['upload_on']), Base_UserCommon::get_user_label($row['upload_by']), $file);
     }
     $this->display_module($gb);
     $tb->end_tab();
     $tb->start_tab('File access history');
     $gb = $this->init_module(Utils_GenericBrowser::module_name(), null, 'hda' . $id);
     $gb->set_inline_display();
     $gb->set_table_columns(array(array('name' => __('Create date'), 'order' => 'created_on', 'width' => 15), array('name' => __('Download date'), 'order' => 'download_on', 'width' => 15), array('name' => __('Who'), 'order' => 'created_by', 'width' => 15), array('name' => __('IP Address'), 'order' => 'ip_address', 'width' => 15), array('name' => __('Host Name'), 'order' => 'host_name', 'width' => 15), array('name' => __('Method description'), 'order' => 'description', 'width' => 20), array('name' => __('Remote'), 'order' => 'remote', 'width' => 10)));
     $gb->set_default_order(array(__('Create date') => 'DESC'));
     $query = 'SELECT uad.created_on,uad.download_on,(SELECT l.login FROM user_login l WHERE uad.created_by=l.id) as created_by,uad.remote,uad.ip_address,uad.host_name,uad.description FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id;
     $query_qty = 'SELECT count(*) FROM utils_attachment_download uad INNER JOIN utils_attachment_file uaf ON uaf.id=uad.attach_file_id WHERE uaf.attach_id=' . $id;
     if (Base_AclCommon::check_permission('Attachments - view full download history')) {
         $ret = $gb->query_order_limit($query, $query_qty);
     } else {
         print 'You are allowed to see your own downloads only';
         $who = ' AND uad.created_by=' . Acl::get_user();
         $ret = $gb->query_order_limit($query . $who, $query_qty . $who);
     }
     while ($row = $ret->FetchRow()) {
         $r = $gb->get_new_row();
         $r->add_data(Base_RegionalSettingsCommon::time2reg($row['created_on']), $row['remote'] != 1 ? Base_RegionalSettingsCommon::time2reg($row['download_on']) : '', $row['created_by'], $row['ip_address'], $row['host_name'], $row['description'], $row['remote'] == 0 ? 'no' : 'yes');
     }
     $this->display_module($gb);
     $tb->end_tab();
     $this->display_module($tb);
     $this->caption = 'Note history';
     return true;
 }
Exemplo n.º 30
0
 public static function get_alarm($id)
 {
     $recurrence = strpos($id, '_');
     if ($recurrence !== false) {
         $id = substr($id, 0, $recurrence);
     }
     $hndlr = DB::GetOne('SELECT id FROM crm_calendar_custom_events_handlers WHERE group_name=%s', array('Meetings'));
     $a = self::get($hndlr . '#' . $id);
     if (!$a) {
         return __('Private record');
     }
     if (isset($a['timeless'])) {
         $date = __('Timeless event: %s', array(Base_RegionalSettingsCommon::time2reg($a['timeless'], false)));
     } else {
         $date = __('Start: %s', array(Base_RegionalSettingsCommon::time2reg($a['start'], 2))) . "\n" . __('End: %s', array(Base_RegionalSettingsCommon::time2reg($a['end'], 2)));
     }
     return $date . "\n" . __('Title: %s', array($a['title']));
 }