Example #1
0
        <tr>
            <th>
                <?php 
echo _l('Configuration Key');
?>
            </th>
            <th>
                <?php 
echo _l('Configuration Value');
?>
            </th>
        </tr>
        </thead>
        <tbody>
        <?php 
foreach (get_multiple('config', false, 'key', 'exact', '`key`') as $config) {
    if (isset($config['key']) && isset($config['key'][0]) && $config['key'][0] == '_') {
        continue;
    }
    ?>
        <tr>
            <th>
                <?php 
    echo $config['key'];
    ?>
            </th>
            <td>
                <span data-name="config[<?php 
    echo htmlspecialchars($config['key']);
    ?>
]" class="config_variable"><?php 
                                    </td><td>
                                        <input type="text" name="invoice_invoice_payment[<?php 
            echo $invoice_payment_id;
            ?>
][method]" value="<?php 
            echo htmlspecialchars($invoice_payment_data['method']);
            ?>
" size="20">
                                    </td>
                                    <td nowrap="">
                                        <?php 
            echo '<input type="text" name="invoice_invoice_payment[' . $invoice_payment_id . '][amount]" value="' . number_out($invoice_payment_data['amount']) . '" id="' . $invoice_payment_id . 'invoice_paymentamount" class="currency">';
            ?>

                                        <?php 
            echo print_select_box(get_multiple('currency', '', 'currency_id'), 'invoice_invoice_payment[' . $invoice_payment_id . '][currency_id]', $invoice_payment_data['currency_id'], '', false, 'code');
            ?>

                                    </td>
                                    <td>
                                        <?php 
            $notes = '';
            $details = false;
            if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) {
                $details = @unserialize($invoice_payment_data['data']);
                if ($details && isset($details['custom_notes'])) {
                    $notes = $details['custom_notes'];
                }
            }
            ?>
Example #3
0
 public static function get_notes($search = false)
 {
     return get_multiple("note", $search, "note_id", "exact", "note_id");
 }
Example #4
0
    public static function print_table_data($owner_table, $owner_id)
    {
        if (self::can_i('view', 'Extra Fields') && isset(self::$column_headers[$owner_table])) {
            $extra_data = get_multiple('extra', array('owner_table' => $owner_table, 'owner_id' => $owner_id), 'extra_key');
            foreach (self::$column_headers[$owner_table] as $column_header) {
                ?>

                <td>
                    <?php 
                echo isset($extra_data[$column_header['key']]) ? forum_text($extra_data[$column_header['key']]['extra']) : '';
                ?>

                </td>
                <?php 
            }
        }
    }
Example #5
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;
 }
Example #6
0
 public static function get_product_categories($search = array())
 {
     return get_multiple("product_category", $search, "product_category_id", "fuzzy", "product_category_name");
 }
Example #7
0
 function get_datas($search = false)
 {
     return get_multiple("data_record", $search, "data_record_id", "fuzzy");
 }
Example #8
0
    public function output_block($level)
    {
        if (!$this->get('social_twitter_message_id') || $level < -3) {
            return;
        }
        $twitter_data = @json_decode($this->get('data'), true);
        // any previous messages?
        if ($level <= 0) {
            if ($this->get('reply_to_id')) {
                // this tweet is a reply to a previous tweet!
                ?>
				<div class="twitter_previous_messages">
					<?php 
                $reply_message = new ucm_twitter_message($this->twitter_account, $this->get('reply_to_id'));
                $reply_message->output_block($level - 1);
                ?>
				</div>
				<?php 
            } else {
                if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                    // find previous message(s)
                    $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                    $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                    if ($from && $to) {
                        $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time <= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` DESC LIMIT 1";
                        $previous = qa1($sql);
                        if ($previous && $previous['social_twitter_message_id']) {
                            ?>
						<div class="twitter_previous_messages twitter_direct">
							<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $previous['social_twitter_message_id']);
                            $reply_message->output_block($level - 1);
                            ?>
						</div>
						<?php 
                        }
                    }
                }
            }
        }
        $message_from = isset($twitter_data['user']) ? $twitter_data['user'] : (isset($twitter_data['sender']) ? $twitter_data['sender'] : false);
        if ($this->get('summary')) {
            if ($message_from && $this->get('type') != _TWITTER_MESSAGE_TYPE_DIRECT) {
                $message_from['tweet_id'] = isset($twitter_data['id_str']) ? $twitter_data['id_str'] : false;
            }
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            ?>
			<div class="twitter_comment <?php 
            echo $level != 0 ? ' twitter_comment_clickable' : 'twitter_comment_current';
            ?>
" data-id="<?php 
            echo $this->social_twitter_message_id;
            ?>
" data-link="<?php 
            echo module_social_twitter::link_open_twitter_message($this->get('social_twitter_id'), $this->social_twitter_message_id);
            ?>
" data-title="<?php 
            echo _l('Tweet');
            ?>
">
				<div class="twitter_comment_picture">
					<?php 
            if (isset($twitter_data['user']['id_str'])) {
                $pic = array('screen_name' => isset($twitter_data['user']['screen_name']) ? $twitter_data['user']['screen_name'] : '', 'image' => isset($twitter_data['user']['profile_image_url_https']) ? $twitter_data['user']['profile_image_url_https'] : '');
            } else {
                if (isset($twitter_data['sender']['id_str'])) {
                    $pic = array('screen_name' => isset($twitter_data['sender']['screen_name']) ? $twitter_data['sender']['screen_name'] : '', 'image' => isset($twitter_data['sender']['profile_image_url_https']) ? $twitter_data['sender']['profile_image_url_https'] : '');
                } else {
                    $pic = false;
                }
            }
            if ($pic) {
                ?>
						<img src="<?php 
                echo $pic['image'];
                ?>
">
						<?php 
            }
            ?>
				</div>
				<div class="twitter_comment_header">
					<?php 
            _e('From:');
            echo ' ';
            echo $message_from ? ucm_twitter::format_person($message_from) : 'N/A';
            ?>
					<span><?php 
            $time = strtotime($this->get('message_time'));
            echo $time ? ' @ ' . print_date($time, true) : '';
            if ($this->get('user_id')) {
                echo ' (sent by ' . module_user::link_open($this->get('user_id'), true) . ')';
            }
            ?>
					</span>
				</div>
				<div class="twitter_comment_body">
					<?php 
            if (isset($twitter_data['entities']['media']) && is_array($twitter_data['entities']['media'])) {
                foreach ($twitter_data['entities']['media'] as $media) {
                    if ($media['type'] == 'photo') {
                        ?>
								<div class="twitter_picture">
									<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 <a
										href="<?php 
                            echo htmlspecialchars($media['url']);
                            ?>
"
										target="_blank"> <?php 
                        }
                        ?>
										<img src="<?php 
                        echo htmlspecialchars($media['media_url_https']);
                        ?>
">
										<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 </a> <?php 
                        }
                        ?>
								</div>
							<?php 
                    }
                }
            }
            ?>
					<div>
						<?php 
            echo forum_text($this->get('summary'));
            ?>
					</div>
					<div class="twitter_comment_stats">
						<?php 
            $data = @json_decode($this->get('data'), true);
            //print_r($data);
            if ($data && (isset($data['retweet_count']) && $data['retweet_count'] > 0 || isset($data['favorite_count']) && $data['favorite_count'] > 0)) {
                if (isset($data['retweet_count']) && $data['retweet_count'] > 0) {
                    echo _l('Retweets: %s', $data['retweet_count']);
                }
                echo ' ';
                if (isset($data['favorite_count']) && $data['favorite_count'] > 0) {
                    echo _l('Favorites: %s', $data['favorite_count']);
                }
            }
            ?>
					</div>
				</div>
				<div class="twitter_comment_actions">
					<?php 
            if ($this->can_reply) {
                ?>
						<a href="#" class="twitter_reply_button"><?php 
                _e('Reply');
                ?>
</a>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
        ?>
		<?php 
        if ($level == 0) {
            ?>
			<div class="twitter_comment_replies">
			<?php 
            //if(strpos($twitter_data['message'],'picture')){
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            //}
            if ($this->can_reply) {
                $this->reply_box($level, $message_from);
            }
            ?>
			</div>
		<?php 
        }
        if ($level >= 0) {
            // any follow up messages?
            if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                if ($from && $to) {
                    $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time >= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` ASC LIMIT 1";
                    $next = qa1($sql);
                    if ($next && $next['social_twitter_message_id']) {
                        ?>
						<div class="twitter_next_messages twitter_direct">
							<?php 
                        $reply_message = new ucm_twitter_message($this->twitter_account, $next['social_twitter_message_id']);
                        $reply_message->output_block($level + 1);
                        ?>
						</div>
						<?php 
                    }
                }
            } else {
                $next = get_multiple('social_twitter_message', array('social_twitter_id' => $this->twitter_account->get('social_twitter_id'), 'reply_to_id' => $this->social_twitter_message_id), 'social_twitter_message_id');
                if ($next) {
                    foreach ($next as $n) {
                        // this tweet is a reply to a previous tweet!
                        if ($n['social_twitter_message_id']) {
                            ?>
							<div class="twitter_next_messages">
								<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $n['social_twitter_message_id']);
                            $reply_message->output_block($level + 1);
                            ?>
							</div>
							<?php 
                        }
                    }
                }
            }
        }
    }
