Example #1
0
 /**
  * For internal use only.
  */
 public function edit($parent, $key = null)
 {
     if ($this->is_back()) {
         return false;
     }
     $id = Utils_CommonDataCommon::get_id($parent);
     if (!$id) {
         print __('No such array');
         return false;
     }
     $f = $this->init_module(Libs_QuickForm::module_name(), null, 'edit');
     $f->addElement('header', null, $key === null ? __('New node') : __('Edit node'));
     $f->add_table('utils_commondata_tree', array(array('name' => 'akey', 'label' => __('Key'), 'rule' => array(array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key'), 'message' => __('Specified key already exists')), array('type' => 'callback', 'param' => array($parent, $key), 'func' => array($this, 'check_key2'), 'message' => __('Specified contains invalid character "/"')))), array('name' => 'value', 'label' => __('Value'))));
     if ($key !== null) {
         $value = Utils_CommonDataCommon::get_value($parent . '/' . $key);
         $f->setDefaults(array('akey' => $key, 'value' => $value));
     }
     if ($f->validate()) {
         $submited = $f->exportValues();
         if ($key !== null) {
             Utils_CommonDataCommon::rename_key($parent, $key, $submited['akey']);
         }
         Utils_CommonDataCommon::set_value($parent . '/' . $submited['akey'], $submited['value']);
         return false;
     }
     Base_ActionBarCommon::add('save', __('Save'), $f->get_submit_form_href());
     Base_ActionBarCommon::add('back', __('Cancel'), $this->create_back_href());
     $f->display();
     return true;
 }
Example #2
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;
 }
Example #3
0
<?php

/**
 * @author       Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2006, Telaxus LLC
 * @version 1.0
 * @license MIT
 * @package epesi-utils
 * @subpackage CommonData
 */
if (!isset($_POST['value'])) {
    die('alert(\'Invalid request\')');
}
define('JS_OUTPUT', 1);
define('SET_SESSION', 0);
require_once '../../../include.php';
ModuleManager::load_modules();
$ret = Utils_CommonDataCommon::get_value($_POST['value'], true);
if (!$ret) {
    $ret = array();
}
print json_encode($ret);
exit;
Example #4
0
 public static function get_val($tab, $field, $record, $links_not_recommended = false, $args = null)
 {
     static $recurrence_call_stack = array();
     self::init($tab);
     $commondata_sep = '/';
     if (!isset(self::$table_rows[$field])) {
         if (!isset(self::$hash[$field])) {
             trigger_error('Unknown field "' . $field . '" for recordset "' . $tab . '"', E_USER_ERROR);
         }
         $field = self::$hash[$field];
     }
     if ($args === null) {
         $args = self::$table_rows[$field];
     }
     if (!array_key_exists('id', $record)) {
         $record['id'] = null;
     }
     if (!array_key_exists($args['id'], $record)) {
         trigger_error($args['id'] . ' - unknown field for record ' . serialize($record), E_USER_ERROR);
     }
     $val = $record[$args['id']];
     $function_call_id = implode('|', array($tab, $field, serialize($val)));
     if (isset($recurrence_call_stack[$function_call_id])) {
         return '!! ' . __('recurrence issue') . ' !!';
     } else {
         $recurrence_call_stack[$function_call_id] = true;
     }
     self::display_callback_cache($tab);
     if (isset(self::$display_callback_table[$tab][$field])) {
         $ret = self::call_display_callback(self::$display_callback_table[$tab][$field], $record, $links_not_recommended, self::$table_rows[$field], $tab);
     } else {
         $ret = $val;
         if ($args['type'] == 'select' || $args['type'] == 'multiselect') {
             if (is_array($val) && empty($val) || !is_array($val) && $val == '') {
                 $ret = '---';
                 unset($recurrence_call_stack[$function_call_id]);
                 return $ret;
             }
             $param = explode(';', $args['param']);
             $pp = explode('::', $param[0]);
             $tab = $pp[0];
             if (isset($pp[1])) {
                 $col = $pp[1];
             } else {
                 $col = null;
             }
             //return;//trigger_error("\"param\" attribute of field \"$field\" is not valid. Please set <recordset>::<field>");
             if (!$col && $tab == '__COMMON__') {
                 unset($recurrence_call_stack[$function_call_id]);
                 return;
             }
             if (!is_array($val)) {
                 $val = array($val);
             }
             //              if ($tab=='__COMMON__') $data = Utils_CommonDataCommon::get_translated_array($col, true);
             if ($tab == '__RECORDSETS__') {
                 $single_tab = false;
             } else {
                 $tabs = explode(',', $tab);
                 $single_tab = count($tabs) == 1;
             }
             $ret = '';
             $first = true;
             foreach ($val as $k => $v) {
                 //                  if ($tab=='__COMMON__' && !isset($data[$v])) continue;
                 if ($tab == '__COMMON__') {
                     $path = explode('/', $v);
                     $tooltip = '';
                     $res = '';
                     if (count($path) > 1) {
                         $res .= Utils_CommonDataCommon::get_value($col . '/' . $path[0], true);
                         if (count($path) > 2) {
                             $res .= $commondata_sep . '...';
                             $tooltip = '';
                             $full_path = $col;
                             foreach ($path as $w) {
                                 $full_path .= '/' . $w;
                                 $tooltip .= ($tooltip ? $commondata_sep : '') . Utils_CommonDataCommon::get_value($full_path, true);
                             }
                         }
                         $res .= $commondata_sep;
                     }
                     $val = Utils_CommonDataCommon::get_value($col . '/' . $v, true);
                     if (!$val) {
                         continue;
                     }
                     $res .= $val;
                     if ($first) {
                         $first = false;
                     } else {
                         $ret .= '<br>';
                     }
                     $res = self::no_wrap($res);
                     if ($tooltip) {
                         $res = '<span ' . Utils_TooltipCommon::open_tag_attrs($tooltip, false) . '>' . $res . '</span>';
                     }
                     $ret .= $res;
                 } else {
                     if (!$single_tab) {
                         list($tab, $v) = explode('/', $v, 2);
                     }
                     if ($first) {
                         $first = false;
                     } else {
                         $ret .= '<br>';
                     }
                     if ($col) {
                         $columns = explode('|', $col);
                         $ret .= Utils_RecordBrowserCommon::create_linked_label($tab, $columns, $v, $links_not_recommended);
                     } else {
                         $ret .= Utils_RecordBrowserCommon::create_default_linked_label($tab, $v, $links_not_recommended);
                     }
                 }
             }
             if ($ret == '') {
                 $ret = '---';
             }
         } elseif ($args['type'] == 'commondata') {
             if (!isset($val) || $val === '') {
                 $ret = '';
             } else {
                 $arr = explode('::', $args['param']['array_id']);
                 $path = array_shift($arr);
                 foreach ($arr as $v) {
                     $path .= '/' . $record[self::get_field_id($v)];
                 }
                 $path .= '/' . $record[$args['id']];
                 $ret = Utils_CommonDataCommon::get_value($path, true);
             }
             /*            } elseif ($args['type']=='record') {
                           if (!isset($val) || $val==='') {
                               $ret = '';
                           } else {
                               @list($rs,$rid) = explode('#',$record[$args['id']],2);
                               if(!$rid) $ret = '';
                               else {
                                   $ret = self::create_default_linked_label($rs,$rid,$links_not_recommended);
                               }
                           }*/
         } elseif ($args['type'] == 'autonumber') {
             if (!$links_not_recommended && isset($record['id']) && $record['id']) {
                 $ret = self::record_link_open_tag_r($tab, $record) . $val . self::record_link_close_tag();
             }
         } elseif ($args['type'] == 'currency') {
             $val = Utils_CurrencyFieldCommon::get_values($val);
             $ret = Utils_CurrencyFieldCommon::format($val[0], $val[1]);
         } elseif ($args['type'] == 'checkbox') {
             $ret = $ret ? __('Yes') : __('No');
         } elseif ($args['type'] == 'date') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, false, true, false);
             }
         } elseif ($args['type'] == 'timestamp') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds');
             }
         } elseif ($args['type'] == 'time') {
             if ($val != '') {
                 $ret = Base_RegionalSettingsCommon::time2reg($val, 'without_seconds', false);
             }
         } elseif ($args['type'] == 'long text') {
             $ret = htmlspecialchars($val);
             $ret = str_replace("\n", '<br>', $ret);
             $ret = Utils_BBCodeCommon::parse($ret);
         }
     }
     unset($recurrence_call_stack[$function_call_id]);
     return $ret;
 }
