示例#1
0
 public function init()
 {
     $this->module_name = "encrypt";
     $this->module_position = 1;
     $this->version = 2.269;
     // 2.2 - initial release
     // 2.21 - better support for new 'extra' fields
     // 2.22 - permissions.
     // 2.221 - typo.
     // 2.23 - a better "e" value in RSA to support easier server side public key encryption.
     // 2.24 - sidebar encryption in ticket extra fields.
     // 2.25 - link fix, no htmlspecialchars
     // 2.26 - save decrypted
     // 2.261 - remove console .log
     // 2.262 - fix for encrypted ticket submission + attachments
     // 2.263 - larger popup
     // 2.264 - 2013-04-07 - fix for special characters in encryption
     // 2.265 - 2013-11-23 - working on new ui
     // 2.266 - 2014-01-17 - compatibility update for custom data plugin
     // 2.267 - 2014-01-21 - updated js encryption library
     // 2.268 - 2014-10-13 - hook_filter_var for better theme support
     // 2.269 - 2015-04-12 - fix dollar sign in extra field bug
     module_config::register_js('encrypt', 'sjcl.js');
     module_config::register_js('encrypt', 'encrypt.js');
     module_config::register_css('encrypt', 'encrypt.css');
     hook_add('extra_fields_output', 'module_encrypt::extra_fields_output_callback');
 }
示例#2
0
    public static function header_print_js()
    {
        $pages = isset($_REQUEST['p']) ? is_array($_REQUEST['p']) ? $_REQUEST['p'] : array($_REQUEST['p']) : array();
        $modules = isset($_REQUEST['m']) ? is_array($_REQUEST['m']) ? $_REQUEST['m'] : array($_REQUEST['m']) : array();
        foreach ($pages as $pid => $p) {
            $pages[$pid] = preg_replace('#[^a-z_]#', '', $p);
        }
        foreach ($modules as $pid => $p) {
            $modules[$pid] = preg_replace('#[^a-z_]#', '', $p);
        }
        ?>
		<script type="text/javascript">
			ucm.help.current_modules = '<?php 
        echo implode('/', $modules);
        ?>
';
			ucm.help.current_pages = '<?php 
        echo implode('/', $pages);
        ?>
';
			ucm.help.lang.help = '<?php 
        _e('Help');
        ?>
';
			ucm.help.url_extras = '&codes=<?php 
        echo base64_encode(module_config::c('_installation_code'));
        ?>
&host=<?php 
        echo urlencode(htmlspecialchars(full_link('/')));
        ?>
';
		</script>
		<?php 
    }
示例#3
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 
        }
    }
 public function init()
 {
     $this->links = array();
     $this->module_name = "webnpro_menu_module_redbooth";
     $this->module_position = '13';
     $this->version = '1.0';
     module_config::save_config('_menu_order_webnpro_menu_module_redbooth', '13');
 }
 public function init()
 {
     $this->links = array();
     $this->module_name = "webnpro_menu_module_template_builder";
     $this->module_position = '10';
     $this->version = '1.0';
     module_config::save_config('_menu_order_webnpro_menu_module_template_builder', '10');
 }
示例#6
0
 public static function check_captcha_form()
 {
     $privatekey = module_config::c('recaptcha_private_key', '6Leym88SAAAAANbBjtrjNfeu6NXDSCXGBSbKzqnN');
     require_once 'inc/recaptchalib.php';
     $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : '', isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : '');
     if (!$resp->is_valid) {
         // What happens when the CAPTCHA was entered incorrectly
         return false;
     } else {
         return true;
     }
 }
示例#7
0
 function init()
 {
     $this->links = array();
     $this->module_name = "social";
     $this->module_position = 25.1;
     $this->version = 2.131;
     // 2.131 - 2014-08-04 - responsive improvements
     // 2.13 - 2014-05-23 - social fixes
     // 2.12 - 2014-04-05 - ability to disable social plugin
     // 2.11 - 2014-04-05 - better message archiving
     // 2.1 - 2014-03-25 - initial release
     if (self::is_plugin_enabled()) {
         module_config::register_css('social', 'social.css', true, 5);
         module_config::register_js('social', 'social.js', true, 5);
     }
 }
示例#8
0
 public function init()
 {
     $this->links = array();
     $this->map_types = array();
     $this->module_name = "map";
     $this->module_position = 14;
     $this->version = 2.21;
     //2.21 - 2015-09-10 - map marker fix
     //2.2 - 2015-09-09 - map marker fix
     //2.1 - 2015-06-10 - initial release
     // the link within Admin > Settings > Maps.
     if (module_security::has_feature_access(array('name' => 'Settings', 'module' => 'config', 'category' => 'Config', 'view' => 1, 'description' => 'view'))) {
         $this->links[] = array("name" => "Maps", "p" => "map_settings", 'holder_module' => 'config', 'holder_module_page' => 'config_admin', 'menu_include_parent' => 0);
     }
     if ($this->can_i('view', 'Maps') && module_config::c('enable_customer_maps', 1) && module_map::is_plugin_enabled()) {
         // only display if a customer has been created.
         if (isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] && $_REQUEST['customer_id'] != 'new') {
             // how many maps?
             $name = 'Maps';
             $this->links[] = array("name" => $name, "p" => "map_admin", 'args' => array('map_id' => false), 'holder_module' => 'customer', 'holder_module_page' => 'customer_admin_open', 'menu_include_parent' => 0, 'icon_name' => 'globe');
         }
         $this->links[] = array("name" => 'Maps', "p" => "map_admin", 'args' => array('map_id' => false), 'icon_name' => 'globe');
     }
 }