Example #9
0
function upload($save_path, $custom_upload_max_filesize, $key, $type = array('jpg', 'jpeg', 'gif', 'png'))
{
    $return_data = array();
    //获取phpini配置文件里面的upload_max_filesize值
    $phpini = ini_get('upload_max_filesize');
    //获取phpini配置文件里面的upload_max_filesize值的单位
    $phpini_unit = strtoupper(substr($phpini, -1));
    //获取phpini配置文件里面的upload_max_filesize值的数字部分
    $phpini_number = substr($phpini, 0, -1);
    //计算出转换成字节应该乘以的倍数
    $phpini_multiple = get_multiple($phpini_unit);
    //转换成字节
    $phpini_bytes = $phpini_number * $phpini_multiple;
    $custom_unit = strtoupper(substr($custom_upload_max_filesize, -1));
    $custom_number = substr($custom_upload_max_filesize, 0, -1);
    $custom_multiple = get_multiple($custom_unit);
    $custom_bytes = $custom_number * $custom_multiple;
    if ($custom_bytes > $phpini_bytes) {
        $return_data['error'] = '传入的$custom_upload_max_filesize大于PHP配置文件里面的' . $phpini;
        $return_data['return'] = false;
        return $return_data;
    }
    $arr_errors = array(1 => '上传的文件超过了 php.ini中 upload_max_filesize 选项限制的值', 2 => '上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值', 3 => '文件只有部分被上传', 4 => '没有文件被上传', 6 => '找不到临时文件夹', 7 => '文件写入失败');
    if (!isset($_FILES[$key]['error'])) {
        $return_data['error'] = '由于未知原因导致,上传失败,请重试!';
        $return_data['return'] = false;
        return $return_data;
    }
    if ($_FILES[$key]['error'] != 0) {
        $return_data['error'] = $arr_errors[$_FILES['error']];
        $return_data['return'] = false;
        return $return_data;
    }
    if (!is_uploaded_file($_FILES[$key]['tmp_name'])) {
        $return_data['error'] = '您上传的文件不是通过 HTTP POST方式上传的!';
        $return_data['return'] = false;
        return $return_data;
    }
    if ($_FILES[$key]['size'] > $custom_bytes) {
        $return_data['error'] = '上传文件的大小超过了程序作者限定的' . $custom_upload_max_filesize;
        $return_data['return'] = false;
        return $return_data;
    }
    $arr_filename = pathinfo($_FILES[$key]['name']);
    if (!isset($arr_filename['extension'])) {
        $arr_filename['extension'] = '';
    }
    if (!in_array($arr_filename['extension'], $type)) {
        $return_data['error'] = '上传文件的后缀名必须是' . implode(',', $type) . '这其中的一个';
        $return_data['return'] = false;
        return $return_data;
    }
    if (!file_exists($save_path)) {
        if (!mkdir($save_path, 0777, true)) {
            $return_data['error'] = '上传文件保存目录创建失败,请检查权限!';
            $return_data['return'] = false;
            return $return_data;
        }
    }
    $new_filename = str_replace('.', '', uniqid(mt_rand(100000, 999999), true));
    if ($arr_filename['extension'] != '') {
        $new_filename .= ".{$arr_filename['extension']}";
    }
    $save_path = rtrim($save_path, '/') . '/';
    if (!move_uploaded_file($_FILES[$key]['tmp_name'], $save_path . $new_filename)) {
        $return_data['error'] = '临时文件移动失败,请检查权限!';
        $return_data['return'] = false;
        return $return_data;
    }
    $return_data['save_path'] = $save_path . $new_filename;
    $return_data['filename'] = $new_filename;
    $return_data['return'] = true;
    return $return_data;
}
Example #10
0
 public static function get_groups_search($search = false)
 {
     $groups = get_multiple('group_member', $search);
     foreach ($groups as $group_id => $group) {
         // find the group name for this group.
         $groups[$group_id] = array_merge($group, self::get_group($group['group_id']));
     }
     return $groups;
 }
