/**
 * @param $edit_page
 * @param $obsolete_flag
 */
function print_versions($edit_page, $obsolete_flag)
{
    $specmanagement_database_api = new specmanagement_database_api();
    $specmanagement_print_api = new specmanagement_print_api();
    $obsolote = false;
    if ($obsolete_flag) {
        $obsolote = null;
    }
    if ($edit_page) {
        $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, null);
    } else {
        $versions = version_get_all_rows_with_subs(helper_get_current_project(), null, $obsolote);
    }
    for ($version_index = 0; $version_index < count($versions); $version_index++) {
        $version = $versions[$version_index];
        $current_type = $specmanagement_database_api->get_type_string($specmanagement_database_api->get_type_by_version($version['id']));
        $specmanagement_print_api->printRow();
        echo '<input type="hidden" name="version_ids[]" value="' . $version['id'] . '"/>';
        print_name($edit_page, $version);
        print_released($edit_page, $version_index, $version);
        print_obsolete($edit_page, $version_index, $version);
        print_date($edit_page, $version);
        print_type($edit_page, $current_type, $version);
        print_description($edit_page, $version);
        print_action($edit_page, $version);
        echo '</tr>';
    }
}
function extract_data($value)
{
    $htmlvalue = str_get_html($value);
    //print $htmlvalue;
    $link = $htmlvalue->find('li[class="first last"] a', 0);
    $title = $htmlvalue->find('li[class="first last"] a', 0);
    $description = $htmlvalue->find('li[class="first last"] a', 0);
    $date = $htmlvalue->find('span[class="date-display-single"]', 0);
    $processdate = substr($date->plaintext, -10);
    //print $link->href. "\n";
    //print $title->plaintext. "\n";
    //print $description->plaintext. "\n";
    $when = date_create_from_format('d/m/Y', $processdate);
    print_date($when);
    $data = array('link' => $link->href, 'title' => $title->plaintext, 'description' => $description->plaintext, 'date' => $when);
    scraperwiki::save(array('title'), $data);
}
Ejemplo n.º 3
0
if (count($blank_invoices)) {
    ?>
	<h2>Blank invoices found</h2>
	We found the following <?php 
    echo count($blank_invoices);
    ?>
 blank invoices that were created from a recent "Subscription" bug:
	<ul>
		<?php 
    foreach ($blank_invoices as $blank_invoice) {
        ?>
		<li><?php 
        echo module_invoice::link_open($blank_invoice['invoice_id'], true);
        ?>
 created on <?php 
        echo print_date($blank_invoice['date_created']);
        ?>
</li>
		<?php 
    }
    ?>
	</ul>
	You can remove all these invoices manually, or click the button below to remove them automatically.
	<form action="" method="post">
		<input type="hidden" name="remove_duplicates" value="yes">
		<input type="submit" value="Remove these <?php 
    echo count($blank_invoices);
    ?>
 invoices">
	</form>
	<?php 
Ejemplo n.º 4
0
?>
">
                    <img class="img-responsive" src="<?php 
pic_location(11);
?>
" alt="">
                </a>
                <h3><a href="<?php 
pic_location(11);
?>
"><?php 
print_name(11);
?>
</a></h3>
                <p><?php 
print_date(11);
?>
</p>
            </div>
        </div>
        <!-- /.row -->

       

        <!-- Footer -->
        <footer>
            <div class="row">
                <div class="col-lg-12">
                    <p>Copyright &copy; Aaron Wisner 2014 aaronwisner@gmail.com</p>
                </div>
            </div>
Ejemplo n.º 5
0
    } else {
        echo '<select ', helper_get_tab_index(), ' name="user_id">';
        print_user_option_list($t_tag_row['user_id'], ALL_PROJECTS, config_get('tag_create_threshold'));
        echo '</select>';
    }
} else {
    echo user_get_name($t_tag_row['user_id']);
}
?>
</td>
	<td><?php 
echo print_date(config_get('normal_date_format'), db_unixtimestamp($t_tag_row['date_created']));
?>
 </td>
	<td><?php 
echo print_date(config_get('normal_date_format'), db_unixtimestamp($t_tag_row['date_updated']));
?>
 </td>
</tr>

<!-- spacer -->
<tr class="spacer">
	<td colspan="5"></td>
</tr>

<!-- Description -->
<tr <?php 
echo helper_alternate_class();
?>
>
	<td class="category"><?php 
Ejemplo n.º 6
0
        echo _l('(%s out of %s tickets)', ordinal($ticket['position']), $ticket['total_pending']);
    }
    ?>

	                    <input type="hidden" name="status_id" value="<?php 
    echo $ticket['status_id'];
    ?>