Example #5
0
 public static function crm_event_get($id, $day = null)
 {
     if (!is_array($id)) {
         $id = explode('_', $id);
         if (isset($id[1]) && $day === null) {
             $day = $id[1];
         }
         $id = reset($id);
         $r = Utils_RecordBrowserCommon::get_record('crm_meeting', $id);
     } else {
         $r = $id;
         $id = $r['id'];
     }
     $r = Utils_RecordBrowserCommon::filter_record_by_access('crm_meeting', $r);
     if ($r === false) {
         return null;
     }
     $next = array('type' => __('Meeting'));
     //		if ($r['duration']!=-1) {
     //			$r['date'] = Base_RegionalSettingsCommon::time2reg($r['date'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false);
     //			$r['recurrence_end'] = Base_RegionalSettingsCommon::time2reg($r['recurrence_end'].' '.date('H:i:s', strtotime($r['time'])),false,true,true,false);
     //		}
     if ($day === null) {
         $day = $r['date'];
         $iday = strtotime($day);
         $next['id'] = $r['id'];
     } else {
         $iday = strtotime($day);
         if ($day < $r['date']) {
             return null;
         }
         if ($r['recurrence_end'] && $day > $r['recurrence_end']) {
             return null;
         }
         if ($r['recurrence_type'] <= 7 && $r['recurrence_type'] > 0) {
             $diff = round(($iday - strtotime($r['date'])) / (3600 * 24));
             if ($diff < 0 || $diff % $r['recurrence_type'] != 0) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 8) {
             if (isset($r['recurrence_hash'][date('N', $iday) - 1]) && !$r['recurrence_hash'][date('N', $iday) - 1]) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 9) {
             $diff = round(($iday - strtotime($r['date'])) / (3600 * 24));
             if ($diff < 0 || $diff % 14 != 0) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 10) {
             $numdays = date('t', $iday);
             $cday = date('d', $iday);
             $tday = date('d', strtotime($r['date']));
             if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) {
                 return null;
             }
         }
         if ($r['recurrence_type'] == 11) {
             $cmonth = date('m', $iday);
             $tmonth = date('m', strtotime($r['date']));
             if ($cmonth != $tmonth) {
                 return null;
             }
             $numdays = date('t', $iday);
             $cday = date('d', $iday);
             $tday = date('d', strtotime($r['date']));
             if ($cday != $tday && ($tday <= $numdays || $numdays != $cday)) {
                 return null;
             }
         }
         $next['id'] = $r['id'];
     }
     if ($r['recurrence_type'] > 0) {
         $next['id'] = $r['id'] . '_' . $day;
     }
     $base_unix_time = strtotime(date('1970-01-01 00:00:00'));
     //		$next['start'] = Base_RegionalSettingsCommon::reg2time(Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])), true, false, true, false));
     //		$next['end'] = Base_RegionalSettingsCommon::reg2time(date('Y-m-d',$iday).' '.Base_RegionalSettingsCommon::time2reg(date('Y-m-d',$iday).' '.date('H:i:s',strtotime($r['time'])+$r['duration']), true, false, true, false));
     $next['start'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time']));
     $next['end'] = date('Y-m-d', $iday) . ' ' . date('H:i:s', strtotime($r['time']) + $r['duration']);
     $next['start'] = strtotime($next['start']);
     $next['end'] = strtotime($next['end']);
     if ($r['duration'] == -1) {
         $next['timeless'] = $day;
     }
     $next['duration'] = intval($r['duration']);
     $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';
     }
     if ($r['recurrence_type']) {
         $next['title'] = '<img src="' . Base_ThemeCommon::get_template_file('CRM_Calendar_Event', 'recurrence.png') . '" border=0 hspace=0 vspace=0 align=left>' . $next['title'];
     }
     $next['view_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'view', array('day' => $day));
     if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'edit', $r) !== false) {
         $next['edit_action'] = Utils_RecordBrowserCommon::create_record_href('crm_meeting', $r['id'], 'edit');
         if ($r['status'] <= 1) {
             $r_new = $r;
             if ($r['status'] == 0) {
                 $r_new['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'))));
         }
     } else {
         $next['edit_action'] = false;
         $next['move_action'] = false;
     }
     if (Utils_RecordBrowserCommon::get_access('crm_meeting', 'delete', $r) == false) {
         $next['delete_action'] = false;
     }
     $start_time = Base_RegionalSettingsCommon::time2reg($next['start'], 2, false, $r['duration'] != -1);
     $event_date = Base_RegionalSettingsCommon::time2reg($next['start'], false, 3, $r['duration'] != -1);
     $end_time = Base_RegionalSettingsCommon::time2reg($next['end'], 2, false, $r['duration'] != -1);
     $inf2 = array(__('Date') => '<b>' . $event_date . '</b>');
     if ($r['duration'] == -1) {
         $inf2 += array(__('Time') => __('Timeless event'));
     } else {
         $inf2 += array(__('Time') => $start_time . ' - ' . $end_time, __('Duration') => Base_RegionalSettingsCommon::seconds_to_words($r['duration']));
     }
     $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(__('Event') => '<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('crm_meeting/' . $r['id']));
     //		$next['employees'] = implode('<br>',$emps);
     //		$next['customers'] = implode('<br>',$cuss);
     $next['employees'] = $r['employees'];
     $next['customers'] = $r['customers'];
     $next['status'] = $r['status'] <= 2 ? 'active' : 'closed';
     $next['custom_tooltip'] = '<center><b>' . __('Meeting') . '</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;
 }
