Exemple #1
0
<?php

/**
 * Download data
 *
 * @author Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2006, Telaxus LLC
 * @version 1.0
 * @license MIT
 * @package epesi-libs
 * @subpackage openflashchart
 */
if (!isset($_REQUEST['id']) || !isset($_REQUEST['chart'])) {
    die('Invalid usage');
}
$id = $_REQUEST['id'];
$chart_id = $_REQUEST['chart'];
define('CID', $id);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
$fn = Module::static_get_module_variable($chart_id, 'data', null);
echo $fn;
 /**
  * Get module info from cache or server.
  * @param numeric|array $module_id module id
  * @param boolean $force set true to force query to server
  * @return array modules data array
  */
 public static function get_module_info($module_id, $force = false)
 {
     $modules_cache = Module::static_get_module_variable(self::MOD_PATH, 'modules_info', array());
     $ret = array();
     $request = array();
     $return_array = is_array($module_id) ? true : false;
     if (!is_array($module_id)) {
         $module_id = array($module_id);
     }
     // split cached and modules for request.
     foreach ($module_id as $id) {
         if (!array_key_exists($id, $modules_cache) || $force) {
             $request[] = $id;
         } else {
             $ret[$id] = $modules_cache[$id];
         }
     }
     // request modules info and merge with cache and return value
     if (count($request)) {
         $response = Base_EssClientCommon::server()->module_get_info($request);
         if (is_array($response)) {
             foreach ($response as $k => $v) {
                 $ret[$k] = $v;
                 $modules_cache[$k] = $v;
             }
         }
     }
     Module::static_set_module_variable(self::MOD_PATH, 'modules_info', $modules_cache);
     // ret only one record if only one was requested
     return $return_array ? $ret : reset($ret);
 }
Exemple #3
0
    public function recordpicker_fs($crits, $cols, $order, $filters, $path) {
		self::$browsed_records = array();
        $this->init();
        $theme = $this->init_module('Base/Theme');
        Base_ThemeCommon::load_css($this->get_type(),'Browsing_records');
        $this->set_module_variable('rp_fs_path',$path);
        $selected = Module::static_get_module_variable($path,'selected',array());
        $theme->assign('filters', $this->show_filters($filters));
        $theme->assign('disabled', '');
        foreach ($crits as $k=>$v) {
            if (!is_array($v)) $v = array($v);
            if (isset($this->crits[$k]) && !empty($v)) {
                foreach ($v as $w) if (!in_array($w, $this->crits[$k])) $this->crits[$k][] = $w;
            } else $this->crits[$k] = $v;
        }
        $theme->assign('table', $this->show_data($this->crits, $cols, $order, false, true));
        if ($this->amount_of_records>=10000) {
            $theme->assign('disabled', '_disabled');
            $theme->assign('select_all', array('js'=>'', 'label'=>__('Select all')));
            $theme->assign('deselect_all', array('js'=>'', 'label'=>__('Deselect all')));
        } else {
            load_js('modules/Utils/RecordBrowser/RecordPickerFS/select_all.js');
            $theme->assign('select_all', array('js'=>'RecordPicker_select_all(1,\''.$this->get_path().'\',\''.__('Processing...').'\');', 'label'=>__('Select all')));
            $theme->assign('deselect_all', array('js'=>'RecordPicker_select_all(0,\''.$this->get_path().'\',\''.__('Processing...').'\');', 'label'=>__('Deselect all')));
        }

        load_js('modules/Utils/RecordBrowser/rpicker_fs.js');
        if (isset(self::$browsed_records['records'])) {
            foreach(self::$browsed_records['records'] as $id=>$i) {
                eval_js('rpicker_fs_init('.$id.','.(isset($selected[$id]) && $selected[$id]?1:0).',\''.$this->get_path().'\')');
            }
        }
/*
        $rpicker_ind = $this->get_module_variable('rpicker_ind');
        $init_func = 'init_all_rpicker_'.$element.' = function(id, cstring){';
        foreach($rpicker_ind as $v)
            $init_func .= 'rpicker_init(\''.$element.'\','.$v.');';
        $init_func .= '}';
        eval_js($init_func.';init_all_rpicker_'.$element.'();');*/
        $theme->display('Record_picker');
    }
Exemple #4
0
 * @author Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2006, Telaxus LLC
 * @version 1.0
 * @license MIT
 * @package epesi-libs
 * @subpackage tcpdf
 */