">
						<?php 
}))));
if ($ticket['last_message_timestamp']) {
    $fieldset_data['elements'][] = array('title' => _l('Date/Time'), 'fields' => array(function () use($ticket, $limit_time) {
        if ($ticket['last_message_timestamp'] < $limit_time) {
            echo '<span class="important">';
        }
        echo print_date($ticket['last_message_timestamp'], true);
        // how many days ago was this?
        echo ' ';
        $days = ceil(($ticket['last_message_timestamp'] + 1 - time()) / 86400);
        if (abs($days) == 0) {
            _e('(today)');
        } else {
            _e(' (%s days ago)', abs($days));
        }
        if ($ticket['last_message_timestamp'] < $limit_time) {
            echo '</span>';
        }
    }));
}
$fieldset_data['elements'][] = array('title' => _l('Subject'), 'fields' => array(function () use($ticket) {
    if ($ticket['subject']) {
Ejemplo n.º 7
0
		<?php 
echo get_enum_element('reproducibility', $t_bug->reproducibility);
?>
	</td>

	<!-- Date Submitted -->
	<td>
		<?php 
print_date(config_get('normal_date_format'), $t_bug->date_submitted);
?>
	</td>

	<!-- Date Updated -->
	<td>
		<?php 
print_date(config_get('normal_date_format'), $t_bug->last_updated);
?>
	</td>

</tr>


<!-- spacer -->
<tr class="spacer">
	<td colspan="6"></td>
</tr>


<tr <?php 
echo helper_alternate_class();
?>
Ejemplo n.º 8
0
}, 'cell_class' => 'row_action');
$columns['newsletter_from'] = array('title' => 'Sent From', 'callback' => function ($newsletter) {
    ?>
 &lt;<?php 
    echo htmlspecialchars($newsletter['from_name']);
    ?>
&gt; <?php 
    echo htmlspecialchars($newsletter['from_email']);
    ?>
 <?php 
});
$columns['newsletter_date'] = array('title' => 'Sent Date', 'callback' => function ($newsletter) {
    if (!$newsletter['send_data'] || !$newsletter['send_data']['finish_time']) {
        echo _l('Never sent');
    } else {
        echo print_date($newsletter['send_data']['finish_time'], true);
    }
});
$columns['newsletter_to'] = array('title' => 'Sent To', 'callback' => function ($newsletter) {
    if ($newsletter['send_data']) {
        echo _l('%s of %s', (int) $newsletter['send_data']['total_sent_count'], (int) $newsletter['send_data']['total_member_count']);
    }
});
$columns['newsletter_views'] = array('title' => 'Views', 'callback' => function ($newsletter) {
    if ($newsletter['send_data']) {
        echo (int) $newsletter['send_data']['total_open_count'];
        echo ' ';
        if ($newsletter['send_data']['total_member_count'] > 0) {
            echo '(' . (int) ($newsletter['send_data']['total_open_count'] / $newsletter['send_data']['total_member_count'] * 100) . '%)';
        }
    }
Ejemplo n.º 9
0
    html_set_rss_link($t_rss_link);
}
html_page_top1();
html_page_top2();
if (!current_user_is_anonymous()) {
    echo '<div class="quick-summary-left">';
    echo lang_get('open_and_assigned_to_me') . ': ';
    echo '<a class="subtle" href="view_all_set.php?type=1&amp;handler_id=' . auth_get_current_user_id() . '&amp;hide_status=' . RESOLVED . '">' . current_user_get_assigned_open_bug_count() . '</a>';
    echo '</div>';
    echo '<div class="quick-summary-right">';
    echo lang_get('open_and_reported_to_me') . ': ';
    echo '<a class="subtle" href="view_all_set.php?type=1&amp;reporter_id=' . auth_get_current_user_id() . '&amp;hide_status=' . RESOLVED . '">' . current_user_get_reported_open_bug_count() . '</a>';
    echo '</div>';
    echo '<div class="quick-summary-left">';
    echo lang_get('last_visit') . ': ';
    echo print_date(config_get('normal_date_format'), db_unixtimestamp(current_user_get_field('last_visit')));
    echo '</div>';
}
echo '<br />';
echo '<br />';
echo '<br />';
$t_news_rows = news_get_limited_rows($f_offset, $t_project_id);
$t_news_count = count($t_news_rows);
# Loop through results
for ($i = 0; $i < $t_news_count; $i++) {
    $t_row = $t_news_rows[$i];
    # only show VS_PRIVATE posts to configured threshold and above
    if (VS_PRIVATE == $t_row['view_state'] && !access_has_project_level(config_get('private_news_threshold'))) {
        continue;
    }
    print_news_entry_from_row($t_row);
Ejemplo n.º 10
0
                <?php 
print_heading(array('type' => 'h3', 'title' => 'Send Statistics'));
?>
                <table class="tableclass tableclass_form tableclass_full">
                    <tbody>
                    <tr>
                        <th class="width1"><?php 
_e('Start sending');
?>
</th>
                        <td>
                            <?php 
if ($start_time <= time()) {
    _e('Now');
} else {
    echo print_date($start_time, true);
}
?>
                        </td>
                    </tr>
                    <tr>
                        <th><?php 
_e('Sent To');
?>
</th>
                        <td id="sent_to">
                            <?php 
echo _l('%s of %s', (int) $send['total_sent_count'], (int) $send['total_member_count']);
?>
                        </td>
                    </tr>
Ejemplo n.º 11
0
    </div>
    <?php 
}
if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2) {
    // disabled & shown.
    return;
}
if ($allow_new) {
    ?>
<div class="task_job_discussion_comments">
    <div class="info">
        <?php 
    echo $current_user_id ? module_user::link_open($current_user_id, true, array(), true) : 'Unknown';
    ?>
        <?php 
    echo print_date(time(), true);
    ?>
    </div>
    <textarea rows="4" cols="30" name="new_comment"></textarea> <br/>
    <input type="button" name="add" value="<?php 
    _e('Add Comment');
    ?>
" class="task_job_discussion_add small_button" data-jobid="<?php 
    echo $job_id;
    ?>
" data-taskid="<?php 
    echo $task_id;
    ?>
">
    <?php 
    $send_to_customer_ids = array();
Ejemplo n.º 12
0
        ?>
">
                <?php 
    }
    ?>
            <?php 
    $next_due = strtotime($recurring['next_due_date']);
    if (!$recurring['next_due_date'] || $recurring['next_due_date'] == '0000-00-00') {
        echo _l('(recurring finished)');
    } else {
        if ($next_due < time()) {
            echo '<span class="important">';
            echo print_date($recurring['next_due_date']);
            echo '</span>';
        } else {
            echo print_date($recurring['next_due_date']);
        }
    }
    //if($show_record_button){
    $days = ceil(($next_due + 1 - time()) / 86400);
    if (abs($days) == 0) {
        _e('(today)');
    } else {
        _e(' (%s days)', $days);
    }
    //}
    ?>
                <?php 
    if ($show_record_button) {
        ?>
                </a>
Ejemplo n.º 13
0
	<th class="sf_admin_text sf_admin_list_th ui-state-default ui-th-column"></th>
	<th class="sf_admin_text sf_admin_list_th ui-state-default ui-th-column">Fecha</th>
	<th class="sf_admin_text sf_admin_list_th ui-state-default ui-th-column">Monto</th>
</tr>
</thead>  
  <?php 
$_LIST_SIZE = 10;
foreach ($client->getMembershipFees() as $membership) {
    ?>
		<tr class="sf_admin_row ui-widget-content odd">
			<td class="sf_admin_text sf_admin_list_td"> 
  					<img alt="Checked" title="Checked" src="/sfDoctrinePlugin/images/tick.png">
			</td>
			<td class="sf_admin_text sf_admin_list_td">
				<?php 
    echo print_date($membership->getDate(), 'd-m-Y');
    ?>
			</td>
			<td class="sf_admin_text sf_admin_list_td">
			<?php 
    echo $membership->getAmount();
    ?>
			</td>
		</tr>
   <?php 
    $_LIST_SIZE--;
    if ($_LIST_SIZE <= 0) {
        break;
    }
}
?>
Ejemplo n.º 14
0
    function get_form_element($element, $viewing_revision = false, $data_record = array())
    {
        $has_write_access = !$viewing_revision;
        // convert our data field to an element.
        $element['name'] = isset($element['name']) && !empty($element['name']) ? $element['name'] : 'data_field[' . $element['data_field_id'] . ']';
        $element['id'] = 'data_field_' . $element['data_field_id'] . '';
        $element['type'] = $element['field_type'];
        if (!isset($element['value'])) {
            $element['value'] = '';
        }
        if (!$has_write_access) {
            //$element['disabled'] = 'disabled';
            $element['class'] = 'data_field_view';
        }
        $highlight = false;
        $this->ajax_edit = false;
        $input_name = $element['name'];
        if (!$input_name) {
            return false;
        }
        if (isset($element['id']) && $element['id']) {
            $input_id = $element['id'];
        } else {
            $element['id'] = $input_name;
            $input_id = $input_name;
        }
        //if(!$value && isset($_REQUEST[$input_name]))$value = $_REQUEST[$input_name];
        if (!$element['value']) {
            $element['value'] = $element['default'];
        }
        if (!is_array($element['value'])) {
            //$value=htmlspecialchars($value);
        }
        if (!isset($element['class'])) {
            $element['class'] = '';
        }
        $attr = $attr_other = '';
        if ($has_write_access) {
            if ($element['type'] == 'radio' || $element['type'] == 'checkbox_list') {
                // hacky!
                if ($element['required']) {
                    $attr_other .= ' class="form_field form_field_required"';
                } else {
                    $attr_other .= ' class="form_field"';
                }
            } else {
                $element['class'] .= " form_field";
                if ($element['required']) {
                    $element['class'] .= " form_field_required";
                }
            }
            switch ($element['type']) {
                case 'date':
                    $element['class'] .= " date_field";
                    if (!isset($element['size']) || !$element['size']) {
                        $element['size'] = 8;
                    }
                    if (strtolower($element['value']) == 'now') {
                        $element['value'] = print_date(time());
                    }
                    break;
                case 'datetime':
                    $element['class'] .= " date_time_field";
                    if (!isset($element['size']) || !$element['size']) {
                        $element['size'] = 12;
                    }
                    if (strtolower($element['value']) == 'now') {
                        $element['value'] = print_date(time(), true);
                    }
                    break;
            }
        }
        switch ($element['type']) {
            case 'checkbox_list':
            case 'radio':
                $element['attributes'] = array();
                foreach (explode("\n", trim($element['field_data'])) as $line) {
                    $line = trim($line);
                    if (preg_match('/^attributes=/', $line)) {
                        $line = preg_replace('/^attributes=/', '', $line);
                        $element['attributes'] = explode("|", $line);
                        break;
                    }
                }
                break;
            case 'select':
                if (!isset($element['attributes']) || !is_array($element['attributes']) || !count($element['attributes'])) {
                    $element['attributes'] = array();
                    foreach (explode("\n", trim($element['field_data'])) as $line) {
                        $line = trim($line);
                        if (preg_match('/^attributes=/', $line)) {
                            $line = preg_replace('/^attributes=/', '', $line);
                            if (preg_match('#hook:([\\w_]+)$#', $line, $matches)) {
                                // see if we get anything back from this hook.
                                $attributes = array();
                                $attributes = hook_filter_var($matches[1], $attributes, $element);
                                if (is_array($attributes)) {
                                    $element['attributes'] = $attributes;
                                } else {
                                    $element['attributes'] = array('Unable to call hook: ' . $matches[1]);
                                }
                            } else {
                                $element['attributes'] = explode("|", $line);
                            }
                            break;
                        }
                    }
                }
                break;
        }
        if (!isset($element['style'])) {
            $element['style'] = '';
        }
        // we have to apply some custom width/height styles if they exist.
        $width = $height = false;
        foreach (explode("\n", trim($element['field_data'])) as $line) {
            $line = trim($line);
            if (preg_match('/^width=/', $line)) {
                $line = preg_replace('/^width=/', '', $line);
                $width = (int) $line;
            }
            if (preg_match('/^height=/', $line)) {
                $line = preg_replace('/^height=/', '', $line);
                $height = (int) $line;
            }
        }
        if (!$height && $height < _MIN_INPUT_HEIGHT) {
            $height = _MIN_INPUT_HEIGHT;
        }
        switch ($element['type']) {
            case 'text':
            case 'date':
            case 'datetime':
                if ($width) {
                    $element['style'] .= 'width:' . $width . 'px; ';
                }
                break;
            case 'radio':
                if ($width) {
                    $attr_other .= ' style="width:' . $width . 'px; "';
                }
                break;
            case 'textarea':
            case 'textbox':
                if ($width) {
                    $element['style'] .= 'width:' . $width . 'px; ';
                }
                if ($has_write_access && $height) {
                    $element['style'] .= 'height:' . $height . 'px; ';
                }
                break;
        }
        if (isset($element['width'])) {
            unset($element['width']);
        }
        if (isset($element['height'])) {
            unset($element['height']);
        }
        if (isset($element['multiple']) && $element['multiple']) {
            $element['multiple'] = true;
            // pass 'multiple' through to the UCM form builder which should handle everything
            $value_unserialize = @unserialize($element['value']);
            if (is_array($value_unserialize)) {
                $element['values'] = $value_unserialize;
                // 'values' is used in the UCM field generation tool
            }
            $element['name'] = $element['name'] . '[]';
        } else {
            $element['multiple'] = false;
        }
        if (!$has_write_access && $element['multiple'] && isset($element['values']) && is_array($element['values'])) {
            $element['value'] = $element['values'];
        }
        if (is_array($element['value']) && count($element['value'])) {
            $all_values = $element['value'];
        } else {
            $all_values = array($element['value']);
        }
        if ($element['type'] == 'checkbox_list') {
            $test = @unserialize($element['value']);
            if (is_array($test) && count($test)) {
                $all_values = array($test);
            } else {
                $all_values = array($element['value']);
            }
        }
        if ($element['type'] == "cancel" && !isset($element['onclick'])) {
            $element['onclick'] = "history.go(-1);";
        }
        if ($highlight) {
            $element['class'] .= " form_field_highlight";
        }
        /*if(!$has_write_access){
        			$element['class'] .= ' form_disabled';
        		}*/
        $attribute_keys = array('class', 'disabled', 'onclick', 'onfocus', 'onmouseup', 'onmousedown', 'onchange', 'size', 'cols', 'rows', 'width', 'style');
        foreach ($element as $key => $val) {
            if (!is_array($val) && !trim($val)) {
                continue;
            }
            if (in_array(strtolower($key), $attribute_keys)) {
                if (in_array(strtolower($key), array('size', 'cols', 'rows', 'width', 'height')) && (int) $val == 0) {
                    continue;
                }
                $attr .= ' ' . $key . '="' . $val . '"';
            }
        }
        // check for default values, these are cleared when submitting the form
        if ($element['default']) {
            $has_default = true;
        }
        $real_input_id = $input_id;
        $real_input_name = $input_name;
        ob_start();
        foreach ($all_values as $value_key => $value) {
            if (!$has_write_access) {
                // disabled.
                if (isset($width) && $width && $element['type'] != 'encrypted') {
                    echo '<span ' . $attr;
                    echo ' style="width:' . $width . 'px;"';
                    echo '>&nbsp;';
                }
                // display value differently depending on value type.
                switch ($element['type']) {
                    case 'checkbox_list':
                        $other = '';
                        if (is_array($value)) {
                            if (isset($value['other_val'])) {
                                $other = $value['other_val'];
                                unset($value['other_val']);
                            }
                            echo implode(', ', array_keys($value));
                        }
                        echo ' ' . $other;
                        break;
                    case 'select':
                        if (isset($element['attributes'])) {
                            $attributes = $element['attributes'];
                        } else {
                            $attributes = array();
                        }
                        if (isset($attributes[0])) {
                            $new_attributes = array();
                            foreach ($attributes as $aid => $a) {
                                $new_attributes[$aid + 1] = $a;
                            }
                            $attributes = $new_attributes;
                        }
                        if (isset($attributes[$value])) {
                            echo $attributes[$value];
                        }
                        break;
                    case 'textarea':
                    case 'textbox':
                        echo nl2br(htmlspecialchars($value));
                        break;
                    case 'file':
                        if ($value) {
                            $file_data = @unserialize($value);
                            $file_link = 'includes/plugin_data/upload/' . $file_data['file'];
                            if (is_file($file_link)) {
                                $download_link = self::link_public_file_download($data_record['data_record_id'], $data_record['data_type_id'], $element['data_field_group_id'], $element['data_field_id']);
                                echo '<a href="' . $download_link . '" target="_blank">' . $file_data['name'] . '</a>';
                            } else {
                                echo 'File Not Found';
                            }
                        }
                        break;
                    case 'wysiwyg':
                        echo module_security::purify_html($value);
                        break;
                    case 'encrypted':
                        if (class_exists('module_encrypt', false)) {
                            ob_start();
                            $element['type'] = 'text';
                            module_form::generate_form_element($element);
                            $enc_html = ob_get_clean();
                            echo module_encrypt::parse_html_input('custom_data', $enc_html, false);
                        }
                        break;
                    case 'created_date_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A');
                        break;
                    case 'created_date':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A');
                        break;
                    case 'created_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A');
                        break;
                    case 'updated_date_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'));
                        break;
                    case 'updated_date':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'));
                        break;
                    case 'updated_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'));
                        break;
                    case 'created_by':
                        echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A');
                        break;
                    case 'updated_by':
                        echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'));
                        break;
                    case 'url':
                        echo '<a href="' . htmlspecialchars($value) . '" target="_blank">' . htmlspecialchars($value) . '</a>';
                        break;
                    default:
                        echo htmlspecialchars($value);
                        break;
                }
                if (isset($width) && $width && $element['type'] != 'encrypted') {
                    echo '&nbsp;</span>';
                }
            } else {
                // update for UCM: use the ucm form generator
                if (isset($element['default']) && $element['default'] && !$element['value']) {
                    $element['value'] = $element['default'];
                }
                switch ($element['type']) {
                    case 'wysiwyg':
                        $element['options']['inline'] = false;
                        module_form::generate_form_element($element);
                        break;
                    case "radio":
                        $has_val = false;
                        foreach ($element['attributes'] as $attribute) {
                            $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute);
                            ?>

                            <span class="field_radio">
                            <input type="radio" name="<?php 
                            echo $input_name;
                            ?>
" id="<?php 
                            echo $this_input_id;
                            ?>
" value="<?php 
                            echo htmlspecialchars($attribute);
                            ?>
"<?php 
                            if ($attribute == $value || strtolower($attribute) == 'other' && !$has_val) {
                                // assumes "OTHER" is always last... fix with a separate loop before hand checking all vals
                                if (strtolower($attribute) != 'other') {
                                    $has_val = true;
                                }
                                echo " checked";
                            }
                            echo ' ' . $attr;
                            if (strtolower($attribute) == 'other') {
                                echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"';
                                echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"';
                            }
                            ?>
>
                                <label for="<?php 
                            echo $this_input_id;
                            ?>
"><?php 
                            echo $attribute;
                            ?>
</label>
                                <?php 
                            if (strtolower($attribute) == 'other') {
                                ?>

                                    <span class="data_field_input">
                                    <input type="text" name="other_<?php 
                                echo $input_name;
                                ?>
" id="other_<?php 
                                echo $this_input_id;
                                ?>
" value="<?php 
                                if (!$has_val) {
                                    echo htmlspecialchars($value);
                                }
                                ?>
" onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php 
                                echo $attr . $attr_other;
                                ?>
>
                                    </span>
                                <?php 
                            }
                            ?>

                            </span>
                            <?php 
                        }
                        break;
                    case "checkbox_list":
                        $has_val = false;
                        if (!is_array($value)) {
                            $value = array();
                        }
                        foreach ($element['attributes'] as $attribute) {
                            $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute);
                            ?>

                            <span class="field_radio">
                            <input type="checkbox" name="<?php 
                            echo $input_name;
                            ?>
[<?php 
                            echo htmlspecialchars($attribute);
                            ?>
]" id="<?php 
                            echo $this_input_id;
                            ?>
" value="1"<?php 
                            if (isset($value[$attribute])) {
                                if (strtolower($attribute) != 'other') {
                                    $has_val = true;
                                }
                                echo " checked";
                            }
                            echo ' ' . $attr;
                            if (strtolower($attribute) == 'other') {
                                echo ' onmouseup="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"';
                                echo ' onchange="if(this.checked)$(\'#other_' . $this_input_id . '\')[0].focus();"';
                            }
                            ?>
>
                                <label for="<?php 
                            echo $this_input_id;
                            ?>
"><?php 
                            echo $attribute;
                            ?>
</label>
                                <?php 
                            if (strtolower($attribute) == 'other') {
                                ?>

                                    <span class="data_field_input">
                                        <input type="text" name="<?php 
                                echo $input_name;
                                ?>
[other_val]" id="other_<?php 
                                echo $this_input_id;
                                ?>
" value="<?php 
                                echo isset($value['other_val']) ? htmlspecialchars($value['other_val']) : '';
                                ?>
" onchange="$('input[type=radio]',$(this).parent())[0].checked = true;" <?php 
                                echo $attr . $attr_other;
                                ?>
>
                                    </span>
                                <?php 
                            }
                            ?>

                            </span>
                            <?php 
                        }
                        break;
                    case "file":
                        $this->has_files = true;
                        ?>

                        <input type="file" name="<?php 
                        echo $input_name;
                        ?>