示例#9
0
      }else{
          echo 'success_text';
      }
      echo '">';
      if($invoice['total_amount_due']>0){
          echo dollar($invoice['total_amount_due'],true,$job['currency_id']);
          echo ' '._l('due');
      }else{
          echo _l('All paid');
      }
      echo '</span>';*/
} else {
    if ($task_editable) {
        ?>
                <?php 
        if (module_config::c('job_task_edit_icon', 0)) {
            // old icon:
            ?>
                <a href="#" class="ui-state-default ui-corner-all ui-icon ui-icon-<?php 
            echo $percentage == 1 ? 'pencil' : 'check';
            ?>
" title="<?php 
            _e($percentage == 1 ? 'Edit' : 'Complete');
            ?>
" onclick="edittask(<?php 
            echo $task_id;
            ?>
,<?php 
            echo $task_data['hours'] != 0 ? $task_data['hours'] - $task_data['completed'] : 1;
            ?>
); return false;"><?php 
示例#10
0
            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 {
                    $this_plugin_results = $plugin->ajax_search($search_text);
                    $_SESSION['previous_search'][$plugin_name] = array('l' => $search_text, 'c' => count($this_plugin_results));
                }
                $search_results = array_merge($search_results, $this_plugin_results);
            }
        }
        if (count($search_results)) {
            echo '<ul>';
            foreach ($search_results as $r) {
                echo '<li>' . $r . '</li>';
            }
            echo '</ul>';
        } else {
            //_e('No results');
        }
    } else {
        echo '';
    }
    if (module_config::c('search_ajax_show_time', 0)) {
        echo '<br>';
        echo 'Search took: ' . round(microtime(true) - $start_search_time, 5);
    }
    exit;
}
示例#11
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
 */
if (!module_config::can_i('view', 'Settings') || !module_template::can_i('edit', 'Templates')) {
    redirect_browser(_BASE_HREF);
}
$template_id = $_REQUEST['template_id'];
$template = array();
if ((int) $template_id && $template_id != 'new') {
    $template = module_template::get_template($template_id);
}
if (!$template) {
    $template_id = 'new';
    $template = array('template_id' => 'new', 'template_key' => '', 'description' => '', 'content' => '', 'name' => '', 'default_text' => '', 'wysiwyg' => 1);
    module_security::sanatise_data('template', $template);
}
?>

<form action="<?php 
echo module_template::link_open(false);
?>
" method="post" id="template_form">
示例#12
0
 public static function is_mobile_browser()
 {
     if (!module_config::c('mobile_enabled', 1)) {
         return false;
     }
     if (!isset($_SERVER['HTTP_USER_AGENT'])) {
         return false;
     }
     if (!isset($_SERVER['HTTP_ACCEPT'])) {
         return false;
     }
     $mobile_browser = '0';
     if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
         $mobile_browser++;
     }
     if (strpos(strtolower($_SERVER['HTTP_ACCEPT']), 'application/vnd.wap.xhtml+xml') > 0 or (isset($_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']))) {
         $mobile_browser++;
     }
     $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
     $mobile_agents = array('w3c ', 'acs-', 'alav', 'alca', 'amoi', 'audi', 'avan', 'benq', 'bird', 'blac', 'blaz', 'brew', 'cell', 'cldc', 'cmd-', 'dang', 'doco', 'eric', 'hipt', 'inno', 'ipaq', 'java', 'jigs', 'kddi', 'keji', 'leno', 'lg-c', 'lg-d', 'lg-g', 'lge-', 'maui', 'maxo', 'midp', 'mits', 'mmef', 'mobi', 'mot-', 'moto', 'mwbp', 'nec-', 'newt', 'noki', 'oper', 'palm', 'pana', 'pant', 'phil', 'play', 'port', 'prox', 'qwap', 'sage', 'sams', 'sany', 'sch-', 'sec-', 'send', 'seri', 'sgh-', 'shar', 'sie-', 'siem', 'smal', 'smar', 'sony', 'sph-', 'symb', 't-mo', 'teli', 'tim-', 'tosh', 'tsm-', 'upg1', 'upsi', 'vk-v', 'voda', 'wap-', 'wapa', 'wapi', 'wapp', 'wapr', 'webc', 'winw', 'winw', 'xda ', 'xda-');
     if (in_array($mobile_ua, $mobile_agents)) {
         $mobile_browser++;
     }
     if (isset($_SERVER['ALL_HTTP']) && strpos(strtolower($_SERVER['ALL_HTTP']), 'OperaMini') > 0) {
         $mobile_browser++;
     }
     if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') > 0) {
         $mobile_browser = 0;
     }
     return $mobile_browser;
 }
示例#13
0
	display: inline;
}
#panel {
    position: absolute;
    top: 5px;
    left: 50%;
    margin-left: -180px;
    z-index: 5;
    background-color: #fff;
    padding: 5px;
    border: 1px solid #999;
  }
</style>