Example #11
0
 public static function get_languages_attributes()
 {
     $all = array();
     $language_files = glob(_UCM_FOLDER . 'includes/plugin_language/custom/*.php');
     if (is_array($language_files)) {
         foreach ($language_files as $language) {
             $language = strtolower(str_replace('.php', '', basename($language)));
             if ($language[0] == '_') {
                 continue;
             }
             $all[$language] = array('language_name' => $language, 'language_code' => $language);
         }
     }
     $language_files = glob(_UCM_FOLDER . 'includes/plugin_language/labels/*.php');
     if (is_array($language_files)) {
         foreach ($language_files as $language) {
             $language = strtolower(str_replace('.php', '', basename($language)));
             if ($language[0] == '_') {
                 continue;
             }
             $all[$language] = array('language_name' => $language, 'language_code' => $language);
         }
     }
     if (self::is_language_db_enabled()) {
         foreach ($all as $language_code => $language) {
             // does this language code exist in the database?
             $language_db = get_single('language', 'language_code', $language_code);
             if (!$language_db || $language_db['language_code'] != $language_code) {
                 update_insert('language_id', false, 'language', array('language_code' => $language['language_code'], 'language_name' => $language['language_name']));
             }
         }
         // now we get any language attributes from the database and overwrite the old file based ones with those.
         foreach (get_multiple('language', false, 'language_id', 'exact', 'language_code') as $language) {
             if (isset($all[strtolower($language['language_code'])])) {
                 // this language exists in the old file based method.
                 $all[strtolower($language['language_code'])] = $language;
             } else {
                 // this is a language that only exists in the new database translation method.
                 $all[strtolower($language['language_code'])] = $language;
             }
             // todo - well, not sure about the above. maybe we do some update here and remove the old files ??? move everything to the database or something?? meh..
         }
     }
     return $all;
 }
echo htmlspecialchars($invoice['total_tax_rate']);
?>
" style="width:35px;">%

                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <?php 
echo _l('Currency');
?>

                                </th>
                                <td>
                                    <?php 
echo print_select_box(get_multiple('currency', '', 'currency_id'), 'currency_id', $invoice['currency_id'], '', false, 'code');
?>

                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <?php 
echo _l('Hourly Rate');
?>

                                </th>
                                <td>
                                    <?php 
echo currency('<input type="text" name="hourly_rate" class="currency" value="' . $invoice['hourly_rate'] . '">', true, $invoice['currency_id']);
echo _h('This hourly rate will be applied to all manual tasks (tasks that did not come from jobs) in this invoice');
Example #13
0
            <th class="width2">
                <?php 
_e('Menu Item');
?>
            </th>
            <th>
                <?php 
_e('Position');
?>
            </th>
        </tr>
        </thead>
        <tbody>
        <?php 
$c = 0;
foreach (get_multiple('config') as $config) {
    if (preg_match('#_menu_order_(.*)#', $config['key'], $matches)) {
        ?>
                <tr class="<?php 
        echo $c++ % 2 ? 'odd' : 'even';
        ?>
">
                    <td>
                        <?php 
        echo $matches[1];
        ?>
                    </td>
                    <td>
                        <input type="text" name="save_config[<?php 
        echo $matches[0];
        ?>
Example #14
0
 public static function get_faq($faq_id)
 {
     $faq = get_single('faq', 'faq_id', $faq_id);
     // get linked ids
     $faq['faq_product_ids'] = array();
     foreach (get_multiple('faq_product_rel', array('faq_id' => $faq_id)) as $product) {
         $faq['faq_product_ids'][$product['faq_product_id']] = $product['faq_product_id'];
     }
     return $faq;
 }
Example #15
0
 public static function get_encrypt_keys()
 {
     return get_multiple('encrypt_key', false, 'encrypt_key_id');
 }
Example #16
0
        if ($currency['currency_id'] == module_config::c('default_currency_id', 1)) {
            _e('(default)');
        }
        ?>
                </td>
                <td>
                    <?php 
        echo htmlspecialchars($currency['symbol']);
        ?>
                </td>
                <td>
                    <?php 
        echo dollar(1234.56, true, $currency['currency_id']);
        ?>
                </td>
            </tr>
        <?php 
    }
    ?>
      </tbody>
    </table>
    </form>

<?php 
    $currencies = array();
    foreach (get_multiple('currency', '', 'currency_id') as $currency) {
        $currencies[$currency['currency_id']] = $currency['code'] . ' ' . $currency['symbol'];
    }
    $settings = array(array('key' => 'default_currency_id', 'default' => '1', 'type' => 'select', 'description' => 'Default currency to use throughout the system', 'options' => $currencies));
    module_config::print_settings_form($settings);
}
Example #17
0
 public static function get_templates($search = array())
 {
     if (self::db_table_exists('template')) {
         // useto be sorted by template_id
         return get_multiple("template", $search, "template_id", "exact", "template_key ASC");
     } else {
         return array();
     }
 }
Example #18
0
 public static function get_change_requests($search = array())
 {
     return get_multiple("change_request", $search, "change_request_id", "exact", "name");
 }