" id="<?php 
                        echo $input_id;
                        ?>
" value="<?php 
                        echo $value;
                        ?>
"<?php 
                        echo $attr;
                        ?>
>
                        <?php 
                        break;
                    case 'select':
                        $attributes = isset($element['attributes']) ? $element['attributes'] : array();
                        if (isset($attributes[0])) {
                            $new_attributes = array();
                            foreach ($attributes as $aid => $a) {
                                $new_attributes[$aid + 1] = $a;
                            }
                            $attributes = $new_attributes;
                        }
                        $element['options'] = $attributes;
                        module_form::generate_form_element($element);
                        break;
                    case 'encrypted':
                        if (class_exists('module_encrypt', false)) {
                            ob_start();
                            $element['type'] = 'text';
                            module_form::generate_form_element($element);
                            $enc_html = ob_get_clean();
                            echo module_encrypt::parse_html_input('custom_data', $enc_html);
                        }
                        break;
                    case 'created_date_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A');
                        break;
                    case 'created_date':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A');
                        break;
                    case 'created_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A');
                        break;
                    case 'updated_date_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'));
                        break;
                    case 'updated_date':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'));
                        break;
                    case 'updated_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'));
                        break;
                    case 'created_by':
                        echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A');
                        break;
                    case 'updated_by':
                        echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'));
                        break;
                    case 'url':
                        $element['type'] = 'text';
                        module_form::generate_form_element($element);
                        break;
                    default:
                        module_form::generate_form_element($element);
                }
                if (isset($element['after_link']) && $element['after_link']) {
                    if (preg_match('/^https?:\\/\\//', $value) || ($have_www = preg_match('/^www\\./', $value) || ($have_www = preg_match('/\\.com/', $value) && !preg_match('/\\w@\\w/', $value)))) {
                        // we have a url
                        if ($have_www) {
                            $value = "http://" . $value;
                        }
                        ?>

						<a href="<?php 
                        echo $value;
                        ?>
" target="_blank">&raquo;</a>
						<?php 
                    }
                    if (preg_match('/\\w@\\w/', $value)) {
                        ?>

						<a href="mailto:<?php 
                        echo $value;
                        ?>
">&raquo;</a>
					<?php 
                    }
                }
            }
            // editable
            echo '&nbsp;';
        }
        // foreach all values
        //${$element_id} = ob_get_clean();
        // we just print the html for now
        return ob_get_clean();
    }