<script src="https://maps.googleapis.com/maps/api/js?key=<?php 
echo htmlspecialchars(module_config::c('google_maps_api_key', 'AIzaSyDFYt1ozmTn34lp96W0AakC-tSJVzEdXjk'));
?>
&callback=initializeMaps" async defer></script>
<script>
var geocoder;
var map;
var infowindow = false;
function createInfoWindow(item,content) {
    if(!infowindow){
        infowindow = new google.maps.InfoWindow({});
    }
    google.maps.event.addListener(item, 'click', function(event) {
        infowindow.close();
        infowindow = new google.maps.InfoWindow({
            content: content,
            position: event.latLng
 public function __construct($config = array())
 {
     $this->config = array_merge(array('consumer_key' => module_config::c('social_twitter_api_key', ''), 'consumer_secret' => module_config::c('social_twitter_api_secret', ''), 'user_agent' => 'UCM Twitter 0.1'), $config);
     parent::__construct($this->config);
 }
示例#15
0
</a>
                                    </td>
                                </tr>
                        <?php 
    }
    ?>

                        </tbody>
					</table>
                        </div>

                        <?php 
    $fieldset_data = array('heading' => array('title' => _l('Invoice Payment History'), 'type' => 'h3'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
    if (class_exists('module_finance', false) && module_finance::is_plugin_enabled() && module_finance::can_i('view', 'Finance') && module_finance::is_enabled() && is_file('includes/plugin_finance/pages/finance_invoice_edit.php') && module_config::c('invoice_show_finances', 1)) {
        include 'includes/plugin_finance/pages/finance_invoice_edit.php';
    }
}
// invoice_id check
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_left', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'onclick' => "\$('#form_redirect').val('" . (!$invoice_id && isset($_REQUEST['job_id']) && (int) $_REQUEST['job_id'] > 0 ? module_job::link_open($_REQUEST['job_id']) : module_invoice::link_open(false)) . "');", 'value' => _l('Save and Return')), array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save'))));
if ((int) $invoice_id) {
    if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
        $form_actions['elements'][] = array('type' => 'save_button', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Receipt'));
    } else {
        $form_actions['elements'][] = array('type' => 'submit', 'class' => 'submit_button', 'name' => 'butt_email', 'value' => _l('Email Invoice'));
    }
    if (function_exists('convert_html2pdf')) {
        if (!module_invoice::can_i('edit', 'Invoices')) {
            $form_actions['elements'][] = array('type' => 'button', 'class' => 'submit_button no_permissions', 'name' => 'butt_print', 'value' => _l('Print PDF'), 'onclick' => "window.location.href='" . module_invoice::link_public_print($invoice_id) . "';");
<?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
 */
// UPDATE:::: to modify this layout please now go to Settings > Templates and look for "invoice_payment_history"
if (module_config::c('invoice_show_payment_history', 1)) {
    $payment_historyies = module_invoice::get_invoice_payments($invoice_id);
    foreach ($payment_historyies as $invoice_payment_id => $invoice_payment_data) {
        if (module_config::c('invoice_hide_pending_payments', 1)) {
            if (!trim($invoice_payment_data['date_paid']) || $invoice_payment_data['date_paid'] == '0000-00-00') {
                unset($payment_historyies[$invoice_payment_id]);
            }
        }
    }
    if (count($payment_historyies)) {
        ob_start();
        ?>
		<table cellpadding="4" cellspacing="0" class="table tableclass tableclass_rows" style="width: 100%" id="invoice_payment_history">
			<thead>
				<tr class="task_header">
                    <th>{l:Payment Date}</th>
                    <th>{l:Payment Method}</th>
                    <th>{l:Details}</th>
                    <th>{l:Amount}</th>
                    <td><?php 
            echo isset($row['amount_paid_link']) ? $row['amount_paid_link'] : $row['amount_paid'];
            ?>
</td>
                    <?php 
            if (module_finance::is_expense_enabled()) {
                ?>
                        <td><?php 
                echo isset($row['amount_spent_link']) ? $row['amount_spent_link'] : $row['amount_spent'];
                ?>
</td>
                    <?php 
            }
            ?>
                    <?php 
            if (class_exists('module_envato', false) && module_config::c('envato_include_in_dashbaord', 1)) {
                ?>
                    <td><?php 
                echo isset($row['envato_earnings_link']) ? $row['envato_earnings_link'] : $row['envato_earnings'];
                ?>
</td>
                    <?php 
            }
            ?>
                </tr>
            <?php 
        }
        ?>
            </tbody>
        </table>
        <?php 
示例#18
0
 public static function calculate_fee($invoice_id, $invoice_data, $payment_amount, $options)
 {
     /* options array(
            'percent' => $fee_percent,
            'amount' => $fee_amount,
            'description' => $fee_description,
        ) */
     if (module_config::c('invoice_fee_calculate_reverse', 0)) {
         $fee_total = round(($payment_amount + (isset($options['amount']) ? $options['amount'] : 0)) / (isset($options['percent']) ? 1 - $options['percent'] / 100 : 1), 2) - $payment_amount;
     } else {
         $fee_total = round($payment_amount * ((isset($options['percent']) ? $options['percent'] : 0) / 100) + (isset($options['amount']) ? $options['amount'] : 0), 2);
     }
     // do we add in taxes ? nfi. for not - no
     return $fee_total;
 }
示例#19
0
); this.form.submit();">
	            <p>
		            <?php 
    _e('If you cannot solve this ticket please assign it to someone else in the drop down list.');
    ?>

	            </p>
            </div>
            <?php 
    $fieldset_data = array('heading' => array('title' => _l('Unassigned Ticket'), 'type' => 'h3'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
}
/** TICKET MESSAGES */
if (!$done_messages) {
    $tickets_in_reverse = module_config::c('ticket_messages_in_reverse', 0);
    include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php');
}
hook_handle_callback('layout_column_half', 'end');
echo $action_buttons;
?>


</form>

<?php 
if (($last_response_from == 'customer' || $last_response_from == 'autoreply') && $ticket['status_id'] != _TICKET_STATUS_RESOLVED_ID) {
    // don't do this for resolved tickets
    // only set the default field if the last respose was from the customer.
    module_form::set_default_field('new_ticket_message');
}
示例#20
0
    ?>
				</a>
			</li>
		<?php 
}
unset($menu_holder);
unset($menu_type);
unset($current_link);
unset($menu_allow_nesting);
?>
        <?php 
if (isset($show_quick_search) && $show_quick_search) {
    ?>
        <?php 
    if (module_security::getcred() && module_security::can_user(module_security::get_loggedin_id(), 'Show Quick Search') && $display_mode != 'mobile') {
        if (module_config::c('global_search_focus', 1) == 1) {
            module_form::set_default_field('ajax_search_text');
        }
        ?>
            <li>
                <div id="quick_search_box">
                    <div id="quick_search_placeholder"><div><?php 
        _e('Quick Search:');
        ?>
</div></div>
                    <input type="text" name="quick_search" id="ajax_search_text" size="10" value="">
                    <div id="ajax_search_result"></div>
                </div>
            </li>
         <?php 
    }
示例#21
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();
示例#22
0
    $columns['quote_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($quote) {
        echo module_website::link_open($quote['website_id'], true);
    });
}
if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
    $columns['quote_customer'] = array('title' => 'Customer', 'callback' => function ($quote) {
        echo module_customer::link_open($quote['customer_id'], true);
    });
}
$columns['quote_type'] = array('title' => 'Type', 'callback' => function ($quote) {
    echo htmlspecialchars($quote['type']);
});
$columns['quote_status'] = array('title' => 'Status', 'callback' => function ($quote) {
    echo htmlspecialchars($quote['status']);
});
if (module_config::c('quote_allow_staff_assignment', 1)) {
    $columns['quote_staff'] = array('title' => 'Staff Member', 'callback' => function ($quote) {
        echo module_user::link_open($quote['user_id'], true);
    });
}
if (module_job::can_i('view', 'Jobs')) {
    $job_ids = array();
    $columns['job'] = array('title' => 'Job', 'callback' => function ($quote) use(&$job_ids) {
        $job_ids = array();
        foreach (module_job::get_jobs(array('quote_id' => $quote['quote_id'])) as $job) {
            $job = module_job::get_job($job['job_id']);
            if (!$job) {
                continue;
            }
            echo module_job::link_open($job['job_id'], true);
            $job_ids[] = $job['job_id'];
    echo htmlspecialchars($subscription['customer_count']);
    ?>
 </td>
            <td> <?php 
    echo htmlspecialchars($subscription['website_count']);
    ?>
 </td>
            <td><?php 
    echo $subscription['automatic_renew'] ? _l('Yes') : _l('No');
    ?>
</td>
            <td><?php 
    echo $subscription['automatic_email'] ? _l('Yes') : _l('No');
    ?>
</td>
        </tr>
	<?php 
}
?>

  </tbody>
</table>
<?php 
echo $pagination['links'];
?>

</form>

<?php 
module_config::print_settings_form(array('title' => 'Subscription Options', 'settings' => array(array('key' => 'subscription_invoice_due_date', 'default' => 0, 'type' => 'text', 'description' => 'Invoice Due Date Days', 'help' => 'How many days after the invoice is created should the due date be set?'))));
示例#24
0
?>
" />
	<input type="hidden" name="customer_id" value="<?php 
echo $user['customer_id'];
?>
" />


    <?php 
module_form::print_form_auth();
module_form::prevent_exit(array('valid_exits' => array('.submit_button')));
module_form::set_required(array('fields' => array('name' => 'Name', 'email' => 'Email')));
hook_handle_callback('layout_column_half', 1);
$title = 'User Details';
include module_theme::include_ucm('includes/plugin_user/pages/contact_admin_form.php');
if (module_config::c('users_have_address', 0)) {
    ob_start();
    handle_hook("address_block", $module, "physical", "user", "user_id");
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Address'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
}
if ((int) $user_id > 0) {
    //handle_hook("note_list",$module,"user","user_id",$user_id);
    if (class_exists('module_note', false) && module_note::is_plugin_enabled()) {
        module_note::display_notes(array('title' => 'User Notes', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => $module->link_open($user_id)));
    }
    if (class_exists('module_group', false) && module_group::is_plugin_enabled()) {
        module_group::display_groups(array('title' => 'User Groups', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => module_user::link_open($user_id)));
    }
}
示例#25
0
include('quote_public.php');
$quote['quote_tasks'] = ob_get_clean();*/
// generate the PDF ready for sending.
$pdf = module_quote::generate_pdf($quote_id);
// find available "to" recipients.
// customer contacts.
$to_select = false;
if ($quote['customer_id']) {
    $customer = module_customer::get_customer($quote['customer_id']);
    $quote['customer_name'] = $customer['customer_name'];
    $to = module_user::get_contacts(array('customer_id' => $quote['customer_id']));
    if ($quote['contact_user_id']) {
        $primary = module_user::get_user($quote['contact_user_id']);
        if ($primary) {
            $to_select = $primary['email'];
        }
    } else {
        if ($customer['primary_user_id']) {
            $primary = module_user::get_user($customer['primary_user_id']);
            if ($primary) {
                $to_select = $primary['email'];
            }
        }
    }
} else {
    $to = array();
}
$template->assign_values($quote);
ob_start();
module_email::print_compose(array('title' => _l('Email Quote: %s', $quote['name']), 'find_other_templates' => 'quote_email', 'current_template' => $template_name, 'customer_id' => $quote['customer_id'], 'quote_id' => $quote['quote_id'], 'debug_message' => 'Sending quote as email', 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_quote::link_open($quote_id), 'cancel_url' => module_quote::link_open($quote_id), 'attachments' => array(array('path' => $pdf, 'name' => basename($pdf), 'preview' => module_quote::link_public_print($quote_id)))));
示例#26
0
 public static function check_for_upgrades($requested_plugin = '', $get_file_contents = 0)
 {
     // compile a list of current plugins
     // along with the users installation code
     // send it to our server and get a response with a list of available updates for this user.
     $current_plugins = array();
     $current_files = array();
     global $plugins;
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'start'));
     }
     foreach ($plugins as $plugin_name => $p) {
         if ($requested_plugin && $requested_plugin != $plugin_name) {
             continue;
         }
         if (!$p->is_plugin_enabled()) {
             $p->init();
         }
         $current_plugins[$plugin_name] = $p->get_plugin_version();
         // find all the files related to this plugin.
         if (function_exists('getFilesFromDir') && module_config::c('upgrade_post_file_list', 1)) {
             $directory = 'includes/plugin_' . $plugin_name . '/';
             $files = getFilesFromDir($directory);
             $files = array_flip($files);
             foreach ($files as $file => $tf) {
                 // ignore certain files.
                 if (strpos($file, 'plugin_file/upload') !== false || strpos($file, 'plugin_data/upload') !== false || strpos($file, '/cache/') !== false || strpos($file, '/html2ps/') !== false || strpos($file, 'backup/backups/backup_') !== false || strpos($file, '/attachments/') !== false || strpos($file, '/temp/') !== false || strpos($file, '/tmp/') !== false) {
                     unset($files[$file]);
                 } else {
                     $d = preg_replace('#Envato:[^\\r\\n]*#', '', preg_replace('#Package Date:[^\\r\\n]*#', '', preg_replace('#IP Address:[^\\r\\n]*#', '', preg_replace('#Licence:[^\\r\\n]*#', '', file_get_contents($file)))));
                     $files[$file] = md5(base64_encode($d));
                 }
             }
             $current_files[$plugin_name] = $files;
         }
         if (_DEBUG_MODE) {
             module_debug::log(array('title' => 'Checking for upgrades:', 'data' => $plugin_name . ' done'));
         }
     }
     //print_r($current_files);exit;
     $available_updates = array();
     $post_fields = array('application' => _APPLICATION_ID, 'installation_code' => module_config::c('_installation_code'), 'current_version' => module_config::c('_admin_system_version', 2.1), 'current_plugins' => json_encode($current_plugins), 'current_files' => json_encode($current_files), 'client_ip' => $_SERVER['REMOTE_ADDR'], 'installation_location' => full_link('/'), 'requested_plugin' => $requested_plugin, 'get_file_contents' => $get_file_contents);
     $url = module_config::c('ucm_upgrade_url', 'http://api.ultimateclientmanager.com/upgrade.php');
     if ($url == 'http://ultimateclientmanager.com/api/upgrade.php') {
         $url = 'http://api.ultimateclientmanager.com/upgrade.php';
         // hack to use new update subdomain
     }
     if ($url != 'http://ultimateclientmanager.com/api/upgrade.php' && $url != 'http://api.ultimateclientmanager.com/upgrade.php') {
         set_error('Incorrect API url');
         redirect_browser(_BASE_HREF);
     }
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'Posting to API'));
     }
     if (!function_exists('curl_init')) {
         $postdata = http_build_query($post_fields);
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
         $context = stream_context_create($opts);
         $result = file_get_contents($url, false, $context);
     } else {
         //$url = 'http://localhost/ucm/web/api/upgrade.php';
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
         curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
         // fixes netregistr, may break others?
         $result = curl_exec($ch);
     }
     $data = json_decode($result, true);
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'Received response from API'));
     }
     if ($data && isset($data['available_updates']) && is_array($data['available_updates'])) {
         $available_updates = $data['available_updates'];
     }
     if ($data && isset($data['licence_codes']) && is_array($data['licence_codes'])) {
         // find out what the licence codes  are (url / name) so we can dispaly this under each code nicely.
         foreach ($data['licence_codes'] as $code => $foo) {
             if (strlen($code) > 10 && strlen($foo) > 10) {
                 module_config::save_config('_licence_code_' . $code, $foo);
                 // this might not be working
             }
         }
     }
     if (!$data) {
         echo $result;
     }
     //echo '<pre>';print_r($current_plugins);print_r($result);echo '</pre>';
     return $available_updates;
 }