Example #19
0
    public static function hook_job_task_after($hook, $job_id, $task_id, $job_data, $task_data)
    {
        $comments = get_multiple('job_discussion', array('job_id' => $job_id, 'task_id' => $task_id), 'job_discussion_id', 'exact', 'job_discussion_id');
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 1) {
            // disabled & hidden.
            return;
        }
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2 && count($comments) == 0) {
            // disabled & shown.
            return;
        }
        if (isset($_POST['job_discussion_add_job_id']) && isset($_POST['job_discussion_add_task_id']) && $_POST['job_discussion_add_job_id'] == $job_id && $_POST['job_discussion_add_task_id'] == $task_id && isset($_POST['note']) && strlen($_POST['note'])) {
            $x = 0;
            while (ob_get_level() && $x++ < 10) {
                ob_end_clean();
            }
            $current_user_id = module_security::get_loggedin_id();
            $customer = module_customer::get_customer($job_data['customer_id']);
            if (!$current_user_id) {
                if ($job_data['customer_id'] && $customer['primary_user_id']) {
                    $current_user_id = $customer['primary_user_id'];
                }
            }
            $result = array();
            // adding a new note.
            $job_discussion_id = update_insert('job_discussion_id', 0, 'job_discussion', array('job_id' => $job_id, 'task_id' => $task_id, 'user_id' => $current_user_id, 'note' => $_POST['note']));
            $result['job_discussion_id'] = $job_discussion_id;
            $result['count'] = count($comments) + 1;
            $tasks = module_job::get_tasks($job_id);
            $result['email_customer'] = array();
            if (isset($_POST['sendemail_customer']) && is_array($_POST['sendemail_customer'])) {
                //$_POST['sendemail_customer'] == 'yes' && $customer['primary_user_id']){
                // send email to customer primary user id.
                $customer_contacts = module_user::get_contacts(array('customer_id' => $job_data['customer_id']));
                foreach ($_POST['sendemail_customer'] as $user_id) {
                    $user_id = (int) $user_id;
                    if ($user_id && isset($customer_contacts[$user_id])) {
                        // we can email this user.
                        $user = module_user::get_user($user_id, false);
                        if ($user && $user['user_id'] == $user_id) {
                            $values = array_merge($user, $job_data);
                            $values['job_url'] = module_job::link_public($job_id);
                            $values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
                            $values['job_name'] = $job_data['name'];
                            $values['customer_name'] = $user['name'] . ' ' . $user['last_name'];
                            $values['note'] = $_POST['note'];
                            //todo: no order if no showning numbers
                            $values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
                            $template = module_template::get_template_by_key('job_discussion_email_customer');
                            $template->assign_values($values);
                            $html = $template->render('html');
                            $email = module_email::new_email();
                            $email->replace_values = $values;
                            $email->set_to('user', $user['user_id']);
                            $email->set_from('user', $current_user_id);
                            $email->set_subject($template->description);
                            // do we send images inline?
                            $email->set_html($html);
                            if ($email->send()) {
                                // it worked successfully!!
                                $result['email_customer'][] = $user['user_id'];
                            } else {
                                /// log err?
                            }
                        }
                    }
                }
                /*$user = module_user::get_user($customer['primary_user_id'],false);
                                if($user['user_id'] == $customer['primary_user_id']){
                                    $values = array_merge($user,$job_data);
                                    $values['job_url'] = module_job::link_public($job_id);
                                    $values['job_url'] .= (strpos($values['job_url'],'?')===false ? '?' : '&').'discuss='.$task_id.'#discuss'.$task_id;
                                    $values['job_name'] = $job_data['name'];
                                    $values['customer_name'] = $user['name'].' '.$user['last_name'];
                                    $values['note'] = $_POST['note'];
                                    //todo: no order if no showning numbers
                                    $values['task_name'] = '#'.$tasks[$task_id]['task_order'].': '.$tasks[$task_id]['description'];
                
                                    $template = module_template::get_template_by_key('job_discussion_email_customer');
                                    $template->assign_values($values);
                                    $html = $template->render('html');
                
                                    $email = module_email::new_email();
                                    $email->replace_values = $values;
                                    $email->set_to('user',$user['user_id']);
                                    $email->set_from('user',$current_user_id);
                                    $email->set_subject($template->description);
                                    // do we send images inline?
                                    $email->set_html($html);
                
                                    if($email->send()){
                                        // it worked successfully!!
                                        $result['email_customer'] = 1;
                                    }else{
                                        /// log err?
                                        $result['email_customer'] = 0;
                                    }
                                }else{
                                    // log error?
                                    $result['email_customer'] = 0;
                                }*/
            }
            if (isset($_POST['sendemail_staff']) && is_array($_POST['sendemail_staff'])) {
                // == 'yes' && $job_data['user_id']
                // todo: handle the restul better when sending to multiple people
                $result['email_staff_list'] = $_POST['sendemail_staff'];
                foreach ($_POST['sendemail_staff'] as $staff_id) {
                    // send email to staff
                    $staff_id = (int) $staff_id;
                    if (!$staff_id) {
                        $result['nostaff'] = 1;
                        continue;
                    }
                    if (isset($task_data['user_id']) && $task_data['user_id'] == $staff_id || isset($job_data['user_id']) && $job_data['user_id'] == $staff_id) {
                        //$user = module_user::get_user($job_data['user_id'],false);
                        $user = module_user::get_user($staff_id, false);
                        if ($user['user_id'] == $staff_id) {
                            $values = array_merge($user, $job_data);
                            $values['job_url'] = module_job::link_public($job_id);
                            $values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
                            $values['job_name'] = $job_data['name'];
                            $values['staff_name'] = $user['name'] . ' ' . $user['last_name'];
                            $values['note'] = $_POST['note'];
                            //todo: no order if no showning numbers
                            $values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
                            $template = module_template::get_template_by_key('job_discussion_email_staff');
                            $template->assign_values($values);
                            $html = $template->render('html');
                            $email = module_email::new_email();
                            $email->replace_values = $values;
                            $email->set_to('user', $staff_id);
                            $email->set_from('user', $current_user_id);
                            $email->set_subject($template->description);
                            // do we send images inline?
                            $email->set_html($html);
                            if ($email->send()) {
                                // it worked successfully!!
                                $result['email_staff'] = 1;
                            } else {
                                /// log err?
                                $result['email_staff'] = 0;
                            }
                        } else {
                            // log error?
                            $result['email_staff'] = 0;
                        }
                    }
                }
            }
            $x = 0;
            while ($x++ < 5 && ob_get_level()) {
                ob_end_clean();
            }
            header("Content-type: text/javascript", true);
            echo json_encode($result);
            exit;
        }
        $label = htmlspecialchars(module_config::c('job_discussion_button_label', 'Task Comments'));
        ?>

        <a href="<?php 
        echo self::link_public($job_id, $task_id);
        ?>
" id="discuss<?php 
        echo $task_id;
        ?>
" class="task_job_discussion <?php 
        echo $label ? 'with_text' : '';
        ?>
" title="<?php 
        _e('View Discussion');
        ?>
"><span><?php 
        echo count($comments) > 0 ? count($comments) : '';
        ?>
</span><?php 
        echo $label;
        ?>
</a>
            <div class="task_job_discussion_holder"<?php 
        echo isset($_REQUEST['discuss']) && $_REQUEST['discuss'] == $task_id ? ' style="display:block;"' : '';
        ?>
>
                <?php 
        if (isset($_REQUEST['discuss']) && $_REQUEST['discuss'] == $task_id) {
            $_REQUEST['t'] = $task_id;
            $_REQUEST['i'] = $job_id;
            $_REQUEST['hash'] = self::link_public($job_id, $task_id, true);
            self::external_hook('public');
        }
        ?>

            </div>
        <?php 
    }