Ejemplo n.º 15
0
                                        <?php 
                echo $alert['warning'] ? '<span class="important">' : '';
                ?>
                                        <?php 
                echo $alert['days'];
                ?>
                                        <?php 
                echo $alert['warning'] ? '</span>' : '';
                ?>
                                    </td>
                                <td width="16%">
                                    <?php 
                echo $alert['warning'] ? '<span class="important">' : '';
                ?>
                                    <?php 
                echo print_date($alert['date']);
                ?>
                                    <?php 
                echo $alert['warning'] ? '</span>' : '';
                ?>
                                </td>
                                <?php 
                if (isset($alert['hide_key']) && $alert['hide_key']) {
                    ?>
                                <td width="10">
                                    <a href="#" class="ui-corner-all ui-icon ui-icon-trash" onclick="return hide_item('<?php 
                    echo $alert['hide_key'];
                    ?>
');">[x]</a>
                                </td>
                                <?php 
Ejemplo n.º 16
0
_e('To');
?>
</th>
                <th><?php 
_e('User');
?>
</th>
            </tr>
        </thead>
        <tbody>
            <?php 
foreach ($pagination['rows'] as $n) {
    ?>
                <tr>
                    <td><?php 
    echo print_date($n['sent_time']);
    ?>
</td>
                    <td><?php 
    echo htmlspecialchars($n['subject']);
    ?>
</td>
                    <td><?php 
    $headers = unserialize($n['headers']);
    if (isset($headers['to']) && is_array($headers['to'])) {
        foreach ($headers['to'] as $to) {
            echo $to['email'] . ' ';
        }
    }
    ?>
</td>
Ejemplo n.º 17
0
 public static function get_finance($finance_id, $full = true, $invoice_payment_id = false)
 {
     if (!$invoice_payment_id) {
         $invoice_payment_id = isset($_REQUEST['invoice_payment_id']) && (int) $_REQUEST['invoice_payment_id'] > 0 ? (int) $_REQUEST['invoice_payment_id'] : false;
     }
     $finance_id = (int) $finance_id;
     if ($finance_id > 0) {
         if (!$full) {
             return get_single("finance", "finance_id", $finance_id);
         }
         $sql = "SELECT f.* ";
         $sql .= " , fa.name AS account_name ";
         $sql .= " , GROUP_CONCAT(fc.`name` ORDER BY fc.`name` ASC SEPARATOR ', ') AS categories ";
         $sql .= " FROM `" . _DB_PREFIX . "finance` f ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "finance_account` fa USING (finance_account_id) ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "finance_category_rel` fcr ON f.finance_id = fcr.finance_id ";
         $sql .= " LEFT JOIN `" . _DB_PREFIX . "finance_category` fc ON fcr.finance_category_id = fc.finance_category_id ";
         $sql .= " WHERE f.finance_id = {$finance_id} ";
         $sql .= " GROUP BY f.finance_id ";
         $sql .= " ORDER BY f.transaction_date DESC ";
         $finance = qa1($sql);
         $finance_id = $finance['finance_id'];
         // get the categories.
         $finance['category_ids'] = get_multiple('finance_category_rel', array('finance_id' => $finance_id), 'finance_category_id');
         $finance['taxes'] = get_multiple('finance_tax', array('finance_id' => $finance_id), 'finance_tax_id', 'exact', 'order');
         // get any linked items.
         $linked_finances = $linked_invoice_payments = array();
         // find any child / linked transactions to this one.
         if ((int) $finance_id > 0 && isset($finance['parent_finance_id']) && $finance['parent_finance_id'] > 0) {
             // todo - this could cause problems!
             $foo = module_finance::get_finance($finance['parent_finance_id'], false);
             if ($foo['finance_id'] != $finance_id) {
                 // copied from get_finances() method
                 $foo['url'] = module_finance::link_open($foo['finance_id'], false);
                 $foo['credit'] = $foo['type'] == 'i' ? $foo['amount'] : 0;
                 $foo['debit'] = $foo['type'] == 'e' ? $foo['amount'] : 0;
                 if (!isset($foo['categories'])) {
                     $foo['categories'] = '';
                 }
                 if (!isset($foo['account_name'])) {
                     $foo['account_name'] = '';
                 }
                 $linked_finances[] = $foo;
             }
             // find any child finances that are also linked to this parent finance.
             foreach (module_finance::get_finances_simple(array('parent_finance_id' => $finance['parent_finance_id'])) as $foo) {
                 if ($foo['finance_id'] != $finance_id) {
                     // copied from get_finances() method
                     $foo['url'] = module_finance::link_open($foo['finance_id'], false);
                     $foo['credit'] = $foo['type'] == 'i' ? $foo['amount'] : 0;
                     $foo['debit'] = $foo['type'] == 'e' ? $foo['amount'] : 0;
                     if (!isset($foo['categories'])) {
                         $foo['categories'] = '';
                     }
                     if (!isset($foo['account_name'])) {
                         $foo['account_name'] = '';
                     }
                     $linked_finances[] = $foo;
                 }
             }
             // find any child invoice payments that are also linked to this parent finance
             foreach (get_multiple('invoice_payment', array('parent_finance_id' => $finance['parent_finance_id'])) as $invoice_payments) {
                 if ($invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_NORMAL || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_OVERPAYMENT_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_REFUND) {
                     $invoice_payments = module_invoice::get_invoice_payment($invoice_payments['invoice_payment_id']);
                     // copied from get_finances() method
                     $invoice_payments = self::_format_invoice_payment($invoice_payments, $finance);
                     $linked_invoice_payments[$invoice_payments['invoice_payment_id']] = $invoice_payments;
                 }
             }
         }
         if ((int) $finance_id > 0) {
             // find any child finances that are linked to this finance.
             foreach (module_finance::get_finances_simple(array('parent_finance_id' => $finance_id)) as $foo) {
                 if ($foo['finance_id'] != $finance_id) {
                     // copied from get_finances() method
                     $foo['url'] = module_finance::link_open($foo['finance_id'], false);
                     $foo['credit'] = $foo['type'] == 'i' ? $foo['amount'] : 0;
                     $foo['debit'] = $foo['type'] == 'e' ? $foo['amount'] : 0;
                     if (!isset($foo['categories'])) {
                         $foo['categories'] = '';
                     }
                     if (!isset($foo['account_name'])) {
                         $foo['account_name'] = '';
                     }
                     $linked_finances[] = $foo;
                 }
             }
             // find any child invoice payments that are also linked to this parent finance
             foreach (get_multiple('invoice_payment', array('parent_finance_id' => $finance_id)) as $invoice_payments) {
                 if ($invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_NORMAL || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_OVERPAYMENT_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_REFUND) {
                     // copied from get_finances() method
                     $invoice_payments = module_invoice::get_invoice_payment($invoice_payments['invoice_payment_id']);
                     $invoice_payments = self::_format_invoice_payment($invoice_payments, $finance);
                     // hack to pull tax information from a linked invoice payment to replace current items tax if none is defined
                     if (!$finance['taxes'] && count($invoice_payments['taxes']) && $invoice_payments['amount'] == $finance['amount']) {
                         $finance['taxes'] = $invoice_payments['taxes'];
                         $finance['taxable_amount'] = $invoice_payments['taxable_amount'];
                         $finance['sub_amount'] = $invoice_payments['sub_amount'];
                     }
                     $linked_invoice_payments[$invoice_payments['invoice_payment_id']] = $invoice_payments;
                 }
             }
             if (isset($finance['invoice_payment_id']) && $finance['invoice_payment_id'] > 0) {
                 $invoice_payments = module_invoice::get_invoice_payment($finance['invoice_payment_id']);
                 if ($invoice_payments && ($invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_NORMAL || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_OVERPAYMENT_CREDIT || $invoice_payments['payment_type'] == _INVOICE_PAYMENT_TYPE_REFUND)) {
                     $invoice_payments = self::_format_invoice_payment($invoice_payments, $finance);
                     // hack to pull tax information from a linked invoice payment to replace current items tax if none is defined
                     if (!$finance['taxes'] && count($invoice_payments['taxes']) && $invoice_payments['amount'] == $finance['amount']) {
                         $finance['taxes'] = $invoice_payments['taxes'];
                         $finance['taxable_amount'] = $invoice_payments['taxable_amount'];
                         $finance['sub_amount'] = $invoice_payments['sub_amount'];
                     }
                     $linked_invoice_payments[$invoice_payments['invoice_payment_id']] = $invoice_payments;
                 } else {
                     if (!$invoice_payments) {
                         // todo: this shou;ldnt happen, fix!
                     }
                 }
             }
         }
         $finance['linked_invoice_payments'] = $linked_invoice_payments;
         $finance['linked_finances'] = $linked_finances;
     }
     if ($finance_id <= 0) {
         $finance = array('finance_id' => 0, 'parent_finance_id' => 0, 'transaction_date' => print_date(time()), 'name' => '', 'description' => '', 'type' => 'e', 'sub_amount' => 0, 'taxable_amount' => 0, 'tax_mode' => module_config::c('finance_default_tax_mode', 0), 'taxes' => array(), 'amount' => 0, 'currency_id' => module_config::c('default_currency_id', 1), 'category_ids' => array(), 'customer_id' => 0, 'job_id' => 0, 'invoice_id' => 0, 'job_staff_expense' => 0, 'user_id' => 0);
         if (isset($_REQUEST['from_job_id'])) {
             $job_data = module_job::get_job((int) $_REQUEST['from_job_id']);
             $finance['job_id'] = $job_data['job_id'];
             if ($job_data['customer_id']) {
                 $finance['customer_id'] = $job_data['customer_id'];
             }
             if (isset($_REQUEST['job_staff_expense']) && (int) $_REQUEST['job_staff_expense'] > 0) {
                 // we have a job staff expense, load up the job tasks for this staff member and find out the cost.
                 if (isset($job_data['staff_total_grouped'][$_REQUEST['job_staff_expense']])) {
                     $staff_member = module_user::get_user($_REQUEST['job_staff_expense']);
                     if ($staff_member && $staff_member['user_id'] == $_REQUEST['job_staff_expense']) {
                         // valid job found, load in the defaults.
                         $finance['name'] = $job_data['name'];
                         $finance['description'] = _l('Job Expense For Staff Member: %s', $staff_member['name'] . ' ' . $staff_member['last_name']);
                         $finance['type'] = 'e';
                         $finance['amount'] = $job_data['staff_total_grouped'][$_REQUEST['job_staff_expense']];
                         $finance['taxes'] = array();
                         $finance['job_staff_expense_id'] = $job_data['job_id'];
                         $finance['job_id'] = $job_data['job_id'];
                         $finance['currency_id'] = $job_data['currency_id'];
                         $finance['transaction_date'] = print_date($job_data['date_completed']);
                         $finance['user_id'] = $staff_member['user_id'];
                         $finance['job_staff_expense'] = $staff_member['user_id'];
                     }
                 }
             }
         }
         if (!$full) {
             return $finance;
         }
         if ($invoice_payment_id && $invoice_payment_id > 0) {
             $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
             if ($invoice_payment_data && $invoice_payment_data['invoice_id']) {
                 $finance = self::_format_invoice_payment($invoice_payment_data, $finance);
                 $finance['invoice_id'] = $invoice_payment_data['invoice_id'];
                 $finance['currency_id'] = $invoice_payment_data['currency_id'];
             }
         }
     }
     if (isset($finance['invoice_id']) && $finance['invoice_id']) {
         $new_finance = hook_handle_callback('finance_invoice_listing', $finance['invoice_id'], $finance);
         if (is_array($new_finance) && count($new_finance)) {
             foreach ($new_finance as $n) {
                 $finance = array_merge($finance, $n);
             }
         }
     }
     $finance['taxes'] = self::sanatise_taxes(isset($finance['taxes']) ? $finance['taxes'] : array(), isset($finance['taxable_amount']) ? $finance['taxable_amount'] : 0);
     return $finance;
 }
Ejemplo n.º 18
0
                    echo print_date($job['date_start']);
                    //is there a renewal date?
                    if (isset($job['date_renew']) && $job['date_renew'] && $job['date_renew'] != '0000-00-00') {
                        _e(' to %s', print_date(strtotime("-1 day", strtotime($job['date_renew']))));
                    }
                    ?>

								    </td>
								    <td>
									    <?php 
                    if ($job['total_percent_complete'] != 1 && strtotime($job['date_due']) < time()) {
                        echo '<span class="error_text">';
                        echo print_date($job['date_due']);
                        echo '</span>';
                    } else {
                        echo print_date($job['date_due']);
                    }
                    ?>

								    </td>
								    <td>
                            <span class="<?php 
                    echo $job['total_percent_complete'] >= 1 ? 'success_text' : '';
                    ?>
">
                                <?php 
                    echo $job['total_percent_complete'] * 100 . '%';
                    ?>

                            </span>
								    </td>
Ejemplo n.º 19
0
    <tbody>
    <?php 
$c = 0;
foreach ($facebook_accounts as $facebook_account) {
    ?>
        <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
            <td class="row_action">
                <?php 
    echo module_social_facebook::link_open($facebook_account['social_facebook_id'], true, $facebook_account);
    ?>
            </td>
            <td>
                <?php 
    echo print_date($facebook_account['last_checked'], true);
    ?>
            </td>
            <!--<td>
                <?php 
    /*
     */
    ?>
            </td>-->
        </tr>
    <?php 
}
?>
  </tbody>
</table>
Ejemplo n.º 20
0
 /**
  * @param $invoice_id
  * @param $invoice_data
  * @return array
  *
  * todo: make this method call the other 'get_replace_fields' available in website/job/etc..
  */
 public static function get_replace_fields($invoice_id, $invoice_data = false)
 {
     if (!$invoice_data) {
         $invoice_data = self::get_invoice($invoice_id);
     }
     $customer_data = array();
     if ($invoice_data['customer_id']) {
         $customer_data = module_customer::get_replace_fields($invoice_data['customer_id'], $invoice_data['user_id']);
     }
     if (!is_array($customer_data)) {
         $customer_data = array();
     }
     $data = array_merge($customer_data, $invoice_data);
     // so we get total_amount_due and stuff.
     $data = array_merge($data, array('invoice_number' => htmlspecialchars($invoice_data['name']), 'project_type' => _l(module_config::c('project_name_single', 'Website')), 'print_link' => self::link_public_print($invoice_id), 'title' => module_config::s('admin_system_name'), 'invoice_paid' => $invoice_data['total_amount_due'] <= 0 ? '<p> <font style="font-size: 1.6em;"><strong>' . _l('INVOICE PAID') . '</strong></font> </p>' : '', 'is_invoice_paid' => $invoice_data['total_amount_due'] <= 0 ? 1 : '', 'date_create' => print_date($invoice_data['date_create']), 'due_date' => print_date($invoice_data['date_due'])));
     $data['total_amount'] = dollar($invoice_data['total_amount'], true, $invoice_data['currency_id']);
     $data['total_amount_due'] = dollar($invoice_data['total_amount_due'], true, $invoice_data['currency_id']);
     $data['total_amount_paid'] = dollar($invoice_data['total_amount_paid'], true, $invoice_data['currency_id']);
     $data['date_paid'] = print_date($invoice_data['date_paid']);
     $data['date_due'] = print_date($invoice_data['date_due']);
     $data['date_sent'] = print_date($invoice_data['date_sent']);
     $data['invoice_number'] = $invoice_data['name'];
     $data['invoice_url'] = module_invoice::link_public($invoice_id);
     $data['invoice_date_range'] = '';
     if ($invoice_data['date_renew'] != '0000-00-00') {
         $data['invoice_date_range'] = _l('%s to %s', print_date($invoice_data['date_create']), print_date(strtotime("-1 day", strtotime($invoice_data['date_renew']))));
     }
     if (isset($invoice_data['credit_note_id']) && $invoice_data['credit_note_id']) {
         $credit_invoice = module_invoice::get_invoice($invoice_data['credit_note_id'], true);
         $data['credit_invoice_number'] = htmlspecialchars($credit_invoice['name']);
     }
     $data['invoice_notes'] = '';
     // grab any public notes
     if (class_exists('module_note', false) && module_note::is_plugin_enabled()) {
         $notes = module_note::get_notes(array('public' => 1, 'owner_table' => 'invoice', 'owner_id' => $invoice_id));
         if (count($notes) > 1) {
             $data['invoice_notes'] .= '<ul>';
             foreach ($notes as $note) {
                 if ($note['public']) {
                     $data['invoice_notes'] .= '<li>';
                     $data['invoice_notes'] .= htmlspecialchars($note['note']);
                     $data['invoice_notes'] .= '</li>';
                 }
             }
             $data['invoice_notes'] .= '</ul>';
         } else {
             $note = array_shift($notes);
             $data['invoice_notes'] .= htmlspecialchars($note['note']);
         }
     }
     $job_names = $website_url = $project_names = $project_names_and_url = array();
     foreach ($invoice_data['job_ids'] as $job_id) {
         $job_data = module_job::get_job($job_id);
         if ($job_data && $job_data['job_id'] == $job_id) {
             $job_names[$job_data['job_id']] = $job_data['name'];
             if (module_config::c('job_invoice_show_date_range', 1)) {
                 // check if this job is a renewable job.
                 if ($job_data['date_renew'] != '0000-00-00') {
                     $data['invoice_date_range'] = _l('%s to %s', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew']))));
                 }
             }
             $fields = module_job::get_replace_fields($job_id, $job_data);
             foreach ($fields as $key => $val) {
                 if (!isset($data[$key]) || !$data[$key] && $val) {
                     $data[$key] = $val;
                 }
             }
             if ($job_data['website_id']) {
                 $website_data = module_website::get_website($job_data['website_id']);
                 if ($website_data && $website_data['website_id'] == $job_data['website_id']) {
                     if (isset($website_data['url']) && $website_data['url']) {
                         $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                         $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
                     } else {
                         $website_data['name_url'] = $website_data['name'];
                     }
                     $project_names[$website_data['website_id']] = $website_data['name'];
                     $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
                     $fields = module_website::get_replace_fields($website_data['website_id'], $website_data);
                     foreach ($fields as $key => $val) {
                         if (!isset($data[$key]) || !$data[$key] && $val) {
                             $data[$key] = $val;
                         }
                     }
                 }
             }
         }
     }
     if (isset($invoice_data['website_id']) && $invoice_data['website_id']) {
         $website_data = module_website::get_website($invoice_data['website_id']);
         if ($website_data && $website_data['website_id'] == $invoice_data['website_id']) {
             if (isset($website_data['url']) && $website_data['url']) {
                 $website_url[$website_data['website_id']] = module_website::urlify($website_data['url']);
                 $website_data['name_url'] = $website_data['name'] . ' (' . module_website::urlify($website_data['url']) . ')';
             } else {
                 $website_data['name_url'] = $website_data['name'];
             }
             $project_names[$website_data['website_id']] = $website_data['name'];
             $project_names_and_url[$website_data['website_id']] = $website_data['name_url'];
             $fields = module_website::get_replace_fields($website_data['website_id'], $website_data);
             foreach ($fields as $key => $val) {
                 if (!isset($data[$key]) || !$data[$key] && $val) {
                     $data[$key] = $val;
                 }
             }
         }
     }
     $data['website_name'] = $data['project_name'] = forum_text(count($project_names) ? implode(', ', $project_names) : '');
     $data['website_name_url'] = forum_text(count($project_names_and_url) ? implode(', ', $project_names_and_url) : '');
     $data['website_url'] = forum_text(count($website_url) ? implode(', ', $website_url) : '');
     $data['job_name'] = forum_text($job_names ? implode(', ', $job_names) : '');
     if (class_exists('module_group', false)) {
         // get the job groups
         $wg = array();
         $g = array();
         foreach ($invoice_data['job_ids'] as $group_job_id) {
             $group_job_id = (int) trim($group_job_id);
             if ($group_job_id > 0) {
                 $job_data = module_job::get_job($group_job_id);
                 foreach (module_group::get_groups_search(array('owner_table' => 'job', 'owner_id' => $group_job_id)) as $group) {
                     $g[$group['group_id']] = $group['name'];
                 }
                 // get the website groups
                 if ($job_data['website_id']) {
                     foreach (module_group::get_groups_search(array('owner_table' => 'website', 'owner_id' => $job_data['website_id'])) as $group) {
                         $wg[$group['group_id']] = $group['name'];
                     }
                 }
             }
         }
         if (isset($invoice_data['website_id']) && $invoice_data['website_id']) {
             foreach (module_group::get_groups_search(array('owner_table' => 'website', 'owner_id' => $invoice_data['website_id'])) as $group) {
                 $wg[$group['group_id']] = $group['name'];
             }
         }
         $data['job_group'] = implode(', ', $g);
         $data['website_group'] = implode(', ', $wg);
     }
     // addition. find all extra keys for this invoice and add them in.
     // we also have to find any EMPTY extra fields, and add those in as well.
     if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
         $all_extra_fields = module_extra::get_defaults('invoice');
         foreach ($all_extra_fields as $e) {
             $data[$e['key']] = _l('N/A');
         }
         // and find the ones with values:
         $extras = module_extra::get_extras(array('owner_table' => 'invoice', 'owner_id' => $invoice_id));
         foreach ($extras as $e) {
             $data[$e['extra_key']] = $e['extra'];
         }
     }
     $new_data = hook_handle_callback('invoice_replace_fields', $invoice_id, $data);
     if (is_array($new_data)) {
         foreach ($new_data as $new_d) {
             $data = array_merge($data, $new_d);
         }
     }
     return $data;
 }
Ejemplo n.º 21
0
     $replace['title'] = '<h3>' . _l('Payment History:') . '</h3>';
 } else {
     $replace['title'] = '<strong>' . _l('Payment History:') . '</strong><br/>';
 }
 if (preg_match('#<tr[^>]+data-item-row="true">.*</tr>#imsU', $t->content, $matches)) {
     $item_row_html = $matches[0];
     $t->content = str_replace($item_row_html, '{ITEM_ROW_CONTENT}', $t->content);
 } else {
     set_error('Please ensure a TR with data-item-row="true" is in the invoice_payment_history template');
     $item_row_html = '';
 }
 $all_item_row_html = '';
 $item_count = 0;
 // changed from 1
 foreach ($payment_historyies as $invoice_payment_id => $invoice_payment_data) {
     $row_replace = array('ITEM_ODD_OR_EVEN' => $item_count++ % 2 ? 'odd' : 'even', 'ITEM_PAYMENT_DATE' => !trim($invoice_payment_data['date_paid']) || $invoice_payment_data['date_paid'] == '0000-00-00' ? _l('Pending on %s', print_date($invoice_payment_data['date_created'])) : print_date($invoice_payment_data['date_paid']), 'ITEM_PAYMENT_METHOD' => htmlspecialchars($invoice_payment_data['method']), 'ITEM_PAYMENT_DETAILS' => '', 'ITEM_PAYMENT_AMOUNT' => dollar($invoice_payment_data['amount'], true, $invoice_payment_data['currency_id']), 'ITEM_PAYMENT_RECEIPT_URL' => module_invoice::link_receipt($invoice_payment_data['invoice_payment_id']));
     if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) {
         $details = unserialize($invoice_payment_data['data']);
         if (isset($details['custom_notes'])) {
             $row_replace['ITEM_PAYMENT_DETAILS'] = htmlspecialchars($details['custom_notes']);
         }
     }
     $this_item_row_html = $item_row_html;
     $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html);
     foreach ($row_replace as $key => $val) {
         $this_item_row_html = str_replace('{' . strtoupper($key) . '}', $val, $this_item_row_html);
     }
     $all_item_row_html .= $this_item_row_html;
 }
 $replace['ITEM_ROW_CONTENT'] = $all_item_row_html;
 $t->assign_values($replace);