Example #6
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);
 }
Example #7
0
 public static function display_phone($r, $nolink, $desc)
 {
     if ($nolink) {
         return $r[$desc['id']];
     }
     if (MOBILE_DEVICE && IPHONE && preg_match('/^([0-9\\t\\+-]+)/', $r[$desc['id']], $args)) {
         return '<a href="tel:' . $args[1] . '">' . $r[$desc['id']] . '</a>';
     }
     $num = $r[$desc['id']];
     if ($num && strpos($num, '+') === false) {
         if (isset($r['country']) && $r['country']) {
             $calling_code = Utils_CommonDataCommon::get_value('Calling_Codes/' . $r['country']);
             if ($calling_code) {
                 $num = $calling_code . $num;
             }
         }
     }
     return CRM_CommonCommon::get_dial_code($num);
 }
Example #8
0
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Edit'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Add'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 Utils_RecordBrowserCommon::new_record_field('contact', array('name' => _M('Delete'), 'type' => 'crm_contact', 'param' => array('field_type' => 'multiselect', 'crits' => array('Custom_CADES_AccessRestrictionsCommon', 'employee_crits'), 'format' => array('CRM_ContactsCommon', 'contact_format_no_company')), 'required' => false, 'extra' => true, 'filter' => false, 'visible' => false));
 // migrate data
 if (Utils_RecordBrowserCommon::check_table_name('cades_access_control', false, false)) {
     $recs = DB::Execute('SELECT * FROM cades_access_control_data_1 WHERE active=1');
     $perms = array();
     $rm_acl = array();
     $count = 0;
     $done = 0;
     while ($r = $recs->FetchRow()) {
         if (!isset($rm_acl[$r['f_patient']])) {
             $rm_acl[$r['f_patient']] = array();
         }
         $rm_acl[$r['f_patient']][] = $r['id'];
         $field = Utils_RecordBrowserCommon::get_field_id(Utils_CommonDataCommon::get_value('CADES/AccessLevel/' . $r['f_permission_level']));
         $fields = explode('_', $field);
         foreach ($fields as $field) {
             if (!isset($perms[$r['f_patient']][$field])) {
                 $perms[$r['f_patient']][$field] = array();
             }
             $perms[$r['f_patient']][$field][] = $r['f_employee'];
         }
     }
     print 'Patients left: ' . count($perms) . '<br>';
     foreach ($perms as $patient => $v) {
         print 'Patient ' . $patient;
         Utils_RecordBrowserCommon::update_record('contact', $patient, $v);
         print '... cleanup... ';
         DB::StartTrans();
         foreach ($rm_acl[$patient] as $i) {