Example #20
0
 public static function save_quote($quote_id, $data)
 {
     if (isset($data['customer_id']) && $data['customer_id'] > 0) {
         // check we have access to this customer from this quote.
         $customer_check = module_customer::get_customer($data['customer_id']);
         if (!$customer_check || $customer_check['customer_id'] != $data['customer_id']) {
             unset($data['customer_id']);
         }
     }
     if (isset($data['website_id']) && $data['website_id']) {
         $website = module_website::get_website($data['website_id']);
         if ($website && (int) $website['website_id'] > 0 && $website['website_id'] == $data['website_id']) {
             // website exists.
             // make this one match the website customer_id, or set teh website customer_id if it doesn't have any.
             if ((int) $website['customer_id'] > 0) {
                 if ($data['customer_id'] > 0 && $data['customer_id'] != $website['customer_id']) {
                     set_message('Changed this Quote to match the Website customer');
                 }
                 $data['customer_id'] = $website['customer_id'];
             } else {
                 if (isset($data['customer_id']) && $data['customer_id'] > 0) {
                     // set the website customer id to this as well.
                     update_insert('website_id', $website['website_id'], 'website', array('customer_id' => $data['customer_id']));
                 }
             }
         }
     }
     if ((int) $quote_id > 0) {
         $original_quote_data = self::get_quote($quote_id, false);
         if (!$original_quote_data || $original_quote_data['quote_id'] != $quote_id) {
             $original_quote_data = array();
             $quote_id = false;
         }
     } else {
         $original_quote_data = array();
         $quote_id = false;
     }
     // check create permissions.
     if (!$quote_id && !self::can_i('create', 'Quotes')) {
         // user not allowed to create quotes.
         set_error('Unable to create new Quotes');
         redirect_browser(self::link_open(false));
     }
     if (!(int) $quote_id && module_config::c('quote_name_incrementing', 0)) {
         // incrememnt next quote number on save.
         $quote_number = module_config::c('quote_name_incrementing_next', 1);
         module_config::save_config('quote_name_incrementing_next', $quote_number + 1);
     }
     $quote_id = update_insert("quote_id", $quote_id, "quote", $data);
     $return = false;
     if ($quote_id) {
         hook_handle_callback('quote_save', $quote_id);
         // save the quote tax rates (copied from invoice.php)
         if (isset($data['tax_ids']) && isset($data['tax_names']) && $data['tax_percents']) {
             $existing_taxes = get_multiple('quote_tax', array('quote_id' => $quote_id), 'quote_tax_id', 'exact', 'order');
             $order = 1;
             foreach ($data['tax_ids'] as $key => $val) {
                 if (isset($data['tax_percents'][$key]) && $data['tax_percents'][$key] == 0) {
                     // we are not saving this particular tax item because it has a 0% tax rate
                 } else {
                     if ((int) $val > 0 && isset($existing_taxes[$val])) {
                         // this means we are trying to update an existing record on the quote_tax table, we confirm this id matches this quote.
                         $quote_tax_id = $val;
                         unset($existing_taxes[$quote_tax_id]);
                         // so we know which ones to remove from the end.
                     } else {
                         $quote_tax_id = false;
                         // create new record
                     }
                     $quote_tax_data = array('quote_id' => $quote_id, 'percent' => isset($data['tax_percents'][$key]) ? $data['tax_percents'][$key] : 0, 'amount' => 0, 'name' => isset($data['tax_names'][$key]) ? $data['tax_names'][$key] : 'TAX', 'order' => $order++, 'increment' => isset($data['tax_increment_checkbox']) && $data['tax_increment_checkbox'] ? 1 : 0);
                     $quote_tax_id = update_insert('quote_tax_id', $quote_tax_id, 'quote_tax', $quote_tax_data);
                 }
             }
             foreach ($existing_taxes as $existing_tax) {
                 delete_from_db('quote_tax', array('quote_id', 'quote_tax_id'), array($quote_id, $existing_tax['quote_tax_id']));
             }
         }
         module_cache::clear('quote');
         $return = array('quote_id' => $quote_id, 'task_result' => self::save_quote_tasks($quote_id, $data));
         $check_completed = true;
         switch ($return['task_result']['status']) {
             case 'created':
                 // we added a new task.
                 break;
             case 'deleted':
                 // we deleted a task.
                 break;
             case 'edited':
                 // we changed a task (ie: completed?);
                 break;
             default:
                 // nothing changed.
                 // $check_completed = false;
                 break;
         }
         if ($check_completed) {
             self::update_quote_completion_status($quote_id);
         }
         if ($original_quote_data) {
             // we check if the hourly rate has changed
             if (isset($data['hourly_rate']) && $data['hourly_rate'] != $original_quote_data['hourly_rate']) {
                 // update all the task hours, but only for hourly tasks:
                 $sql = "UPDATE `" . _DB_PREFIX . "quote_task` SET `amount` = 0 WHERE `hours` > 0 AND quote_id = " . (int) $quote_id . " AND ( manual_task_type = " . _TASK_TYPE_HOURS_AMOUNT;
                 if ($data['default_task_type'] == _TASK_TYPE_HOURS_AMOUNT) {
                     $sql .= " OR manual_task_type = -1 ";
                 }
                 $sql .= " )";
                 query($sql);
             }
             // check if the quote assigned user id has changed.
             if (module_config::c('quote_allow_staff_assignment', 1)) {
                 if (isset($data['user_id'])) {
                     // && $data['user_id'] != $original_quote_data['user_id']){
                     // user id has changed! update any that were the old user id.
                     $sql = "UPDATE `" . _DB_PREFIX . "quote_task` SET `user_id` = " . (int) $data['user_id'] . " WHERE (`user_id` = " . (int) $original_quote_data['user_id'] . " OR user_id = 0) AND quote_id = " . (int) $quote_id;
                     query($sql);
                 }
             }
             // check if the quote was approved.
             if (!isset($original_quote_data['date_approved']) || !$original_quote_data['date_approved'] || $original_quote_data['date_approved'] == '0000-00-00') {
                 // original quote wasn't approved.
                 if (isset($data['date_approved']) && !empty($data['date_approved']) && $data['date_approved'] != '0000-00-00') {
                     // quote was approved!
                     self::quote_approved($quote_id);
                 }
             }
         }
     }
     if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
         module_extra::save_extras('quote', 'quote_id', $quote_id);
     }
     module_cache::clear('quote');
     return $return;
 }