Ejemplo n.º 22
0
 public static function post_author_date($uid, $author, $date)
 {
     $u = page::link("user/" . $uid, $author);
     $k = print_date($date);
     return t("posted by %user on %date", array("%user" => $u, "%date" => $k));
 }
Ejemplo n.º 23
0
">
                                    <td>
                                        <?php 
        if (module_invoice::can_i('edit', 'Invoice Payments') && module_security::is_page_editable()) {
            ?>

                                            <?php 
            echo !trim($invoice_payment_data['date_paid']) || $invoice_payment_data['date_paid'] == '0000-00-00' ? _l('Pending on %s', print_date($invoice_payment_data['date_created'])) : print_date($invoice_payment_data['date_paid']);
            ?>

                                        <?php 
        } else {
            ?>

                                            <?php 
            echo print_date($invoice_payment_data['date_paid']);
            ?>

                                        <?php 
        }
        if ($invoice_payment_data['date_paid'] == '0000-00-00') {
            ?>
 (<a href="<?php 
            echo htmlspecialchars($_SERVER['REQUEST_URI']) . '&_process=make_payment&invoice_payment_id=' . $invoice_payment_id;
            ?>
"><?php 
            _e('complete');
            ?>
</a>) <?php 
        }
        ?>
Ejemplo n.º 24
0
        } else {
            echo print_date($task_data['date_due']);
        }
    }
    ?>
        </td>
        <?php 
}
?>
        <?php 
