Ejemplo n.º 1
0
    public function handle_hook($hook_name)
    {
        if ($hook_name == 'top_menu_end' && module_config::c('timer_enabled', 1) && module_security::is_logged_in() && self::can_i('view', 'Task Timer') && get_display_mode() != 'mobile') {
            ?>

            <li id="timer_menu_button">
                <div id="timer_menu_options">
                    <div class="timer_title">
                        <?php 
            _e('Active Timers');
            ?>

                    </div>
                    <ul id="active_timer_list">
                    </ul>
                </div>
                <a href="#" onclick="return false;" title="<?php 
            _e('Timer');
            ?>
"><span><?php 
            _e('Timers');
            ?>
<span class="menu_label" id="current_timer_count">1</span></span></a>
            </li>
            <?php 
        }
    }
Ejemplo n.º 2
0
 function init()
 {
     $this->module_name = "language";
     $language_code = basename(module_config::c('default_language'));
     if (module_security::is_logged_in()) {
         $user = module_user::get_user(module_security::get_loggedin_id(), false);
         if ($user && $user['user_id'] && isset($user['language']) && $user['language']) {
             $language_code = basename($user['language']);
         }
     }
     // language code, like en, gb, etc..
     self::set_ui_language($language_code);
 }
Ejemplo n.º 3
0
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_config::can_i('view', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
$show_theme_selector = false;
$themes = module_theme::get_available_themes();
if (count($themes) > 1) {
    $show_theme_selector = true;
}
if ($show_theme_selector) {
    $settings = array(array('key' => 'theme_name', 'default' => 'default', 'type' => 'select', 'options' => $themes, 'options_array_id' => 'name', 'description' => 'Default theme to use'), array('key' => _THEME_CONFIG_PREFIX . 'theme_logo', 'default' => _BASE_HREF . 'images/logo.png', 'type' => 'text', 'description' => 'URL for header logo'), array('key' => _THEME_CONFIG_PREFIX . 'theme_favicon', 'default' => '', 'type' => 'text', 'description' => 'URL for favicon', 'help' => 'Please google for "How to make a favicon". It should be a small PNG or ICO image.'), array('key' => _THEME_CONFIG_PREFIX . 'theme_custom_css', 'default' => '', 'type' => 'textarea', 'description' => 'Custom CSS Code', 'help' => 'Add your own custom CSS code here and it will be included in all pages of the website. You may have to clear your browser cache in order to see these changes. This code is added to the "ext.php?m=theme&amp;h=css" file if you are looking at the page source code.'));
    if (module_security::is_logged_in() && module_config::c('theme_per_user', 0)) {
        $default_theme = is_dir('includes/plugin_theme/themes/metis/') ? 'metis' : 'default';
        $settings[] = array('key' => 'theme_name_' . module_security::get_loggedin_id(), 'default' => module_config::c('theme_name', $default_theme), 'options' => $themes, 'options_array_id' => 'name', 'type' => 'select', 'description' => 'Theme to use when logged into your account');
    }
    module_config::print_settings_form(array('title' => _l('Theme Settings'), 'settings' => $settings));
}
?>

<form action="" method="post">
    <input type="hidden" name="_config_settings_hook" value="save_config">

    <?php 
module_form::print_form_auth();
module_form::prevent_exit(array('valid_exits' => array('.submit_button')));
?>
Ejemplo n.º 4
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca, 0a3014a3-2b8f-460b-8850-d6025aa845f8
 * Package Date: 2015-11-25 03:08:17 
 * IP Address: 67.79.165.254
 */
$start_search_time = microtime(true);
$noredirect = true;
header('Content-Type: text/html; charset=UTF-8');
require_once 'init.php';
if (module_security::is_logged_in()) {
    if (!isset($_SESSION['previous_search'])) {
        $_SESSION['previous_search'] = array();
    }
    $search_text = isset($_REQUEST['ajax_search_text']) ? trim(urldecode($_REQUEST['ajax_search_text'])) : false;
    if ($search_text) {
        $search_results = array();
        foreach ($plugins as $plugin_name => &$plugin) {
            // we work out if we bother searching this plugin for results or not.
            if (strlen($search_text) > module_config::c('search_ajax_min_length', 2)) {
                if (isset($_SESSION['previous_search'][$plugin_name]) && $_SESSION['previous_search'][$plugin_name]['c'] == 0 && strlen($search_text) >= strlen($_SESSION['previous_search'][$plugin_name]['l']) && strpos($search_text, $_SESSION['previous_search'][$plugin_name]['l']) === 0) {
                    $_SESSION['previous_search'][$plugin_name]['l'] = $search_text;
                    // not really needed. but when you backspace a failed search it will force refresh all which might be good.
                    //$this_plugin_results=array('skipping ' . $search_text.' in '.$plugin_name.' last search was '.$_SESSION['previous_search'][$plugin_name]['l'],);
                    continue;
                } else {
Ejemplo n.º 5
0
 public function init()
 {
     $this->module_name = "config";
     $this->module_position = 40;
     $this->version = 2.416;
     //2.416 - 2015-06-07 - new settings button
     //2.415 - 2015-04-05 - stuck plugin update fix
     //2.414 - 2015-04-05 - character encoding fix
     //2.413 - 2015-03-14 - speed improvement
     //2.412 - 2015-02-08 - theme/custom override js file support
     //2.411 - 2015-01-20 - more speed improvements
     //2.41 - 2014-12-22 - ssl fix
     //2.4 - 2014-11-17 - much faster upgrade system
     //2.393 - 2014-11-04 - upgrade page improvement
     //2.392 - 2014-11-04 - upgrade page improvement
     //2.391 - 2014-10-07 - showing latest updates/blog posts in upgrade window.
     //2.39 - 2014-09-29 - faster update checking
     //2.389 - 2014-09-05 - improved config defaults
     //2.388 - 2014-08-12 - faster updates
     //2.387 - 2014-08-10 - fixed updater
     //2.386 - 2014-08-10 - fixed updater
     //2.385 - 2014-08-10 - progress showing in upgrader
     //2.384 - 2014-08-09 - bug fix for older jquery
     //2.383 - 2014-08-06 - better js handling
     //2.382 - 2014-07-25 - faster updates
     //2.381 - 2014-07-09 - js_combine / css_combine for much faster page loading
     //2.38 - 2014-07-05 - js_combine / css_combine for much faster page loading
     //2.379 - 2014-07-02 - js_combine / css_combine for much faster page loading
     //2.378 - 2014-03-12 - improved upgrader
     //2.377 - 2014-02-25 - improved installer
     //2.376 - 2013-11-13 - company config bug fix
     //2.375 - 2013-10-06 - software update reminder on dashboard
     //2.374 - 2013-10-05 - settings page improvement
     //2.373 - 2013-09-06 - installation improvement
     //2.372 - 2013-09-01 - fix for cache bug
     //2.371 - 2013-06-21 - different config vars per company
     //2.37 - 2013-04-30 - clearer upgrade instructions
     //2.31 - putting date_input to the general settings area
     //2.32 - friendly licence code names
     //2.33 - menu fix.
     //2.34 - js / css callbacks
     //2.35 - skipping custom files in the upgrade process
     //2.36 - permission fixes
     //2.361 - memory limit via config
     //2.362 - memory limit fix
     //2.363 - upload php limit fix
     //2.364 - php5/6 fix
     //2.365 - date format settings fix
     //2.366 - css/js updates
     //2.367 - css loading fix
     //2.368 - upgrade fixing
     //2.369 - click to edit config values
     // load some default configurations.
     if (!defined('_DATE_FORMAT')) {
         define('_DATE_FORMAT', module_config::c('date_format', 'd/m/Y'));
         // todo: read from database
     }
     if (!defined('_DATE_INPUT')) {
         // 1 = DD/MM/YYYY
         // 2 = YYYY/MM/DD
         // 3 = MM/DD/YYYY
         define('_DATE_INPUT', module_config::c('date_input', '1'));
     }
     if (!defined('_ERROR_EMAIL')) {
         define('_ERROR_EMAIL', module_config::c('admin_email_address', 'info@' . $_SERVER['HTTP_HOST']));
     }
     date_default_timezone_set(module_config::c('timezone', 'America/New_York'));
     if (module_security::is_logged_in() && isset($_POST['_config_settings_hook']) && $_POST['_config_settings_hook'] == 'save_config') {
         $this->_handle_save_settings_hook();
     }
     // try to set our memory limit.
     $desired_limit_r = module_config::c('php_memory_limit', '64M');
     $desired_limit = trim($desired_limit_r);
     $last = strtolower($desired_limit[strlen($desired_limit) - 1]);
     switch ($last) {
         // The 'G' modifier is available since PHP 5.1.0
         case 'g':
             $desired_limit *= 1024;
         case 'm':
             $desired_limit *= 1024;
         case 'k':
             $desired_limit *= 1024;
     }
     $memory_limit = ini_get('memory_limit');
     $val = trim($memory_limit);
     $last = strtolower($val[strlen($val) - 1]);
     switch ($last) {
         // The 'G' modifier is available since PHP 5.1.0
         case 'g':
             $val *= 1024;
         case 'm':
             $val *= 1024;
         case 'k':
             $val *= 1024;
     }
     if (!$memory_limit || $val < $desired_limit) {
         // try to increase to 64M
         if (!_DEMO_MODE) {
             @ini_set('memory_limit', $desired_limit_r);
         }
     }
     /*
             // try to set our post_max_size limit.
             $desired_limit_r = module_config::c('php_post_max_size','10M');
             $desired_limit = trim($desired_limit_r);
             $last = strtolower($desired_limit[strlen($desired_limit)-1]);
             switch($last) {
                 // The 'G' modifier is available since PHP 5.1.0
                 case 'g':
                     $desired_limit *= 1024;
                 case 'm':
                     $desired_limit *= 1024;
                 case 'k':
                     $desired_limit *= 1024;
             }
     
             $post_max_size_limit = ini_get('post_max_size');
             $val = trim($post_max_size_limit);
             $last = strtolower($val[strlen($val)-1]);
             switch($last) {
                 // The 'G' modifier is available since PHP 5.1.0
                 case 'g':
                     $val *= 1024;
                 case 'm':
                     $val *= 1024;
                 case 'k':
                     $val *= 1024;
             }
     
     
             if(!$post_max_size_limit || $val < $desired_limit){
                 // try to increase to 64M
                 if(!_DEMO_MODE){
                     @ini_set('post_max_size',$desired_limit_r);
                 }
             }*/
     self::register_js('config', 'settings.js');
 }
Ejemplo n.º 6
0
    public function init()
    {
        $this->links = array();
        $this->product_types = array();
        $this->module_name = "product";
        $this->module_position = 31;
        $this->version = 2.155;
        // 2.155 - 2015-07-18 - product search
        // 2.154 - 2015-06-28 - started work on product API
        // 2.153 - 2015-02-12 - ui fix and product defaults (tax/bill/type)
        // 2.152 - 2014-01-23 - new quote feature
        // 2.151 - 2013-11-15 - working on new UI
        // 2.15 - 2013-10-02 - bulk product delete and product category import fix
        // 2.149 - 2013-09-08 - faq permission fix
        // 2.148 - 2013-08-07 - css improvement
        // 2.147 - 2013-06-16 - javascript fix
        // 2.146 - 2013-06-07 - further work on product categories
        // 2.145 - 2013-05-28 - further work on product categories
        // 2.144 - 2013-05-28 - started work on product categories
        // 2.143 - 2013-04-27 - css fix for large product list
        // 2.142 - 2013-04-16 - product fix in invoice
        // 2.141 - 2013-04-05 - product support in invoices
        // 2.14 - product import via CSV
        // 2.13 - permission fix
        // 2.12 - product permissions
        // 2.11 - initial release
        hook_add('api_callback_product', 'module_product::api_filter_product');
        if (module_security::is_logged_in() && self::can_i('view', 'Products')) {
            module_config::register_css('product', 'product.css');
            module_config::register_js('product', 'product.js');
            if (isset($_REQUEST['_products_ajax'])) {
                switch ($_REQUEST['_products_ajax']) {
                    case 'products_ajax_search':
                        //                        $sent = headers_sent($file, $line);
                        //                        echo 'here';
                        //                        print_r($sent);
                        //                        print_r($file);
                        //                        print_r($line);
                        if (self::$_product_count === false) {
                            self::$_product_count = count(self::get_products());
                        }
                        $product_name = isset($_REQUEST['product_name']) ? $_REQUEST['product_name'] : '';
                        if (self::$_product_count > 0) {
                            $search = array();
                            if (strlen($product_name) > 2) {
                                $search['general'] = $product_name;
                            }
                            $products = self::get_products($search);
                            if (count($products) > 0) {
                                // sort products by categories.
                                $products_in_categories = array();
                                foreach ($products as $product_id => $product) {
                                    if ($product['product_category_id'] && $product['product_category_name']) {
                                        if (!isset($products_in_categories[$product['product_category_name']])) {
                                            $products_in_categories[$product['product_category_name']] = array();
                                        }
                                        $products_in_categories[$product['product_category_name']][] = $product;
                                        unset($products[$product_id]);
                                    } else {
                                    }
                                }
                                $cat_id = 1;
                                ?>

                                <ul>
                                    <?php 
                                foreach ($products_in_categories as $category_name => $cat_products) {
                                    ?>

                                        <li>
                                            <a href="#" class="product_category_parent"><?php 
                                    echo htmlspecialchars($category_name);
                                    ?>
</a> (<?php 
                                    _e('%s products', count($cat_products));
                                    ?>
)
                                            <ul style="display:none;" id="product_category_<?php 
                                    echo $cat_id++;
                                    ?>
">
                                                <?php 
                                    foreach ($cat_products as $product) {
                                        ?>

                                                    <li>
                                                       <a href="#" onclick="return ucm.product.select_product(<?php 
                                        echo $product['product_id'];
                                        ?>
);"> <?php 
                                        echo htmlspecialchars($product['name']);
                                        ?>
</a>
                                                    </li>
                                                <?php 
                                    }
                                    ?>

                                            </ul>

                                    <?php 
                                }
                                ?>

                                    <?php 
                                foreach ($products as $product) {
                                    ?>

                                    <li>
                                        <a href="#" onclick="return ucm.product.select_product(<?php 
                                    echo $product['product_id'];
                                    ?>
);"><?php 
                                    /*if($product['product_category_name']){
                                          echo htmlspecialchars($product['product_category_name']);
                                          echo ' &raquo; ';
                                      }*/
                                    echo htmlspecialchars($product['name']);
                                    ?>
</a>
                                    </li>
                                    <?php 
                                }
                                ?>

                                </ul>
                                <?php 
                            }
                        } else {
                            if (!strlen($product_name)) {
                                _e('Pleae create Products first by going to Settings > Products');
                            }
                        }
                        exit;
                    case 'products_ajax_get':
                        $product_id = (int) $_REQUEST['product_id'];
                        if ($product_id) {
                            $product = self::get_product($product_id);
                        } else {
                            $product = array();
                        }
                        echo json_encode($product);
                        exit;
                }
            }
        }
    }
Ejemplo n.º 7
0
 public function replace_content()
 {
     $content = $this->content;
     $this->add_tags($this->template_key, $this->values);
     // add todays date values
     if (!isset($this->values['day'])) {
         $this->values['day'] = date('d');
     }
     if (!isset($this->values['month'])) {
         $this->values['month'] = date('m');
     }
     if (!isset($this->values['year'])) {
         $this->values['year'] = date('y');
     }
     if (!isset($this->values['current_user']) && module_security::is_logged_in()) {
         $this->values['current_user'] = module_security::get_loggedin_id();
         $user_details = module_user::get_replace_fields(module_security::get_loggedin_id());
         foreach ($user_details as $key => $val) {
             $this->values['current_' . $key . ''] = $val;
         }
     }
     // basic conditional tags - eg: {if:name}Dear {name},{else:name}Hello,{endif:name}
     // todo - support nested if - pass to template module.
     $debug = false;
     if (preg_match_all('#\\{if:([^\\}=]+)([^\\}]*)\\}(.*){endif:\\1\\}.*#imsU', $content, $matches)) {
         foreach ($matches[1] as $key => $template_tag) {
             // does this first if have a conditional statement (eg: {if:STATUS=New}sdfasdf{else}asdfasdf{/if:STATUS}
             $bits = preg_split('#{else[^\\}]*}#', $matches[3][$key]);
             preg_match_all('#\\{(else)?(if:([^\\}=]+)([^\\}]*))?\\}#ims', $matches[0][$key], $elseif_matches);
             $new_content = false;
             if ($debug) {
                 echo $matches[0][$key] . "\n";
             }
             if ($debug) {
                 print_r($bits);
             }
             if ($debug) {
                 print_r($elseif_matches);
             }
             foreach ($elseif_matches[0] as $elseif_key => $elseif_condition) {
                 $template_tag_value = isset($this->values[strtolower($elseif_matches[3][$elseif_key])]) ? trim($this->values[strtolower($elseif_matches[3][$elseif_key])]) : '';
                 if (!strlen(trim($elseif_matches[3][$elseif_key]))) {
                     // we are at the final {else} statement, this means all other checks before have failed. we use this content.
                     if ($debug) {
                         echo "Reached final {else} statement, using this value\n";
                     }
                     $new_content = $bits[$elseif_key];
                     break;
                 } else {
                     if ($debug) {
                         echo "Checking {$elseif_condition} against " . $elseif_matches[3][$elseif_key] . " which has the value: " . $template_tag_value . "\n";
                     }
                     if (strlen($elseif_matches[4][$elseif_key]) && $elseif_matches[4][$elseif_key][0] == '=') {
                         // the if/elseif tag is checking a condition, rather than just an "does exist" check
                         $check_matching_value = ltrim(trim($elseif_matches[4][$elseif_key]), '=');
                         if ($debug) {
                             echo "Checking if it matches {$check_matching_value} \n";
                         }
                         if ($check_matching_value == $template_tag_value) {
                             if ($debug) {
                                 echo "YES WE HAVE A MATCH \n";
                             }
                             // this first if statement matches this query! yes!
                             // use its value in the final $new_content
                             $new_content = $bits[$elseif_key];
                             break;
                         } else {
                             if ($debug) {
                                 echo "No match this time \n";
                             }
                         }
                     } else {
                         // we're just checking if this value exists or not.
                         if (strlen($template_tag_value) > 0 && $template_tag_value != '0000-00-00' && $template_tag_value != _l('N/A')) {
                             // it's a match!
                             $new_content = $bits[$elseif_key];
                             break;
                         } else {
                             // no match, move onto next bit.
                         }
                     }
                 }
             }
             if ($debug) {
                 echo "Final content to use will be: \n" . $new_content;
             }
             $content = str_replace($matches[0][$key], $new_content, $content);
         }
     }
     foreach ($this->values as $key => $val) {
         if (is_array($val)) {
             continue;
         }
         // if this isn't a html field we add newlines.
         if (!preg_match('#<[^>]+>#', $val)) {
             // raw text. nl2br
             $val = nl2br($val);
         }
         $content = str_replace('{' . strtoupper($key) . '}', $val, $content);
         // we perform some basic arithmetic on some replace fields.
         if (preg_match_all('#\\{(currency:)?' . preg_quote(strtoupper($key), '#') . '([*+-])([\\d\\.]+)\\}#', $content, $matches)) {
             // pull the "number" portion out of this string for math processing.
             // string could look like this: "$150.10 USD"
             $mathval = $originalval = $val;
             if (preg_match('#([\\d.,]+)#', $val, $mathvalmatches)) {
                 $mathval = $originalval = $mathvalmatches[1];
             }
             foreach ($matches[0] as $i => $v) {
                 $mathval = $originalval;
                 if ($matches[2][$i] == '-') {
                     $mathval = $mathval - $matches[3][$i];
                 } else {
                     if ($matches[2][$i] == '+') {
                         $mathval = $mathval + $matches[3][$i];
                     } else {
                         if ($matches[2][$i] == '*') {
                             $mathval = $mathval * $matches[3][$i];
                         }
                     }
                 }
                 if (strtolower($matches[1][$i]) == 'currency:') {
                     $mathval = dollar($mathval, true, isset($this->values['currency_id']) ? $this->values['currency_id'] : false);
                 }
                 $newval = str_replace($originalval, $mathval, $val);
                 $content = str_replace($v, $newval, $content);
             }
         }
         if (preg_match_all('#\\{currency:(' . preg_quote(strtoupper($key), '#') . ')\\}#', $content, $matches)) {
             foreach ($matches[0] as $i => $v) {
                 $content = str_replace($v, dollar($val, true, isset($this->values['currency_id']) ? $this->values['currency_id'] : false), $content);
             }
         }
         // we perform some arithmetic on date fields.
         $matches = false;
         if (stripos($key, 'date') !== false && $val && strlen($val) > 6 && preg_match_all('#' . preg_quote('{' . strtoupper($key), '#') . '((?>[+-]\\d+[ymd])*)\\}#', $content, $matches)) {
             //$processed_date = (input_date($val)); $processed_date_timeo =
             $processed_date_time = strtotime(input_date($val));
             foreach ($matches[0] as $i => $v) {
                 if (preg_match_all('#([+-])(\\d+)([ymd])#', $matches[1][$i], $date_math)) {
                     foreach ($date_math[1] as $di => $dv) {
                         $period = $date_math[3][$di];
                         $period = $period == 'd' ? 'day' : ($period == 'm' ? 'month' : ($period == 'y' ? 'year' : 'days'));
                         //echo $dv.$date_math[2][$di]." ".$period."\n";
                         $processed_date_time = strtotime($dv . $date_math[2][$di] . " " . $period, $processed_date_time);
                     }
                     $content = str_replace($v, print_date($processed_date_time), $content);
                     //echo "Processing date: $val - $processed_date (time: $processed_date_timeo / ".print_date($processed_date_timeo).") with result of: ".print_date($processed_date_time); exit;
                 }
             }
         }
         // we perform some date splitting
         $matches = false;
         if (stripos($key, 'date') !== false && $val && strlen($val) > 6 && preg_match_all('#' . preg_quote('{' . strtoupper($key), '#') . '-([ymdYMDjlSWFn])\\}#', $content, $matches)) {
             $processed_date_time = strtotime(input_date($val));
             foreach ($matches[0] as $i => $v) {
                 $content = str_replace($v, date($matches[1][$i], $processed_date_time), $content);
             }
         }
         //$val = str_replace(array('\\', '$'), array('\\\\', '\$'), $val);
         //$content = preg_replace('/\{'.strtoupper(preg_quote($key,'/')).'\}/',$val,$content);
     }
     if (preg_match_all('#\\{l:([^\\}]+)\\}#', $content, $matches)) {
         foreach ($matches[1] as $key => $label) {
             $content = str_replace($matches[0][$key], _l($label), $content);
         }
     }
     return $content;
 }
Ejemplo n.º 8
0
 public static function run_cron($debug = false)
 {
     // we only want to perform these cron actions if we're after a certain time of day
     // because we dont want to be generating these renewals and sending them at midnight, can get confusing
     $after_time = module_config::c('invoice_automatic_after_time', 7);
     $time_of_day = date('G');
     if ($time_of_day < $after_time) {
         if ($debug) {
             echo "Not performing automatic subscription operations until after {$after_time}:00 - it is currently {$time_of_day}:" . date('i') . "<br>\n";
         }
         return;
     }
     // find all automatic subscriptions and renew them (if applicable)
     $sql = "SELECT * FROM `" . _DB_PREFIX . "subscription` s ";
     $sql .= " WHERE s.automatic_renew = 1";
     $subscriptions = qa($sql);
     foreach ($subscriptions as $subscription) {
         if ($subscription['automatic_renew']) {
             if ($debug) {
                 echo "<br>\nProcessing subscription renewals for subscription " . module_subscription::link_open($subscription['subscription_id'], true) . "<br>\n<br>\n";
             }
             // find all the members/customers from this subscription
             //$members = module_subscription::get_subscribed_members($subscription['subscription_id']);
             //$customers = module_subscription::get_subscribed_customers($subscription['subscription_id']);
             $owners = module_subscription::get_subscribed_owners($subscription['subscription_id']);
             foreach ($owners as $member) {
                 if (!$member['next_generation_date'] || $member['next_generation_date'] == '0000-00-00') {
                     continue;
                 }
                 if (!$member['next_due_date'] || $member['next_due_date'] == '0000-00-00') {
                     continue;
                 }
                 if ($debug) {
                     echo "Doing: " . $member['owner_table'] . " " . $member['owner_id'] . "<br>\n";
                 }
                 // check permissions for logged in users, dont want the cron to run when someone is logged in and no access to this account.
                 if (module_security::is_logged_in()) {
                     switch ($member['owner_table']) {
                         case 'website':
                             $website_perm_check = module_website::get_website($member['owner_id']);
                             if (!$website_perm_check || $website_perm_check['website_id'] != $member['owner_id']) {
                                 continue 2;
                             }
                             if ($debug) {
                                 echo "permission pass for website: " . $website_perm_check['website_id'];
                             }
                             break;
                         case 'customer':
                             $customer_perm_check = module_customer::get_customer($member['owner_id']);
                             if (!$customer_perm_check || $customer_perm_check['customer_id'] != $member['owner_id']) {
                                 continue 2;
                             }
                             if ($debug) {
                                 echo "permission pass for customer: " . $customer_perm_check['customer_id'];
                             }
                             break;
                     }
                 }
                 // is the last invoice unpaid?
                 $history = self::get_subscription_history($subscription['subscription_id'], $member['owner_table'], $member['owner_id']);
                 $next_due_time_invoice_created = false;
                 $invoice_unpaid = false;
                 if (isset($member['recur_limit']) && (int) $member['recur_limit'] > 0 && count($history) >= (int) $member['recur_limit']) {
                     if ($debug) {
                         echo " - not renewing this one because it has hit our recur limit of " . $member['recur_limit'] . "<br>\n";
                     }
                     continue;
                 }
                 foreach ($history as $h) {
                     $last_invoice = module_invoice::get_invoice($h['invoice_id']);
                     if (!$last_invoice || $last_invoice['date_cancel'] != '0000-00-00') {
                         continue;
                     }
                     // check the new 'next_due_date' entry in the db table
                     if (isset($h['from_next_due_date']) && $h['from_next_due_date'] && $h['from_next_due_date'] != '0000-00-00') {
                         // we're using the new method of checking when an invoice was generated, rather than the confusing invoice 'date_create' check below
                         if ($debug) {
                             echo " - checking if next_due_date " . print_date($member['next_due_date']) . " matches subscription history from_next_due_date for invoice " . module_invoice::link_open($h['invoice_id'], true, $last_invoice) . " from_next_due_date: " . print_date($h['from_next_due_date']) . " (invoice create_date: " . print_date($last_invoice['date_create']) . ")<br>\n";
                         }
                         if (print_date($member['next_due_date']) == print_date($h['from_next_due_date'])) {
                             //print_date($last_invoice['date_create'])){
                             // this invoice is for the next due date.
                             $next_due_time_invoice_created = $last_invoice;
                         }
                     } else {
                         if ($debug) {
                             echo " - checking if next_generation_date (" . print_date($member['next_generation_date']) . ") or next_due_date (" . print_date($member['next_due_date']) . ") matches invoice " . module_invoice::link_open($h['invoice_id'], true, $last_invoice) . " created date (" . print_date($last_invoice['date_create']) . ") <br>\n";
                         }
                         if (print_date($member['next_generation_date']) == print_date($last_invoice['date_create']) || print_date($member['next_due_date']) == print_date($last_invoice['date_create'])) {
                             //print_date($last_invoice['date_create'])){
                             // this invoice is for the next due date.
                             $next_due_time_invoice_created = $last_invoice;
                         }
                     }
                     if ($last_invoice['total_amount_due'] > 0) {
                         $invoice_unpaid = true;
                     }
                 }
                 //self::generate_subscription_invoice($subscription_id, $customer_hack, $member_id, $date, $amount)
                 $next_due_time = strtotime($member['next_generation_date']);
                 if ($debug) {
                     echo " - next subscription time is " . $member['next_generation_date'] . " <br>\n";
                 }
                 if ($next_due_time <= strtotime(date('Y-m-d')) && !$next_due_time_invoice_created) {
                     if ($debug) {
                         echo " - Yes its time to generate an invoice!<br>\n";
                     }
                     if (module_config::c('invoice_auto_renew_only_paid_invoices', 1) && $invoice_unpaid) {
                         if ($debug) {
                             echo " - skipping generating renewal for " . $member['owner_table'] . " " . $member['owner_id'] . " because a previous subscription is unpaid <br>\n";
                         }
                         continue;
                     }
                     // time to generate! woo!
                     if ($debug) {
                         echo " - generating subscription renewal for " . $member['owner_table'] . " " . $member['owner_id'] . "<br>\n";
                     }
                     $invoice_id = self::generate_subscription_invoice($subscription['subscription_id'], $member['owner_table'], $member['owner_id'], $member['next_generation_date'], $subscription['amount']);
                     if ($debug) {
                         echo " - generated invoice " . module_invoice::link_open($invoice_id, true) . " for subscription <br>\n";
                     }
                     if ($subscription['automatic_email']) {
                         if ($debug) {
                             echo " - emailing invoice to " . $member['owner_table'] . "... <br>\n";
                         }
                         if (module_invoice::email_invoice_to_customer($invoice_id, $debug)) {
                             if ($debug) {
                                 echo "send successfully <br>\n";
                             }
                         } else {
                             echo " - failed to send invoice " . module_invoice::link_open($invoice_id, true) . " to " . $member['owner_table'] . " <br>\n";
                         }
                     }
                 } else {
                     if ($debug) {
                         echo " - skipping generating renewal for " . $member['owner_table'] . " " . $member['owner_id'] . " because the due date has already been generated <br>\n";
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
 private static function save_quote_tasks($quote_id, $data)
 {
     $result = array('status' => false);
     $check_completed = false;
     $quote_data = false;
     // check for new tasks or changed tasks.
     $tasks = self::get_tasks($quote_id);
     if (isset($data['quote_task']) && is_array($data['quote_task'])) {
         foreach ($data['quote_task'] as $quote_task_id => $task_data) {
             if (isset($task_data['manual_percent']) && strlen($task_data['manual_percent']) == 0) {
                 unset($task_data['manual_percent']);
             }
             $original_quote_task_id = $quote_task_id;
             $quote_task_id = (int) $quote_task_id;
             if (!is_array($task_data)) {
                 continue;
             }
             if ($quote_task_id > 0 && !isset($tasks[$quote_task_id])) {
                 $quote_task_id = 0;
                 // creating a new task on this quote.
             }
             if (!isset($task_data['description']) || $task_data['description'] == '' || $task_data['description'] == _TASK_DELETE_KEY) {
                 if ($quote_task_id > 0 && $task_data['description'] == _TASK_DELETE_KEY) {
                     // remove task.
                     // but onyl remove it if it hasn't been invoiced.
                     $sql = "DELETE FROM `" . _DB_PREFIX . "quote_task` WHERE quote_task_id = '{$quote_task_id}' AND quote_id = {$quote_id} LIMIT 1";
                     query($sql);
                     $result['status'] = 'deleted';
                     $result['quote_task_id'] = $quote_task_id;
                 }
                 continue;
             }
             // add / save this task.
             $task_data['quote_id'] = $quote_id;
             $task_data['hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['hours']) : $task_data['hours'];
             // remove the amount of it equals the hourly rate.
             if (isset($task_data['amount']) && $task_data['amount'] != 0 && isset($task_data['hours']) && $task_data['hours'] > 0) {
                 if (isset($data['hourly_rate']) && $task_data['amount'] - $task_data['hours'] * $data['hourly_rate'] == 0) {
                     unset($task_data['amount']);
                 }
             }
             // check if we haven't unticked a non-hourly task
             // check if we haven't unticked a billable task
             if (isset($task_data['billable_t']) && $task_data['billable_t'] && !isset($task_data['billable'])) {
                 $task_data['billable'] = 0;
             }
             // set default taxable status
             if (!isset($task_data['taxable_t'])) {
                 // we're creating a new task.
                 $task_data['taxable'] = module_config::c('task_taxable_default', 1);
             }
             if (isset($task_data['taxable_t']) && $task_data['taxable_t'] && !isset($task_data['taxable'])) {
                 $task_data['taxable'] = 0;
             }
             // todo: move the task creation code into a public method so that the public user can add tasks to their quotes.
             if (!$quote_task_id && module_security::is_logged_in() && !module_quote::can_i('create', 'Quote Tasks')) {
                 continue;
                 // dont allow new tasks.
             }
             // check if the user is allowed to create new tasks.
             $quote_task_id = update_insert('quote_task_id', $quote_task_id, 'quote_task', $task_data);
             // todo - fix cross task quote boundary issue. meh.
             $result['quote_task_id'] = $quote_task_id;
             if ($quote_task_id != $original_quote_task_id) {
                 $result['status'] = 'created';
             } else {
                 $result['status'] = 'edited';
             }
         }
     }
     if ($check_completed) {
         self::update_quote_completion_status($quote_id);
     }
     module_cache::clear('quote');
     return $result;
 }
Ejemplo n.º 10
0
    public function process()
    {
        if ("ajax_dashboard_tabs" == $_REQUEST['_process']) {
            header("Content-type: text/javascript");
            if (module_security::is_logged_in() && module_security::can_user(module_security::get_loggedin_id(), 'Show Dashboard Alerts')) {
                $items_to_hide = json_decode(module_config::c('_dashboard_item_hide' . module_security::get_loggedin_id(), '{}'), true);
                if (!is_array($items_to_hide)) {
                    $items_to_hide = array();
                }
                //$results = handle_hook("home_alerts");
                global $plugins;
                $tabid = 1;
                // Implicitly flush the buffer(s)
                @ini_set('implicit_flush', true);
                @ob_implicit_flush(true);
                ?>

	            var tabs = $('#dashboard_tabs'); //.tabs();
	            var ul = tabs.find( "ul" );
	            <?php 
                if (is_array($plugins)) {
                    foreach ($plugins as $plugin_name => $plugin) {
                        if (is_callable(array($plugin, 'handle_hook'))) {
                            $argv = array('home_alerts');
                            $this_return = call_user_func_array(array(&$plugin, 'handle_hook'), $argv);
                            if ($this_return !== false && $this_return !== null && is_array($this_return) && count($this_return)) {
                                // we found some home dashboard alerts! yew! print these out for our ajax display and exit, waiting for the next one.
                                uasort($this_return, 'sort_ajax_alert');
                                $dashboard_alerts = array();
                                foreach ($this_return as $alert) {
                                    $group_key = isset($alert['group']) ? $alert['group'] : $alert['item'];
                                    if (!isset($dashboard_alerts[$group_key])) {
                                        $dashboard_alerts[$group_key] = array();
                                    }
                                    $dashboard_alerts[$group_key][] = $alert;
                                }
                                if (!isset($_REQUEST['show_hidden'])) {
                                    foreach ($dashboard_alerts as $key => $val) {
                                        // see if any of these "$val" alert entries are marked as hidden
                                        foreach ($val as $k => $v) {
                                            $hide_key = md5($v['link'] . $v['item'] . (isset($v['name']) ? $v['name'] : ''));
                                            $dashboard_alerts[$key][$k]['hide_key'] = $val[$k]['hide_key'] = $hide_key;
                                            if (in_array($hide_key, $items_to_hide)) {
                                                unset($val[$k]);
                                                unset($dashboard_alerts[$key][$k]);
                                            }
                                        }
                                    }
                                }
                                //print_r($dashboard_alerts);
                                foreach ($dashboard_alerts as $key => $alerts) {
                                    if (!count($alerts)) {
                                        continue;
                                    }
                                    $tabid++;
                                    ?>

	                                $( "<li><a href='#newtab<?php 
                                    echo $tabid;
                                    ?>
'><?php 
                                    echo $key;
                                    ?>
 (<?php 
                                    echo count($alerts);
                                    ?>
)</a></li>" ).appendTo( ul );
	                                <?php 
                                    ob_start();
                                    if (isset(module_dashboard::$group_settings[$key])) {
                                        ?>

	                                <table class="tableclass tableclass_rows tableclass_full" id="alert_table_<?php 
                                        echo strtolower(str_replace(' ', '', $key));
                                        ?>
">
	                                    <thead>
		                                    <tr>
		                                        <?php 
                                        foreach (module_dashboard::$group_settings[$key]['columns'] as $column_key => $column_title) {
                                            ?>

		                                        <th class="alert_column_<?php 
                                            echo $column_key;
                                            ?>
"><?php 
                                            echo $column_title;
                                            ?>
</th>
		                                        <?php 
                                        }
                                        ?>

		                                        <th width="10" class="alert_column_delete"></th>
		                                    </tr>
	                                    </thead>
	                                    <tbody>
	                                        <?php 
                                        if (count($alerts)) {
                                            $y = 0;
                                            foreach ($alerts as $alert) {
                                                ?>

	                                                <tr class="<?php 
                                                echo $y++ % 2 ? 'even' : 'odd';
                                                ?>
">
	                                                    <?php 
                                                foreach (module_dashboard::$group_settings[$key]['columns'] as $column_key => $column_title) {
                                                    ?>

	                                                    <td><?php 
                                                    echo isset($alert[$column_key]) ? $alert[$column_key] : '';
                                                    ?>
</td>
	                                                    <?php 
                                                }
                                                ?>

	                                                    <?php 
                                                if (isset($alert['hide_key']) && $alert['hide_key']) {
                                                    ?>

	                                                    <td width="10">
	                                                        <a href="#" class="ui-corner-all ui-icon ui-icon-trash" onclick="return hide_item('<?php 
                                                    echo $alert['hide_key'];
                                                    ?>
');">[x]</a>
	                                                    </td>
	                                                    <?php 
                                                }
                                                ?>

	                                                </tr>
	                                            <?php 
                                            }
                                        } else {
                                            ?>

	                                            <tr>
	                                                <td class="odd" colspan="4"><?php 
                                            _e('Yay! No alerts!');
                                            ?>
</td>
	                                            </tr>
	                                        <?php 
                                        }
                                        ?>

	                                    </tbody>
	                                </table>
	                                <?php 
                                    } else {
                                        // old method of output for unregistered alerts:
                                        // will remove once all have been converted.
                                        ?>

	                            <table class="tableclass tableclass_rows tableclass_full tbl_fixed" id="alert_table_<?php 
                                        echo strtolower(str_replace(' ', '', $key));
                                        ?>
">
	                                    <tbody>
	                                    <?php 
                                        if (count($alerts)) {
                                            $y = 0;
                                            foreach ($alerts as $alert) {
                                                ?>

	                                            <tr class="<?php 
                                                echo $y++ % 2 ? 'even' : 'odd';
                                                ?>
">
	                                                <td class="row_action">
	                                                    <a href="<?php 
                                                echo $alert['link'];
                                                ?>
"><?php 
                                                echo htmlspecialchars($alert['item']);
                                                ?>
</a>
	                                                </td>
	                                                    <td>
	                                                        <?php 
                                                echo isset($alert['name']) ? htmlspecialchars($alert['name']) : '';
                                                ?>

	                                                    </td>
	                                                    <td width="16%">
	                                                        <?php 
                                                echo $alert['warning'] ? '<span class="important">' : '';
                                                ?>

	                                                        <?php 
                                                echo $alert['days'];
                                                ?>

	                                                        <?php 
                                                echo $alert['warning'] ? '</span>' : '';
                                                ?>

	                                                    </td>
	                                                <td width="16%">
	                                                    <?php 
                                                echo $alert['warning'] ? '<span class="important">' : '';
                                                ?>

	                                                    <?php 
                                                echo print_date($alert['date']);
                                                ?>

	                                                    <?php 
                                                echo $alert['warning'] ? '</span>' : '';
                                                ?>

	                                                </td>
	                                                <?php 
                                                if (isset($alert['hide_key']) && $alert['hide_key']) {
                                                    ?>

	                                                <td width="10">
	                                                    <a href="#" class="ui-corner-all ui-icon ui-icon-trash" onclick="return hide_item('<?php 
                                                    echo $alert['hide_key'];
                                                    ?>
');">[x]</a>
	                                                </td>
	                                                <?php 
                                                }
                                                ?>

	                                            </tr>
	                                        <?php 
                                            }
                                        } else {
                                            ?>

	                                        <tr>
	                                            <td class="odd" colspan="4"><?php 
                                            _e('Yay! No alerts!');
                                            ?>
</td>
	                                        </tr>
	                                    <?php 
                                        }
                                        ?>

	                                    </tbody>
	                                </table>
	                            <?php 
                                    }
                                    // end old method
                                    $html = ob_get_clean();
                                    $html = preg_replace('#\\s+#', ' ', $html);
                                    $html = addcslashes($html, "'");
                                    ?>

	                                $( '<div id="newtab<?php 
                                    echo $tabid;
                                    ?>
"><?php 
                                    echo $html;
                                    ?>
</div>' ).appendTo( tabs );
	                                <?php 
                                }
                                ?>

	                            tabs.tabs( "refresh" );
	                            <?php 
                                for ($x = 1; $x < 50; $x++) {
                                    echo " \t \n";
                                }
                                @flush();
                                @ob_end_flush();
                            } else {
                                // nothing? continue onto next hook...
                            }
                        }
                    }
                }
            }
            ?>

            $('#tabs_loading').hide();
            <?php 
            exit;
        }
    }
Ejemplo n.º 11
0
 public static function put($group, $cache_key, $data, $seconds = false)
 {
     if (!module_config::c('cache_enabled', 1)) {
         return false;
     }
     if (!$seconds) {
         $seconds = module_config::c('cache_objects', 60);
     }
     $cache_key = module_security::get_loggedin_id() . '/' . $cache_key;
     $full_cache_key = $group . '||' . $cache_key;
     //if(!isset($_SESSION['_cache_keys']))$_SESSION['_cache_keys'] = array();
     //if(!isset($_SESSION['_cache_keys'][$group]))$_SESSION['_cache_keys'][$group] = array();
     //$_SESSION['_cache_keys'][$group][$cache_key] = true;
     //self::time_save($group.'||'.$cache_key,$data,$timeout);
     $data = array('create' => time(), 'd' => $data, 'e' => time() + $seconds);
     if (self::$_use_memcache) {
         // version this as well
         if (_DEBUG_MODE && module_config::c('cache_debug', 0)) {
             module_debug::log(array('title' => 'MemCache Time Save', 'data' => "For: {$full_cache_key} = Storing for {$seconds}"));
         }
         if (!self::$_memcache_instance->replace(self::$_memcache_prefix . $full_cache_key, $data, 0, $seconds)) {
             self::$_memcache_instance->set(self::$_memcache_prefix . $full_cache_key, $data, 0, $seconds);
         }
     } else {
         if (module_security::is_logged_in()) {
             self::$_db_cache[$group][$cache_key] = $data;
             //$data = serialize($data);
             if (_DEBUG_MODE && module_config::c('cache_debug', 0)) {
                 module_debug::log(array('title' => 'Cache Time Save', 'data' => "For: {$group} - {$cache_key} = Storing for {$seconds}"));
             }
             //if(strlen($data)>3000)return; // can have issues with sessions stored in db?
             /*if(self::db_table_exists('cache_store')){
                   $sql = "REPLACE INTO `"._DB_PREFIX."cache_store` SET `cache_group` = '".mysql_real_escape_string($group)."', `cache_key` = '".mysql_real_escape_string($cache_key)."', cache_data = '".mysql_real_escape_string($data)."', `create_user_id` = ".module_security::get_loggedin_id().", expire_time = ".((int)time()+$seconds);
                   query($sql);
               }*/
         }
         // just save in session for amount of time.
         /*if(!isset($_SESSION['_c'])){
               $_SESSION['_c'] = array();
           }
           $_SESSION['_c'][$full_cache_key] = array(
               'e' => time()+$seconds,
               'd'=>$data,
           );*/
     }
 }
Ejemplo n.º 12
0
 public static function get_current_theme()
 {
     if (_DEMO_MODE && get_display_mode() != 'mobile' && is_dir('includes/plugin_theme/themes/pro/')) {
         hook_add('header_print_js', 'module_theme::hook_header_print_js_demo');
         if (isset($_REQUEST['demo_theme'])) {
             $_SESSION['_demo_theme'] = basename($_REQUEST['demo_theme']);
             if (!$_SESSION['_demo_theme']) {
                 $_SESSION['_demo_theme'] = module_config::c('theme_name', 'default');
             }
         }
         $current_theme = isset($_SESSION['_demo_theme']) ? $_SESSION['_demo_theme'] : module_config::c('theme_name', 'default');
     } else {
         $current_theme = module_config::c('theme_name', is_dir('includes/plugin_theme/themes/metis/') ? 'metis' : 'default');
         if (module_security::is_logged_in() && module_config::c('theme_per_user', 0)) {
             // we allow users to pick their own themes.
             $current_theme = module_config::c('theme_name_' . module_security::get_loggedin_id(), self::$current_theme);
         }
     }
     return $current_theme;
 }
Ejemplo n.º 13
0
                 $content = ob_get_contents();
                 ob_clean();
                 echo '<div class="final_content_wrap">';
                 echo $content;
                 echo '</div>';
             }
         }
         if (isset($links)) {
             unset($links);
         }
     }
     $inner_content[] = ob_get_clean();
     // END INNER CONTENT OB
 }
 // see if this module has a page title.
 if ($module && module_security::is_logged_in()) {
     if ($module->get_page_title()) {
         $page_title = htmlspecialchars($module->get_page_title()) . $page_title_delim . $page_title;
     }
 }
 if (isset($module)) {
     unset($module);
 }
 /*if(preg_match('#\{INNER_CONTENT\}#',$inner_content)){
 			$inner_content = preg_replace('#\{INNER_CONTENT\}#',$this_content,$inner_content);
 		}else{
 			$inner_content .= $this_content;
 		}
 		unset($this_content);*/
 unset($load_page);
 if ($display_mode == 'iframe' || $display_mode == 'ajax') {
Ejemplo n.º 14
0
 public static function can_edit_tickets()
 {
     return module_security::is_logged_in() && self::can_i('edit', 'Tickets');
 }
Ejemplo n.º 15
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'popup':
                // popup not used any more. cross domain issues.
                // load up the full script to be injected into our clients website.
                $website_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $change_request_id = $change_id = isset($_REQUEST['change_id']) ? (int) $_REQUEST['change_id'] : false;
                $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : false;
                $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : false;
                if ($type == 'popupjs') {
                    @ob_end_clean();
                    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                    header("Cache-Control: no-cache");
                    header("Pragma: no-cache");
                    header("Content-type: text/javascript");
                }
                if ($website_id && $hash && module_change_request::link_popup($website_id, true) == $hash) {
                    $change_history = module_change_request::get_remaining_changes($website_id);
                    $step = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0;
                    // get the change details out
                    if ($change_request_id) {
                        $change_request = module_change_request::get_change_request_by_website($website_id, $change_request_id);
                    } else {
                        $change_request = array();
                    }
                    if (!$change_request) {
                        $change_request = array('change_request_id' => 0, 'name' => '', 'request' => '', 'attachments' => array());
                    }
                    switch ($type) {
                        case 'save':
                            // saving a change.
                            $data = $_POST;
                            $data['url'] = urldecode($data['url']);
                            $data['website_id'] = $website_id;
                            $data['change_request_id'] = $change_request['change_request_id'];
                            if (isset($_REQUEST['completed_test'])) {
                                if (!isset($_REQUEST['completed']) || !$_REQUEST['completed']) {
                                    $data['status'] = _CHANGE_REQUEST_STATUS_NEW;
                                    // not completed.
                                } else {
                                    $data['status'] = _CHANGE_REQUEST_STATUS_COMPLETE;
                                    // completed!
                                }
                            }
                            if (isset($_REQUEST['delete_request'])) {
                                $data['status'] = _CHANGE_REQUEST_STATUS_DELETE;
                                // deleted
                            }
                            $change_request_id = update_insert('change_request_id', $change_request['change_request_id'], 'change_request', $data);
                            // redirect to send email page if we're logged in
                            if (module_security::is_logged_in() && isset($_REQUEST['completed_send_email']) && $_REQUEST['completed_send_email'] && self::can_i('edit', 'Change Requests')) {
                                // don't do the template, do the redirect to the email page (todo!)
                                redirect_browser(self::link_open($change_request_id));
                            } else {
                                // send email to administrator (everyone with change request edit permissions?) about this change request.
                                $alert_users = module_user::get_users_by_permission(array('category' => 'Change Request', 'name' => 'Change Requests', 'module' => 'change_request', 'edit' => 1));
                                $email_data = get_single('change_request', 'change_request_id', $change_request_id);
                                $customer_data = $website_data = array();
                                if ($website_id) {
                                    $website_data = module_website::get_website($website_id);
                                    $email_data['website_name'] = $website_data['name'];
                                    $email_data['website_link'] = module_website::link_open($website_id, true);
                                    if ($website_data && $website_data['customer_id']) {
                                        $customer_data = module_customer::get_customer($website_data['customer_id'], true);
                                    }
                                }
                                if (isset($email_data['request'])) {
                                    $email_data['request'] = nl2br($email_data['request']);
                                    // for the plain text emails.
                                }
                                foreach ($alert_users as $alert_user) {
                                    // todo: make sure this staff member has access to this website?
                                    // nfi how to figure this out. maybe we just look for staff members who are assigned jobs/tasks against this website?
                                    $template = module_template::get_template_by_key('change_request_alert_email');
                                    $template->assign_values(array_merge($customer_data, $website_data, $email_data));
                                    $html = $template->render('html');
                                    // send an email to this user.
                                    $email = module_email::new_email();
                                    $email->replace_values = array_merge($customer_data, $website_data, $email_data);
                                    $email->set_to('user', $alert_user['user_id']);
                                    $email->set_from('user', module_security::get_loggedin_id() ? module_security::get_loggedin_id() : isset($customer_data['primary_user_id']) ? $customer_data['primary_user_id'] : 0);
                                    $email->set_subject($template->description);
                                    // do we send images inline?
                                    $email->set_html($html);
                                    if ($email->send()) {
                                        // it worked successfully!!
                                        // sweet.
                                    } else {
                                        /// log err?
                                        set_error(_l('Failed to send change notification email to User ID: %s Email: %s Status: %s Error: %s', $alert_user['user_id'], json_encode($email->to), $email->status, $email->error_text));
                                    }
                                }
                            }
                            // display thankyou template.
                            module_template::init_template('change_request_submitted', '<h2>Change Request</h2>
    <p>Thank you. Your change request has been submitted successfully.</p>
    <p>Please <a href="{URL}">click here</a> to continue.</p>
    ', 'Displayed after a change request is created/updated.', 'code');
                            // correct!
                            // load up the receipt template.
                            $template = module_template::get_template_by_key('change_request_submitted');
                            $template->page_title = _l("Change Request");
                            foreach ($data as $key => $val) {
                                if (!is_array($val)) {
                                    $data[$key] = htmlspecialchars($val);
                                }
                            }
                            $template->assign_values($data);
                            echo $template->render('pretty_html');
                            exit;
                            break;
                        case 'display_change':
                            ob_start();
                            ?>

                            <div class="title">
                                <?php 
                            _e('Change request');
                            ?>

                            </div>
                            <div class="content">
                                <p><?php 
                            echo nl2br(htmlspecialchars($change_request['request']));
                            ?>
</p>
                                <div class="wp3changerequest_actions">
                                    <p>
                                       <!-- <strong><?php 
                            _e('Attachments:');
                            ?>
</strong>
                                        <?php 
                            if (!$change_request['attachments']) {
                                ?>
 - none - <?php 
                            } else {
                                foreach ($change_request['attachments'] as $attachment) {
                                    ?>

                                            <a href="#"><?php 
                                    echo htmlspecialchars($attachment->name);
                                    ?>
</a>
                                            <?php 
                                }
                                ?>

                                        <?php 
                            }
                            ?>

                                        <br/>-->
                                        <strong><?php 
                            _e('Created by:');
                            ?>
</strong> <?php 
                            echo htmlspecialchars($change_request['name']);
                            ?>
 <br/>
                                        <strong><?php 
                            _e('Created on:');
                            ?>
</strong> <?php 
                            echo print_date($change_request['date_created'], true);
                            ?>

	                                    <?php 
                            if (isset($change_request['job_id']) && $change_request['job_id']) {
                                ?>
 <br/>
		                                    <strong><?php 
                                _e('Converted to job:');
                                ?>
</strong> <?php 
                                _e('This task has been converted to a Job');
                                ?>

	                                    <?php 
                            }
                            ?>

                                    </p>
                                    <?php 
                            if (!isset($change_request['job_id']) || !$change_request['job_id'] || self::can_i('edit', 'Change Requests')) {
                                ?>

                                    <p align="center">
                                        <input type="button" name="edit" value="<?php 
                                _e('Edit');
                                ?>
" class="wp3changerequest_button wp3changerequest_button_small"  onclick="dtbaker_changerequest.edit(<?php 
                                echo $change_request_id;
                                ?>
); return false;">
                                    </p>
	                                <?php 
                            }
                            ?>

                                </div>
                            </div>
                            <?php 
                            $change_request['html'] = preg_replace('/\\s+/', ' ', ob_get_clean());
                            //                                echo json_encode($change_request);
                            //                                exit;
                            @ob_end_clean();
                            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                            header("Cache-Control: no-cache");
                            header("Pragma: no-cache");
                            header("Content-type: text/javascript");
                            ?>


                            var t = dtbaker_changerequest;
                            var change_id = <?php 
                            echo $change_request_id;
                            ?>
;
                                var msg = <?php 
                            echo json_encode($change_request);
                            ?>
;

                            jQuery('body').prepend('<div class="wp3changerequest_change" id="dtbaker_change_'+change_id+'" style="'+((!t.show_postits) ? 'display:none;':'')+'"></div>');
                            var box = jQuery('#dtbaker_change_'+change_id);
                            box.html(msg.html);
                            if(msg.status == 0){
                                box.addClass('wp3changerequest_change_pending');
                            }else if(msg.status == 2){
                                box.addClass('wp3changerequest_change_complete');
                            }else if(msg.status == 3){
                                box.addClass('wp3changerequest_change_deleted');
                            }
                            box.css('top',msg.y+'px');
                            box.data('window_width',msg.window_width);
                            box.data('left',msg.x);
                            t.set_left(change_id);
                            with({i:change_id}){
                                jQuery(window).resize(function () {
                                    t.set_left(i);
                                });
                            }
                            box.data('original_height',box.height());
                            box.css('overflow','hidden');
                            jQuery('.title',box).slideUp();
                            box.stop(true, true).animate({
                                height: t.min_height,
                                width: t.min_width
                            },500);
                            box.hover(function(){
                                jQuery(this).addClass('wp3changerequest_change_active');
                                jQuery('.title',this).stop(true, true).slideDown();
                                jQuery(this).stop().animate({
                                    width: t.max_width,
                                    height: jQuery(this).data('original_height'),
                                    opacity: 1
                                },500);
                            },function(){
                                jQuery('.title',this).stop(true, true).slideUp();
                                jQuery(this).stop().animate({
                                    width: t.min_width,
                                    height: t.min_height,
                                    opacity: 0.7
                                },500,function(){
                                    jQuery(this).removeClass('wp3changerequest_change_active');
                                });
                            })


                                <?php 
                            break;
                        default:
                            @ob_end_clean();
                            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                            header("Cache-Control: no-cache");
                            header("Pragma: no-cache");
                            header("Content-type: text/javascript");
                            ob_start();
                            include 'pages/popup.php';
                            $html = ob_get_clean();
                            $html = addcslashes($html, "'");
                            $html = preg_replace('#\\r|\\n#', "' +\n'", $html);
                            // inject using javascript. fixes cross domain issues
                            ?>

                            if(!jQuery('#dtbaker_changerequest_inlinewizard').length){
                                // fix for jQuery 1.9+
                                jQuery('body').append('<div id="dtbaker_changerequest_inlinewizard" style="display:none;"></div>');
                            }
                            jQuery('#dtbaker_changerequest_inlinewizard').html('<?php 
                            echo $html;
                            ?>
');
                            <?php 
                    }
                }
                exit;
                break;
            case 'script':
                // load up the full script to be injected into our clients website.
                $website_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : false;
                @ob_end_clean();
                header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                header("Cache-Control: no-cache");
                header("Pragma: no-cache");
                header("Content-type: text/javascript");
                if ($website_id && $hash && module_change_request::link_script($website_id, true) == $hash) {
                    include "js/client.js";
                    $client_url = isset($_REQUEST['url']) ? $_REQUEST['url'] : false;
                    if ($client_url) {
                        $change_requests = self::get_change_requests(array('website_id' => $website_id, 'url' => $client_url));
                        // todo - option this out incase url causes issues. ie: old js check method
                        ?>

                        jQuery(function(){
                            <?php 
                        foreach ($change_requests as $change_request) {
                            $displayed = false;
                            if ($change_request['status'] == _CHANGE_REQUEST_STATUS_NEW) {
                                $displayed = true;
                                ?>

                                    dtbaker_changerequest.display_change(<?php 
                                echo $change_request['change_request_id'];
                                ?>
);
                            <?php 
                            }
                            if (isset($_SESSION['_change_request_highlight']) && $_SESSION['_change_request_highlight'] == $change_request['change_request_id']) {
                                ?>

                                    <?php 
                                if (!$displayed) {
                                    ?>

                                    dtbaker_changerequest.display_change(<?php 
                                    echo $change_request['change_request_id'];
                                    ?>
);
                                    <?php 
                                }
                                ?>

                                    dtbaker_changerequest.highlight(<?php 
                                echo (int) $_SESSION['_change_request_highlight'];
                                ?>
);
                                    <?php 
                                unset($_SESSION['_change_request_highlight']);
                            }
                        }
                        ?>

                        });
                        <?php 
                    } else {
                        // not posting the URL, some setups do not like this
                        // get list of active change requests
                        $change_requests = self::get_change_requests(array('website_id' => $website_id, 'status' => _CHANGE_REQUEST_STATUS_NEW));
                        // we also do completed ones because the change request highlight countbe in there
                        $completed_change_requests = self::get_change_requests(array('website_id' => $website_id, 'status' => _CHANGE_REQUEST_STATUS_COMPLETE));
                        ?>


                        jQuery(function(){
                            var current_url = window.location.href;
                            <?php 
                        foreach ($change_requests as $change_request) {
                            ?>

                            if(current_url == '<?php 
                            echo addcslashes(htmlspecialchars($change_request['url']), "'");
                            ?>
'){
                                // todo: do this better!
                                dtbaker_changerequest.display_change(<?php 
                            echo $change_request['change_request_id'];
                            ?>
);
                            }
                            <?php 
                        }
                        ?>

                            <?php 
                        // todo: do we display all previous change requests on the page or not?
                        if (isset($_SESSION['_change_request_highlight']) && $_SESSION['_change_request_highlight']) {
                            echo '// Checking for request: ' . (int) $_SESSION['_change_request_highlight'];
                            foreach ($completed_change_requests as $complete_change_request) {
                                if ($complete_change_request['change_request_id'] == $_SESSION['_change_request_highlight']) {
                                    // show this completed one as well.
                                    ?>

                                        dtbaker_changerequest.display_change(<?php 
                                    echo $complete_change_request['change_request_id'];
                                    ?>
);
                                        <?php 
                                }
                            }
                            ?>

                            dtbaker_changerequest.highlight(<?php 
                            echo (int) $_SESSION['_change_request_highlight'];
                            ?>
);
                            <?php 
                            // todo: move this unset over to the "display_change" callback so we only remove the session when we know it has been displayed.
                            unset($_SESSION['_change_request_highlight']);
                        }
                        ?>

                        });
                        <?php 
                    }
                }
                exit;
                break;
            case 'public':
                $website_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : false;
                if ($website_id && $hash && module_change_request::link_public($website_id, true) == $hash) {
                    // correct!
                    // redirect to website with our "change_request" url parameter, that is picked up by the included text.
                    $website = module_website::get_website($website_id);
                    $change_request_website = get_single('change_request_website', 'website_id', $website_id);
                    if ($change_request_website && $change_request_website['enabled']) {
                        $url = module_website::urlify($website['url']);
                        // todo - pass this to a (yet to be created) method in website that will deal with https:// or http:// based on user input. stop hardcoding http!
                        if (isset($_REQUEST['change_request_id'])) {
                            $selected_change_request = self::get_change_request_by_website($website_id, (int) $_REQUEST['change_request_id']);
                            if ($selected_change_request && $selected_change_request['url']) {
                                $url = $selected_change_request['url'];
                            }
                            //$url .= "&change_request_id=".(int)$_REQUEST['change_request_id'];
                            $_SESSION['_change_request_highlight'] = (int) $_REQUEST['change_request_id'];
                        }
                        $url = $url . (strpos($url, '?') === false ? '?' : '&') . 'change_request=' . self::link_script($website_id, true);
                        redirect_browser($url);
                    }
                }
                echo "Change request disabled.";
                break;
        }
    }
Ejemplo n.º 16
0
 public static function write($session_id, $data)
 {
     if (self::$destroyed) {
         return false;
     }
     if (self::$session_hash && md5($data) == self::$session_hash) {
         return true;
     }
     // session data hasn't changed, dont re-write it
     if (!self::db_table_exists('session', true)) {
         return file_put_contents(_UCM_FOLDER . "/temp/sess_{$session_id}", $data) === false ? false : true;
     }
     /*if(function_exists('mb_detect_encoding') && mb_detect_encoding($data)!='ASCII'){
           $data = '!'.mb_detect_encoding($data).'!'.$data;
       }*/
     try {
         $user_id = module_security::get_loggedin_id();
         $logged_in = module_security::is_logged_in();
         // are we creating or reading?
         $sql = "SELECT session_id FROM `" . _DB_PREFIX . "session` WHERE `session_id` = '" . mysql_real_escape_string(self::$session_id) . "'";
         $res = query($sql);
         if (mysql_num_rows($res) > 0) {
             // we have a session! woo!
             // update existing
             $data = base64_encode($data);
             $sql = "UPDATE `" . _DB_PREFIX . "session` SET ";
             $sql .= " `last_access` = " . (int) time() . ", `session_data` = '" . mysql_real_escape_string($data) . "', `logged_in` = " . (int) $logged_in . ", ip_address = '" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "' ";
             if ($logged_in) {
                 // only write the user id if we're logged in
                 // this keeps user id active for closed user sessions
                 $sql .= ", `user_id` = " . (int) $user_id . " ";
             }
             $sql .= " WHERE `session_id` = '" . mysql_real_escape_string($session_id) . "'";
             query($sql);
         } else {
             // create new! only difference is set set a created timestamo
             $sql = "INSERT INTO `" . _DB_PREFIX . "session` SET `created` = " . (int) time() . ",`last_access` = " . (int) time() . ", `session_data` = '" . mysql_real_escape_string($data) . "', `user_id` = " . (int) $user_id . ", `logged_in` = " . (int) $logged_in . ", ip_address = '" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "', `session_id` = '" . mysql_real_escape_string($session_id) . "'";
             query($sql);
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
     return true;
 }
Ejemplo n.º 17
0
 public function external_hook($hook)
 {
     switch ($hook) {
         case 'public_signup_form':
             $signup_form = module_template::get_template_by_key('customer_signup_form_wrapper');
             $signup_form->page_title = $signup_form->description;
             $signup_form->assign_values(array('signup_form' => self::get_customer_signup_form_html()));
             echo $signup_form->render('pretty_html');
             exit;
         case 'public_signup':
             // sign out if testing.
             if (module_security::is_logged_in()) {
                 set_message('Logged out due to signup');
                 module_security::logout();
             }
             $result = array('messages' => array());
             function customer_signup_complete($result)
             {
                 if (isset($_REQUEST['via_ajax'])) {
                     echo json_encode($result);
                 } else {
                     echo implode('<br/>', $result['messages']);
                 }
                 exit;
             }
             if (!module_config::c('customer_signup_allowed', 0)) {
                 $result['error'] = 1;
                 $result['messages'][] = 'Customer signup disabled';
                 customer_signup_complete($result);
             }
             //recaptcha on signup form.
             if (module_config::c('captcha_on_signup_form', 0)) {
                 if (!module_captcha::check_captcha_form()) {
                     $result['error'] = 1;
                     $result['messages'][] = 'Captcha fail, please go back and enter correct captcha code.';
                     customer_signup_complete($result);
                 }
             }
             $customer = isset($_POST['customer']) && is_array($_POST['customer']) ? $_POST['customer'] : array();
             $contact = isset($_POST['contact']) && is_array($_POST['contact']) ? $_POST['contact'] : array();
             $contact_extra = isset($contact['extra']) && is_array($contact['extra']) ? $contact['extra'] : array();
             $contact_group = isset($contact['group_ids']) && is_array($contact['group_ids']) ? $contact['group_ids'] : array();
             $customer_extra = isset($customer['extra']) ? $customer['extra'] : array();
             $customer_group = isset($customer['group_ids']) && is_array($customer['group_ids']) ? $customer['group_ids'] : array();
             $address = isset($_POST['address']) ? $_POST['address'] : array();
             $website = isset($_POST['website']) ? $_POST['website'] : array();
             $website_extra = isset($website['extra']) ? $website['extra'] : array();
             $website_group = isset($website['group_ids']) && is_array($website['group_ids']) ? $website['group_ids'] : array();
             $job = isset($_POST['job']) ? $_POST['job'] : array();
             $job_extra = isset($job['extra']) ? $job['extra'] : array();
             $subscription = isset($_POST['subscription']) ? $_POST['subscription'] : array();
             // sanatise possibly problematic fields:
             // customer:
             $allowed = array('name', 'last_name', 'customer_name', 'email', 'phone', 'mobile', 'extra', 'type');
             foreach ($customer as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($customer[$key]);
                 }
             }
             if (isset($customer['type']) && $customer['type'] != _CUSTOMER_TYPE_NORMAL && $customer['type'] != _CUSTOMER_TYPE_LEAD) {
                 unset($customer['type']);
             }
             // added multiple contact support in the form of arrays.
             $contact_fields = array('name', 'last_name', 'email', 'phone');
             if (module_config::c('customer_signup_password', 0)) {
                 $contact_fields[] = 'password';
             }
             foreach ($contact_fields as $multi_value) {
                 if (isset($contact[$multi_value])) {
                     if (!is_array($contact[$multi_value])) {
                         $contact[$multi_value] = array($contact[$multi_value]);
                     }
                 } else {
                     if (isset($customer[$multi_value])) {
                         $contact[$multi_value] = array($customer[$multi_value]);
                     } else {
                         $contact[$multi_value] = array();
                     }
                 }
             }
             $valid_contact_email = false;
             $name_fallback = false;
             $primary_email = false;
             foreach ($contact['email'] as $contact_key => $email) {
                 if (!$name_fallback && isset($contact['name'][$contact_key])) {
                     $name_fallback = $contact['name'][$contact_key];
                 }
                 $contact['email'][$contact_key] = filter_var(strtolower(trim($email)), FILTER_VALIDATE_EMAIL);
                 if ($contact['email'][$contact_key]) {
                     $valid_contact_email = true;
                     if (!$primary_email) {
                         $primary_email = $contact['email'][$contact_key];
                         // set the primary contact details here by adding them to the master customer array
                         foreach ($contact_fields as $primary_contact_field) {
                             $customer[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                             unset($contact[$primary_contact_field][$contact_key]);
                         }
                     }
                 }
             }
             // start error checking / required fields
             if (!isset($customer['customer_name']) || !strlen($customer['customer_name'])) {
                 $customer['customer_name'] = $name_fallback;
             }
             if (!strlen($customer['customer_name'])) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide a customer name.";
             }
             if (!$valid_contact_email || !$primary_email) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide an email address.";
             }
             // check all posted required fields.
             function check_required($postdata, $messages = array())
             {
                 if (is_array($postdata)) {
                     foreach ($postdata as $key => $val) {
                         if (strpos($key, '_required') && strlen($val)) {
                             $required_key = str_replace('_required', '', $key);
                             if (!isset($postdata[$required_key]) || !$postdata[$required_key]) {
                                 $messages[] = 'Required field missing: ' . htmlspecialchars($val);
                             }
                         }
                         if (is_array($val)) {
                             $messages = check_required($val, $messages);
                         }
                     }
                 }
                 return $messages;
             }
             $messages = check_required($_POST);
             if (count($messages)) {
                 $result['error'] = 1;
                 $result['messages'] = array_merge($result['messages'], $messages);
             }
             if (isset($result['error'])) {
                 customer_signup_complete($result);
             }
             // end error checking / required fields.
             // check if this customer already exists in the system, based on email address
             $customer_id = false;
             $creating_new = true;
             $_REQUEST['user_id'] = 0;
             if (isset($customer['email']) && strlen($customer['email']) && !module_config::c('customer_signup_always_new', 0)) {
                 $users = module_user::get_contacts(array('email' => $customer['email']));
                 foreach ($users as $user) {
                     if (isset($user['customer_id']) && (int) $user['customer_id'] > 0) {
                         // this user exists as a customer! yey!
                         // add them to this listing.
                         $customer_id = $user['customer_id'];
                         $creating_new = false;
                         $_REQUEST['user_id'] = $user['user_id'];
                         // dont let signups update existing passwords.
                         if (isset($customer['password'])) {
                             unset($customer['password']);
                         }
                         if (isset($customer['new_password'])) {
                             unset($customer['new_password']);
                         }
                     }
                 }
             }
             $_REQUEST['extra_customer_field'] = array();
             $_REQUEST['extra_user_field'] = array();
             module_extra::$config['allow_new_keys'] = false;
             module_extra::$config['delete_existing_empties'] = false;
             // save customer extra fields.
             if (count($customer_extra)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_extra as $key => $val) {
                     $_REQUEST['extra_customer_field'][] = array('key' => $key, 'val' => $val);
                 }
             }
             // save customer and customer contact details:
             $customer_id = $this->save_customer($customer_id, $customer);
             if (!$customer_id) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: failed to create customer.';
                 customer_signup_complete($result);
             }
             $customer_data = module_customer::get_customer($customer_id);
             // todo - merge primary and secondary contact/extra/group saving into a single loop
             if (!$customer_data['primary_user_id']) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: Failed to create customer contact.';
                 customer_signup_complete($result);
             } else {
                 $role_id = module_config::c('customer_signup_role', 0);
                 if ($role_id > 0) {
                     module_user::add_user_to_role($customer_data['primary_user_id'], $role_id);
                 }
                 // save contact extra data (repeated below for additional contacts)
                 if (isset($contact_extra[0]) && count($contact_extra[0])) {
                     $_REQUEST['extra_user_field'] = array();
                     foreach ($contact_extra[0] as $key => $val) {
                         $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                     }
                     module_extra::save_extras('user', 'user_id', $customer_data['primary_user_id']);
                 }
                 // save contact groups
                 if (isset($contact_group[0]) && count($contact_group[0])) {
                     foreach ($contact_group[0] as $group_id => $tf) {
                         if ($tf) {
                             module_group::add_to_group($group_id, $customer_data['primary_user_id'], 'user');
                         }
                     }
                 }
             }
             foreach ($contact['email'] as $contact_key => $email) {
                 // add any additional contacts to the customer.
                 $users = module_user::get_contacts(array('email' => $email, 'customer_id' => $customer_id));
                 if (count($users)) {
                     // this contact already exists for this customer, dont update/change it.
                     continue;
                 }
                 $new_contact = array('customer_id' => $customer_id);
                 foreach ($contact_fields as $primary_contact_field) {
                     $new_contact[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                 }
                 // dont let additional contacts have passwords.
                 if (isset($new_contact['password'])) {
                     unset($new_contact['password']);
                 }
                 if (isset($new_contact['new_password'])) {
                     unset($new_contact['new_password']);
                 }
                 global $plugins;
                 $contact_user_id = $plugins['user']->create_user($new_contact, 'signup');
                 if ($contact_user_id) {
                     $role_id = module_config::c('customer_signup_role', 0);
                     if ($role_id > 0) {
                         module_user::add_user_to_role($contact_user_id, $role_id);
                     }
                     // save contact extra data  (repeated below for primary contacts)
                     if (isset($contact_extra[$contact_key]) && count($contact_extra[$contact_key])) {
                         $_REQUEST['extra_user_field'] = array();
                         foreach ($contact_extra[$contact_key] as $key => $val) {
                             $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('user', 'user_id', $contact_user_id);
                     }
                     // save contact groups
                     if (isset($contact_group[$contact_key]) && count($contact_group[$contact_key])) {
                         foreach ($contact_group[$contact_key] as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $contact_user_id, 'user');
                             }
                         }
                     }
                 }
             }
             if (count($customer_group)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_group as $group_id => $tf) {
                     if ($tf) {
                         module_group::add_to_group($group_id, $customer_id, 'customer');
                     }
                 }
             }
             $note_keys = array('customer', 'website', 'job', 'address', 'subscription');
             $note_text = _l('Customer signed up from Signup Form:');
             $note_text .= "\n\n";
             foreach ($note_keys as $note_key) {
                 $note_text .= "\n" . ucwords(_l($note_key)) . "\n";
                 if (isset($_POST[$note_key]) && is_array($_POST[$note_key])) {
                     foreach ($_POST[$note_key] as $post_key => $post_val) {
                         $note_text .= "\n - " . _l($post_key) . ": ";
                         if (is_array($post_val)) {
                             foreach ($post_val as $p => $v) {
                                 $note_text .= "\n  - - " . _l($p) . ': ' . $v;
                             }
                         } else {
                             $note_text .= $post_val;
                         }
                     }
                 }
             }
             $note_data = array('note_id' => false, 'owner_id' => $customer_id, 'owner_table' => 'customer', 'note_time' => time(), 'note' => $note_text, 'rel_data' => module_customer::link_open($customer_id), 'reminder' => 0, 'user_id' => 0);
             update_insert('note_id', false, 'note', $note_data);
             // save customer address fields.
             if (count($address)) {
                 $address_db = module_address::get_address($customer_id, 'customer', 'physical');
                 $address_id = $address_db && isset($address_db['address_id']) ? (int) $address_db['address_id'] : false;
                 $address['owner_id'] = $customer_id;
                 $address['owner_table'] = 'customer';
                 $address['address_type'] = 'physical';
                 // we have post data to save, write it to the table!!
                 module_address::save_address($address_id, $address);
             }
             // website:
             $allowed = array('url', 'name', 'extra', 'notes');
             foreach ($website as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($website[$key]);
                 }
             }
             $website['url'] = isset($website['url']) ? strtolower(trim($website['url'])) : '';
             $website_id = 0;
             if (count($website) && class_exists('module_website', false) && module_website::is_plugin_enabled()) {
                 if (strlen($website['url'])) {
                     // see if website already exists, don't create or update existing one for now.
                     $existing_websites = module_website::get_websites(array('customer_id' => $customer_id, 'url' => $website['url']));
                     foreach ($existing_websites as $existing_website) {
                         $website_id = $existing_website['website_id'];
                     }
                 }
                 //   echo $website_id;echo $website['url']; print_r($website_extra);exit;
                 if (!$website_id) {
                     $website_data = module_website::get_website($website_id);
                     $website_data['url'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['name'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['customer_id'] = $customer_id;
                     $website_id = update_insert('website_id', false, 'website', $website_data);
                     // save website extra data.
                     if ($website_id && count($website_extra)) {
                         $_REQUEST['extra_website_field'] = array();
                         foreach ($website_extra as $key => $val) {
                             $_REQUEST['extra_website_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('website', 'website_id', $website_id);
                     }
                     if ($website_id && isset($website['notes']) && strlen($website['notes'])) {
                         // add notes to this website.
                         $note_data = array('note_id' => false, 'owner_id' => $website_id, 'owner_table' => 'website', 'note_time' => time(), 'note' => $website['notes'], 'rel_data' => module_website::link_open($website_id), 'reminder' => 0, 'user_id' => $customer_data['primary_user_id']);
                         $note_id = update_insert('note_id', false, 'note', $note_data);
                     }
                 }
                 if ($website_id) {
                     if (count($website_group)) {
                         // format the address so "save_customer" handles the save for us
                         foreach ($website_group as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $website_id, 'website');
                             }
                         }
                     }
                 }
             }
             // generate jobs for this customer.
             $job_created = array();
             if ($job && isset($job['type']) && is_array($job['type'])) {
                 if (module_config::c('customer_signup_any_job_type', 0)) {
                     foreach ($job['type'] as $type_name) {
                         // we have a match in our system. create the job.
                         $job_data = module_job::get_job(false);
                         $job_data['type'] = $type_name;
                         if (!$job_data['name']) {
                             $job_data['name'] = $type_name;
                         }
                         $job_data['website_id'] = $website_id;
                         $job_data['customer_id'] = $customer_id;
                         $job_id = update_insert('job_id', false, 'job', $job_data);
                         // todo: add default tasks for this job type.
                         $job_created[] = $job_id;
                     }
                 } else {
                     foreach (module_job::get_types() as $type_id => $type) {
                         foreach ($job['type'] as $type_name) {
                             if ($type_name == $type) {
                                 // we have a match in our system. create the job.
                                 $job_data = module_job::get_job(false);
                                 $job_data['type'] = $type;
                                 if (!$job_data['name']) {
                                     $job_data['name'] = $type;
                                 }
                                 $job_data['website_id'] = $website_id;
                                 $job_data['customer_id'] = $customer_id;
                                 $job_id = update_insert('job_id', false, 'job', $job_data);
                                 // todo: add default tasks for this job type.
                                 $job_created[] = $job_id;
                             }
                         }
                     }
                 }
                 if (count($job_created) && count($job_extra)) {
                     // save job extra data.
                     foreach ($job_created as $job_created_id) {
                         if ($job_created_id && count($job_extra)) {
                             $_REQUEST['extra_job_field'] = array();
                             foreach ($job_extra as $key => $val) {
                                 $_REQUEST['extra_job_field'][] = array('key' => $key, 'val' => $val);
                             }
                             module_extra::save_extras('job', 'job_id', $job_created_id);
                         }
                     }
                 }
             }
             // save files against customer
             $uploaded_files = array();
             if (isset($_FILES['customerfiles']) && isset($_FILES['customerfiles']['tmp_name'])) {
                 foreach ($_FILES['customerfiles']['tmp_name'] as $file_id => $tmp_file) {
                     if (is_uploaded_file($tmp_file)) {
                         // save to file module for this customer
                         $file_name = basename($_FILES['customerfiles']['name'][$file_id]);
                         if (strlen($file_name)) {
                             $file_path = 'includes/plugin_file/upload/' . md5(time() . $file_name);
                             if (move_uploaded_file($tmp_file, $file_path)) {
                                 // success! write to db.
                                 $file_data = array('customer_id' => $customer_id, 'job_id' => current($job_created), 'website_id' => $website_id, 'status' => module_config::c('file_default_status', 'Uploaded'), 'pointers' => false, 'description' => "Uploaded from Customer Signup form", 'file_time' => time(), 'file_name' => $file_name, 'file_path' => $file_path, 'file_url' => false);
                                 $file_id = update_insert('file_id', false, 'file', $file_data);
                                 $uploaded_files[] = $file_id;
                             }
                         }
                     }
                 }
             }
             // we create subscriptions for this customer/website (if none already exist)
             $subscription['subscription_name'] = array();
             $subscription['subscription_invoice'] = array();
             if (class_exists('module_subscription', false) && module_subscription::is_plugin_enabled() && isset($subscription['for']) && isset($subscription['subscriptions'])) {
                 if ($subscription['for'] == 'website' && $website_id > 0) {
                     $owner_table = 'website';
                     $owner_id = $website_id;
                 } else {
                     $owner_table = 'customer';
                     $owner_id = $customer_id;
                 }
                 $available_subscriptions = module_subscription::get_subscriptions();
                 $members_subscriptions = module_subscription::get_subscriptions_by($owner_table, $owner_id);
                 foreach ($subscription['subscriptions'] as $subscription_id => $tf) {
                     if (isset($available_subscriptions[$subscription_id])) {
                         if (isset($members_subscriptions[$subscription_id])) {
                             // we don't allow a member to sign up to the same subscription twice (just yet)
                         } else {
                             $subscription['subscription_name'][$subscription_id] = $available_subscriptions[$subscription_id]['name'];
                             $start_date = date('Y-m-d');
                             $start_modifications = module_config::c('customer_signup_subscription_start', '');
                             if ($start_modifications == 'hidden') {
                                 $start_modifications = isset($_REQUEST['customer_signup_subscription_start']) ? $_REQUEST['customer_signup_subscription_start'] : '';
                             }
                             if (!empty($start_modifications)) {
                                 $start_date = date('Y-m-d', strtotime($start_modifications));
                             }
                             $sql = "INSERT INTO `" . _DB_PREFIX . "subscription_owner` SET ";
                             $sql .= " owner_id = '" . (int) $owner_id . "'";
                             $sql .= ", owner_table = '" . mysql_real_escape_string($owner_table) . "'";
                             $sql .= ", subscription_id = '" . (int) $subscription_id . "'";
                             $sql .= ", start_date = '{$start_date}'";
                             query($sql);
                             module_subscription::update_next_due_date($subscription_id, $owner_table, $owner_id, true);
                             // and the same option here to send a subscription straight away upon signup
                             if (module_config::c('subscription_send_invoice_straight_away', 0)) {
                                 global $plugins;
                                 $plugins['subscription']->run_cron();
                                 // check if there are any invoices for this subscription
                                 $history = module_subscription::get_subscription_history($subscription_id, $owner_table, $owner_id);
                                 if (count($history) > 0) {
                                     foreach ($history as $h) {
                                         if ($h['invoice_id']) {
                                             $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                                             if ($invoice_data['date_cancel'] != '0000-00-00') {
                                                 continue;
                                             }
                                             $subscription['subscription_invoice'][] = '<a href="' . module_invoice::link_public($h['invoice_id']) . '">' . _l('Invoice #%s for %s', htmlspecialchars($invoice_data['name']), dollar($invoice_data['total_amount'], true, $invoice_data['currency_id'])) . '</a>';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (!count($subscription['subscription_name'])) {
                 $subscription['subscription_name'][] = _l('N/A');
             }
             if (!count($subscription['subscription_invoice'])) {
                 $subscription['subscription_invoice'][] = _l('N/A');
             }
             $subscription['subscription_name'] = implode(', ', $subscription['subscription_name']);
             $subscription['subscription_invoice'] = implode(', ', $subscription['subscription_invoice']);
             // email the admin when a customer signs up.
             $values = array_merge($customer, $customer_extra, $website, $website_extra, $address, $subscription);
             $values['customer_name'] = $customer['customer_name'];
             $values['CUSTOMER_LINK'] = module_customer::link_open($customer_id);
             $values['CUSTOMER_NAME_LINK'] = module_customer::link_open($customer_id, true);
             if ($website_id) {
                 $values['WEBSITE_LINK'] = module_website::link_open($website_id);
                 $values['WEBSITE_NAME_LINK'] = module_website::link_open($website_id, true);
             } else {
                 $values['WEBSITE_LINK'] = _l('N/A');
                 $values['WEBSITE_NAME_LINK'] = _l('N/A');
             }
             $values['JOB_LINKS'] = '';
             if (count($job_created)) {
                 $values['JOB_LINKS'] .= 'The customer created ' . count($job_created) . ' jobs in the system: <br>';
                 foreach ($job_created as $job_created_id) {
                     $values['JOB_LINKS'] .= module_job::link_open($job_created_id, true) . "<br>\n";
                 }
             } else {
                 $values['JOB_LINKS'] = _l('N/A');
             }
             if (count($uploaded_files)) {
                 $values['uploaded_files'] = 'The customer uploaded ' . count($uploaded_files) . " files:<br>\n";
                 foreach ($uploaded_files as $uploaded_file) {
                     $values['uploaded_files'] .= module_file::link_open($uploaded_file, true) . "<br>\n";
                 }
             } else {
                 $values['uploaded_files'] = 'No files were uploaded';
             }
             $values['WEBSITE_NAME'] = isset($website['url']) ? $website['url'] : 'N/A';
             if (!$creating_new) {
                 $values['system_note'] = "Note: this signup updated the existing customer record in the system.";
             } else {
                 $values['system_note'] = "Note: this signup created a new customer record in the system.";
             }
             $customer_signup_template = module_config::c('customer_signup_email_admin_template', 'customer_signup_email_admin');
             if (isset($_REQUEST['customer_signup_email_admin_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_admin_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to_manual(module_config::c('customer_signup_admin_email', module_config::c('admin_email_address')));
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             $customer_signup_template = module_config::c('customer_signup_email_welcome_template', 'customer_signup_email_welcome');
             if (isset($_REQUEST['customer_signup_email_welcome_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_welcome_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->customer_id = $customer_id;
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to('user', $customer_data['primary_user_id']);
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             //todo: optional redirect to url
             if (isset($_REQUEST['via_ajax'])) {
                 echo json_encode(array('success' => 1, 'customer_id' => $customer_id));
                 exit;
             }
             if (module_config::c('customer_signup_redirect', '')) {
                 redirect_browser(module_config::c('customer_signup_redirect', ''));
             }
             // load up the thank you template.
             $template = module_template::get_template_by_key('customer_signup_thank_you_page');
             $template->page_title = _l("Customer Signup");
             foreach ($values as $key => $val) {
                 if (!is_array($val)) {
                     $values[$key] = htmlspecialchars($val);
                 }
             }
             $template->assign_values($values);
             echo $template->render('pretty_html');
             exit;
             break;
     }
 }
Ejemplo n.º 18
0
 public static function get_job_task_creation_permissions()
 {
     if (!module_security::is_logged_in()) {
         //todo - option to allow guests to create tasks with approval? or not to create tasks at all.
         return _JOB_TASK_CREATION_REQUIRES_APPROVAL;
     } else {
         if (class_exists('module_security', false)) {
             return module_security::can_user_with_options(module_security::get_loggedin_id(), 'Job Task Creation', array(_JOB_TASK_CREATION_WITHOUT_APPROVAL, _JOB_TASK_CREATION_REQUIRES_APPROVAL, _JOB_TASK_CREATION_NOT_ALLOWED));
         } else {
             return _JOB_TASK_CREATION_WITHOUT_APPROVAL;
             // default to all permissions.
         }
     }
 }
Ejemplo n.º 19
0
    public function handle_hook($hook_name)
    {
        if ($hook_name == 'top_menu_end' && module_pin::can_i('view', 'Header Pin') && module_config::c('pin_show_in_menu', 1) && module_security::is_logged_in()) {
            ?>

            <li id="top_menu_pin">
                <div id="top_menu_pin_options">
                    <div class="pin_title">
                        <?php 
            if (module_pin::can_i('create', 'Header Pin')) {
                ?>

                        <a href="#" id="pin_current_page"><?php 
                _e('Pin Current Page +');
                ?>
</a>
                        <?php 
            }
            ?>

                        <?php 
            _e('Quick Pin');
            ?>

                    </div>
                    <ul id="pin_options">
                        <?php 
            foreach ($this->get_pins() as $pin_id => $pin) {
                ?>

                        <li rel="<?php 
                echo $pin_id;
                ?>
">
                            <div class="top_menu_pin_actions">
                                <?php 
                if (module_pin::can_i('edit', 'Header Pin')) {
                    ?>

                                <a href="#" class="top_menu_pin_edit">[e]</a>
                                <?php 
                }
                ?>

                                <?php 
                if (module_pin::can_i('delete', 'Header Pin')) {
                    ?>

                                <a href="#" class="top_menu_pin_delete">[x]</a>
                                <?php 
                }
                ?>

                            </div>
                            <a href="<?php 
                echo $pin[0];
                ?>
" class="top_menu_pin_item"><?php 
                echo htmlspecialchars($pin[1]);
                ?>
</a>
                        </li>
                        <?php 
            }
            ?>

                    </ul>

                    <form action="" method="post" id="pin_action_form">
                        <input type="hidden" name="pin_process" value="pin_save">
                        <input type="hidden" name="pin_id" id="pin_id" value="">
                        <input type="hidden" name="current_url" value="<?php 
            echo htmlspecialchars($_SERVER['REQUEST_URI']);
            ?>
">
                        <input type="hidden" name="current_title" id="pin_current_title" value="">
                        <input type="hidden" name="pin_action" id="pin_action" value="">
                    </form>
                </div>
                <a href="#" title="<?php 
            _e('Pin');
            ?>
"><?php 
            _e('Pin');
            ?>
</a>
            </li>
            <?php 
        }
    }
Ejemplo n.º 20
0
 public static function get_current_logged_in_company_id()
 {
     if (self::$_current_company_id) {
         return self::$_current_company_id;
     }
     if (module_security::is_logged_in()) {
         $company_access = self::get_company_data_access();
         switch ($company_access) {
             case _COMPANY_ACCESS_ALL:
                 break;
             case _COMPANY_ACCESS_ASSIGNED:
             case _COMPANY_ACCESS_CONTACT:
                 // this is a possibility that this user only has access to a single customer
                 $companies = self::get_companys();
                 if (count($companies) == 1) {
                     // only 1 woo! get this id and load in any custom config values.
                     $company = array_shift($companies);
                     if ($company && $company['company_id'] > 0) {
                         self::$_current_company_id = $company['company_id'];
                         return self::$_current_company_id;
                     }
                 }
         }
     }
     return false;
 }
Ejemplo n.º 21
0
    echo htmlspecialchars($change_request['name']);
} else {
    ?>
                <input type="text" name="name" class="wp3changerequest_input" value="<?php 
    echo htmlspecialchars($change_request['name']);
    ?>
">
	            <?php 
}
?>
            </td>
        </tr>
    </table>

    <?php 
if ($change_id && module_security::is_logged_in() && module_change_request::can_i('edit', 'Change Requests')) {
    ?>
    <div class="wp3changerequest_message_box">
        <table>
            <tr>
                <th>
                    <?php 
    _e('Completed?');
    ?>
                </th>
                <td>
                    <input type="hidden" name="completed_test" value="1">
                    <input type="checkbox" id="change_completed" name="completed" value="1">
                    <label for="change_completed"><?php 
    _e('Yes, this change has been completed.');
    ?>
Ejemplo n.º 22
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca, 0a3014a3-2b8f-460b-8850-d6025aa845f8
 * Package Date: 2015-11-25 03:08:08 
 * IP Address: 67.79.165.254
 */
if (isset($_REQUEST['sort_order']) && is_array($_REQUEST['sort_order']) && isset($_REQUEST['auth']) && module_form::get_secure_key() == $_REQUEST['auth'] && module_security::is_logged_in()) {
    module_config::save_config('dash_widgets_sort_' . module_security::get_loggedin_id(), json_encode($_REQUEST['sort_order']));
}
module_config::register_css('theme', 'morris.css', full_link('/includes/plugin_theme_adminlte/css/morris.css'), 12);
module_config::register_css('theme', 'ionicons.min.css', full_link('/includes/plugin_theme_adminlte/css/ionicons.min.css'), 12);
module_config::register_js('theme', 'raphael-min.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/raphael-min.js'), 12);
module_config::register_js('theme', 'morris.min.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/morris.min.js'), 13);
module_config::register_js('theme', 'dashboard.js', full_link('/includes/plugin_theme_adminlte/js/AdminLTE/dashboard.js'), 14);
$calling_module = 'home';
$home_widgets = handle_hook('dashboard_widgets', $calling_module);
$home_widgets2 = hook_handle_callback('dashboard_widgets');
if (is_array($home_widgets2)) {
    $home_widgets = array_merge($home_widgets, $home_widgets2);
}
// group the widgets into columsn.
// the default columns is 3, but each widget can specify which column group they want to appear in.
// layout the default widget structure in the order we want it to display on the page:
$widget_columns = array();
$widget_columns[4] = array(1 => array(), 2 => array(), 3 => array(), 4 => array());
$widget_columns[1] = array(1 => array());
Ejemplo n.º 23
0
    public static function hook_header_print_js()
    {
        if (module_security::is_logged_in()) {
            ?>

			<script type="text/javascript">
			ucm.form_auth_key = '<?php 
            echo self::get_secure_key();
            ?>
';
			ucm.lang.ok = '<?php 
            _e('OK');
            ?>
';
			ucm.lang.mins = '<?php 
            _e('mins');
            ?>
';
			ucm.lang.hr = '<?php 
            _e('hr');
            ?>
';
			ucm.lang.hrs = '<?php 
            _e('hrs');
            ?>
';
			ucm.lang.am = '<?php 
            _e('am');
            ?>
';
			ucm.lang.AM = '<?php 
            _e('AM');
            ?>
';
			ucm.lang.pm = '<?php 
            _e('pm');
            ?>
';
			ucm.lang.PM = '<?php 
            _e('PM');
            ?>
';
			ucm.settings = ucm.settings || {};
			ucm.settings.time_format = '<?php 
            echo preg_replace('#[^a-zA-Z:]#', '', module_config::c('time_format', 'g:ia'));
            ?>
';
			</script>
			<?php 
        }
    }
Ejemplo n.º 24
0
    public function init()
    {
        $this->links = array();
        $this->invoice_types = array();
        $this->module_name = "invoice";
        $this->module_position = 18;
        $this->version = 2.771;
        //2.771 - 2015-10-17 - item_tax template tag fix
        //2.770 - 2015-07-19 - invoice tax discount fix
        //2.769 - 2015-07-18 - hide job if disabled
        //2.768 - 2015-04-13 - credit note pdf fix
        //2.767 - 2015-03-24 - invoice renewal tax fix
        //2.766 - 2015-03-24 - more invoice settings
        //2.765 - 2015-03-24 - blank invoice template fix
        //2.764 - 2015-03-14 - better invoice payment method defaults/overrides
        //2.763 - 2015-03-08 - arithmetic in invoice_task_list template
        //2.762 - 2015-02-24 - invoice email template fix
        //2.761 - 2015-02-12 - product defaults (tax/bill/type)
        //2.76 - 2015-02-08 - invoice_increment_date_check for unique incrementing invoice numbers per year
        //2.759 - 2014-12-31 - hourly rate fix
        //2.758 - 2014-12-22 - invoice task decimal places
        //2.757 - 2014-12-22 - sends invoice due to early subscription payment
        //2.756 - 2014-11-27 - invoice payment improvements
        //2.755 - 2014-11-26 - more work on vendor staff billing feature
        //2.754 - 2014-11-19 - fix for finance list when assigning customer credit / overpayments
        //2.753 - 2014-11-07 - hours:mins bug fix
        //2.752 - 2014-11-05 - link manual invoice to website
        //2.751 - 2014-10-13 - custom subscription invoice templates
        //2.75 - 2014-09-28 - added more tags to invoice_task_list template
        //2.749 - 2014-09-18 - overdue_email_auto_days date calculation fix
        //2.748 - 2014-09-03 - negative taxes
        //2.747 - 2014-09-02 - mark invoice as sent fix and invoice_renew_discounts
        //2.746 - 2014-08-27 - invoice search by date paid
        //2.745 - 2014-08-25 - delete invoice translation fix
        //2.744 - 2014-08-20 - invoice_payment_methods template
        //2.743 - 2014-08-19 - tax_decimal_places and tax_trim_decimal
        //2.742 - 2014-08-18 - pdf invoice printing improvement
        //2.741 - 2014-08-14 - website integration fix
        //2.74 - 2014-08-12 - external_invoice_SUFFIX
        //2.739 - 2014-08-01 - responsive improvements
        //2.738 - 2014-07-22 - invoice translation improvement Qty/Amount/Discount
        //2.737 - 2014-07-14 - improvement with hours:minutes formatting
        //2.736 - 2014-07-08 - quote and job discounts through to invoice
        //2.735 - 2014-07-02 - permission improvement
        //2.734 - 2014-07-01 - automatic invoice payment receipt option
        //2.733 - 2014-07-01 - invoice renewal monthly fix
        //2.732 - 2014-07-01 - invoice_template_print default for customer
        //2.731 - 2014-07-01 - invoice_template_print default for customer
        //2.73 - 2014-06-30 - sending overdue invoice bug fix
        //2.729 - 2014-06-27 - invoice default task fix
        //2.728 - 2014-06-24 - invoice fee calculation improvement
        //2.727 - 2014-06-24 - fix for negative quantites and amounts
        //2.726 - 2014-06-23 - invoice fee calculation improvement
        //2.725 - 2014-06-09 - hours:minutes task formatting
        //2.724 - 2014-05-23 - new invoice pdf template called invoice_print_basic (see blog)
        //2.723 - 2014-05-21 - new invoice pdf template and faster pdf generation
        //2.722 - 2014-04-10 - date_sent added to template tags
        //2.721 - 2014-04-10 - blank invoice subscription bug fix (see Settings-Invoices)
        //2.72 - 2014-04-10 - blank invoice subscription bug fix (see Settings-Invoices)
        //2.719 - 2014-04-09 - invoice page speed improvements
        //2.718 - 2014-04-03 - speed improvements
        //2.717 - 2014-03-31 - duplicate invoice bug fix
        //2.716 - 2014-03-26 - save and return button added
        //2.715 - 2014-03-20 - translation fix in invoice payments and credits
        //2.714 - 2014-03-16 - multiple tax support in jobs
        //2.713 - 2014-03-15 - comma separated default list for multiple taxes
        //2.712 - 2014-03-10 - support for payment gateway fees and discounts
        //2.711 - 2014-03-08 - {if:IS_INVOICE_PAID} template flag
        //2.71 - 2014-03-04 - subscription payments as invoice credit
        //2.699 - 2014-03-04 - allowed payment methods currency restriction fix
        //2.698 - 2014-02-24 - change total amount due to 0 for cancelled invoices
        //2.697 - 2014-02-18 - show offline payment details in main invoice page
        //2.696 - 2014-02-15 - added {RECEIPT_DETAILS} to receipt template
        //2.695 - 2014-02-06 - number_trim_decimals advanced settings
        //2.694 - 2014-02-05 - sorting by total amount due
        //2.693 - 2014-01-30 - thankyou page shown after making an invoice payment
        //2.692 - 2014-01-27 - replace fields from jobs show within invoices as well
        //2.691 - 2014-01-21 - new jquery version fix
        //2.69 - 2014-01-20 - contact email bug fix
        //2.689 - 2014-01-18 - starting work on automatic recurring payments
        //2.688 - 2014-01-11 - invoice in upcoming payments bug fix
        //2.687 - 2014-01-10 - invoice_allow_payment_amount_adjustment added
        //2.686 - 2014-01-03 - invoices with renewal date now appear in finance upcomming
        //2.685 - 2013-12-19 - invoice inrementing bug fix
        //2.684 - 2013-12-15 - support for negative invoice amounts
        //2.683 - 2013-12-11 - permission improvements
        //2.682 - 2013-11-21 - working on new UI
        //2.681 - 2013-11-15 - working on new UI
        //2.68 - 2013-11-13 - advanced option invoice_file_prefix and credit_note_file_prefix for PDFs
        //2.679 - 2013-11-12 - bug fix in new invoice refunds feature
        //2.678 - 2013-11-11 - started on invoice refunds
        //2.677 - 2013-10-30 - sql fix for clients
        //2.676 - 2013-10-11 - fix duplicate tax when saving.
        //2.675 - 2013-10-06 - feature to invoice incomplete job tasks
        //2.674 - 2013-10-05 - Settings > Invoice - option to choose what time of day for renewals/emails to occur
        //2.673 - 2013-10-04 - ability to show tax per line item in invoice PDF
        //2.672 - 2013-10-04 - option to disable website plugin
        //2.671 - 2013-10-04 - merge invoice fix
        //2.67 - 2013-10-02 - print html option
        //2.669 - 2013-10-02 - deleting invoice payment fix
        //2.668 - 2013-10-02 - assign credit currency fix
        //2.667 - 2013-09-29 - ability to disable all payment methods for an invoice
        //2.666 - 2013-09-28 - ability to disable all payment methods for an invoice
        //2.665 - 2013-09-26 - invoice expenses added below invoice
        //2.664 - 2013-09-25 - illegal offset fix
        //2.663 - 2013-09-24 - assign credit button fix
        //2.662 - 2013-09-23 - overdue emails on cancelled invoices bug fix
        //2.661 - 2013-09-20 - invoice paid date correction on split-day payments
        //2.66 - 2013-09-20 - invoice tax included fixes
        //2.659 - 2013-09-13 - ability to assign an invoice to company when customer has more than 1 company
        //2.658 - 2013-09-12 - dashboard speed improvement and better caching
        //2.657 - 2013-09-11 - update customer status after invoice delete
        //2.656 - 2013-09-10 - dashboard alerts cache fix
        //2.655 - 2013-09-09 - invoice primary contact assignment
        //2.654 - 2013-09-09 - invoice renewal redirect/date fix
        //2.653 - 2013-09-07 - bulk delete invoices
        //2.652 - 2013-09-06 - easier to disable plugins
        //2.651 - 2013-09-05 - multiple tax improvement
        //2.649 - 2013-09-03 - hide tax on invoices if none is present
        //2.648 - 2013-09-03 - support for multiple tax rates. Paid date bug fix.
        //2.647 - 2013-09-03 - invoice_auto_renew_only_paid_invoices config variable added
        //2.645 - 2013-08-30 - fix for saving renewable invoices
        //2.644 - 2013-08-30 - added memcache support for huge speed improvements
        //2.643 - 2013-08-28 - big feature - automated customer/member subscriptions
        //2.642 - 2013-08-27 - big feature - automated invoicing + automated overdue emails
        //2.641 - 2013-08-20 - invoices now overdue day after due date
        //2.64 - 2013-08-13 - fix for discount on pdf printout
        //2.639 - 2013-08-08 - fix for hours on dashboard
        //2.638 - 2013-07-29 - new _UCM_SECRET hash in config.php
        //2.637 - 2013-07-25 - invoice bug fixing
        //2.636 - 2013-07-16 - dashboard link fix
        //2.635 - 2013-07-15 - dashboard fix
        //2.634 - 2013-07-15 - bug fix
        //2.633 - 2013-07-01 - add multiple taxes to invoice
        //2.632 - 2013-06-21 - permission update - new invoice permissions
        //2.631 - 2013-06-17 - job improvement when invoice has discount
        //2.63 - 2013-06-14 - customer color coding
        //2.629 - 2013-05-28 - email template field improvements
        //2.628 - 2013-05-28 - email template field improvements
        //2.627 - 2013-05-27 - dashboard alert improvements.
        //2.626 - 2013-05-08 - invoice hours fix
        //2.625 - 2013-04-28 - rounding improvements for different currency formats
        //2.624 - 2013-04-27 - rounding improvements for different currency formats
        //2.623 - 2013-04-26 - task type selection +others on invoice creation
        //2.622 - 2013-04-26 - fix for $0 invoices
        //2.621 - 2013-04-26 - fix for deposit invoices from jobs
        //2.619 - 2013-04-21 - number formatting improvements
        //2.618 - 2013-04-21 - invoice pdf print fix
        //2.617 - 2013-04-20 - invoice merge improvement
        //2.616 - 2013-04-18 - fix for pdf downloads
        //2.615 - 2013-04-16 - PLEASE CHECK YOUR INVOICES AFTER THIS UPDATE TO ENSURE THEY ARE STILL CORRECT!
        //2.614 - 2013-04-16 - PLEASE CHECK YOUR INVOICES AFTER THIS UPDATE TO ENSURE THEY ARE STILL CORRECT!
        //2.613 - 2013-04-16 - new advanced field task_taxable_default
        // old version information prior to 2013-04-16:
        //2.421 - fix for invoice currency in printout.
        //2.422 - fix for assigning credit
        //2.423 - assigning contacts to invoices.
        //2.424 - fix for invoice prefix number.
        //2.5 - recurring invoices. task hourly rates. payment methods per invoice. payment methods text moved to template area.
        //2.51 - date fix for recurring invoices.
        //2.52 - fix for saving extra fields on renewd invoices.
        //2.521 - added currency to invoice hourly amount.
        //2.522 - blank extra fields come through as N/A in invoices now.
        //2.523 - paid date not clearing properly when renewing invoice.
        //2.524 - added member_id for better subscription integration (eg: sending an email).
        //2.525 - multiple currency fixes
        //2.53 - new theme layout
        //2.531 - date done moved into invoice layout.
        //2.532 - bug fix in invoice task list - hourly rate
        //2.533 - permission fix for viewing invoices without customer access.
        //2.534 - customise the Hours column header
        //2.535 - upgrade fix
        //2.536 - replace fields in email template
        //2.537 - CUSTOMER_GROUP, WEBSITE_GROUP and JOB_GROUP added to invoice templates
        //2.538 - testing non-taxable items in invoices
        //2.539 - perm fix
        //2.54 - invoice empty items
        //2.541 - printing from mobile
        //2.542 - invoice qty/amount fix
        //2.543 - another invoice qty/amount fix
        //2.544 - send to primary contact
        //2.545 - discount type
        //2.546 - tax fix. calculate individually on each item.
        //2.547 - date renewl on invoices, -1 day
        //2.548 - mobile fix
        //2.549 - external invoice fix
        //2.55 - fix for invoice re-generation and dates.
        //2.551 - fix for 100% discounted invoices
        //2.552 - extra fields in invoice print from customer section
        //2.553 - custom details in invoice payment area.
        //2.554 - invoice numbers A to Z, then AA to AZ, etc..
        //2.555 - support for incrementing invoice numbers - see advanced invoice_incrementing settings
        //2.556 - better support for multi-job and multi-website invoice prints
        //2.557 - before tax/after tax invoice fix
        //2.558 - 'invoice_send_alerts' advanced setting added
        //2.559 - invoice line numbers are now editable
        //2.56 - quick search based on invoice amount or invoice payment
        //2.561 - remove discount on renewed invoices
        //2.562 - support for negative invoice line items
        //2.563 - invoice bug, possible duplication fix?
        //2.564 - bug fix for incrementing invoice numbers
        //2.565 - option to use invoice name as job name (see invoice_name_match_job option)
        //2.566 - task "long description" added to invoice items like it is in job tasks
        //2.567 - quicker way to print multiple pdf's
        //2.568 - starting work on handling job deposits and customer credit
        //2.569 - added 'contact_first_name' and 'contact_last_name' to template fields.
        //2.570 - speed improvements.
        //2.571 - currency fixes and email features
        //2.572 - currency fixes and email features
        //2.573 - invoice email bug fix
        //2.574 - {INVOICE_DATE_RANGE} template tag added to invoice emails.
        //2.575 - job/invoice deposits made easier.
        //2.576 - deposits and customer credits working nicely now.
        //2.577 - choose different templates when sending an invoice to customer.
        //2.578 - cancel invoice so no more payment reminder
        //2.579 - fix for subscription in finance upcoming items
        //2.58 - invoice credit fixing.
        //2.581 - customer subscription fixes
        //2.582 - support for public invoices notes
        //2.583 - support for multiple invoice pdf print templates
        //2.584 - search by customer group
        //2.585 - speed improvements
        //2.586 - item hourly rate/qty improvements
        //2.587 - bug fix for invoice subscription renewals
        //2.588 - date fix on dashboard invoice alerts
        //2.589 - initial work on a credit note feature
        //2.59 - extra fields update - show in main listing option
        //2.591 - job deposit fix
        //2.592 - customer invoice payment fix
        //2.593 - tax added/included option
        //2.594 - big update - manual task percent, task type (hourly/qty/amount)
        //2.595 - invoice task list improvement
        //2.596 - total_amount_due made available in email template
        //2.597 - bug fix in finance
        //2.598 - 2013-04-04 - fix for 0 invoice amounts.
        //2.599 - 2013-04-04 - new 'invoice_payment_methods_online_footer' template for pdfs
        //2.61 - 2013-04-05 - support for products in invoices
        //2.611 - 2013-04-07 - invoice PDF print fix
        //2.612 - 2013-04-10 - new customer permissions
        // new version information starting from top ^^
        // todo: add completed date as a configurable column
        // todo: move invoice layout to a template system.
        module_config::register_css('invoice', 'invoice.css');
        module_config::register_js('invoice', 'invoice.js');
        hook_add('finance_recurring_list', 'module_invoice::get_finance_recurring_items');
        if (class_exists('module_template', false) && module_security::is_logged_in()) {
            module_template::init_template('invoice_payment_methods', '<table width="100%" class="tableclass" id="invoice_payment_methods">
    <tbody>
    <tr>
        <td valign="top" style="width:50%">
	        {PAYMENT_METHODS_ONLINE}
        </td>
        <td valign="top" style="width:50%">
	        {PAYMENT_METHODS_OFFLINE}
        </td>
    </tr>
    </tbody>
</table><br/>
	        ', 'Holds the invoice payment methods at the bottom.', 'code');
            module_template::init_template('invoice_payment_methods_online', '<strong>Option #1: Pay Online</strong>
	        <br/>
	        We support the following secure payment methods:
	        <br/>
	        ', 'Displayed on the invoice.', 'code');
            module_template::init_template('invoice_payment_methods_online_footer', '{PAYMENT_METHODS}
	        <br/>
	        Please <a href="{LINK}">click here</a> to pay online.
	        ', 'Displayed on the invoice.', 'code', array('LINK' => 'URL link to invoice page', 'PAYMENT_METHODS' => 'List of supported payment methods'));
            module_template::init_template('invoice_payment_methods_offline', '<strong>Option #2: Pay Offline</strong>
	        <br/>
	        We support the following offline payment methods:
	        <br/>
	        ', 'Displayed on the external invoice.', 'code');
            module_template::init_template('invoice_payment_in_full', 'Invoice has been paid in full. <br/><br/>
	        Thank you for your business.
	        ', 'Displayed on the external invoice.', 'code');
            module_template::init_template('invoice_payment_pending', 'Automatic Invoice Payment Pending. <br/><br/>
	        Thank you for your business.
	        ', 'Displayed when a user has an automatic payment pending on an invoice.', 'code');
            //module_template::init_template('invoice_payment_methods_title','','Displayed as the title on invoice for payment methods area','code');
            module_template::init_template('invoice_payment_thankyou', '<h2>Invoice Payment</h2>
	<p>Invoice Number: <strong>{INVOICE_NUMBER}</strong> </p>
	<p>Thank you for making payment on this Invoice. We will email you a receipt shortly.</p>
	', 'This page is displayed after a payment is made on an invoice.', 'code');
            module_template::init_template('invoice_payment_subscription', '<h2>Payment for Invoice {INVOICE_NUMBER}</h2>
<p>Please choose from the available payment options below:</p>
<form action="{PAYMENT_URL}" method="post">
<input type="hidden" name="invoice_payment_id" value="{INVOICE_PAYMENT_ID}">
<input type="hidden" name="payment_method" value="{PAYMENT_METHOD}">
<input type="hidden" name="payment_amount" value="{PAYMENT_AMOUNT}">
<p><input type="submit" name="payment_single" value="Pay a Once Off amount of {PRETTY_PAYMENT_AMOUNT}"></p>
<p><input type="submit" name="payment_subscription" value="Setup Automatic Payments of {PRETTY_PAYMENT_AMOUNT} every {SUBSCRIPTION_PERIOD}"></p>
</form>
', 'Used when a customer tries to pay an invoice that has a subscription option.', 'code');
            module_template::init_template('invoice_email_due', 'Dear {CUSTOMER_NAME},<br>
<br>
Please find attached your invoice {INVOICE_NUMBER}.<br><br>
The {TOTAL_AMOUNT} is due on {DATE_DUE}.<br><br>
You can also view this invoice online by <a href="{INVOICE_URL}">clicking here</a>.<br><br>
Thank you,<br><br>
{FROM_NAME}
', 'Invoice Owing: {INVOICE_NUMBER}', array('CUSTOMER_NAME' => 'Customers Name', 'INVOICE_NUMBER' => 'Invoice Number', 'TOTAL_AMOUNT' => 'Total amount of invoice', 'DATE_DUE' => 'Due Date', 'FROM_NAME' => 'Your name', 'INVOICE_URL' => 'Link to invoice for customer'));
            module_template::init_template('credit_note_email', 'Dear {CUSTOMER_NAME},<br>
<br>
Please find attached your Credit Note {INVOICE_NUMBER} for Invoice {CREDIT_INVOICE_NUMBER}.<br><br>
Total amount: {TOTAL_AMOUNT}<br><br>
You can view this invoice online by <a href="{INVOICE_URL}">clicking here</a>.<br><br>
Thank you,<br><br>
{FROM_NAME}
', 'Credit Note: {INVOICE_NUMBER}', array('CUSTOMER_NAME' => 'Customers Name', 'INVOICE_NUMBER' => 'Credit Note Number', 'CREDIT_INVOICE_NUMBER' => 'Original Invoice Number', 'TOTAL_AMOUNT' => 'Total amount of invoice', 'FROM_NAME' => 'Your name', 'INVOICE_URL' => 'Link to invoice for customer'));
            module_template::init_template('invoice_email_overdue', 'Dear {CUSTOMER_NAME},<br>
<br>
The attached invoice {INVOICE_NUMBER} is now <span style="font-weight:bold; color:#FF0000;">overdue</span>.<br><br>
The {TOTAL_AMOUNT} was due on {DATE_DUE}.<br><br>
You can also view this invoice online by <a href="{INVOICE_URL}">clicking here</a>.<br><br>
Thank you,<br><br>
{FROM_NAME}
', 'Invoice Overdue: {INVOICE_NUMBER}', array('CUSTOMER_NAME' => 'Customers Name', 'INVOICE_NUMBER' => 'Invoice Number', 'TOTAL_AMOUNT' => 'Total amount of invoice', 'DATE_DUE' => 'Due Date', 'FROM_NAME' => 'Your name', 'INVOICE_URL' => 'Link to invoice for customer'));
            module_template::init_template('invoice_email_paid', 'Dear {CUSTOMER_NAME},<br>
<br>
Thank you for your {TOTAL_AMOUNT} payment on invoice {INVOICE_NUMBER}.<br><br>
This invoice was paid in full on {DATE_PAID}.<br><br>
Please find attached the receipt for this invoice payment. <br>
You can also view this invoice online by <a href="{INVOICE_URL}">clicking here</a>.<br><br>
Thank you,<br><br>
{FROM_NAME}
', 'Invoice Paid: {INVOICE_NUMBER}', array('CUSTOMER_NAME' => 'Customers Name', 'INVOICE_NUMBER' => 'Invoice Number', 'TOTAL_AMOUNT' => 'Total amount of invoice', 'DATE_PAID' => 'Paid date', 'FROM_NAME' => 'Your name', 'INVOICE_URL' => 'Link to invoice for customer'));
        }
    }
Ejemplo n.º 25
0
 public function mark_as_read()
 {
     if ($this->social_twitter_message_id && module_security::is_logged_in()) {
         $sql = "REPLACE INTO `" . _DB_PREFIX . "social_twitter_message_read` SET `social_twitter_message_id` = " . (int) $this->social_twitter_message_id . ", `user_id` = " . (int) module_security::get_loggedin_id() . ", read_time = " . (int) time();
         query($sql);
     }
 }
Ejemplo n.º 26
0
    public static function generate_preview($file_id, $file_name, $file_data)
    {
        ob_start();
        if ($file_data['file_name'] && preg_match('/\\.(\\w\\w\\w\\w?)$/', $file_name, $matches)) {
            $show_output = false;
            switch (strtolower($matches[1])) {
                case 'jpg':
                case 'jpeg':
                case 'gif':
                case 'png':
                    $show_output = true;
                    ?>

            <div style="width:100%; overflow:auto;" id="file_preview">
                <div id="pointer_template" style="padding:3px; background-color:#EFEFEF; border:1px solid #CCC; position:absolute; display:none;">
                    #<span class="pointer_id">0</span>
                </div>
                <div id="pointer_holder" style="position: relative; float: left; height: 0pt;"></div>

                        <img src="<?php 
                    echo module_file::link_public_view($file_id);
                    ?>
" alt="<?php 
                    _e('Click to add a comment');
                    ?>
" style="cursor:pointer;"> <!-- style="max-width: 100%" -->
                    </div>
            <?php 
                    if (!module_security::is_logged_in() || module_file::can_i('create', 'File Comments')) {
                        ?>

                    <input type="hidden" name="pointers" id="pointer_save" value="<?php 
                        echo $file_data['pointers'];
                        ?>
" class="no_permissions">
                <?php 
                    }
                    ?>


                <style type="text/css">
                    .pointer-ids{
                        background-color:#EFEFEF;
                        border:1px solid #CCC;
                        cursor:pointer;
                    }
                </style>
                <script language="javascript">
                    var pointers = new Array();
                    var pointer_id;
                    <?php 
                    $pointers = explode('|', $file_data['pointers']);
                    if (!is_array($pointers)) {
                        $pointers = array();
                    }
                    $pointer_id = 0;
                    foreach ($pointers as $pointer) {
                        if (!trim($pointer)) {
                            continue;
                        }
                        $p = explode(",", $pointer);
                        $pointer_id = max($p[0], $pointer_id);
                        ?>

                        pointers.push({
                            id:<?php 
                        echo $p[0];
                        ?>
,
                            x:<?php 
                        echo $p[1];
                        ?>
,
                            y:<?php 
                        echo $p[2];
                        ?>
,
                            printed:false
                        });
                        <?php 
                    }
                    ?>

                    pointer_id = <?php 
                    echo $pointer_id;
                    ?>
;
                    var add_pointer=true;
                    function print_pointers(){
                        var pointer_save = '';
                        for(var i in pointers){
                            pointer_save += pointers[i].id + ',' + pointers[i].x + ',' + pointers[i].y + '|';
                            if(pointers[i].printed)continue;
                            pointers[i].dom = $('#pointer_template').clone(true).attr('id','').show();
                            $('.pointer_id',pointers[i].dom).html(pointers[i].id);
                            $(pointers[i].dom).css('marginTop',pointers[i].y+'px');
                            $(pointers[i].dom).css('marginLeft',pointers[i].x+'px');
                            $(pointers[i].dom).attr('node_id',pointers[i].id);
                            $(pointers[i].dom).data('id',i);
                            $(pointers[i].dom).attr('class','pointer-ids pointer-id-'+pointers[i].id);
                            $(pointers[i].dom).click(function(){
                                add_pointer=false;
                                var id = $(this).data('id');
                                var node_id = $(this).attr('node_id');
                                if(confirm('Really remove pointer '+node_id+'?')){
                                    $(pointers[id].dom).remove();
                                    delete(pointers[id]);
                                    print_pointers();
                                }
                            });
                            $('#pointer_holder').prepend(pointers[i].dom);
                            pointers[i].printed=true;
                            pointer_hover_node(pointers[i].dom);
                        }
                        $('#pointer_save').val(pointer_save);
                    }
                    function pointer_hover_node(node){
                        $(node).hover(
                            function(){
                                var id = $(node).attr('node_id');
                                $('.pointer-id-'+id).css('backgroundColor','#FFC707');
                            },
                            function(){
                                var id = $(node).attr('node_id');
                                $('.pointer-id-'+id).css('backgroundColor','#EFEFEF');
                            }
                        );
                    }
                    $(document).ready(function(){
                        <?php 
                    if (module_file::can_i('create', 'File Comments')) {
                        ?>

                        $("#file_preview").click(function(e){
                            if(!add_pointer){
                                add_pointer=true;
                                return;
                            }
                            pointer_id++;
                            var offset = $(this).offset();
                            pointers.push({
                                id: pointer_id,
                                x: (e.pageX - offset.left) + this.scrollLeft,
                                y: e.pageY - offset.top,
                                printed: false
                            });
                            print_pointers();
                        });
                        <?php 
                    }
                    ?>

                        print_pointers();
                        $('#file_notes .pointer-ids').each(function(){pointer_hover_node(this);});
                    });

                </script>

                        <?php 
                    break;
                case 'pdf':
                    $embed_url = module_file::link_public_view($file_id);
                    $embed_url .= strpos($embed_url, '?') === false ? '?' : '&';
                    $embed_url .= 'embed=true';
                    ?>

                    <iframe src="//docs.google.com/gview?url=<?php 
                    echo urlencode($embed_url);
                    ?>
&embedded=true" style="width:100%; height:900px;" frameborder="0"></iframe>
                    <!-- <object width="100%" height="900" type="application/pdf" data="<?php 
                    echo module_file::link_public_view($file_id);
                    ?>
" id="pdf_content">
                        <a href="<?php 
                    echo module_file::link_public_view($file_id);
                    ?>
">Download File</a>

                      </object> -->
                    <a href="<?php 
                    echo module_file::link_public_view($file_id);
                    ?>
">Download PDF File</a>
                    <?php 
                    break;
                default:
                    // file download link
                    ?>

                        <div style="text-align:center; padding:20px;">
                            <a href="<?php 
                    echo module_file::link_public_view($file_id);
                    ?>
">Download File</a>
                        </div>
                        <?php 
            }
        }
        return ob_get_clean();
    }
Ejemplo n.º 27
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
// todo: _DEMO_MODE - dont allow access to setup wizard.
if (_UCM_INSTALLED && !module_security::is_logged_in()) {
    ob_end_clean();
    echo 'Sorry the system is already installed. You need to be logged in to run the setup again.';
    exit;
}
print_heading('Step #4: Email Configuration');
?>

      <p>Now that the system is installed, it's time to setup your email settings. Please contact your hosting provider if you are unsure of your email settings (some hosting providers require special settings for PHP scripts). If your SMTP details are not working, you can just try the default settings (ie: everything blank) to see if that works. </p>

    <?php 
include 'includes/plugin_email/pages/email_settings.php';
?>


<p>&nbsp;</p>
<p>Once you are happy with the above email settings please click continue below. </p>

<p align="center"><a href="?m=setup&amp;step=5" class="submit_button btn btn-success">Complete Setup &raquo;</a></p>
Ejemplo n.º 28
0
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
/* <div data-role="footer">
		<h4>Footer content</h4>
	</div><!-- /footer --> */
?>

</div><!-- /page -->
<?php 
if (module_config::c('mobile_content_scroll', 1) && module_security::is_logged_in()) {
    ?>
<script type="text/javascript">
    var contentscroll = [];
    var content = null;
    window.addEventListener("resize", function() {
        // Get screen size (inner/outerWidth, inner/outerHeight)
//        var headerheight = 20;
//        $('div[data-role="header"]').each(function(){
//            headerheight+= $(this).height();
//        });
//        if(content != null)content.width(window.innerWidth-10).height(window.innerHeight-headerheight);
//        if(contentscroll != null)contentscroll.refresh();
        for (var i in contentscroll){
            if(typeof contentscroll[i] == 'object'){
                contentscroll[i].refresh();
Ejemplo n.º 29
0
 public static function get_email_compose_options($options)
 {
     $from_email = $from_name = false;
     if (module_security::is_logged_in() && module_config::c('email_from_logged_in_user', 1)) {
         $my_details = module_user::get_user(module_security::get_loggedin_id());
         if (isset($my_details['password'])) {
             unset($my_details['password']);
         }
         $from_email = $my_details['email'];
         $from_name = $my_details['name'] . (module_config::c('email_from_full_name', 1) ? ' ' . $my_details['last_name'] : '');
     }
     $new_options = array('subject' => html_entity_decode(isset($_REQUEST['subject']) ? $_REQUEST['subject'] : (isset($options['subject']) ? $options['subject'] : '')), 'content' => isset($_REQUEST['content']) ? $_REQUEST['content'] : (isset($options['content']) ? $options['content'] : ''), 'cancel_url' => isset($options['cancel_url']) ? $options['cancel_url'] : false, 'complete_url' => isset($options['complete_url']) ? $options['complete_url'] : (isset($options['cancel_url']) ? $options['cancel_url'] : false), 'from_email' => isset($_REQUEST['from_email']) && $_REQUEST['from_email'] ? $_REQUEST['from_email'] : ($from_email ? $from_email : module_config::c('admin_email_address')), 'from_name' => isset($_REQUEST['from_name']) && $_REQUEST['from_name'] ? $_REQUEST['from_name'] : ($from_name ? $from_name : module_config::c('admin_system_name')), 'to' => isset($_REQUEST['to']) ? $_REQUEST['to'] : (isset($options['to']) ? $options['to'] : array()), 'to_select' => isset($_REQUEST['to_select']) ? $_REQUEST['to_select'] : (isset($options['to_select']) ? $options['to_select'] : false), 'cc' => isset($_REQUEST['custom_cc']) ? $_REQUEST['custom_cc'] : (isset($options['cc']) ? $options['cc'] : ''), 'bcc' => isset($_REQUEST['bcc']) ? $_REQUEST['bcc'] : (isset($options['bcc']) ? $options['bcc'] : ''), 'attachments' => isset($options['attachments']) ? $options['attachments'] : array(), 'success_callback' => isset($options['success_callback']) ? $options['success_callback'] : '');
     foreach ($new_options['to'] as $key => $val) {
         if (isset($val['password'])) {
             unset($new_options['to'][$key]['password']);
         }
     }
     foreach (array('website_id', 'invoice_id', 'job_id', 'quote_id') as $key) {
         if (isset($_REQUEST[$key])) {
             $new_options[$key] = $_REQUEST[$key];
         }
     }
     $options = array_merge($options, $new_options);
     return $options;
 }