if (!isset($_REQUEST['id']) || !isset($_REQUEST['pdf']) || !isset($_REQUEST['filename'])) {
    die('Invalid usage');
}
$id = $_REQUEST['id'];
$pdf_id = $_REQUEST['pdf'];
$filename = $_REQUEST['filename'];
define('CID', $id);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
$fn = Module::static_get_module_variable($pdf_id, 'pdf', null);
if (headers_sent()) {
    die('Some data has already been output to browser, can\'t send PDF file');
}
if ($fn === null) {
    die('Invalid link');
}
if (!file_exists($fn)) {
    die('This file is no longer available, please refresh the page and download the file again');
}
$buffer = file_get_contents($fn);
header('Content-Type: application/pdf');
header('Content-Length: ' . strlen($buffer));
header('Content-disposition: filename="' . $filename . '"');
echo $buffer;
Exemple #5
0
 * @license MIT
 * @package epesi-utils
 * @subpackage RecordBrowser
 */
if (!isset($_REQUEST['cid']) || !isset($_REQUEST['path']) || !isset($_REQUEST['tab']) || !isset($_REQUEST['admin'])) {
    die('Invalid usage - missing param');
}
$cid = $_REQUEST['cid'];
$tab = $_REQUEST['tab'];
$admin = $_REQUEST['admin'];
$path = $_REQUEST['path'];
define('CID', $cid);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
$crits = Module::static_get_module_variable($path, 'crits_stuff', null);
$order = Module::static_get_module_variable($path, 'order_stuff', null);
if ($crits === null || $order === null) {
    $crits = $order = array();
}
ModuleManager::load_modules();
if (!Utils_RecordBrowserCommon::get_access($tab, 'export') && !Base_AclCommon::i_am_admin()) {
    die('Access denied');
}
set_time_limit(0);
$tab_info = Utils_RecordBrowserCommon::init($tab);
$records = Utils_RecordBrowserCommon::get_records($tab, $crits, array(), $order, array(), $admin);
header('Content-Type: text/csv');
//header('Content-Length: '.strlen($buffer));
header('Content-disposition: attachement; filename="' . $tab . '_export_' . date('Y_m_d__H_i_s') . '.csv"');
if (headers_sent()) {
    die('Some data has already been output to browser, can\'t send the file');
Exemple #6
0
 public static function get_profile_desc()
 {
     $profile_desc = Module::static_get_module_variable('/Base_Box|0/CRM_Filters|filter', 'profile_desc', '');
     return $profile_desc;
 }
Exemple #7
0
    die('alert(\'Invalid request\')');
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../../include.php';
foreach ($_POST as $k => $v) {
    $_POST[$k] = trim($v, '"');
}
$path = $_POST['path'];
$crits = Module::static_get_module_variable($path, 'crits_stuff', null);
$order = Module::static_get_module_variable($path, 'order_stuff', null);
$tab = Module::static_get_module_variable($path, 'tab', null);
$element = Module::static_get_module_variable($path, 'element', null);
$func = Module::static_get_module_variable($path, 'format_func', null);
$browsed_records = Module::static_get_module_variable($path, 'rpicker_ind', null);
ModuleManager::load_modules();
if ($tab === null || $browsed_records === null || $crits === null || $order === null || $element === null || $func === null) {
    die('alert(\'Invalid usage - variables not set (path - ' . $path . ', module vars - ' . epesi::escapeJS(print_r($_SESSION['client']['__module_vars__'][$path], true)) . ')\');');
}
$tab_info = Utils_RecordBrowserCommon::init($tab);
$records = Utils_RecordBrowserCommon::get_records($tab, $crits, array(), $order, array());
$js = '';
//foreach ($browsed_records as $r) {
//	$js .= '$(\'leightbox_rpicker_'.$element.'_'.$r.'\').checked='.($_POST['select']?1:0).';';
//}
foreach ($records as $row) {
    $js .= 'rpicker_move(\'' . $element . '\',' . $row['id'] . ',\'' . epesi::escapeJS(is_callable($func) ? htmlspecialchars_decode(strip_tags(call_user_func($func, $row, true))) : '') . '\',' . ($_POST['select'] ? 1 : 0) . ');';
}
$js .= 'Epesi.procOn--;Epesi.updateIndicator();';
//error_log($js."\n",3,'data/log.txt');
Exemple #8
0
 * @copyright Copyright &copy; 2008, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-Utils
 * @subpackage calendar
 */
if (!isset($_POST['path']) || !isset($_POST['cid']) || !isset($_POST['ev_id']) || !isset($_POST['cell_id'])) {
    die('alert(\'Invalid request\')');
}
$t = microtime(true);
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
ModuleManager::load_modules();
$mod = Module::static_get_module_variable($_POST['path'], 'event_module');
$ev_id = $_POST['ev_id'];
if (!$mod) {
    die('alert(\'Invalid request!\')');
}
if ($_POST['cell_id'] == 'trash') {
    $ret = call_user_func(array($mod . 'Common', 'delete'), $ev_id);
    if (!$ret) {
        print 'reject=true;';
    }
} else {
    if (!isset($_POST['page_type'])) {
        die('alert(\'Invalid request\')');
    }
    //update event
    $cc = explode('_', $_POST['cell_id']);
Exemple #9
0
 private static function copy_company_data_subroutine($values)
 {
     $access = Utils_RecordBrowserCommon::get_access('contact', 'edit', $values);
     if (!$access) {
         return;
     }
     /* First click should generate html code for leightbox and show it.
      * This function is rarely used and we don't want to increase page size.
      * To do this we use REQUEST variable UCD.
      *
      * We use module variable UCD to indicate that form was shown and we
      * must check if it was submitted. If yes - do action. If it wasn't
      * we should come back to initial state - do not print LB.
      */
     if (!(isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0))) {
         if (isset($values['company_name']) && $values['company_name']) {
             Base_ActionBarCommon::add('edit', __('Copy company data'), Module::create_href(array('UCD' => true)));
         }
     }
     if (isset($_REQUEST['UCD']) || Module::static_get_module_variable('CRM/Contacts', 'UCD', 0)) {
         $ucd = Module::static_get_module_variable('CRM/Contacts', 'UCD', 0);
         $ucd++;
         if ($ucd > 1) {
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
         } else {
             Module::static_set_module_variable('CRM/Contacts', 'UCD', $ucd);
         }
         $lid = 'UCDprompt';
         $form = ModuleManager::new_instance('Libs_QuickForm', null, 'QFUCDprompt');
         $form->construct();
         $sel_val = array();
         foreach (array_merge(array($values['company_name']), is_array($values['related_companies']) ? $values['related_companies'] : array()) as $id) {
             $sel_val[$id] = self::company_format_default(self::get_company($id), true);
         }
         $form->addElement('select', 'company', __('Select company:'), $sel_val);
         unset($sel_val);
         $form->addElement('html', __('Select which fields should be copied:'));
         $data = array(array('sid' => 'address_1', 'tid' => 'address_1', 'text' => __('Address 1'), 'checked' => true), array('sid' => 'address_2', 'tid' => 'address_2', 'text' => __('Address 2'), 'checked' => true), array('sid' => 'city', 'tid' => 'city', 'text' => __('City'), 'checked' => true), array('sid' => 'country', 'tid' => 'country', 'text' => __('Country'), 'checked' => true), array('sid' => 'zone', 'tid' => 'zone', 'text' => __('Zone'), 'checked' => true), array('sid' => 'postal_code', 'tid' => 'postal_code', 'text' => __('Postal Code'), 'checked' => true), array('sid' => 'phone', 'tid' => 'work_phone', 'text' => __('Phone as Work Phone'), 'checked' => false), array('sid' => 'fax', 'tid' => 'fax', 'text' => __('Fax'), 'checked' => false));
         foreach ($data as $row) {
             if (is_array($access) && isset($access[$row['tid']]) && $access[$row['tid']]) {
                 $form->addElement('checkbox', $row['sid'], $row['text'], '', $row['checked'] ? array('checked' => 'checked') : array());
             }
         }
         $ok = $form->createElement('submit', 'submit', __('Confirm'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $cancel = $form->createElement('button', 'cancel', __('Cancel'), array('onclick' => 'leightbox_deactivate("' . $lid . '")'));
         $form->addGroup(array($ok, $cancel));
         if ($form->validate()) {
             $Uvalues = $form->exportValues();
             $fields = array();
             foreach ($data as $row) {
                 if (array_key_exists($row['sid'], $Uvalues)) {
                     $fields[$row['tid']] = $row['sid'];
                 }
             }
             if (isset($Uvalues['company'])) {
                 $company = CRM_ContactsCommon::get_company($Uvalues['company']);
                 $new_data = array();
                 foreach ($fields as $k => $v) {
                     $new_data[$k] = $company[$v];
                 }
                 Utils_RecordBrowserCommon::update_record('contact', $values['id'], $new_data);
             }
             Module::static_unset_module_variable('CRM/Contacts', 'UCD');
             location(array());
         }
         // set default to main company
         if ($mc = self::get_main_company()) {
             $form->setDefaults(array('company' => $mc));
         }
         $html = $form->toHtml();
         Libs_LeightboxCommon::display($lid, $html);
         Base_ActionBarCommon::add('edit', __('Copy company data'), Libs_LeightboxCommon::get_open_href($lid));
         if (isset($_REQUEST['UCD'])) {
             eval_js('leightbox_activate(\'' . $lid . '\')');
         }
         unset($_REQUEST['UCD']);
     }
 }
Exemple #10
0
 private static function format_client_messages($cleanup = true)
 {
     $msgs = Module::static_get_module_variable('Base/EssClient', 'messages', array(array(), array(), array()));
     $red = '#FFCCCC';
     $orange = '#FFDD99';
     $green = '#DDFF99';
     $ret = self::format_messages_frame($red, __('Error messages') . ':', $msgs[2]) . self::format_messages_frame($orange, __('Warning messages') . ':', $msgs[1]) . self::format_messages_frame($green, __('Information messages') . ':', $msgs[0]);
     if ($cleanup) {
         Module::static_unset_module_variable('Base/EssClient', 'messages');
     }
     return $ret;
 }
Exemple #11
0
 * @copyright Copyright &copy; 2006, Telaxus LLC
 * @license MIT
 * @version 1.0
 * @package epesi-utils
 * @subpackage FileDownload
 */
if (!isset($_POST['path'])) {
    die('Invalid request');
}
$path = $_POST['path'];
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
if (!Module::static_isset_module_variable($path, 'download_id')) {
    return;
}
$download_id = Module::static_get_module_variable($path, 'download_id');
$ret = DB::Execute('SELECT size,curr,time,rate FROM utils_filedownload_files WHERE id=%d', array($download_id));
$row = $ret->FetchRow();
if ($row['size'] == -2) {
    print 'File not found.';
    return;
}
if ($row['size'] == -1) {
    print 'Connecting...';
    return;
}
if ($row['curr'] == $row['size']) {
    print 'Finished';
    return;
}
$t = microtime(true);
Exemple #12
0
 * @author Paul Bukowski <*****@*****.**>
 * @copyright Copyright &copy; 2006, Telaxus LLC
 * @version 1.0
 * @license MIT
 * @package epesi-libs
 * @subpackage tcpdf
 */
if (!isset($_REQUEST['id']) || !isset($_REQUEST['p']) || !isset($_REQUEST['filename'])) {
    die('Invalid usage');
}
$id = $_REQUEST['id'];
$p = $_REQUEST['p'];
$filename = $_REQUEST['filename'];
define('CID', $id);
define('READ_ONLY_SESSION', true);
require_once '../../../../include.php';
$csv = Module::static_get_module_variable($p, 'csv', null);
if (headers_sent()) {
    die('Some data has already been output to browser, can\'t send PDF file');
}
if ($csv === null) {
    die('Invalid link');
}
header('Content-Type: text/csv');
//header('Content-Length: '.strlen($buffer));
header('Content-disposition: attachment;filename="' . $filename . '.csv"');
$fp = fopen('php://output', 'w');
foreach ($csv as $array) {
    fputcsv($fp, $array);
}
fclose($fp);
Exemple #13
0
 */
if (!isset($_POST['select']) || !isset($_POST['path']) || !isset($_POST['cid'])) {
    die('alert(\'Invalid request\')');
}
define('JS_OUTPUT', 1);
define('CID', $_POST['cid']);
require_once '../../../../include.php';
foreach ($_POST as $k => $v) {
    $_POST[$k] = trim($v, '"');
}
$path = $_POST['path'];
$select = json_decode($_POST['select']);
$tab = Module::static_get_module_variable($path, 'tab', null);
$crits = Module::static_get_module_variable($path, 'crits_stuff', null);
$rp_path = Module::static_get_module_variable($path, 'rp_fs_path', null);
$selected =& Module::static_get_module_variable($rp_path, 'selected', array());
ModuleManager::load_modules();
if ($tab === null || $crits === null || $rp_path === null) {
    die('alert(\'Invalid usage - variables not set (path - ' . $path . ', module vars - ' . epesi::escapeJS(print_r($_SESSION['client']['__module_vars__'][$path], true)) . ')\');');
}
$tab_info = Utils_RecordBrowserCommon::init($tab);
$records = Utils_RecordBrowserCommon::get_records($tab, $crits, array('id'));
foreach ($records as $r) {
    if ($select) {
        $selected[$r['id']] = 1;
    } else {
        unset($selected[$r['id']]);
    }
}
session_commit();
print 'Epesi.procOn--;_chj(\'\',\'\',\'queue\');';
Exemple #14
0
 * @version 1.0
 * @license MIT
 * @package epesi-libs
 * @subpackage exportxls
 */
if (!isset($_REQUEST['id']) || !isset($_REQUEST['xls']) || !isset($_REQUEST['args']) || !isset($_REQUEST['filename'])) {
    die('Invalid usage');
}
$id = $_REQUEST['id'];
$args = $_REQUEST['args'];
$xls_id = $_REQUEST['xls'];
$filename = $_REQUEST['filename'];
define('CID', $id);
define('READ_ONLY_SESSION', true);
require_once '../../../include.php';
$fn = Module::static_get_module_variable($xls_id, 'callback', null);
if (headers_sent()) {
    die('Some data has already been output to browser, can\'t send PDF file');
}
if ($fn === null) {
    die('Invalid link');
}
ModuleManager::load_modules();
if (!is_callable($fn)) {
    die('Invalid callback');
}
$buffer = call_user_func_array($fn, $args);
header('Content-Type: application/xls');
header('Content-Length: ' . strlen($buffer));
header('Content-disposition: attachement; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');