if (module_config::c('job_show_done_date', 1) && !isset($options['from_quote'])) {
    ?>
        <td valign="top" class="task_drag_handle">
            <?php 
    if (isset($task_data['date_done']) && $task_data['date_done'] && $task_data['date_done'] != '0000-00-00') {
        echo print_date($task_data['date_done']);
    }
    ?>
        </td>
        <?php 
}
?>
        <?php 
if (module_config::c('job_allow_staff_assignment', 1)) {
    ?>
            <td valign="top" class="task_drag_handle">
                <?php 
    echo isset($staff_member_rel[$task_data['user_id']]) ? $staff_member_rel[$task_data['user_id']] : '';
    ?>
            </td>
        <?php 
Ejemplo n.º 25
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_statistic::can_i('view', 'Staff Report')) {
    redirect_browser(_BASE_HREF);
}
$page_title = _l('Staff Report');
$search = isset($_REQUEST['search']) ? $_REQUEST['search'] : array('date_from' => print_date(date('Y-m-d', strtotime('-1 month'))), 'date_to' => print_date(date('Y-m-d')));
$staff_reports = module_statistic::get_statistics_staff($search);
if (class_exists('module_table_sort', false)) {
    module_table_sort::enable_pagination_hook(array('table_id' => 'statistic_list', 'sortable' => array('sort_date' => array('field' => 'transaction_date', 'current' => 2), 'sort_name' => array('field' => 'name'), 'sort_credit' => array('field' => 'credit'), 'sort_debit' => array('field' => 'debit'))));
}
/*

// hack to add a "export" option to the pagination results.
if(class_exists('module_import_export',false) && module_statistic::can_i('view','Export Statistic')){
    module_import_export::enable_pagination_hook(
    // what fields do we pass to the import_export module from this customers?
        array(
            'name' => 'Statistic Export',
            'parent_form' => 'statistic_form',
            'fields'=>array(
                'Date' => 'transaction_date',
Ejemplo n.º 26
0
<form action="" method="post">

<?php 
$search_bar = array('elements' => array('name' => array('title' => _l('Quote Title:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : '', 'size' => 30)), 'type' => array('title' => _l('Type:'), 'field' => array('type' => 'select', 'name' => 'search[type]', 'value' => isset($search['type']) ? $search['type'] : '', 'options' => module_quote::get_types())), 'status' => array('title' => _l('Status:'), 'field' => array('type' => 'select', 'name' => 'search[status]', 'value' => isset($search['status']) ? $search['status'] : '', 'options' => module_quote::get_statuses())), 'accepted' => array('title' => _l('Accepted:'), 'field' => array('type' => 'select', 'name' => 'search[accepted]', 'value' => isset($search['accepted']) ? $search['accepted'] : '', 'options' => array(1 => _l('Both Accepted and Un-Accepted Quotes'), 2 => _l('Only Accepted Quotes'), 3 => _l('Only Un-Accepted Quotes'))))));
echo module_form::search_bar($search_bar);
/** START TABLE LAYOUT **/
$table_manager = module_theme::new_table_manager();
$columns = array();
$columns['quote_title'] = array('title' => 'Quote Title', 'callback' => function ($quote) {
    echo module_quote::link_open($quote['quote_id'], true, $quote);
}, 'cell_class' => 'row_action');
$columns['quote_start_date'] = array('title' => 'Create Date', 'callback' => function ($quote) {
    echo print_date($quote['date_create']);
});
$columns['quote_completed_date'] = array('title' => 'Accepted Date', 'callback' => function ($quote) {
    echo print_date($quote['date_approved']);
});
if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
    $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) {
Ejemplo n.º 27
0
        </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>
        <td>
            <textarea name="data" rows="7" cols="60" id="raw_value"><?php 
echo $encrypt['data'];
?>
</textarea>
Ejemplo n.º 28
0
 public function handle_hook($hook, $mod = false)
 {
     switch ($hook) {
         case "home_alerts":
             $alerts = array();
             // check if the cron job hasn'e run in a certian amount of time.
             if (module_config::can_i('view', 'Upgrade System')) {
                 $last_update = module_config::c('last_update', time());
                 // prompt them to do an update every 7 days
                 if ($last_update < time() - 604800) {
                     $alert_res = process_alert(date('Y-m-d'), _l('Please check for Software Updates'));
                     if ($alert_res) {
                         $alert_res['link'] = $this->link_generate(false, array('page' => 'config_upgrade'));
                         $alert_res['name'] = _l('Please go to Settings > Upgrade and check for latest Software Updates.');
                         $alerts[] = $alert_res;
                     }
                 }
             }
             if (module_config::can_i('view', 'Settings')) {
                 $last_cron_run = module_config::c('cron_last_run', 0);
                 if ($last_cron_run < time() - 86400) {
                     $alert_res = process_alert(date('Y-m-d'), _l('CRON Job Not Setup'));
                     if ($alert_res) {
                         $alert_res['link'] = $this->link_generate(false, array('page' => 'config_cron'));
                         $alert_res['name'] = _l('Has not run since: %s', $last_cron_run > 0 ? print_date($last_cron_run) : _l('Never'));
                         $alerts[] = $alert_res;
                     }
                 }
                 // check our memory limit.
                 if (class_exists('module_pdf', false)) {
                     $desired_limit_r = module_config::c('php_memory_limit', '64M');
                     $desired_limit = trim($desired_limit_r);
                     $last = strtolower($desired_limit[strlen($desired_limit) - 1]);
                     switch ($last) {
                         // The 'G' modifier is available since PHP 5.1.0
                         case 'g':
                             $desired_limit *= 1024;
                         case 'm':
                             $desired_limit *= 1024;
                         case 'k':
                             $desired_limit *= 1024;
                     }
                     $memory_limit = ini_get('memory_limit');
                     $val = trim($memory_limit);
                     $last = strtolower($val[strlen($val) - 1]);
                     switch ($last) {
                         // The 'G' modifier is available since PHP 5.1.0
                         case 'g':
                             $val *= 1024;
                         case 'm':
                             $val *= 1024;
                         case 'k':
                             $val *= 1024;
                     }
                     if (!$memory_limit || $val < $desired_limit || $val < 67108864) {
                         $alert_res = process_alert(date('Y-m-d'), _l('PDF Memory Limit Low'));
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_generate(false, array('page' => 'config_settings'));
                             $alert_res['name'] = _l('php_memory_limit should be 64M or above: %s', $memory_limit);
                             $alerts[] = $alert_res;
                         }
                     }
                 }
                 /*$desired_limit_r = module_config::c('php_post_max_size','10M');
                                     $desired_limit = trim($desired_limit_r);
                                     $last = strtolower($desired_limit[strlen($desired_limit)-1]);
                                     switch($last) {
                                         // The 'G' modifier is available since PHP 5.1.0
                                         case 'g':
                                             $desired_limit *= 1024;
                                         case 'm':
                                             $desired_limit *= 1024;
                                         case 'k':
                                             $desired_limit *= 1024;
                                     }
                 
                                     $memory_limit = ini_get('post_max_size');
                                     $val = trim($memory_limit);
                                     $last = strtolower($val[strlen($val)-1]);
                                     switch($last) {
                                         // The 'G' modifier is available since PHP 5.1.0
                                         case 'g':
                                             $val *= 1024;
                                         case 'm':
                                             $val *= 1024;
                                         case 'k':
                                             $val *= 1024;
                                     }
                 
                 
                                     if(!strlen($memory_limit) || $val < $desired_limit || $val < 10485760){
                                         $alert_res = process_alert(date('Y-m-d'), _l('CSV Import Limit Too Low'));
                                         if($alert_res){
                                             $alert_res['link'] = $this->link_generate(false,array('page'=>'config_settings'));
                                             $alert_res['name'] = _l('php_post_max_size should be %s or above: %s',$desired_limit_r. ' ('.$desired_limit.')',$memory_limit. " ($val)");
                                             $alerts[] = $alert_res;
                                         }
                                     }*/
             }
             return $alerts;
             break;
     }
 }