Example #21
0
    ?>
" style="width:35px;">%
            <a href="#" class="add_addit" onclick="seladd(this); ucm.job.update_job_tax(); return false;">+</a>
            <a href="#" class="remove_addit" onclick="selrem(this); ucm.job.update_job_tax(); return false;">-</a>
        </div>
    <?php 
}
?>

    </div>
    <script type="text/javascript">
        set_add_del('job_tax_holder');
    </script>
    <?php 
$fieldset_data['elements']['tax'] = array('title' => 'Tax', 'fields' => array(ob_get_clean()));
$fieldset_data['elements']['currency'] = array('title' => 'Currency', 'field' => array('type' => 'select', 'options' => get_multiple('currency', '', 'currency_id'), 'name' => 'currency_id', 'value' => $job['currency_id'], 'options_array_id' => 'code'));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
if (module_config::c('job_enable_description', 1)) {
    if (!module_job::can_i('edit', 'Jobs') && !$job['description']) {
        // no description, no ability to edit description, don't show anything.
    } else {
        // can edit description
        $fieldset_data = array('heading' => array('title' => _l('Job Description'), 'type' => 'h3'), 'class' => 'tableclass tableclass_form tableclass_full');
        if (module_job::can_i('edit', 'Jobs')) {
            $fieldset_data['elements'] = array(array('field' => array('type' => 'wysiwyg', 'name' => 'description', 'value' => $job['description'])));
        } else {
            $fieldset_data['elements'] = array(array('fields' => array(module_security::purify_html($job['description']))));
        }
        echo module_form::generate_fieldset($fieldset_data);
        unset($fieldset_data);
Example #22
0
 private static function save_job_tasks($job_id, $data)
 {
     $result = array('status' => false);
     $check_completed = false;
     $job_data = false;
     $job_task_creation_permissions = self::get_job_task_creation_permissions();
     // check for new tasks or changed tasks.
     $tasks = self::get_tasks($job_id);
     if (isset($data['job_task']) && is_array($data['job_task'])) {
         foreach ($data['job_task'] as $task_id => $task_data) {
             if (isset($task_data['manual_percent']) && strlen($task_data['manual_percent']) == 0) {
                 unset($task_data['manual_percent']);
             }
             $original_task_id = $task_id;
             $task_id = (int) $task_id;
             if (!is_array($task_data)) {
                 continue;
             }
             if ($task_id > 0 && !isset($tasks[$task_id])) {
                 $task_id = 0;
                 // creating a new task on this job.
             }
             if (!isset($task_data['description']) || $task_data['description'] == '' || $task_data['description'] == _TASK_DELETE_KEY) {
                 if ($task_id > 0 && $task_data['description'] == _TASK_DELETE_KEY) {
                     // remove task.
                     // but onyl remove it if it hasn't been invoiced.
                     if (isset($tasks[$task_id]) && $tasks[$task_id]['invoiced']) {
                         // it has been invoiced! dont remove it.
                         set_error('Unable to remove an invoiced task');
                         $result['status'] = 'error';
                         break;
                         // break out of loop saving tasks.
                     } else {
                         $sql = "DELETE FROM `" . _DB_PREFIX . "task` WHERE task_id = '{$task_id}' AND job_id = {$job_id} LIMIT 1";
                         query($sql);
                         $sql = "DELETE FROM `" . _DB_PREFIX . "task_log` WHERE task_id = '{$task_id}'";
                         query($sql);
                         $result['status'] = 'deleted';
                         $result['task_id'] = $task_id;
                     }
                 }
                 continue;
             }
             // add / save this task.
             $task_data['job_id'] = $job_id;
             if (module_job::job_task_only_show_split_hours($job_id, $job_data, $task_id, $task_data)) {
                 if (isset($task_data['hours']) && !isset($task_data['staff_hours'])) {
                     $task_data['staff_hours'] = $task_data['hours'];
                     $task_data['staff_amount'] = $task_data['amount'];
                 }
                 if (isset($task_data['hours'])) {
                     unset($task_data['hours']);
                     unset($task_data['amount']);
                 }
             }
             if (isset($task_data['hours'])) {
                 $task_data['hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['hours']) : $task_data['hours'];
             }
             if (isset($task_data['staff_hours'])) {
                 $task_data['staff_hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['staff_hours']) : $task_data['staff_hours'];
             }
             if (isset($task_data['log_hours'])) {
                 $task_data['log_hours'] = function_exists('decimal_time_in') ? decimal_time_in($task_data['log_hours']) : $task_data['log_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']);
                 }
             }
             if (isset($task_data['staff_amount']) && $task_data['staff_amount'] != 0 && isset($task_data['staff_hours']) && $task_data['staff_hours'] > 0) {
                 if (isset($data['staff_hourly_rate']) && $task_data['staff_amount'] - $task_data['staff_hours'] * $data['staff_hourly_rate'] == 0) {
                     unset($task_data['staff_amount']);
                 }
             }
             // check if we haven't unticked a non-hourly task
             if (isset($task_data['fully_completed_t']) && $task_data['fully_completed_t']) {
                 if (!isset($task_data['fully_completed']) || !$task_data['fully_completed']) {
                     // we have unchecked that tickbox
                     $task_data['fully_completed'] = 0;
                 } else {
                     if (isset($tasks[$task_id]) && !$tasks[$task_id]['fully_completed']) {
                         // we completed a preveiously incomplete task.
                         // chekc if this task has a custom percentage filled in, we remove this custom percentage.
                         if (isset($task_data['manual_percent']) && $task_data['manual_percent'] >= 0) {
                             $task_data['manual_percent'] = -1;
                         }
                         // hack: if we haven't logged any hours for this, we log the number of hours.
                         // if we have logged some hours already then we don't log anything extra.
                         // this is so they can log 0.5hours for a 1 hour completed task etc..
                         if (isset($task_data['hours']) && $task_data['hours'] > 0 && (!isset($task_data['log_hours']) || !$task_data['log_hours'])) {
                             $logged_hours = 0;
                             foreach (get_multiple('task_log', array('job_id' => $job_id, 'task_id' => $task_id)) as $task_log) {
                                 $logged_hours += $task_log['hours'];
                             }
                             if ($logged_hours == 0) {
                                 $task_data['log_hours'] = $task_data['hours'];
                             }
                         }
                     }
                 }
                 $check_completed = true;
             }
             // 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 (!$task_id && !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;
             }
             if (isset($task_data['completed']) && $task_data['completed'] > 0) {
                 // check the completed date of all our tasks.
                 $check_completed = true;
             }
             if (!$task_id && isset($task_data['new_fully_completed']) && $task_data['new_fully_completed']) {
                 $task_data['fully_completed'] = 1;
                 // is this bad for set amount tasks?
                 if (!isset($task_data['date_done']) || !$task_data['date_done']) {
                     $task_data['date_done'] = print_date(time());
                 }
                 if (isset($task_data['hours'])) {
                     $task_data['log_hours'] = $task_data['hours'];
                 }
                 $check_completed = true;
             }
             // todo: move the task creation code into a public method so that the public user can add tasks to their jobs.
             if (!$task_id && module_security::is_logged_in() && !module_job::can_i('create', 'Job Tasks')) {
                 continue;
                 // dont allow new tasks.
             }
             // check if the user is allowed to create new tasks.
             // check the approval status of jobs
             switch ($job_task_creation_permissions) {
                 case _JOB_TASK_CREATION_NOT_ALLOWED:
                     if (!$task_id) {
                         continue;
                         // dont allow new tasks.
                     }
                     break;
                 case _JOB_TASK_CREATION_REQUIRES_APPROVAL:
                     $task_data['approval_required'] = 1;
                     break;
                 case _JOB_TASK_CREATION_WITHOUT_APPROVAL:
                     // no action required .
                     break;
             }
             if (isset($tasks[$task_id]) && $tasks[$task_id]['approval_required'] == 2) {
                 // task has been rejected, saving it again for approval.
                 $task_data['approval_required'] = 1;
             }
             $task_id = update_insert('task_id', $task_id, 'task', $task_data);
             // todo - fix cross task job boundary issue. meh.
             $result['task_id'] = $task_id;
             if ($task_id != $original_task_id) {
                 $result['status'] = 'created';
             } else {
                 $result['status'] = 'edited';
             }
             if ($task_id && isset($task_data['log_hours']) && (double) $task_data['log_hours'] > 0) {
                 // we are increasing the task complete hours by the amount specified in log hours.
                 // log a new task record, and incrase the "completed" column.
                 //$original_task_data = $tasks[$task_id];
                 //$task_data['completed'] = $task_data['completed'] + $task_data['log_hours'];
                 // only log hours if it's an hourly task.
                 if (!isset($task_data['manual_task_type']) || $task_data['manual_task_type'] < 0) {
                     if (!$job_data) {
                         $job_data = self::get_job($job_id);
                     }
                     $task_data['manual_task_type'] = $job_data['default_task_type'];
                 }
                 if ($task_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT) {
                     update_insert('task_log_id', 'new', 'task_log', array('task_id' => $task_id, 'job_id' => $job_id, 'hours' => (double) $task_data['log_hours'], 'log_time' => time()));
                     $result['log_hours'] = $task_data['log_hours'];
                 }
             }
         }
     }
     if ($check_completed) {
         self::update_job_completion_status($job_id);
     }
     module_cache::clear('job');
     return $result;
 }
Example #23
0
 public static function is_automatic_paying_invoice($invoice_id)
 {
     $invoice_payments = module_invoice::get_invoice_payments($invoice_id);
     foreach ($invoice_payments as $payment) {
         if (isset($payment['invoice_payment_subscription_id']) && $payment['invoice_payment_subscription_id']) {
             return true;
         }
     }
     // check if this is part of a subscription, and if the previous subscription
     if (class_exists('module_subscription', false)) {
         // THIS CODE EXISTS
         // check if this invoice is part of a subscription.
         // if it is we hunt through the subscription history until we find a recent unpaid invoice
         $subscription_history_item = get_single('subscription_history', 'invoice_id', $invoice_id);
         if ($subscription_history_item && $subscription_history_item['subscription_owner_id']) {
             // we have an invoice that is on a subscription!
             $subscription_owner = module_subscription::get_subscription_owner($subscription_history_item['subscription_owner_id']);
             // check if there are unpaid invoices that were generated after this invoice.
             if ($subscription_owner['subscription_owner_id'] == $subscription_history_item['subscription_owner_id']) {
                 $subscription_history = get_multiple('subscription_history', array('subscription_owner_id' => $subscription_owner['subscription_owner_id']));
                 foreach ($subscription_history as $h) {
                     $invoice_payments = module_invoice::get_invoice_payments($h['invoice_id']);
                     foreach ($invoice_payments as $payment) {
                         if (isset($payment['invoice_payment_subscription_id']) && $payment['invoice_payment_subscription_id']) {
                             $payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $payment['invoice_payment_subscription_id']);
                             if ($payment_subscription && $payment_subscription['status'] == _INVOICE_SUBSCRIPTION_ACTIVE) {
                                 //} || $payment_subscription['status'] == _INVOICE_SUBSCRIPTION_PENDING)){
                                 return true;
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
Example #24
0
    public static function print_table_data($owner_table, $owner_id)
    {
        if (self::can_i('view', 'Subscriptions') && module_config::c('subscription_show_in_table', 1)) {
            $extra_data = get_multiple('subscription_owner', array('owner_table' => $owner_table, 'owner_id' => $owner_id, 'deleted' => 0), 'subscription_owner_id');
            ?>

            <td>
                <?php 
            if ($extra_data) {
                foreach ($extra_data as $e) {
                    $subscription = get_single('subscription', 'subscription_id', $e['subscription_id']);
                    if (isset($subscription['name'])) {
                        echo htmlspecialchars($subscription['name']) . '<br/>';
                    }
                }
            }
            ?>

            </td>
            <?php 
        }
    }
Example #25
0
 public static function hook_invoice_payment_deleted($callback_name, $invoice_payment_id, $invoice_id)
 {
     //find any finance items that are linked with this invoice payment id
     if ($invoice_id > 0 && $invoice_payment_id > 0) {
         $finance_items = get_multiple('finance', array('invoice_payment_id' => $invoice_payment_id));
         foreach ($finance_items as $finance_item) {
             if ($finance_item['finance_id'] && $finance_item['invoice_payment_id'] == $invoice_payment_id) {
                 self::delete($finance_item['finance_id']);
                 //                    $sql = "DELETE FROM `"._DB_PREFIX."finance` WHERE invoice_payment_id = '$invoice_payment_id' LIMIT 1";
                 //                    query($sql);
             }
         }
     }
 }
Example #26
0
 public static function get_security_role($security_role_id)
 {
     $role = get_single('security_role', 'security_role_id', $security_role_id);
     $role['permissions'] = get_multiple('security_role_perm', array('security_role_id' => $security_role_id), 'security_permission_id');
     return $role;
 }
Example #27
0
                            rsa2.e = existing_encrypt_keys[new_id].e;
                        }
                    });
                })
            </script>
        </td>
    </tr>
    <tr>
        <th>
            <?php 
_e('Last Decryption:');
?>
        </th>
        <td>
            <?php 
$last = get_multiple('encrypt_access', array('encrypt_id' => $encrypt_id, 'status' => 2), 'encrypt_access_id', 'exact', 'encrypt_access_id DESC');
if (!$last) {
    _e('N/A');
} else {
    $last = array_shift($last);
    _e('By %s at %s from %s', module_user::link_open($last['create_user_id'], true), print_date($last['date_created'], true), preg_replace('#^(\\d*\\.\\d*).*$#', '$1.**.**', $last['create_ip_address']));
}
?>
        </td>
    </tr>
    <!-- <tr>
        <th>
            <?php 
_e('Raw Value:');
?>
        </th>
Example #28
0
 public static function get_accounts()
 {
     return get_multiple('social_facebook', array(), 'social_facebook_id');
 }
    set_error('Sorry no newsletter send id specified');
    redirect_browser(module_newsletter::link_open($newsletter_id));
}
$send = module_newsletter::get_send($send_id);
if ($send['status'] != _NEWSLETTER_STATUS_SENT) {
    // hasnt sent yet, redirect to the pending watch page.
    redirect_browser(module_newsletter::link_queue_watch($newsletter_id, $send_id));
}
$start_time = $send['start_time'];
if (isset($_REQUEST['show'])) {
    // render the newsletter and display it on screen with nothing else.
    $content = module_newsletter::render($newsletter_id, $send_id, false, 'preview');
    // do the link click overview here:
    ob_end_clean();
    // grab all the links for this send
    $send_links = get_multiple('newsletter_link', array('send_id' => $send_id));
    $links_to_process = array();
    $old_links_by_url = array();
    foreach ($send_links as $send_link) {
        // we have to do this because the link processing part puts a unique member id into these unsubscribe/view online links.
        $parsed_url = preg_replace('#\\&nm=\\d+#', '&nm=', $send_link['link_url']);
        $parsed_url = preg_replace('#\\&hash=\\w+#', '&nm=', $parsed_url);
        // how many opens did this one have?
        $sql = "SELECT COUNT(*) AS `open_count` FROM `" . _DB_PREFIX . "newsletter_link_open` no ";
        $sql .= " WHERE no.send_id = " . (int) $send_id . " AND no.link_id = " . (int) $send_link['link_id'];
        $res = qa1($sql);
        if (!isset($old_links_by_url[$parsed_url])) {
            $old_links_by_url[$parsed_url] = array();
        }
        $links_to_process[$send_link['link_id']] = (int) $res['open_count'];
        $old_links_by_url[$parsed_url][$send_link['link_id']] = (int) $res['open_count'];
Example #30
0
    $show_other_settings = false;
    $extra_default = module_extra::get_extra_default($_REQUEST['extra_default_id']);
    ?>
     <form action="" method="post">
        <input type="hidden" name="_process" value="save_extra_default">
        <input type="hidden" name="extra_default_id" value="<?php 
    echo (int) $_REQUEST['extra_default_id'];
    ?>
" />
     <?php 
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Edit Extra Default Field'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array(array('title' => 'Name/Label', 'field' => array('type' => 'text', 'name' => 'extra_key', 'value' => $extra_default['extra_key'])), array('title' => 'Table', 'field' => array('type' => 'html', 'value' => $extra_default['owner_table'])), array('title' => 'Visibility', 'field' => array('type' => 'select', 'name' => 'display_type', 'value' => $extra_default['display_type'], 'options' => module_extra::get_display_types(), 'blank' => false, 'help' => 'Default will display the extra field when opening an item (eg: opening a customer). If a user can view the customer they will be able to view the extra field information when viewing the customer. Public In Column means that this extra field will also display in the overall listing (eg: customer listing). More options coming soon (eg: private)')), array('title' => 'Order', 'field' => array('type' => 'text', 'name' => 'order', 'value' => $extra_default['order'])), array('title' => 'Searchable', 'field' => array('type' => 'select', 'name' => 'searchable', 'value' => $extra_default['searchable'], 'options' => get_yes_no(), 'blank' => false, 'help' => 'If this field is searchable it will display in the main search bar. Also quick search will return results matching this field. Note: Making every field searchable will slow down the "Quick Search".')), array('title' => 'Field Type', 'field' => array('type' => 'select', 'name' => 'field_type', 'value' => $extra_default['field_type'], 'options' => array('' => 'Text', 'date' => 'Date', 'textarea' => 'Text Area', 'wysiwyg' => 'Rich Text/WYSIWYG', 'checkbox' => 'Tick Box', 'select' => 'Dropdown / Select'), 'blank' => false)), array('title' => 'Dropdown Options', 'field' => array('type' => 'textarea', 'name' => 'options[select]', 'value' => isset($extra_default['options']['select']) ? $extra_default['options']['select'] : '', 'help' => 'Put the drop down options here, one per line (only valid when Field Type is "Dropdown / Select").'))));
    echo module_form::generate_fieldset($fieldset_data);
    $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete'))));
    echo module_form::generate_form_actions($form_actions);
    if ($extra_default['owner_table'] && $extra_default['extra_key']) {
        $extra_values = get_multiple('extra', array('owner_table' => $extra_default['owner_table'], 'extra_key' => $extra_default['extra_key']), 'extra_id', 'exact', 'owner_id');
        if ($extra_values) {
            $table_manager = module_theme::new_table_manager();
            $columns = array();
            $columns['id'] = array('title' => 'ID');
            $columns['name'] = array('title' => 'Name', 'cell_class' => 'row_action');
            $columns['extra'] = array('title' => 'Value');
            $columns['created'] = array('title' => 'Created');
            $columns['updated'] = array('title' => 'Updated');
            $table_manager->set_columns($columns);
            $table_manager->row_callback = function ($row_data) {
                // load the full customer data before displaying each row so we have access to more details
                $row_data['id'] = $row_data['owner_table'] . ' #' . $row_data['owner_id'];
                $row_data['name'] = 'N/A';
                if (is_callable('module_' . basename($row_data['owner_table']) . '::link_open') && $row_data['owner_id']) {
                    eval("\$row_data['name'] = module_" . basename($row_data['owner_table']) . "::link_open(" . $row_data['owner_id'] . ",true);");