示例#27
0
        $invoice_templates[$template['template_key']] = 1;
    }
}
foreach ($invoice_templates as $template_key => $tf) {
    module_template::link_open_popup($template_key);
}
$template_html = ob_get_clean();
$payment_methods_options = array();
$payment_methods = handle_hook('get_payment_methods', $module);
foreach ($payment_methods as $payment_method) {
    if ($payment_method->is_method('online') && $payment_method->is_enabled()) {
        $payment_methods_options[$payment_method->module_name] = $payment_method->get_payment_method_name();
    }
}
$settings = array(array('key' => 'overdue_email_auto', 'default' => '0', 'type' => 'checkbox', 'description' => 'Automatic Overdue Emails', 'help' => 'If this is ticked then by default newly created invoices will be sent automatic overdue notices. This can be disabled/enabled per invoice. See the "Auto Overdue Email" option near "Due Date".'), array('key' => 'invoice_automatic_receipt', 'default' => '1', 'type' => 'checkbox', 'description' => 'Automatic Send Invoice Receipt', 'help' => 'Automatically send the invoice receipt to the customer once the invoice is marked as paid. If this is disabled you will have to go into the invoice and manually send it after payment is received.'), array('key' => 'invoice_template_print_default', 'default' => 'invoice_print', 'type' => 'text', 'description' => 'Default PDF invoice template', 'help' => 'Used for invoice PDF. You can overwrite in the Advanced settings of each invoice.'), array('key' => 'overdue_email_auto_days', 'default' => '3', 'type' => 'text', 'description' => 'Automically send after', 'help' => 'How many days after the invoice is overdue is the automated email sent (set to 0 will send on the date the invoice is due)'), array('key' => 'overdue_email_auto_days_repeat', 'default' => '7', 'type' => 'text', 'description' => 'Automically re-send every', 'help' => 'How many days after the last automatic overdue reminder is the overdue reminder re-sent automatically (set to 0 to disable this option)'), array('key' => 'invoice_automatic_after_time', 'default' => '7', 'type' => 'text', 'description' => 'Hour of day to perform automatic operations', 'help' => 'Enter the hour of day (eg: 7 for 7am, 14 for 2pm) to perform automatic actions - such as renewing invoices, subscriptions, overdue notices, etc...'), array('key' => 'invoice_auto_renew_only_paid_invoices', 'default' => '1', 'type' => 'checkbox', 'description' => 'Only renew paid invoices', 'help' => 'If an invoice (or past subscription invoice) has not been paid then do not renew the next one until original payment has been received.'), array('key' => 'invoice_default_payment_method', 'default' => 'paymethod_paypal', 'type' => 'select', 'options' => $payment_methods_options, 'description' => 'Default Payment Method'), array('key' => 'invoice_due_days', 'default' => '30', 'type' => 'text', 'description' => 'Invoice Due Days', 'help' => 'The number of days used to calculate the "Due Date" on new invoices. Due Date can be overridden per invoice.'), array('key' => 'invoice_name_match_job', 'default' => '0', 'type' => 'checkbox', 'description' => 'Match Invoice with Job Name', 'help' => 'If an invoice is created from a Job, set the Invoice name the same as the job name'), array('key' => 'invoice_incrementing', 'default' => '0', 'type' => 'checkbox', 'description' => 'Incrementing Invoice Numbers', 'help' => 'If this is enabled the system will pick a new invoice number each time. Choose what number to start from below.'), array('key' => 'invoice_incrementing_next', 'default' => '1', 'type' => 'text', 'description' => 'Incrementing Invoice Number', 'help' => 'What will be the next invoice number'), array('key' => 'invoice_task_list_show_date', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Dates on Invoice Items'), array('key' => 'invoice_task_numbers', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Task Numbers on Invoice Items'), array('key' => 'invoice_allow_payment_amount_adjustment', 'default' => '1', 'type' => 'checkbox', 'description' => 'Allow User To Enter Payment Amount', 'help' => 'If this is enabled the user can change the payment amount on invoices. For example, they might want to pay $50 of a $100 invoice with PayPal, and $50 with cash.'), array('type' => 'html', 'description' => 'Templates', 'html' => $template_html));
module_config::print_settings_form(array('heading' => array('title' => 'Invoice Settings', 'type' => 'h2', 'main' => true), 'settings' => $settings));
// find any blank invoices.
$sql = "SELECT * FROM `" . _DB_PREFIX . "invoice` WHERE customer_id IS NULL AND `name` = '' AND `status` = '' AND `date_create` = '0000-00-00' AND `date_sent` = '0000-00-00' AND `date_paid` = '0000-00-00' AND `date_due` = '0000-00-00' AND c_total_amount = 0 ";
$invoices = qa($sql);
$blank_invoices = array();
foreach ($invoices as $invoice) {
    $items = module_invoice::get_invoice_items($invoice['invoice_id']);
    if (empty($items)) {
        $blank_invoices[] = $invoice;
    }
}
if (count($blank_invoices) && isset($_POST['remove_duplicates']) && $_POST['remove_duplicates'] == 'yes') {
    foreach ($blank_invoices as $id => $blank_invoice) {
        module_invoice::delete_invoice($blank_invoice['invoice_id']);
        unset($blank_invoices[$id]);
    }
示例#28
0
 public function get_data()
 {
     if (count($this->_get_data_cache)) {
         return $this->_get_data_cache;
     }
     $file = false;
     if ($this->file_id > 0) {
         $file = get_single("file", "file_id", $this->file_id);
     }
     // check user has permissions to view this file.
     // for now we just base this on the customer id check
     if ($file) {
         // staff listing
         $staff = get_multiple('file_user_rel', array('file_id' => $file['file_id']), 'user_id');
         $file['staff_ids'] = array_keys($staff);
         $file['type'] = isset($file['file_url']) && $file['file_url'] ? 'remote' : (isset($file['bucket']) && $file['bucket'] ? 'bucket' : 'upload');
         if ($this->do_permissions) {
             switch (module_file::get_file_data_access()) {
                 case _FILE_ACCESS_ALL:
                     // all files, no limits on SQL here
                     break;
                 case _FILE_ACCESS_JOBS:
                     $jobs = module_job::get_jobs(array(), array('columns' => 'u.job_id AS id'));
                     if (!$file['job_id'] || !isset($jobs[$file['job_id']])) {
                         $file = false;
                     }
                     break;
                 case _FILE_ACCESS_ME:
                     if ($file['create_user_id'] != module_security::get_loggedin_id()) {
                         $file = false;
                     }
                     break;
                 case _FILE_ACCESS_ASSIGNED:
                     if (!in_array(module_security::get_loggedin_id(), $file['staff_ids'])) {
                         $file = false;
                     }
                     break;
                 case _FILE_ACCESS_CUSTOMERS:
                 default:
                     if (class_exists('module_customer', false)) {
                         //added for compat in newsletter system that doesn't have customer module
                         $customer_permission_check = module_customer::get_customer($file['customer_id']);
                         if ($customer_permission_check['customer_id'] != $file['customer_id']) {
                             $file = false;
                         }
                     }
             }
             // file data access switch
         }
     }
     if (!$file) {
         $file = array('new' => true, 'type' => 'upload', 'file_id' => 0, 'customer_id' => isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : 0, 'job_id' => isset($_REQUEST['job_id']) ? $_REQUEST['job_id'] : 0, 'quote_id' => isset($_REQUEST['quote_id']) ? $_REQUEST['quote_id'] : 0, 'description' => '', 'status' => module_config::c('file_default_status', 'Uploaded'), 'file_name' => '', 'file_url' => '', 'staff_ids' => array(), 'bucket' => 0, 'bucket_parent_file_id' => 0, 'approved_time' => 0);
     }
     $this->_get_data_cache = $file;
     return $file;
 }
示例#29
0
    public static function print_note($note_id, $note_item, $display_summary = false, $can_edit = true, $can_delete = true, $options = array())
    {
        if (!$note_item) {
            $note_item = self::get_note($note_id);
        }
        static $x = 0;
        global $plugins;
        $can_view = $can_edit = $can_create = $can_delete = false;
        // re-check permissions...
        if (isset($options) && isset($options['owner_table']) && $options['owner_table'] && isset($options['title']) && $options['title']) {
            $can_view = $plugins[$options['owner_table']]->can_i('view', $options['title']);
            $can_edit = $plugins[$options['owner_table']]->can_i('edit', $options['title']);
            $can_create = $plugins[$options['owner_table']]->can_i('create', $options['title']);
            $can_delete = $plugins[$options['owner_table']]->can_i('delete', $options['title']);
        } else {
        }
        if (!module_security::is_page_editable()) {
            //$can_edit=$can_create=$can_delete=false;
        }
        if (isset($options['summary_owners'])) {
            unset($options['summary_owners']);
        }
        if (isset($options['display_summary'])) {
            unset($options['display_summary']);
        }
        //
        if (!trim($note_item['note'])) {
            $note_item['note'] = 'none';
        }
        ob_start();
        /** START TABLE LAYOUT **/
        $table_manager = module_theme::new_table_manager();
        $columns = array();
        $columns['date'] = array('title' => 'Date', 'width' => 60, 'callback' => function ($note_item) {
            if ($note_item['reminder']) {
                echo '<strong>';
            }
            echo print_date($note_item['note_time']);
            if ($note_item['reminder']) {
                echo '</strong>';
            }
        });
        $columns['description'] = array('title' => 'Description', 'callback' => function ($note_item) {
            if (isset($note_item['public']) && $note_item['public']) {
                echo '* ';
            }
            if ($note_item['can_edit']) {
                $note_text = nl2br(htmlspecialchars(substr($note_item['note'], 0, module_config::c('note_trim_length', 35))));
                $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length', 35) ? '...' : '';
                ?>

                <a href="<?php 
                echo module_note::link_open($note_item['note_id'], false, $note_item['options']);
                ?>
" data-options="<?php 
                echo htmlspecialchars(base64_encode(serialize($note_item['options'])));
                ?>
" class="note_edit note_options_link" rel="<?php 
                echo $note_item['note_id'];
                ?>
"> <?php 
                echo $note_text;
                ?>
 </a>
                <?php 
            } else {
                echo forum_text($note_item['note']);
            }
        });
        $columns['info'] = array('title' => 'Info', 'width' => 40, 'callback' => function ($note_item) {
            if ($note_item['display_summary']) {
                if ($note_item['rel_data']) {
                    global $plugins;
                    echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'], true);
                }
            } else {
                // find the user name who made thsi note.
                $user_data = module_user::get_user($note_item['create_user_id']);
                echo $user_data['name'];
            }
        });
        if ($can_delete) {
            $columns['del'] = array('title' => ' ', 'callback' => function ($note_item) {
                if ($note_item['can_delete']) {
                    ?>
 <a href="<?php 
                    echo module_note::link_open($note_item['note_id'], false, array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id'])));
                    ?>
" data-options="<?php 
                    echo htmlspecialchars(base64_encode(serialize(array_merge($note_item['options'], array('do_delete' => 'yes', 'note_id' => $note_item['note_id'])))));
                    ?>
" rel="<?php 
                    echo $note_item['note_id'];
                    ?>
" onclick="if(confirm('<?php 
                    _e('Really Delete Note?');
                    ?>
'))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a> <?php 
                }
            });
        }
        $table_manager->set_columns($columns);
        $table_manager->inline_table = true;
        $table_manager->row_callback = function ($row_data, &$row_object) use($display_summary, $can_edit, $can_delete, &$options) {
            $row_data['display_summary'] = $display_summary;
            $row_data['can_edit'] = $can_edit;
            $row_data['can_delete'] = $can_delete;
            $row_data['options'] = $options;
            $row_object->row_id = 'note_' . $row_data['note_id'];
            return $row_data;
        };
        $table_manager->print_row($note_item);
        /*?>
        		<tr id="note_<?php echo $note_item['note_id'];?>" class="<?php echo ($x++%2)?'odd':'even';?>">
        			<td>
                        <?php
                        if($note_item['reminder'])echo '<strong>';
                        echo print_date($note_item['note_time']);
                        if($note_item['reminder'])echo '</strong>';
                        ?>
        			</td>
        			<td>
                        <?php
                        if(isset($note_item['public']) && $note_item['public'])echo '* ';
                        if($can_edit){
                            $note_text = nl2br(htmlspecialchars(substr($note_item['note'],0,module_config::c('note_trim_length',35))));
                            $note_text .= strlen($note_item['note']) > module_config::c('note_trim_length',35) ? '...' : '';
                            ?>
                        <a href="<?php echo self::link_open($note_item['note_id'],false,$options);?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize($options)));?>" class="note_edit note_options_link" rel="<?php echo $note_item['note_id'];?>"> <?php echo $note_text; ?> </a>
                        <?php }else{
                            echo forum_text($note_item['note']);
                        } ?>
        			</td>
        			<td nowrap="nowrap">
        				<?php
        				if($display_summary){
        					if($note_item['rel_data']){
                                echo $plugins[$note_item['owner_table']]->link_open($note_item['owner_id'],true);
        					}
        				}else{
        					// find the user name who made thsi note.
        					$user_data = module_user::get_user($note_item['create_user_id']);
        					echo $user_data['name'];
        				}
        				?>
        			</td>
                    <?php if($can_delete){ ?>
                    <td><a href="<?php echo self::link_open($note_item['note_id'],false,array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])));?>" data-options="<?php echo htmlspecialchars(base64_encode(serialize(array_merge($options,array('do_delete'=>'yes','note_id'=>$note_item['note_id'])))));?>" rel="<?php echo $note_item['note_id'];?>" onclick="if(confirm('<?php _e('Really Delete Note?');?>'))return true; else return false;" class="note_delete note_options_link delete ui-state-default ui-corner-all ui-icon ui-icon-trash">[x]</a></td>
                    <?php } ?>
        		</tr>
        		<?php
        		*/
        return ob_get_clean();
    }
示例#30
0
 public function get_upgrade_sql()
 {
     $sql = '';
     $fields = get_fields('finance_recurring');
     if (!isset($fields['next_due_date_custom'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance_recurring` ADD  `next_due_date_custom` TINYINT( 1 ) NOT NULL DEFAULT  '0' AFTER  `next_due_date`;";
     }
     if (!isset($fields['currency_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance_recurring` ADD  `currency_id` int( 11 ) NOT NULL DEFAULT  '" . module_config::c('default_currency_id', 1) . "' AFTER  `amount`;";
     }
     $fields = get_fields('finance');
     if (!isset($fields['currency_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `currency_id` int( 11 ) NOT NULL DEFAULT  '" . module_config::c('default_currency_id', 1) . "' AFTER  `type`;";
     }
     if (!isset($fields['customer_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `customer_id` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `finance_recurring_id`;";
     }
     if (!isset($fields['job_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `job_id` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `customer_id`;";
     }
     if (!isset($fields['invoice_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `invoice_id` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `job_id`;";
     }
     if (!isset($fields['company_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `company_id` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `invoice_id`;";
     }
     if (!isset($fields['sub_amount'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `sub_amount` decimal(10,2) NOT NULL DEFAULT  '0' AFTER  `description`;";
         $sql .= "UPDATE `" . _DB_PREFIX . "finance` SET  `sub_amount` = `amount` WHERE `sub_amount` = 0 AND `amount` > 0;";
     }
     if (!isset($fields['user_id'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `user_id` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `company_id`;";
     }
     if (!isset($fields['job_staff_expense'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `job_staff_expense` int( 11 ) NOT NULL DEFAULT  '0' AFTER  `user_id`;";
     }
     if (!isset($fields['taxable_amount'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `taxable_amount` decimal(10,2) NOT NULL DEFAULT  '0' AFTER  `sub_amount`;";
         if (isset($fields['taxible_amount'])) {
             // typo - damnnn
             $sql .= "UPDATE `" . _DB_PREFIX . "finance` SET  `taxable_amount` = `taxible_amount` WHERE `taxable_amount` = 0 AND `taxible_amount` > 0;";
         } else {
             $sql .= "UPDATE `" . _DB_PREFIX . "finance` SET  `taxable_amount` = `sub_amount` WHERE `taxable_amount` = 0 AND `sub_amount` > 0;";
         }
     }
     if (!isset($fields['tax_mode'])) {
         $sql .= "ALTER TABLE `" . _DB_PREFIX . "finance` ADD  `tax_mode` tinyint(1) NOT NULL DEFAULT '0' AFTER  `sub_amount`;";
     }
     self::add_table_index('finance', 'job_id');
     self::add_table_index('finance', 'invoice_id');
     self::add_table_index('finance', 'customer_id');
     self::add_table_index('finance', 'type');
     self::add_table_index('finance', 'company_id');
     self::add_table_index('finance', 'amount');
     self::add_table_index('finance', 'user_id');
     self::add_table_index('finance', 'job_staff_expense');
     if (!self::db_table_exists('finance_tax')) {
         $sql .= "CREATE TABLE IF NOT EXISTS `" . _DB_PREFIX . "finance_tax` (\n  `finance_tax_id` int(11) NOT NULL AUTO_INCREMENT,\n  `finance_id` int(11) NOT NULL,\n  `percent` decimal(10,2) NOT NULL,\n  `amount` decimal(10,2) NOT NULL,\n  `name` varchar(50) NOT NULL,\n  `order` int(4) NOT NULL DEFAULT '0',\n  `increment` tinyint(1) NOT NULL DEFAULT '0',\n  `create_user_id` int(11) NOT NULL,\n  `update_user_id` int(11) DEFAULT NULL,\n  `date_created` date NOT NULL,\n  `date_updated` date DEFAULT NULL,\n  PRIMARY KEY (`finance_tax_id`),\n  KEY (`finance_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
     }
     return $sql;
 }