Ejemplo n.º 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();
    }
Ejemplo n.º 30
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'view':
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        if ($file_data && $file_data['file_id'] == $file_id) {
                            if (isset($_POST['save_file_comments'])) {
                                if (isset($_POST['file_approve']) && isset($_POST['file_approve_go']) && isset($_POST['file_approve_name']) && strlen($_POST['file_approve_name']) > 0) {
                                    update_insert('file_id', $file_id, 'file', array('approved_time' => time(), 'approved_by' => $_POST['file_approve_name']));
                                    // send email, same 'updated' email as before.
                                    $this->send_file_changed_notice($file_id, false, true);
                                    //redirect_browser($this->link_public($file_id));
                                    $_REQUEST['new_comment_text'] = _l('File was approved at %s by %s', print_date(time(), true), htmlspecialchars($_POST['file_approve_name']));
                                }
                                if (isset($_POST['pointers'])) {
                                    update_insert('file_id', $file_id, 'file', array('pointers' => $_POST['pointers']));
                                }
                                $this->save_file_comments($file_id);
                                redirect_browser($this->link_public($file_id));
                            }
                            module_template::init_template('file_approval_view', '<h2>File Details</h2>
    File Name: <strong>{FILE_NAME}</strong> <br/>
    Download: <strong><a href="{FILE_DOWNLOAD_URL}">Click Here</a></strong> <br/>
    Status: <strong>{STATUS}</strong> <br/>
    Customer: <strong>{CUSTOMER_NAME}</strong> <br/>
    {if:JOB_NAME}Job: <strong>{JOB_NAME}</strong> <br/>{endif:JOB_NAME}
    {if:FILE_APPROVAL_PENDING}
    <h2>File Approval Pending</h2>
    <p>If you would like to approve this file please complete the form below:</p>
    <p>Your Name: <input type="text" name="file_approve_name"> </p>
    <p><input type="checkbox" name="file_approve_go" value="yes"> Yes, I approve this file. </p>
    <p><input type="submit" name="file_approve" value="Approve File" class="submit_button save_button"></p>
    {endif:FILE_APPROVAL_PENDING}
    {if:FILE_APPROVED}
    <h2>File Has Been Approved</h2>
    <p>Thank you, the file was approved by <strong>{APPROVED_BY}</strong> on <strong>{APPROVED_TIME}</strong>.</p>
    {endif:FILE_APPROVED}
    <h2>File Comments</h2>
    <p>Please feel free to add comments to this file using the form below.</p>
    {FILE_COMMENTS}
    {if:FILE_PREVIEW}
    <h2>File Preview</h2>
    <div style="overflow:scroll;">{FILE_PREVIEW}</div>
    {endif:FILE_PREVIEW}
    ', 'Used when displaying the file to a customer for approval.', 'code');
                            $template = module_template::get_template_by_key('file_approval_view');
                            // generate the html for the task output
                            $job_data = $file_data['job_id'] ? module_job::get_replace_fields($file_data['job_id']) : array();
                            if (class_exists('module_quote', false)) {
                                $quote_data = $file_data['quote_id'] ? module_quote::get_replace_fields($file_data['quote_id']) : array();
                            }
                            $customer_data = $file_data['customer_id'] ? module_customer::get_replace_fields($file_data['customer_id']) : array();
                            $file_data['file_preview'] = module_file::generate_preview($file_id, $file_data['file_name'], $file_data);
                            $file_data['FILE_DOWNLOAD_URL'] = module_file::link_public_view($file_id);
                            if (isset($file_data['approved_time'])) {
                                switch ($file_data['approved_time']) {
                                    case -1:
                                        $file_data['FILE_APPROVAL_PENDING'] = 1;
                                        break;
                                    case 0:
                                        break;
                                    default:
                                        $file_data['FILE_APPROVED'] = 1;
                                        $file_data['APPROVED_TIME'] = print_date($file_data['approved_time'], true);
                                }
                            }
                            if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) {
                                $all_extra_fields = module_extra::get_defaults('file');
                                foreach ($all_extra_fields as $e) {
                                    $file_data[$e['key']] = _l('N/A');
                                }
                                // and find the ones with values:
                                $extras = module_extra::get_extras(array('owner_table' => 'file', 'owner_id' => $file_id));
                                foreach ($extras as $e) {
                                    $file_data[$e['extra_key']] = $e['extra'];
                                }
                            }
                            ob_start();
                            ?>

                            <div id="file_notes">
                            <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                                <textarea name="new_comment_text" style="width:100%;" class="no_permissions"></textarea>
                                <div style="text-align: right;">
                                <input type="submit" name="butt_save_note" id="butt_save_note" value="<?php 
                            echo _l('Add Comment');
                            ?>
" class="submit_button no_permissions">
                                    </div>
                            </div>
                            <?php 
                            foreach (module_file::get_file_comments($file_id) as $item) {
                                $note_text = forum_text($item['comment']);
                                if (preg_match_all('/#(\\d+)/', $note_text, $matches)) {
                                    //
                                    foreach ($matches[1] as $digit) {
                                        $note_text = preg_replace('/#' . $digit . '([^\\d]*)/', '<span node_id=' . $digit . ' class="pointer-ids pointer-id-' . $digit . '">#' . $digit . '</span>$1', $note_text);
                                    }
                                }
                                ?>

                                <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;">
                                    <?php 
                                echo $note_text;
                                ?>

                                    <div style="font-size:10px; text-align:right; color:#CCCCCC;">From <?php 
                                echo $item['create_user_id'] ? module_user::link_open($item['create_user_id'], true) : _l('Customer');
                                ?>
 on <?php 
                                echo print_date($item['date_created'], true);
                                ?>

                                    </div>
                                </div>

                                <?php 
                            }
                            ?>

                            </div>
                            <?php 
                            $file_data['file_comments'] = ob_get_clean();
                            $template->assign_values($file_data);
                            $template->assign_values($customer_data);
                            $template->assign_values($job_data);
                            if (class_exists('module_quote', false)) {
                                $quote_data['quote_approved_by'] = $quote_data['approved_by'];
                                $quote_data['quote_date_approved'] = $quote_data['date_approved'];
                                unset($quote_data['approved_by']);
                                unset($quote_data['date_approved']);
                                $template->assign_values($quote_data);
                            }
                            $template->page_title = $file_data['file_name'];
                            $template->content = '<form action="" method="post"><input type="hidden" name="save_file_comments" value="1">' . $template->content . '</form>';
                            echo $template->render('pretty_html');
                        }
                    }
                }
                break;
            case 'download_bucket':
                @ob_end_clean();
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public_download_bucket($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        @ignore_user_abort(true);
                        $search = array();
                        $search['bucket_parent_file_id'] = $file_id;
                        $files = module_file::get_files($search);
                        //Create ZIP
                        $zip = new ZipArchive();
                        $zipName = "bucket-" . $file_id . "-" . md5($file_id . _UCM_SECRET) . ".zip";
                        if ($zip->open(_FILE_UPLOAD_PATH . $zipName, ZIPARCHIVE::CREATE) !== TRUE) {
                            echo 'Failed to create bucket zip file';
                            exit;
                        }
                        foreach ($files as $file) {
                            if (is_file($file['file_path'])) {
                                $zip->addFromString($file['file_name'], file_get_contents($file['file_path']));
                            }
                        }
                        $zip->close();
                        //Set headers
                        header("Pragma: public");
                        header("Expires: 0");
                        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                        header("Cache-Control: public");
                        header("Content-Description: File Transfer");
                        header("Content-type: application/octet-stream");
                        //header("Content-Disposition: attachment; filename='" . $zipName . "'");
                        header("Content-Disposition: attachment; filename=\"" . preg_replace("#[^a-zA-Z0-9]+#", "-", $file_data['file_name']) . ".zip\";");
                        header("Content-Transfer-Encoding: binary");
                        header("Content-Length: " . filesize(_FILE_UPLOAD_PATH . $zipName));
                        @clearstatcache();
                        //Make sure the file size isn't cached
                        $size = @readfile(_FILE_UPLOAD_PATH . $zipName);
                        if (!$size) {
                            echo file_get_contents(_FILE_UPLOAD_PATH . $zipName);
                        }
                        @unlink(_FILE_UPLOAD_PATH . $zipName);
                    }
                }
                exit;
                break;
            case 'download':
                @ob_end_clean();
                $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($file_id && $hash) {
                    $correct_hash = $this->link_public_view($file_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $file_data = $this->get_file($file_id, false);
                        if (isset($file_data['file_url']) && strlen($file_data['file_url'])) {
                            redirect_browser($file_data['file_url']);
                        } else {
                            if (is_file($file_data['file_path'])) {
                                header("Pragma: public");
                                header("Expires: 0");
                                header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
                                header("Cache-Control: private", false);
                                header("Content-type: " . dtbaker_mime_type($file_data['file_name'], $file_data['file_path']));
                                if (!isset($_REQUEST['embed'])) {
                                    header("Content-Disposition: attachment; filename=\"" . $file_data['file_name'] . "\";");
                                    header("Content-Transfer-Encoding: binary");
                                }
                                header("Content-Length: " . filesize($file_data['file_path']));
                                //readfile($file_data['file_path']);
                                $size = @readfile($file_data['file_path']);
                                if (!$size) {
                                    echo file_get_contents($file_data['file_path']);
                                }
                            } else {
                                echo 'Not found';
                            }
                        }
                    }
                }
                exit;
                break;
        }
    }