Пример #1
0
                        <?php 
    if (module_config::c('ticket_allow_priority', 0)) {
        ?>

                        <tr>
                            <th class="width1">
                                <?php 
        echo _l('Priority Support');
        ?>

                            </th>
                            <td>
                                <?php 
        module_template::init_template('ticket_priority_support', '<em>New!</em> Need a <strong>fast</strong> reply? Priority support will place your ticket at the front of the support queue. <br/>Priority Support Cost: {COST}<br/>{CHECKBOX} <label for="do_priority">Yes, upgrade to <strong>priority support</strong> and move my ticket to position: {TICKET_POSITION}</label>', 'Displayed at the bottom of ticket support signup', 'code', array('cost' => 'Cost as defined by ticket_priority_code advanced setting', 'TICKET_POSITION' => 'displays the string (example) "1st out of 44"'));
        $template = module_template::get_template_by_key('ticket_priority_support');
        $template->assign_values(array('cost' => dollar(module_config::c('ticket_priority_cost', 10), true, module_config::c('ticket_priority_currency', 1)), 'TICKET_POSITION' => _l('%s out of %s', ordinal(module_ticket::ticket_count('priority') + 1), $ticket['total_pending']), 'CHECKBOX' => '<input type="checkbox" name="do_priority" id="do_priority" value="1">'));
        echo $template->replace_content();
        ?>


                            </td>
                        </tr>
                            <?php 
    }
    ?>

                        <?php 
    if (module_config::c('ticket_turn_around_days_show', 1)) {
        ?>
Пример #2
0
                 module_form::generate_form_element($element);
                 echo '<br/>';
                 $element = array('type' => 'checkbox', 'name' => 'renew_email', 'value' => isset($invoice['renew_email']) && $invoice['renew_email'], 'label' => 'Automatically Email', 'help' => 'When this Invoice is renewed it will be automatically emailed to the customer.');
                 module_form::generate_form_element($element);
             }
         }
     }));
 } else {
     $fieldset_data['elements'][] = array('title' => 'Renewal Date', 'fields' => array('(recurring invoices available in <a href="http://codecanyon.net/item/ultimate-client-manager-pro-edition/2621629?ref=dtbaker" target="_blank">UCM Pro Edition</a>)'));
 }
 $fieldset_data['elements'][] = array('title' => 'Cancel Date', 'hidden' => !((int) $invoice_id > 0), 'fields' => array(array('type' => 'date', 'name' => 'date_cancel', 'value' => print_date($invoice['date_cancel']), 'help' => 'If the invoice has been cancelled set the date here. Payment reminders for this invoice will no longer be generated.')));
 $find_other_templates = 'invoice_print';
 $current_template = isset($invoice['invoice_template_print']) && strlen($invoice['invoice_template_print']) ? $invoice['invoice_template_print'] : module_config::c('invoice_template_print_default', 'invoice_print');
 if (function_exists('convert_html2pdf') && isset($find_other_templates) && strlen($find_other_templates) && isset($current_template) && strlen($current_template)) {
     $other_templates = array();
     foreach (module_template::get_templates() as $possible_template) {
         if (strpos($possible_template['template_key'], $find_other_templates) !== false) {
             // found another one!
             $other_templates[$possible_template['template_key']] = $possible_template['template_key'];
             //$possible_template['description'];
         }
     }
     if (count($other_templates) > 1) {
         $fieldset_data['elements'][] = array('title' => 'PDF Template', 'field' => array('type' => 'select', 'options' => $other_templates, 'name' => 'invoice_template_print', 'value' => $current_template, 'help' => 'Choose the default template for PDF printing and PDF emailing. Name your custom templates invoice_print_SOMETHING for them to appear in this listing.'));
     }
 }
 if (class_exists('module_company', false) && module_company::is_enabled() && defined('COMPANY_UNIQUE_CONFIG') && COMPANY_UNIQUE_CONFIG && module_company::can_i('view', 'Company') && $invoice['customer_id'] > 0) {
     $company_list = module_company::get_companys_by_customer($invoice['customer_id']);
     if (count($company_list) > 1) {
         $fieldset_data['elements'][] = array('title' => 'Company', 'fields' => array(array('type' => 'select', 'name' => 'set_manual_company_id', 'options' => $company_list, 'blank' => _l('Default'), 'options_array_id' => 'name', 'value' => isset($invoice['company_id']) ? $invoice['company_id'] : 0)));
     }
Пример #3
0
$invoice_templates['invoice_payment_receipt'] = 1;
$invoice_templates['invoice_print'] = 1;
$invoice_templates['invoice_print_basic'] = 1;
$invoice_templates['invoice_task_list'] = 1;
$invoice_templates['credit_note_pdf'] = 1;
$invoice_templates['invoice_email_due'] = 1;
$invoice_templates['invoice_email_overdue'] = 1;
$invoice_templates['invoice_email_paid'] = 1;
$invoice_templates['credit_note_email'] = 1;
foreach ($templates as $template) {
    if (stripos($template['template_key'], 'invoice')) {
        $invoice_templates[$template['template_key']] = 1;
    }
}
foreach ($invoice_templates as $template_key => $tf) {
    module_template::link_open_popup($template_key);
}
$template_html = ob_get_clean();
$payment_methods_options = array();
$payment_methods = handle_hook('get_payment_methods', $module);
foreach ($payment_methods as $payment_method) {
    if ($payment_method->is_method('online') && $payment_method->is_enabled()) {
        $payment_methods_options[$payment_method->module_name] = $payment_method->get_payment_method_name();
    }
}
$settings = array(array('key' => 'overdue_email_auto', 'default' => '0', 'type' => 'checkbox', 'description' => 'Automatic Overdue Emails', 'help' => 'If this is ticked then by default newly created invoices will be sent automatic overdue notices. This can be disabled/enabled per invoice. See the "Auto Overdue Email" option near "Due Date".'), array('key' => 'invoice_automatic_receipt', 'default' => '1', 'type' => 'checkbox', 'description' => 'Automatic Send Invoice Receipt', 'help' => 'Automatically send the invoice receipt to the customer once the invoice is marked as paid. If this is disabled you will have to go into the invoice and manually send it after payment is received.'), array('key' => 'invoice_template_print_default', 'default' => 'invoice_print', 'type' => 'text', 'description' => 'Default PDF invoice template', 'help' => 'Used for invoice PDF. You can overwrite in the Advanced settings of each invoice.'), array('key' => 'overdue_email_auto_days', 'default' => '3', 'type' => 'text', 'description' => 'Automically send after', 'help' => 'How many days after the invoice is overdue is the automated email sent (set to 0 will send on the date the invoice is due)'), array('key' => 'overdue_email_auto_days_repeat', 'default' => '7', 'type' => 'text', 'description' => 'Automically re-send every', 'help' => 'How many days after the last automatic overdue reminder is the overdue reminder re-sent automatically (set to 0 to disable this option)'), array('key' => 'invoice_automatic_after_time', 'default' => '7', 'type' => 'text', 'description' => 'Hour of day to perform automatic operations', 'help' => 'Enter the hour of day (eg: 7 for 7am, 14 for 2pm) to perform automatic actions - such as renewing invoices, subscriptions, overdue notices, etc...'), array('key' => 'invoice_auto_renew_only_paid_invoices', 'default' => '1', 'type' => 'checkbox', 'description' => 'Only renew paid invoices', 'help' => 'If an invoice (or past subscription invoice) has not been paid then do not renew the next one until original payment has been received.'), array('key' => 'invoice_default_payment_method', 'default' => 'paymethod_paypal', 'type' => 'select', 'options' => $payment_methods_options, 'description' => 'Default Payment Method'), array('key' => 'invoice_due_days', 'default' => '30', 'type' => 'text', 'description' => 'Invoice Due Days', 'help' => 'The number of days used to calculate the "Due Date" on new invoices. Due Date can be overridden per invoice.'), array('key' => 'invoice_name_match_job', 'default' => '0', 'type' => 'checkbox', 'description' => 'Match Invoice with Job Name', 'help' => 'If an invoice is created from a Job, set the Invoice name the same as the job name'), array('key' => 'invoice_incrementing', 'default' => '0', 'type' => 'checkbox', 'description' => 'Incrementing Invoice Numbers', 'help' => 'If this is enabled the system will pick a new invoice number each time. Choose what number to start from below.'), array('key' => 'invoice_incrementing_next', 'default' => '1', 'type' => 'text', 'description' => 'Incrementing Invoice Number', 'help' => 'What will be the next invoice number'), array('key' => 'invoice_task_list_show_date', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Dates on Invoice Items'), array('key' => 'invoice_task_numbers', 'default' => '1', 'type' => 'checkbox', 'description' => 'Show Task Numbers on Invoice Items'), array('key' => 'invoice_allow_payment_amount_adjustment', 'default' => '1', 'type' => 'checkbox', 'description' => 'Allow User To Enter Payment Amount', 'help' => 'If this is enabled the user can change the payment amount on invoices. For example, they might want to pay $50 of a $100 invoice with PayPal, and $50 with cash.'), array('type' => 'html', 'description' => 'Templates', 'html' => $template_html));
module_config::print_settings_form(array('heading' => array('title' => 'Invoice Settings', 'type' => 'h2', 'main' => true), 'settings' => $settings));
// find any blank invoices.
$sql = "SELECT * FROM `" . _DB_PREFIX . "invoice` WHERE customer_id IS NULL AND `name` = '' AND `status` = '' AND `date_create` = '0000-00-00' AND `date_sent` = '0000-00-00' AND `date_paid` = '0000-00-00' AND `date_due` = '0000-00-00' AND c_total_amount = 0 ";
$invoices = qa($sql);
$blank_invoices = array();
                <strong><?php 
            echo $payment_methods_of['name'];
            ?>
</strong><br/>
                <?php 
            echo $payment_methods_of['description'];
            ?>
            </li>
            <?php 
        }
        ?>
        </ul>
        <?php 
    }
    $payment_methods_offline_html = ob_get_clean();
    $template_invoice_payment_methods = module_template::get_template_by_key('invoice_payment_methods');
    $template_invoice_payment_methods->assign_values(array('PAYMENT_METHODS_ONLINE' => $payment_methods_online_html, 'PAYMENT_METHODS_OFFLINE' => $payment_methods_offline_html));
    $template_invoice_payment_methods->assign_values(module_invoice::get_replace_fields($invoice_id, $invoice_data));
    echo $template_invoice_payment_methods->replace_content();
} else {
    ?>

    <p align="center">
    <?php 
    $template_print = module_template::get_template_by_key('invoice_payment_in_full');
    echo $template_print->content;
    ?>
	</p>
    
<?php 
}
Пример #5
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;
        }
    }
Пример #6
0
$widget_columns[1] = array(1 => array());
$widget_columns[2] = array(1 => array(), 2 => array());
$widget_columns[3] = array(1 => array(), 2 => array(), 3 => array());
// then display the welcome message:
module_template::init_template('welcome_message', '<p>
   Hi {USER_NAME}, and Welcome to {SYSTEM_NAME}
</p>', 'Welcome message on Dashboard', array('USER_NAME' => 'Current user name', 'SYSTEM_NAME' => 'System name from settings area'));
// check if there is a template for this user role.
$my_account = module_user::get_user(module_security::get_loggedin_id());
$security_role = current($my_account['roles']);
$template = false;
if ($security_role && isset($security_role['security_role_id'])) {
    $template = module_template::get_template_by_key('welcome_message_role_' . $security_role['security_role_id']);
}
if (!$template || !$template->template_key) {
    $template = module_template::get_template_by_key('welcome_message');
}
$template->assign_values(array('user_name' => htmlspecialchars($_SESSION['_user_name']), 'system_name' => htmlspecialchars(module_config::s('admin_system_name'))));
$widget_sort_json = @json_decode(module_config::c('dash_widgets_sort_' . module_security::get_loggedin_id()), true);
if (!is_array($widget_sort_json)) {
    $widget_sort_json = array();
}
$widget_sort_order = array();
$widget_sort_page_order = 1;
foreach ($widget_sort_json as $id => $vals) {
    $bits = explode('|', $vals);
    if (count($bits) == 3) {
        $widget_sort_order[$bits[2]] = array('column' => $bits[0], 'column_number' => $bits[1], 'page_order' => $widget_sort_page_order++);
    }
}
$widget_sort_id = 1;
Пример #7
0
    public static function hook_job_task_after($hook, $job_id, $task_id, $job_data, $task_data)
    {
        $comments = get_multiple('job_discussion', array('job_id' => $job_id, 'task_id' => $task_id), 'job_discussion_id', 'exact', 'job_discussion_id');
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 1) {
            // disabled & hidden.
            return;
        }
        if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2 && count($comments) == 0) {
            // disabled & shown.
            return;
        }
        if (isset($_POST['job_discussion_add_job_id']) && isset($_POST['job_discussion_add_task_id']) && $_POST['job_discussion_add_job_id'] == $job_id && $_POST['job_discussion_add_task_id'] == $task_id && isset($_POST['note']) && strlen($_POST['note'])) {
            $x = 0;
            while (ob_get_level() && $x++ < 10) {
                ob_end_clean();
            }
            $current_user_id = module_security::get_loggedin_id();
            $customer = module_customer::get_customer($job_data['customer_id']);
            if (!$current_user_id) {
                if ($job_data['customer_id'] && $customer['primary_user_id']) {
                    $current_user_id = $customer['primary_user_id'];
                }
            }
            $result = array();
            // adding a new note.
            $job_discussion_id = update_insert('job_discussion_id', 0, 'job_discussion', array('job_id' => $job_id, 'task_id' => $task_id, 'user_id' => $current_user_id, 'note' => $_POST['note']));
            $result['job_discussion_id'] = $job_discussion_id;
            $result['count'] = count($comments) + 1;
            $tasks = module_job::get_tasks($job_id);
            $result['email_customer'] = array();
            if (isset($_POST['sendemail_customer']) && is_array($_POST['sendemail_customer'])) {
                //$_POST['sendemail_customer'] == 'yes' && $customer['primary_user_id']){
                // send email to customer primary user id.
                $customer_contacts = module_user::get_contacts(array('customer_id' => $job_data['customer_id']));
                foreach ($_POST['sendemail_customer'] as $user_id) {
                    $user_id = (int) $user_id;
                    if ($user_id && isset($customer_contacts[$user_id])) {
                        // we can email this user.
                        $user = module_user::get_user($user_id, false);
                        if ($user && $user['user_id'] == $user_id) {
                            $values = array_merge($user, $job_data);
                            $values['job_url'] = module_job::link_public($job_id);
                            $values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
                            $values['job_name'] = $job_data['name'];
                            $values['customer_name'] = $user['name'] . ' ' . $user['last_name'];
                            $values['note'] = $_POST['note'];
                            //todo: no order if no showning numbers
                            $values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
                            $template = module_template::get_template_by_key('job_discussion_email_customer');
                            $template->assign_values($values);
                            $html = $template->render('html');
                            $email = module_email::new_email();
                            $email->replace_values = $values;
                            $email->set_to('user', $user['user_id']);
                            $email->set_from('user', $current_user_id);
                            $email->set_subject($template->description);
                            // do we send images inline?
                            $email->set_html($html);
                            if ($email->send()) {
                                // it worked successfully!!
                                $result['email_customer'][] = $user['user_id'];
                            } else {
                                /// log err?
                            }
                        }
                    }
                }
                /*$user = module_user::get_user($customer['primary_user_id'],false);
                                if($user['user_id'] == $customer['primary_user_id']){
                                    $values = array_merge($user,$job_data);
                                    $values['job_url'] = module_job::link_public($job_id);
                                    $values['job_url'] .= (strpos($values['job_url'],'?')===false ? '?' : '&').'discuss='.$task_id.'#discuss'.$task_id;
                                    $values['job_name'] = $job_data['name'];
                                    $values['customer_name'] = $user['name'].' '.$user['last_name'];
                                    $values['note'] = $_POST['note'];
                                    //todo: no order if no showning numbers
                                    $values['task_name'] = '#'.$tasks[$task_id]['task_order'].': '.$tasks[$task_id]['description'];
                
                                    $template = module_template::get_template_by_key('job_discussion_email_customer');
                                    $template->assign_values($values);
                                    $html = $template->render('html');
                
                                    $email = module_email::new_email();
                                    $email->replace_values = $values;
                                    $email->set_to('user',$user['user_id']);
                                    $email->set_from('user',$current_user_id);
                                    $email->set_subject($template->description);
                                    // do we send images inline?
                                    $email->set_html($html);
                
                                    if($email->send()){
                                        // it worked successfully!!
                                        $result['email_customer'] = 1;
                                    }else{
                                        /// log err?
                                        $result['email_customer'] = 0;
                                    }
                                }else{
                                    // log error?
                                    $result['email_customer'] = 0;
                                }*/
            }
            if (isset($_POST['sendemail_staff']) && is_array($_POST['sendemail_staff'])) {
                // == 'yes' && $job_data['user_id']
                // todo: handle the restul better when sending to multiple people
                $result['email_staff_list'] = $_POST['sendemail_staff'];
                foreach ($_POST['sendemail_staff'] as $staff_id) {
                    // send email to staff
                    $staff_id = (int) $staff_id;
                    if (!$staff_id) {
                        $result['nostaff'] = 1;
                        continue;
                    }
                    if (isset($task_data['user_id']) && $task_data['user_id'] == $staff_id || isset($job_data['user_id']) && $job_data['user_id'] == $staff_id) {
                        //$user = module_user::get_user($job_data['user_id'],false);
                        $user = module_user::get_user($staff_id, false);
                        if ($user['user_id'] == $staff_id) {
                            $values = array_merge($user, $job_data);
                            $values['job_url'] = module_job::link_public($job_id);
                            $values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
                            $values['job_name'] = $job_data['name'];
                            $values['staff_name'] = $user['name'] . ' ' . $user['last_name'];
                            $values['note'] = $_POST['note'];
                            //todo: no order if no showning numbers
                            $values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
                            $template = module_template::get_template_by_key('job_discussion_email_staff');
                            $template->assign_values($values);
                            $html = $template->render('html');
                            $email = module_email::new_email();
                            $email->replace_values = $values;
                            $email->set_to('user', $staff_id);
                            $email->set_from('user', $current_user_id);
                            $email->set_subject($template->description);
                            // do we send images inline?
                            $email->set_html($html);
                            if ($email->send()) {
                                // it worked successfully!!
                                $result['email_staff'] = 1;
                            } else {
                                /// log err?
                                $result['email_staff'] = 0;
                            }
                        } else {
                            // log error?
                            $result['email_staff'] = 0;
                        }
                    }
                }
            }
            $x = 0;
            while ($x++ < 5 && ob_get_level()) {
                ob_end_clean();
            }
            header("Content-type: text/javascript", true);
            echo json_encode($result);
            exit;
        }
        $label = htmlspecialchars(module_config::c('job_discussion_button_label', 'Task Comments'));
        ?>

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

            </div>
        <?php 
    }
Пример #8
0
        $this_taxes = module_finance::sanatise_taxes($quote_item_data['taxes'], $quote_item_data['quote_item_amount']);
        $this_taxes_amounts = array();
        $this_taxes_rates = array();
        if (!count($this_taxes)) {
            $this_taxes = array('amount' => 0, 'percent' => 0);
        }
        foreach ($this_taxes as $this_tax) {
            $this_taxes_amounts[] = dollar($this_tax['amount'], true, $quote['currency_id']);
            $this_taxes_rates[] = $this_tax['percent'] . '%';
        }
        $row_replace['item_tax'] = implode(', ', $this_taxes_amounts);
        $row_replace['item_tax_rate'] = implode(', ', $this_taxes_rates);
    }
    $this_item_row_html = $item_row_html;
    $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html);
    // we pass this through the template system so we can make use of things like arithmatic.
    $temp_template = new module_template();
    $temp_template->assign_values($row_replace);
    $temp_template->content = $this_item_row_html;
    $this_item_row_html = $temp_template->replace_content();
    /*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);
echo $t->render();
if (isset($row_replace) && count($row_replace)) {
    module_template::add_tags('quote_task_list', $row_replace);
}
Пример #9
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'popup':
                // popup not used any more. cross domain issues.
                // load up the full script to be injected into our clients website.
                $website_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $change_request_id = $change_id = isset($_REQUEST['change_id']) ? (int) $_REQUEST['change_id'] : false;
                $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : false;
                $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : false;
                if ($type == 'popupjs') {
                    @ob_end_clean();
                    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
                    header("Cache-Control: no-cache");
                    header("Pragma: no-cache");
                    header("Content-type: text/javascript");
                }
                if ($website_id && $hash && module_change_request::link_popup($website_id, true) == $hash) {
                    $change_history = module_change_request::get_remaining_changes($website_id);
                    $step = isset($_REQUEST['step']) ? (int) $_REQUEST['step'] : 0;
                    // get the change details out
                    if ($change_request_id) {
                        $change_request = module_change_request::get_change_request_by_website($website_id, $change_request_id);
                    } else {
                        $change_request = array();
                    }
                    if (!$change_request) {
                        $change_request = array('change_request_id' => 0, 'name' => '', 'request' => '', 'attachments' => array());
                    }
                    switch ($type) {
                        case 'save':
                            // saving a change.
                            $data = $_POST;
                            $data['url'] = urldecode($data['url']);
                            $data['website_id'] = $website_id;
                            $data['change_request_id'] = $change_request['change_request_id'];
                            if (isset($_REQUEST['completed_test'])) {
                                if (!isset($_REQUEST['completed']) || !$_REQUEST['completed']) {
                                    $data['status'] = _CHANGE_REQUEST_STATUS_NEW;
                                    // not completed.
                                } else {
                                    $data['status'] = _CHANGE_REQUEST_STATUS_COMPLETE;
                                    // completed!
                                }
                            }
                            if (isset($_REQUEST['delete_request'])) {
                                $data['status'] = _CHANGE_REQUEST_STATUS_DELETE;
                                // deleted
                            }
                            $change_request_id = update_insert('change_request_id', $change_request['change_request_id'], 'change_request', $data);
                            // redirect to send email page if we're logged in
                            if (module_security::is_logged_in() && isset($_REQUEST['completed_send_email']) && $_REQUEST['completed_send_email'] && self::can_i('edit', 'Change Requests')) {
                                // don't do the template, do the redirect to the email page (todo!)
                                redirect_browser(self::link_open($change_request_id));
                            } else {
                                // send email to administrator (everyone with change request edit permissions?) about this change request.
                                $alert_users = module_user::get_users_by_permission(array('category' => 'Change Request', 'name' => 'Change Requests', 'module' => 'change_request', 'edit' => 1));
                                $email_data = get_single('change_request', 'change_request_id', $change_request_id);
                                $customer_data = $website_data = array();
                                if ($website_id) {
                                    $website_data = module_website::get_website($website_id);
                                    $email_data['website_name'] = $website_data['name'];
                                    $email_data['website_link'] = module_website::link_open($website_id, true);
                                    if ($website_data && $website_data['customer_id']) {
                                        $customer_data = module_customer::get_customer($website_data['customer_id'], true);
                                    }
                                }
                                if (isset($email_data['request'])) {
                                    $email_data['request'] = nl2br($email_data['request']);
                                    // for the plain text emails.
                                }
                                foreach ($alert_users as $alert_user) {
                                    // todo: make sure this staff member has access to this website?
                                    // nfi how to figure this out. maybe we just look for staff members who are assigned jobs/tasks against this website?
                                    $template = module_template::get_template_by_key('change_request_alert_email');
                                    $template->assign_values(array_merge($customer_data, $website_data, $email_data));
                                    $html = $template->render('html');
                                    // send an email to this user.
                                    $email = module_email::new_email();
                                    $email->replace_values = array_merge($customer_data, $website_data, $email_data);
                                    $email->set_to('user', $alert_user['user_id']);
                                    $email->set_from('user', module_security::get_loggedin_id() ? module_security::get_loggedin_id() : isset($customer_data['primary_user_id']) ? $customer_data['primary_user_id'] : 0);
                                    $email->set_subject($template->description);
                                    // do we send images inline?
                                    $email->set_html($html);
                                    if ($email->send()) {
                                        // it worked successfully!!
                                        // sweet.
                                    } else {
                                        /// log err?
                                        set_error(_l('Failed to send change notification email to User ID: %s Email: %s Status: %s Error: %s', $alert_user['user_id'], json_encode($email->to), $email->status, $email->error_text));
                                    }
                                }
                            }
                            // display thankyou template.
                            module_template::init_template('change_request_submitted', '<h2>Change Request</h2>
    <p>Thank you. Your change request has been submitted successfully.</p>
    <p>Please <a href="{URL}">click here</a> to continue.</p>
    ', 'Displayed after a change request is created/updated.', 'code');
                            // correct!
                            // load up the receipt template.
                            $template = module_template::get_template_by_key('change_request_submitted');
                            $template->page_title = _l("Change Request");
                            foreach ($data as $key => $val) {
                                if (!is_array($val)) {
                                    $data[$key] = htmlspecialchars($val);
                                }
                            }
                            $template->assign_values($data);
                            echo $template->render('pretty_html');
                            exit;
                            break;
                        case 'display_change':
                            ob_start();
                            ?>

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

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

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

                                        <?php 
                            }
                            ?>

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

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

	                                    <?php 
                            }
                            ?>

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

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

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


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

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


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

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

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

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

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

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

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

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


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

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

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

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

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

                        });
                        <?php 
                    }
                }
                exit;
                break;
            case 'public':
                $website_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? $_REQUEST['hash'] : false;
                if ($website_id && $hash && module_change_request::link_public($website_id, true) == $hash) {
                    // correct!
                    // redirect to website with our "change_request" url parameter, that is picked up by the included text.
                    $website = module_website::get_website($website_id);
                    $change_request_website = get_single('change_request_website', 'website_id', $website_id);
                    if ($change_request_website && $change_request_website['enabled']) {
                        $url = module_website::urlify($website['url']);
                        // todo - pass this to a (yet to be created) method in website that will deal with https:// or http:// based on user input. stop hardcoding http!
                        if (isset($_REQUEST['change_request_id'])) {
                            $selected_change_request = self::get_change_request_by_website($website_id, (int) $_REQUEST['change_request_id']);
                            if ($selected_change_request && $selected_change_request['url']) {
                                $url = $selected_change_request['url'];
                            }
                            //$url .= "&change_request_id=".(int)$_REQUEST['change_request_id'];
                            $_SESSION['_change_request_highlight'] = (int) $_REQUEST['change_request_id'];
                        }
                        $url = $url . (strpos($url, '?') === false ? '?' : '&') . 'change_request=' . self::link_script($website_id, true);
                        redirect_browser($url);
                    }
                }
                echo "Change request disabled.";
                break;
        }
    }
Пример #10
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_config::can_i('view', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
print_heading('Bank Transfer Settings');
module_config::print_settings_form(array(array('key' => 'payment_method_banktransfer_enabled', 'default' => 1, 'type' => 'checkbox', 'description' => 'Enable Payment Method'), array('key' => 'payment_method_banktransfer_enabled_default', 'default' => 1, 'type' => 'checkbox', 'description' => 'Available By Default On Invoices', 'help' => 'If this option is enabled, all new invoices will have this payment method available. If this option is disabled, it will have to be enabled on individual invoices.'), array('key' => 'payment_method_banktransfer_label', 'default' => 'Bank Transfer', 'type' => 'text', 'description' => 'Name this payment method')));
print_heading('Bank Transfer Templates');
echo module_template::link_open_popup('paymethod_banktransfer');
echo module_template::link_open_popup('paymethod_banktransfer_details');
Пример #11
0
 public static function start_payment($invoice_id, $payment_amount, $invoice_payment_id, $user_id = false)
 {
     if ($invoice_id && $payment_amount && $invoice_payment_id) {
         // we are starting a payment via paypal!
         // setup a pending payment and redirect to paypal.
         $invoice_data = module_invoice::get_invoice($invoice_id);
         if (!$user_id) {
             $user_id = $invoice_data['user_id'];
         }
         if (!$user_id) {
             $user_id = isset($invoice_data['primary_user_id']) ? $invoice_data['primary_user_id'] : 0;
         }
         $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
         // we add the fee details to the invoice payment record so that the new invoice total can be calculated.
         $fee_percent = module_config::c('payment_method_paypal_charge_percent', 0);
         $fee_amount = module_config::c('payment_method_paypal_charge_amount', 0);
         $fee_description = module_config::c('payment_method_paypal_charge_description', 'PayPal Fee');
         $fee_total = 0;
         if ($fee_percent != 0 || $fee_amount != 0) {
             $fee_total = module_invoice::calculate_fee($invoice_id, $invoice_data, $payment_amount, array('percent' => $fee_percent, 'amount' => $fee_amount, 'description' => $fee_description));
             if ($fee_total != 0) {
                 // add this percent/amount to the invoice payment
                 $payment_amount = $payment_amount + $fee_total;
                 update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('fee_percent' => $fee_percent, 'fee_amount' => $fee_amount, 'fee_description' => $fee_description, 'fee_total' => $fee_total, 'amount' => $payment_amount));
             }
         }
         // we check if this payment is a recurring payment or a standard one off payment.
         if (module_config::c('payment_method_paypal_subscriptions', 0)) {
             // we support subscriptions!
             // first check if the subscription module is active, and if this invoice is part of an active subscription.
             $is_subscription = false;
             if (class_exists('module_subscription', false)) {
                 $subscription_history = get_single('subscription_history', 'invoice_id', $invoice_id);
                 if ($subscription_history && $subscription_history['subscription_id']) {
                     // this invoice is for a subscription! woo!
                     // work out when we should bill for this subscription.
                     $subscription = module_subscription::get_subscription($subscription_history['subscription_id']);
                     $subscription_owner = module_subscription::get_subscription_owner($subscription_history['subscription_owner_id']);
                     if ($subscription_owner['owner_table'] && $subscription_owner['owner_id']) {
                         // work out when the next invoice will be generated for this subscription.
                         $members_subscriptions = module_subscription::get_subscriptions_by($subscription_owner['owner_table'], $subscription_owner['owner_id']);
                         if (isset($members_subscriptions[$subscription_history['subscription_id']])) {
                             $member_subscription = $members_subscriptions[$subscription_history['subscription_id']];
                             // everything checks out! good to go....
                             // for now we just do a basic "EVERY X TIME" subscription
                             // todo: work out how long until next generate date, and set that (possibly smaller) time period as the first portion of the subscription
                             /*echo '<pre>';
                               print_r($subscription_history);
                               print_r($subscription);
                               print_r($subscription_owner);
                               print_r($member_subscription);
                               exit;*/
                             $is_subscription = array();
                             if ($subscription['days'] > 0) {
                                 $is_subscription['days'] = $subscription['days'];
                             }
                             if ($subscription['months'] > 0) {
                                 $is_subscription['months'] = $subscription['months'];
                             }
                             if ($subscription['years'] > 0) {
                                 $is_subscription['years'] = $subscription['years'];
                             }
                             if (count($is_subscription)) {
                                 $is_subscription['name'] = $subscription['name'];
                             }
                         }
                     }
                 }
             }
             // todo: check if this invoice has a manual renewal date, perform subscription feature as above.
             if ($is_subscription) {
                 $bits = array();
                 if (isset($is_subscription['days']) && $is_subscription['days'] > 0) {
                     $bits[] = _l('%s days', $is_subscription['days']);
                 }
                 if (isset($is_subscription['months']) && $is_subscription['months'] > 0) {
                     $bits[] = _l('%s months', $is_subscription['months']);
                 }
                 if (isset($is_subscription['years']) && $is_subscription['years'] > 0) {
                     $bits[] = _l('%s years', $is_subscription['years']);
                 }
                 $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                 if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) {
                     // existing subscription already!
                     // not really sure what to do here, just redirect to paypal as if the user is doing it for the first time.
                     $_REQUEST['payment_subscription'] = true;
                     // hacks!
                 }
                 if (isset($_REQUEST['payment_subscription']) || module_config::c('payment_method_paypal_force_subscription', 0)) {
                     // user is setting up a subscription! yes!!
                     // we create an entry in our database for this particular subscription
                     // or if one exists for this payment already then we just continue with that (ie: the user is going in again to redo it)
                     // setup a new subscription in the database for us.
                     if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) {
                         $invoice_payment_subscription_id = $invoice_payment_data['invoice_payment_subscription_id'];
                     } else {
                         $invoice_payment_subscription_id = update_insert('invoice_payment_subscription_id', false, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_PENDING, 'days' => isset($is_subscription['days']) ? $is_subscription['days'] : 0, 'months' => isset($is_subscription['months']) ? $is_subscription['months'] : 0, 'years' => isset($is_subscription['years']) ? $is_subscription['years'] : 0, 'date_start' => '0000-00-00', 'date_last_pay' => '0000-00-00', 'date_next' => '0000-00-00'));
                         update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                     }
                     $description = _l('Recurring payment for %s every %s', $is_subscription['name'], implode(', ', $bits));
                     unset($is_subscription['name']);
                     // so reset/key cals below rosk.
                     $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                     $url = 'https://www.' . (self::is_sandbox() ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr?';
                     // if there are more than 1 recurring amounts then we convert it to days, as paypal only supports one time period.
                     if (count($is_subscription) > 1) {
                         $days = isset($is_subscription['days']) ? $is_subscription['days'] : 0;
                         if (isset($is_subscription['months'])) {
                             $days += $is_subscription['months'] * 30;
                             unset($is_subscription['months']);
                         }
                         if (isset($is_subscription['years'])) {
                             $days += $is_subscription['years'] * 365;
                             unset($is_subscription['years']);
                         }
                         $is_subscription['days'] = $days;
                     }
                     reset($is_subscription);
                     $time = key($is_subscription);
                     if ($time == 'days') {
                         $time = 'D';
                     } else {
                         if ($time == 'months') {
                             $time = 'M';
                         } else {
                             if ($time == 'years') {
                                 $time = 'Y';
                             }
                         }
                     }
                     $fields = array('cmd' => '_xclick-subscriptions', 'business' => module_config::c('payment_method_paypal_email', _ERROR_EMAIL), 'currency_code' => $currency['code'], 'item_name' => $description, 'no_shipping' => 1, 'page_style' => module_config::c('paypal_page_style', ''), 'return' => module_invoice::link_public_payment_complete($invoice_id), 'rm' => 1, 'cancel_return' => module_invoice::link_public($invoice_id), 'notify_url' => full_link(_EXTERNAL_TUNNEL . '?m=paymethod_paypal&h=ipn&method=paypal'), 'custom' => self::paypal_custom($user_id, $invoice_payment_id, $invoice_id, $invoice_payment_subscription_id), 'a3' => $payment_amount, 'p3' => current($is_subscription), 't3' => $time, 'src' => 1, 'sra' => 1, 'no_note' => 1);
                     // is there a subscription trail period
                     if (isset($subscription['settings']['trial_period']) && $subscription['settings']['trial_period'] > 0) {
                         // we have to hacck the payment_amount here.
                         // $payment_amount will be the discounted amount (eg: $5 instead of $10)
                         // so we reverse that discounted amount for the real amount.
                         $real_amount = $payment_amount - $fee_amount - (isset($subscription['settings']['trial_price_adjust']) ? $subscription['settings']['trial_price_adjust'] : 0);
                         $real_fee_total = module_invoice::calculate_fee($invoice_id, $invoice_data, $real_amount, array('percent' => $fee_percent, 'amount' => $fee_amount, 'description' => $fee_description));
                         $real_amount += $real_fee_total;
                         $fields['a3'] = $real_amount;
                         $fields['a1'] = $payment_amount;
                         // $real_amount + (isset($subscription['settings']['trial_price_adjust']) ? $subscription['settings']['trial_price_adjust'] : 0);
                         $fields['p1'] = current($is_subscription);
                         // * $subscription['settings']['trial_period'];
                         $fields['t1'] = $time;
                     }
                     //echo '<pre>'; print_r($fields);exit;
                     foreach ($fields as $key => $val) {
                         $url .= $key . '=' . urlencode($val) . '&';
                     }
                     //echo '<a href="'.$url.'">'.$url.'</a>';exit;
                     redirect_browser($url);
                 } else {
                     if (isset($_REQUEST['payment_single'])) {
                         // use is choosing to continue payment as a once off amount
                     } else {
                         // give the user an option
                         module_template::init_template('invoice_payment_subscription', '<h2>Payment for Invoice {INVOICE_NUMBER}</h2>
                     <p>Please choose from the available payment options below:</p>
                     <form action="{PAYMENT_URL}" method="post">
                     <input type="hidden" name="invoice_payment_id" value="{INVOICE_PAYMENT_ID}">
                     <input type="hidden" name="payment_method" value="{PAYMENT_METHOD}">
                     <input type="hidden" name="payment_amount" value="{PAYMENT_AMOUNT}">
                     <p><input type="submit" name="payment_single" value="Pay a Once Off amount of {PRETTY_PAYMENT_AMOUNT}"></p>
                     <p><input type="submit" name="payment_subscription" value="Setup Automatic Payments of {PRETTY_PAYMENT_AMOUNT} every {SUBSCRIPTION_PERIOD}"></p>
                     </form>
                     ', 'Used when a customer tries to pay an invoice that has a subscription option.', 'code');
                         $template = module_template::get_template_by_key('invoice_payment_subscription');
                         $template->page_title = htmlspecialchars($invoice_data['name']);
                         $template->assign_values($invoice_payment_data);
                         $template->assign_values(module_invoice::get_replace_fields($invoice_data['invoice_id'], $invoice_data));
                         $template->assign_values(array('invoice_payment_id' => $invoice_payment_id, 'payment_url' => module_invoice::link_public_pay($invoice_data['invoice_id']), 'payment_method' => 'paymethod_paypal', 'payment_amount' => $payment_amount, 'pretty_payment_amount' => dollar($payment_amount, true, $invoice_data['currency_id']), 'subscription_period' => implode(', ', $bits), 'fee_amount' => dollar($fee_amount, true, $invoice_data['currency_id']), 'fee_total' => dollar($fee_total, true, $invoice_data['currency_id']), 'fee_percent' => $fee_percent, 'fee_description' => $fee_description));
                         echo $template->render('pretty_html');
                         exit;
                     }
                 }
             }
         }
         $description = _l('Payment for Invoice %s', $invoice_data['name']);
         self::paypal_redirect($description, $payment_amount, $user_id, $invoice_payment_id, $invoice_id, $invoice_payment_data['currency_id']);
         return true;
     }
     return false;
 }
Пример #12
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_config::can_i('view', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
print_heading('Check Settings');
module_config::print_settings_form(array(array('key' => 'payment_method_check_enabled', 'default' => 0, 'type' => 'checkbox', 'description' => 'Enable Payment Method'), array('key' => 'payment_method_check_enabled_default', 'default' => 1, 'type' => 'checkbox', 'description' => 'Available By Default On Invoices', 'help' => 'If this option is enabled, all new invoices will have this payment method available. If this option is disabled, it will have to be enabled on individual invoices.'), array('key' => 'payment_method_check_label', 'default' => 'Check', 'type' => 'text', 'description' => 'Name this payment method')));
print_heading('Check Templates');
echo module_template::link_open_popup('paymethod_check');
echo module_template::link_open_popup('paymethod_check_details');
Пример #13
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 (!$ticket_safe) {
    die('failed');
}
$ticket_id = (int) $_REQUEST['ticket_id'];
$ticket = module_ticket::get_ticket($ticket_id);
print_heading(_l('Notify Staff About Ticket: %s', module_ticket::ticket_number($ticket['ticket_id'])));
// template for sending emails.
// are we sending the paid one? or the dueone.
$template = module_template::get_template_by_key('ticket_email_notify');
$ticket['ticket_number'] = module_ticket::ticket_number($ticket['ticket_id']);
$ticket['from_name'] = module_security::get_loggedin_name();
$ticket['ticket_url'] = module_ticket::link_open($ticket_id);
$ticket['ticket_subject'] = $ticket['subject'];
// sending to the staff member.
$to = module_user::get_user($ticket['assigned_user_id']);
$ticket['staff_name'] = $to['name'] . ' ' . $to['last_name'];
$to = array($to);
$template->assign_values($ticket);
module_email::print_compose(array('to' => $to, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_ticket::link_open($ticket_id), 'cancel_url' => module_ticket::link_open($ticket_id)));
Пример #14
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'public':
                $faq_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($faq_id && $hash) {
                    $correct_hash = $this->link_open_public($faq_id, true);
                    if ($correct_hash == $hash) {
                        $faq = array();
                        if ($faq_id > 0) {
                            $faq = $this->get_faq($faq_id);
                        }
                        if ($faq) {
                            $template = module_template::get_template_by_key('faq_item');
                            $faq['answer'] = self::html_faq($faq['answer']);
                            $faq['faq_back'] = $this->link_open_public(-1) . (isset($_REQUEST['faq_product_id']) ? '&faq_product_id=' . (int) $_REQUEST['faq_product_id'] : '');
                            $template->assign_values($faq);
                            $template->page_title = $faq['question'];
                            echo $template->render('pretty_html');
                        } else {
                            $template = module_template::get_template_by_key('faq_list');
                            $data = array();
                            ob_start();
                            include 'public/faq_listing.php';
                            $data['listing'] = ob_get_clean();
                            $template->assign_values($data);
                            $template->page_title = _l('FAQ');
                            echo $template->render('pretty_html');
                        }
                    }
                }
                break;
            case 'faq_list_json':
                @ob_end_clean();
                header("Content-type: text/javascript");
                $faq_id = isset($_REQUEST['faq_id']) ? (int) $_REQUEST['faq_id'] : false;
                if ($faq_id > 0) {
                    $faq = $this->get_faq($faq_id);
                    if ($faq) {
                        $faq['url'] = module_faq::link_open_public($faq_id, false);
                        echo json_encode($faq);
                        /*$template = module_template::get_template_by_key('faq_item');
                          $faq['answer'] = forum_text($faq['answer']);
                          $faq['faq_back'] = $this->link_open_public(-1).(isset($_REQUEST['faq_product_id']) ? '&faq_product_id='.(int)$_REQUEST['faq_product_id'] : '');
                          $template->assign_values($faq);
                          $template->page_title = $faq['question'];
                          echo $template->replace_content();*/
                    }
                    exit;
                }
                $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false;
                $faq_search = isset($_REQUEST['faq_search']) ? $_REQUEST['faq_search'] : false;
                $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id, 'question' => $faq_search));
                $faqs_json = array();
                $all_products = module_faq::get_faq_products_rel();
                foreach ($faqs as $faq) {
                    $faq = module_faq::get_faq($faq['faq_id']);
                    $faq_products = array();
                    foreach ($faq['faq_product_ids'] as $faq_product_id) {
                        $faq_products[$faq_product_id] = $all_products[$faq_product_id];
                    }
                    $faqs_json[$faq['faq_id']] = array('question' => $faq['question'], 'url' => module_faq::link_open_public($faq['faq_id'], false), 'products' => $faq_products);
                }
                echo json_encode($faqs_json);
                exit;
                break;
            case 'ticket_list':
                $faq_product_id = isset($_REQUEST['faq_product_id']) ? (int) $_REQUEST['faq_product_id'] : false;
                @ob_end_clean();
                header("Content-type: text/javascript");
                if ($faq_product_id) {
                    $product = $this->get_faq_product($faq_product_id);
                    // find the faq items that match this product id.
                    if ($product && $product['faq_product_id'] == $faq_product_id) {
                        $faqs = $this->get_faqs(array('faq_product_id' => $faq_product_id));
                        ob_start();
                        $x = 0;
                        $half = ceil(count($faqs) / 2);
                        ?>

                        <tr>
                            <th>
                                <?php 
                        _e('FAQ');
                        ?>

                            </th>
                            <td>
                                <?php 
                        _e('Please read through the below FAQ to see if the question has already been answered');
                        ?>

                        </tr>
                        <tr>
                            <td colspan="2">
                                <table width="100%" class="tableclass tableclass_full table_faq_class">
                                    <tbody>
                                    <tr>
                                        <td width="50%" valign="top">
                                            <ul><?php 
                        for (true; $x < $half; $x++) {
                            $data = array_shift($faqs);
                            $faq = module_faq::get_faq($data['faq_id']);
                            ?>

                                                    <li>
                                                        <a href="<?php 
                            echo module_faq::link_open_public($data['faq_id'], false);
                            ?>
" target="_blank"><?php 
                            echo htmlspecialchars($faq['question']);
                            ?>
</a>
                                                    </li>
                                                    <?php 
                        }
                        ?>

                                            </ul>
                                        </td>
                                        <td width="50%" valign="top">
                                            <ul><?php 
                        foreach ($faqs as $data) {
                            $faq = module_faq::get_faq($data['faq_id']);
                            ?>

                                                    <li>
                                                        <a href="<?php 
                            echo module_faq::link_open_public($data['faq_id'], false);
                            ?>
" target="_blank"><?php 
                            echo htmlspecialchars($faq['question']);
                            ?>
</a>
                                                    </li>
                                                    <?php 
                        }
                        ?>

                                            </ul>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                            </td>
                        </tr>
                        <?php 
                        $html = preg_replace('#\\s+#', ' ', ob_get_clean());
                        ?>

                        $('#faq_product_area').html('<?php 
                        echo addcslashes($html, "'");
                        ?>
');
                        <?php 
                        if ($product['default_type_id']) {
                            ?>

                            $('#ticket_type_id').val(<?php 
                            echo (int) $product['default_type_id'];
                            ?>
);
                        <?php 
                        }
                        // and now we have to set the ticket position.
                        if (module_config::c('ticket_show_position', 1)) {
                            $new_position = module_ticket::ticket_position(false, $faq_product_id);
                            ?>

                            $('#ticket_position_field').html('<?php 
                            echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'");
                            ?>
');
                            <?php 
                            if (module_config::c('ticket_allow_priority', 0)) {
                                $c = module_ticket::get_ticket_count($faq_product_id);
                                ?>

                                $('#priority_ticket_position').html('<?php 
                                _e('%s out of %s', ordinal($c['priority'] + 1), $new_position['total'] + 1);
                                ?>
');
                                <?php 
                            }
                        }
                        exit;
                    }
                }
                ?>
  $('#faq_product_area').html(''); <?php 
                if (module_config::c('ticket_show_position', 1)) {
                    $new_position = module_ticket::ticket_position();
                    ?>

                    $('#ticket_position_field').html('<?php 
                    echo addcslashes(_l('%s out of %s other support tickets', ordinal($new_position['current'] + 1), $new_position['total'] + 1), "'");
                    ?>
');
                    <?php 
                    if (module_config::c('ticket_allow_priority', 0)) {
                        ?>

                        $('#priority_ticket_position').html('<?php 
                        _e('%s out of %s', ordinal(module_ticket::ticket_count('priority') + 1), $new_position['total'] + 1);
                        ?>
');
                        <?php 
                    }
                }
                break;
        }
    }
Пример #15
0

<form action="" method="post">
<input type="hidden" name="_process" value="save_data_type" />
<input type="hidden" name="_redirect" value="<?php 
echo $module->link("", array("saved" => true, "data_type_id" => (int) $data_type_id ? $data_type_id : ''));
?>
" />
<input type="hidden" name="data_type_id" value="<?php 
echo $data_type_id;
?>
" />

    <?php 
$templates = array();
foreach (module_template::get_templates() as $template) {
    $templates[$template['template_key']] = $template['template_key'] . ' (' . $template['description'] . ')';
}
$header_buttons = array();
$fieldset_data = array('heading' => array('main' => true, 'type' => 'h2', 'title' => 'Data Settings', 'button' => $header_buttons), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => _l('Name'), 'field' => array('type' => 'text', 'name' => 'data_type_name', 'value' => isset($data_type['data_type_name']) ? htmlspecialchars($data_type['data_type_name']) : '')), 'hook' => array('title' => _l('Display Location'), 'field' => array('type' => 'select', 'name' => 'data_type_menu', 'options' => module_data::get_menu_locations(), 'blank' => false, 'value' => isset($data_type['data_type_menu']) ? htmlspecialchars($data_type['data_type_menu']) : '', 'help' => 'This is where your custom data type will display within the system. Main will put it in the main menu. Customer will put it underneath a customer menu. None will hide this from the menu system all together')), 'icon' => array('title' => _l('Icon'), 'field' => array('type' => 'text', 'name' => 'data_type_icon', 'value' => isset($data_type['data_type_icon']) ? htmlspecialchars($data_type['data_type_icon']) : '', 'help' => 'Type the icon name from http://fontawesome.io/icons/ (eg: bell). Compatible with the Metis theme.')), 'max_entries' => array('title' => _l('Single or Multiple'), 'field' => array('type' => 'select', 'name' => 'max_entries', 'value' => isset($data_type['max_entries']) ? (int) $data_type['max_entries'] : 0, 'blank' => false, 'options' => array(0 => _l('Multiple Entries (default)'), 1 => _l('Single Entry Only')), 'help' => 'Here you can allow a single form entry or multiple entries. A single form entry can be used to record some information against a customer, the single entry will be displayed straight away instead of the list of multiple entries.')), 'print_pdf_template' => array('title' => _l('Allow PDF'), 'field' => array('type' => 'select', 'name' => 'print_pdf_template', 'value' => isset($data_type['print_pdf_template']) ? $data_type['print_pdf_template'] : '', 'options' => $templates, 'blank' => _l(' - disable Print to PDF - '), 'help' => 'These are all the available templates in the system. Create your own ( Settings > Templates ) and select it here. A Print PDF button will be available for each data record.')), 'email_template' => array('title' => _l('Allow Email'), 'field' => array('type' => 'select', 'name' => 'email_template', 'value' => isset($data_type['email_template']) ? $data_type['email_template'] : '', 'options' => $templates, 'blank' => _l(' - disable Email - '), 'help' => 'These are all the available templates in the system. Create your own ( Settings > Templates ) and select it here. An email button will be available for each data record.'))));
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$form_actions = array('class' => 'action_bar action_bar_center action_bar_single', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save Settings')), array('type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete'), 'onclick' => "return confirm('Really delete?');"), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link() . "';")));
echo module_form::generate_form_actions($form_actions);
?>


<p>&nbsp;</p>
<?php 
if ($data_type_id && $data_type_id != 'new') {
    $data_field_groups = $module->get_data_field_groups($data_type_id);
Пример #16
0
 public static function quote_html($quote_id, $quote_data, $mode = 'html')
 {
     if ($quote_id && $quote_data) {
         // spit out the quote html into a file, then pass it to the pdf converter
         // to convert it into a PDF.
         $quote = $quote_data;
         if (class_exists('module_company', false) && isset($quote_data['company_id']) && (int) $quote_data['company_id'] > 0) {
             module_company::set_current_company_id($quote_data['company_id']);
         }
         $quote_template = isset($quote_data['quote_template_print']) && strlen($quote_data['quote_template_print']) ? $quote_data['quote_template_print'] : module_config::c('quote_template_print_default', 'quote_pdf');
         $quote_template_suffix = '';
         if ($quote_template != 'quote_pdf') {
             $quote_template_suffix = str_replace('quote_pdf', '', $quote_template);
         }
         ob_start();
         include module_theme::include_ucm('includes/plugin_quote/template/quote_task_list.php');
         $task_list_html = ob_get_clean();
         $replace = self::get_replace_fields($quote_id, $quote_data);
         $replace['task_list'] = $task_list_html;
         $replace['quote_link'] = module_quote::link_public($quote_id);
         $replace['external_quote_template_html'] = '';
         $external_quote_template = module_template::get_template_by_key('quote_pdf');
         $external_quote_template->assign_values($replace);
         $replace['external_quote_template_html'] = $external_quote_template->replace_content();
         ob_start();
         $template = module_template::get_template_by_key($quote_template);
         $template->assign_values($replace);
         echo $template->render('html');
         $quote_html = ob_get_clean();
         return $quote_html;
     }
     return false;
 }
Пример #17
0
    public function render($type = 'html', $options = array())
    {
        ob_start();
        switch ($type) {
            case 'pretty_html':
                // header and footer so plain contnet can be rendered nicely.
                $display_mode = get_display_mode();
                // addition - woah! we pass this through to the template module for re-rending again:
                ob_start();
                ?>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>{PAGE_TITLE}</title>
    {FAVICON}
    {AUTOMATIC_STYLES}
    {AUTOMATIC_SCRIPTS}
    <style type="text/css">
        body{
            margin:0;
        }
    </style>
</head>
<body>
<div class="pretty_content_wrap">
    {CONTENT}
</div>
</body>
</html>
                <?php 
                /*$c = $this->replace_content();
                  if(!$this->wysiwyg){
                      //$c = nl2br($c);
                  }
                  echo $c;*/
                module_template::init_template('external_template', ob_get_clean(), 'Used when displaying the external content such as "External Jobs" and "External Invoices" and "External Tickets".', 'code', array('CONTENT' => 'The inner content', 'PAGE_TITLE' => 'in the <title> tag', 'FAVICON' => 'if the theme specifies a favicon it will be here', 'AUTOMATIC_STYLES' => 'system generated stylesheets', 'AUTOMATIC_SCRIPTS' => 'system generated javascripts'));
                ob_start();
                ?>

                <link rel="stylesheet" href="<?php 
                echo _BASE_HREF;
                ?>
css/desktop.css" type="text/css">
                <link rel="stylesheet" href="<?php 
                echo _BASE_HREF;
                ?>
css/print.css" type="text/css" media="print">
                <link rel="stylesheet" href="<?php 
                echo _BASE_HREF;
                ?>
css/styles.css" type="text/css">
                <link type="text/css" href="<?php 
                echo _BASE_HREF;
                ?>
css/smoothness/jquery-ui-1.9.2.custom.min.css" rel="stylesheet" />
                <?php 
                module_config::print_css();
                ?>
 <?php 
                $css = ob_get_clean();
                ob_start();
                ?>

                <script type="text/javascript" src="<?php 
                echo _BASE_HREF;
                ?>
js/jquery-1.8.3.min.js"></script>
                <script type="text/javascript" src="<?php 
                echo _BASE_HREF;
                ?>
js/jquery-ui-1.9.2.custom.min.js"></script>
                <script type="text/javascript" src="<?php 
                echo _BASE_HREF;
                ?>
js/timepicker.js"></script>
                <script type="text/javascript" src="<?php 
                echo _BASE_HREF;
                ?>
js/cookie.js"></script>
                <script type="text/javascript" src="<?php 
                echo _BASE_HREF;
                ?>
js/javascript.js?ver=2"></script>
                <?php 
                module_config::print_js();
                ?>

                <?php 
                $scripts = ob_get_clean();
                $external_template = self::get_template_by_key('external_template');
                $external_template->assign_values(array('CONTENT' => $this->replace_content(), 'PAGE_TITLE' => $this->page_title ? $this->page_title : module_config::s('admin_system_name'), 'FAVICON' => module_theme::get_config('theme_favicon', '') ? '<link rel="icon" href="' . htmlspecialchars(module_theme::get_config('theme_favicon', '')) . '">' : '', 'AUTOMATIC_STYLES' => $css, 'AUTOMATIC_SCRIPTS' => $scripts));
                echo $external_template->render('raw');
                break;
            case 'html':
            default:
                $c = $this->replace_content();
                if ($this->wysiwyg) {
                    //$c = nl2br($c);
                }
                echo $c;
                break;
        }
        return ob_get_clean();
    }
Пример #18
0
 private static function send_job_task_email($job_id, $task_id, $reason)
 {
     $return_messages = array();
     if (module_config::c('job_send_staff_task_email_automatically', 0) && $reason == 'created') {
         // send the same emial as if going to job_admin_email_staff.php
         $task_data = self::get_task($job_id, $task_id);
         $job_data = self::get_job($job_id);
         if ($task_data['user_id'] > 0 && $task_data['user_id'] != module_security::get_loggedin_id()) {
             $staff = module_user::get_user($task_data['user_id']);
             if ($staff && $staff['user_id'] == $task_data['user_id'] && !(module_config::c('job_staff_email_skip_complete', 0) && $task_data['fully_completed'])) {
                 $template = module_template::get_template_by_key('job_staff_email');
                 $job_data['job_name'] = $job_data['name'];
                 $job_data['staff_name'] = $staff['name'];
                 $job_data['job_url'] = module_job::link_open($job_id);
                 $job_data['job_tasks'] = '<ul>';
                 $job_data['task_count'] = 0;
                 //foreach($job_tasks as $job_task){
                 $job_task = $task_data;
                 //if($job_task['user_id']!=$staff_id)continue;
                 //if(module_config::c('job_staff_email_skip_complete',0)&&$job_task['fully_completed'])continue;
                 $job_data['job_tasks'] .= '<li><strong>' . $job_task['description'] . '</strong>';
                 if ($job_task['fully_completed']) {
                     $job_data['job_tasks'] .= ' <span style="color: #99cc00; font-weight:bold;">(' . _l('complete') . ')</span>';
                 }
                 $job_data['job_tasks'] .= ' <br/>';
                 if ($job_task['long_description']) {
                     $job_data['job_tasks'] .= _l('Notes:') . ' <em>' . $job_task['long_description'] . '</em><br/>';
                 }
                 if ($job_task['date_due'] && $job_task['date_due'] != '0000-00-00') {
                     $job_data['job_tasks'] .= _l('Date Due:') . ' ' . print_date($job_task['date_due']) . '<br/>';
                 }
                 if ($job_task['hours']) {
                     $job_data['job_tasks'] .= _l('Assigned Hours:') . ' ' . $job_task['hours'] . '<br/>';
                 }
                 if ($job_task['completed']) {
                     $job_data['job_tasks'] .= _l('Completed Hours:') . ' ' . $job_task['completed'] . '<br/>';
                 }
                 $job_data['job_tasks'] .= '</li>';
                 $job_data['task_count']++;
                 //}
                 $job_data['job_tasks'] .= '</ul>';
                 // find available "to" recipients.
                 // customer contacts.
                 $to = array();
                 $to[] = array('name' => $staff['name'], 'email' => $staff['email']);
                 $html = $template->render('html');
                 // send an email to this user.
                 $email = module_email::new_email();
                 $email->replace_values = $job_data;
                 $email->set_to('user', $staff['user_id']);
                 $email->set_bcc_manual(module_config::c('admin_email_address', ''), '');
                 //$email->set_from('user',); // nfi
                 $email->set_subject($template->description);
                 // do we send images inline?
                 $email->set_html($html);
                 $email->job_id = $job_id;
                 $email->prevent_duplicates = true;
                 if ($email->send(false)) {
                     self::add_history($job_id, _l('Job task emailed to staff successfully'));
                     $return_messages[] = _l(' and email sent to staff %s', $staff['name']);
                 } else {
                     /// log err?
                 }
             }
         }
     }
     if (module_config::c('job_send_task_completion_email_automatically', 0) && isset($_POST['confirm_job_task_email'])) {
         $task_data = self::get_task($job_id, $task_id);
         $job_data = self::get_job($job_id);
         if ($task_data['fully_completed'] && $job_data['customer_id']) {
             $template_name = 'job_task_completion_email';
             /*if(class_exists('module_company',false) && isset($invoice_data['company_id']) && (int)$invoice_data['company_id']>0){
             			module_company::set_current_company_id($invoice_data['company_id']);
             		}*/
             $template = module_template::get_template_by_key($template_name);
             $replace = module_job::get_replace_fields($job_id, $job_data);
             $to_select = false;
             if ($job_data['customer_id']) {
                 $customer = module_customer::get_customer($job_data['customer_id']);
                 $replace['customer_name'] = $customer['customer_name'];
                 $to = module_user::get_contacts(array('customer_id' => $job_data['customer_id']));
                 if ($customer['primary_user_id']) {
                     $primary = module_user::get_user($customer['primary_user_id']);
                     if ($primary) {
                         $to_select = $primary['email'];
                     }
                 }
             } else {
                 $to = array();
             }
             $replace['job_name'] = $job_data['name'];
             $replace['task_description'] = $task_data['description'];
             $template->assign_values($replace);
             $html = $template->render('html');
             // send an email to this user.
             $email = module_email::new_email();
             $email->replace_values = $replace;
             // todo: send to all customer contacts ?
             if ($to_select) {
                 $email->set_to_manual($to_select);
             } else {
                 foreach ($to as $t) {
                     $email->set_to_manual($t['email']);
                     break;
                     // only 1? todo: all?
                 }
             }
             $email->set_bcc_manual(module_config::c('admin_email_address', ''), '');
             //$email->set_from('user',); // nfi
             $email->set_subject($template->description);
             // do we send images inline?
             $email->set_html($html);
             $email->job_id = $job_id;
             $email->customer_id = $job_data['customer_id'];
             $email->prevent_duplicates = true;
             if ($email->send(false)) {
                 // it worked successfully!!
                 // record a log on the invoice when it's done.
                 /*self::email_sent(array(
                 			'invoice_id' => $invoice_id,
                 			'template_name' => $template_name,
                 		));*/
                 self::add_history($job_id, _l('Job task emailed to customer successfully'));
                 $return_messages[] = _l(' and email sent to customer');
             } else {
                 // log err?
             }
         }
     }
     // if we are approving or rejecting job tasks with a message.
     if (isset($_POST['job_task'][$task_id]['approval_actioned']) && $_POST['job_task'][$task_id]['approval_actioned']) {
         $task_data = self::get_task($job_id, $task_id);
         $job_data = self::get_job($job_id);
         if ($task_data['user_id'] > 0) {
             $staff = module_user::get_user($task_data['user_id']);
             if ($staff && $staff['user_id'] == $task_data['user_id'] && !(module_config::c('job_staff_email_skip_complete', 0) && $task_data['fully_completed'])) {
                 $template = module_template::get_template_by_key('job_task_approval');
                 $job_data['job_name'] = $job_data['name'];
                 $job_data['staff_name'] = $staff['name'];
                 $job_data['job_url'] = module_job::link_open($job_id);
                 $job_data['approved_or_rejected'] = $_POST['job_task'][$task_id]['approval_required'] == 2 ? _l('Rejected') : _l('Approved');
                 $job_data['message'] = isset($_POST['job_task'][$task_id]['approval_message']) ? $_POST['job_task'][$task_id]['approval_message'] : _l('N/A');
                 $job_data['job_task'] = '<ul>';
                 $job_data['task_count'] = 0;
                 //foreach($job_tasks as $job_task){
                 $job_task = $task_data;
                 //if($job_task['user_id']!=$staff_id)continue;
                 //if(module_config::c('job_staff_email_skip_complete',0)&&$job_task['fully_completed'])continue;
                 $job_data['job_task'] .= '<li><strong>' . $job_task['description'] . '</strong>';
                 if ($job_task['fully_completed']) {
                     $job_data['job_task'] .= ' <span style="color: #99cc00; font-weight:bold;">(' . _l('complete') . ')</span>';
                 }
                 $job_data['job_task'] .= ' <br/>';
                 if ($job_task['long_description']) {
                     $job_data['job_task'] .= _l('Notes:') . ' <em>' . $job_task['long_description'] . '</em><br/>';
                 }
                 if ($job_task['date_due'] && $job_task['date_due'] != '0000-00-00') {
                     $job_data['job_task'] .= _l('Date Due:') . ' ' . print_date($job_task['date_due']) . '<br/>';
                 }
                 if ($job_task['hours']) {
                     $job_data['job_task'] .= _l('Assigned Hours:') . ' ' . $job_task['hours'] . '<br/>';
                 }
                 if (isset($job_task['completed']) && $job_task['completed']) {
                     $job_data['job_task'] .= _l('Completed Hours:') . ' ' . (isset($job_task['completed']) ? $job_task['completed'] : '') . '<br/>';
                 }
                 $job_data['job_task'] .= '</li>';
                 $job_data['task_count']++;
                 //}
                 $job_data['job_task'] .= '</ul>';
                 // find available "to" recipients.
                 // customer contacts.
                 $to = array();
                 $to[] = array('name' => $staff['name'], 'email' => $staff['email']);
                 $template->assign_values($job_data);
                 $html = $template->render('html');
                 // send an email to this user.
                 $email = module_email::new_email();
                 $email->replace_values = $job_data;
                 $email->set_to('user', $staff['user_id']);
                 $email->set_bcc_manual(module_config::c('admin_email_address', ''), '');
                 //$email->set_from('user',); // nfi
                 $email->set_subject($template->description);
                 // do we send images inline?
                 $email->set_html($html);
                 $email->job_id = $job_id;
                 $email->prevent_duplicates = true;
                 if ($email->send(false)) {
                     self::add_history($job_id, _l('Job task emailed to staff successfully'));
                     $return_messages[] = _l(' and email sent to staff %s', $staff['name']);
                 } else {
                     /// log err?
                 }
             }
         }
     }
     if (count($return_messages)) {
         return array('message' => implode(' ', $return_messages));
     }
     return false;
 }
Пример #19
0
 public function external_hook($hook)
 {
     switch ($hook) {
         case 'event_ipn':
             $body = @file_get_contents('php://input');
             $event_json = json_decode($body);
             ob_start();
             echo "UCM coinbase DEBUG:<br><br>JSON: <br>\n";
             print_r($event_json);
             echo "<br><br>\n";
             $success = false;
             $bits = explode(':', isset($event_json->order->custom) ? $event_json->order->custom : '');
             if (count($bits) == 4) {
                 // we have our custom bits, invoice_id, invoice_payment_id and hash
                 // check they are right
                 $invoice_id = (int) $bits[0];
                 $invoice_payment_id = (int) $bits[1];
                 $invoice_payment_subscription_id = (int) $bits[2];
                 $hash = $bits[3];
                 $correct_hash = self::get_payment_key($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id, true);
                 if ($invoice_id && $invoice_payment_id && $hash == $correct_hash) {
                     // This will send receipts on succesful invoices
                     // todo - coinbase doesnt sent this callback correctly just yet
                     if ($event_json && isset($event_json->recurring_payment) && $invoice_payment_subscription_id) {
                         // status changes on a recurring payment.
                         $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                         if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                             // no start date yet, set the start date now.
                             if ($event_json->recurring_payment->status == 'active') {
                                 update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                             }
                         }
                         if ($event_json->recurring_payment->status == 'paused' || $event_json->recurring_payment->status == 'canceled') {
                             update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_FAILED));
                         }
                     }
                     if ($event_json && isset($event_json->order->status) && $event_json->order->status == 'completed' && isset($event_json->order->total_native) && isset($event_json->order->custom)) {
                         // crab out the custom bits so we know what to deal with.
                         $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                         $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                         if ($invoice_payment_subscription_id) {
                             // this API result is for a subscription payment.
                             $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                             if ($invoice_payment_subscription && $invoice_payment_subscription['invoice_payment_subscription_id'] == $invoice_payment_subscription_id && $currency['code'] == $event_json->order->total_native->currency_iso) {
                                 if (!$invoice_payment_subscription['date_start'] || $invoice_payment_subscription['date_start'] == '0000-00-00') {
                                     // no start date yet, set the start date now (this should really happen in the above callback, but coinbase isn't working right now)
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d')));
                                 }
                                 // we have a subscription payment. woo!
                                 // this gets a bit tricky, we have to work out if the invoice has been generated for this subscription yet.
                                 // if this invoice hasn't been generated yet then we have to generate it.
                                 // pass this back to the invoice class so we can reuse this feature in the future.
                                 $data = module_invoice::create_new_invoice_for_subscription_payment($invoice_id, $invoice_payment_id, $invoice_payment_subscription_id);
                                 if ($data && $data['invoice_id'] && $data['invoice_payment_id']) {
                                     $next_time = time();
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['days']) . ' days', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['months']) . ' months', $next_time);
                                     $next_time = strtotime('+' . abs((int) $invoice_payment_subscription['years']) . ' years', $next_time);
                                     update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('date_last_pay' => date('Y-m-d'), 'date_next' => date('Y-m-d', $next_time)));
                                     update_insert("invoice_payment_id", $data['invoice_payment_id'], "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100, 'method' => self::get_payment_method_name() . ' (Subscription)', 'invoice_payment_subscription_id' => $invoice_payment_subscription_id));
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Invoice Payment Subscription Received!");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Destination Address: " . $event_json->order->receive_address);
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Currency code matches, marking invoice as paid.");
                                     self::add_payment_data($data['invoice_payment_id'], 'log', "Raw Event Data: \n" . json_encode($event_json));
                                     module_invoice::save_invoice($data['invoice_id'], array());
                                     echo "Successful Subscription Payment!";
                                 } else {
                                     send_error("Coinbase Subscription Error (failed to generate new invoice!) " . var_export($data, true));
                                 }
                             } else {
                                 send_error('Currency code missmatch on coinbase subscription payment');
                             }
                         } else {
                             // this is a normal once off payment.
                             self::add_payment_data($invoice_payment_id, 'log', "API IP is " . $_SERVER['REMOTE_ADDR']);
                             self::add_payment_data($invoice_payment_id, 'log', "Received BTC: " . $event_json->order->total_btc->cents / 10000000);
                             self::add_payment_data($invoice_payment_id, 'log', "Received " . $event_json->order->total_native->currency_iso . ': ' . $event_json->order->total_native->cents / 100);
                             self::add_payment_data($invoice_payment_id, 'log', "Destination Address: " . $event_json->order->receive_address);
                             if ($currency['code'] == $event_json->order->total_native->currency_iso) {
                                 self::add_payment_data($invoice_payment_id, 'log', "Currency code matches, marking invoice as paid.");
                                 update_insert("invoice_payment_id", $invoice_payment_id, "invoice_payment", array('date_paid' => date('Y-m-d'), 'amount' => $event_json->order->total_native->cents / 100));
                                 module_invoice::save_invoice($invoice_id, array());
                                 echo "Successful Payment!";
                                 $success = true;
                             } else {
                                 self::add_payment_data($invoice_payment_id, 'log', "Currency code missmatch, please check settings!");
                             }
                             self::add_payment_data($invoice_payment_id, 'log', "Raw Event Data: \n" . json_encode($event_json));
                         }
                     }
                 }
             }
             $debug = ob_get_clean();
             if (module_config::c('coinbase_payment_debug', 0)) {
                 send_error("Coinbase Debug: {$debug}");
             }
             exit;
             break;
         case 'pay_subscription':
             $invoice_id = isset($_REQUEST['invoice_id']) ? $_REQUEST['invoice_id'] : false;
             $invoice_payment_id = isset($_REQUEST['invoice_payment_id']) ? $_REQUEST['invoice_payment_id'] : false;
             $invoice_payment_subscription_id = isset($_REQUEST['invoice_payment_subscription_id']) ? $_REQUEST['invoice_payment_subscription_id'] : false;
             $coinbase_plan_id = isset($_REQUEST['coinbase_plan_id']) ? $_REQUEST['coinbase_plan_id'] : false;
             $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : false;
             if ($invoice_id && $invoice_payment_id && $coinbase_plan_id && $invoice_payment_subscription_id && $user_id && isset($_POST['coinbaseToken'])) {
                 $user_data = module_user::get_user($user_id);
                 $email = isset($_REQUEST['coinbaseEmail']) && strlen($_REQUEST['coinbaseEmail']) ? $_REQUEST['coinbaseEmail'] : $user_data['email'];
                 if (!$email || !strpos($email, '@')) {
                     die('Please ensure your user account has a valid email address before paying with coinbase');
                 }
                 $invoice_payment = get_single('invoice_payment', 'invoice_payment_id', $invoice_payment_id);
                 $invoice_payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $invoice_payment_subscription_id);
                 if (!$invoice_payment || !$invoice_payment_subscription || $invoice_payment['invoice_id'] != $invoice_id || $invoice_payment['invoice_payment_subscription_id'] != $invoice_payment_subscription_id) {
                     die('Invalid invoice payment subscription id');
                 }
                 $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id);
                 $invoice_data = module_invoice::get_invoice($invoice_id);
                 if ($invoice_payment_data && $invoice_data && $invoice_id == $invoice_data['invoice_id'] && $invoice_payment_data['invoice_id'] == $invoice_data['invoice_id']) {
                     $currency = module_config::get_currency($invoice_payment_data['currency_id']);
                     $currency_code = $currency['code'];
                     $description = isset($_REQUEST['description']) ? $_REQUEST['description'] : 'N/A';
                     $template = new module_template();
                     ob_start();
                     require_once 'includes/plugin_paymethod_coinbase/coinbase-php/lib/coinbase.php';
                     $coinbase = array("secret_key" => module_config::c('payment_method_coinbase_api_key'), "publishable_key" => module_config::c('payment_method_coinbase_secret_key'));
                     coinbase::setApiKey($coinbase['secret_key']);
                     try {
                         // todo- search for existing customer based on email address???
                         // todo: check if adding new plan to existing customer work??
                         $coinbase_customer = coinbase_Customer::create(array("card" => $_POST['coinbaseToken'], "email" => $email, 'metadata' => array('user_id' => $user_id)));
                         if ($coinbase_customer && $coinbase_customer->id) {
                             //} && $coinbase_customer->subscriptions){
                             $coinbase_subscription = $coinbase_customer->subscriptions->create(array('plan' => $coinbase_plan_id));
                             if ($coinbase_subscription && $coinbase_subscription->id) {
                                 update_insert('invoice_payment_subscription_id', $invoice_payment_subscription_id, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_ACTIVE, 'date_start' => date('Y-m-d'), 'coinbase_customer' => $coinbase_customer->id, 'coinbase_subscription' => $coinbase_subscription->id));
                                 module_paymethod_coinbase::add_payment_data($invoice_payment_id, 'log', "Started coinbase Subscription: " . var_export(array('customer.id' => $coinbase_customer->id, 'plan.id' => $coinbase_plan_id, 'subscription.id' => $coinbase_subscription->id), true));
                                 // success!
                                 // redirect to receipt page.
                                 redirect_browser(module_invoice::link_public_payment_complete($invoice_id));
                             } else {
                                 echo 'Failed to create subscription with coinbase';
                             }
                         }
                         $error = "Something went wrong during coinbase payment. Please confirm invoice payment went through: " . htmlspecialchars($description);
                         send_error($error);
                         echo $error;
                     } catch (coinbase_CardError $e) {
                         // The card has been declined
                         $body = $e->getJsonBody();
                         $err = $body['error'];
                         $error = "Sorry: Payment failed. <br><br>\n\n" . htmlspecialchars($description) . ". <br><br>\n\n";
                         $error .= $err['message'];
                         echo $error;
                         $error .= "\n\n\n" . var_export($err, true);
                         send_error($error);
                     } catch (Exception $e) {
                         $body = $e->getJsonBody();
                         $err = $body['error'];
                         $error = "Sorry: Payment failed. <br><br>\n\n" . htmlspecialchars($description) . ". <br><br>\n\n";
                         $error .= $err['message'];
                         echo $error;
                         $error .= "\n\n\n" . var_export($err, true);
                         send_error($error);
                     }
                     $template->content = ob_get_clean();
                     echo $template->render('pretty_html');
                     exit;
                 }
             }
             echo 'Error paying via coinbase';
             exit;
     }
 }
Пример #20
0
 public static function hook_filter_var_invoice_email_template($callback, $template_name, $invoice_id, $invoice_data)
 {
     // we check if this invoice is part of a subscription
     if ($template_name) {
         $number_of_past_invoices = 0;
         $subscription_history_item = get_single('subscription_history', 'invoice_id', $invoice_id);
         if ($subscription_history_item && $subscription_history_item['subscription_owner_id']) {
             // we have an invoice that is on a subscription!
             $subscription_owner = module_subscription::get_subscription_owner($subscription_history_item['subscription_owner_id']);
             // check if there are unpaid invoices that were generated after this invoice.
             if ($subscription_owner['subscription_owner_id'] == $subscription_history_item['subscription_owner_id']) {
                 $history = get_multiple('subscription_history', array('subscription_owner_id' => $subscription_owner['subscription_owner_id']));
                 foreach ($history as $h) {
                     if (!$h['invoice_id']) {
                     } else {
                         $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                         if ($invoice_data['date_cancel'] != '0000-00-00') {
                             continue;
                         }
                         $number_of_past_invoices++;
                     }
                 }
             }
             $template_test = module_template::get_template_by_key($template_name . '_' . $number_of_past_invoices);
             if ($template_test->template_id > 0) {
                 return $template_test->template_key;
             }
         }
     }
     return $template_name;
 }
Пример #21
0
 foreach ($data_field_groups as $data_field_group) {
     $data_field_group_id = $data_field_group['data_field_group_id'];
     $data_field_group = $module->get_data_field_group($data_field_group_id);
     $data_fields = $module->get_data_fields($data_field_group_id);
     foreach ($data_fields as $data_field) {
         $data_field_id = $data_field['data_field_id'];
         if (isset($data_items[$data_field_id])) {
             $data_field['value'] = $data_items[$data_field_id]['data_text'];
             // todo, could be data_number or data_varchar as well... hmmm
         }
         $replace[$data_field['title']] = $module->get_form_element($data_field, true, isset($data_record) ? $data_record : array());
     }
 }
 ob_end_clean();
 ob_start();
 $template = module_template::get_template_by_key($data_type['print_pdf_template']);
 if (!$template || $template->template_key != $data_type['print_pdf_template']) {
     echo "PDF template " . $data_type['print_pdf_template'] . " not found";
 } else {
     $template->assign_values($replace);
     echo $template->render('html');
 }
 $html_output = ob_get_clean();
 $pdf_name = basename(preg_replace('#[^a-zA-Z0-9_]#', '_', $data_type['data_type_name']));
 $html_file_name = _UCM_FOLDER . 'temp/data_' . $pdf_name . '.html';
 $pdf_file_name = _UCM_FOLDER . 'temp/data_' . $pdf_name . '.pdf';
 file_put_contents($html_file_name, $html_output);
 $pdf_file = convert_html2pdf($html_file_name, $pdf_file_name);
 @ob_end_clean();
 @ob_end_clean();
 // send pdf headers and prompt the user to download the PDF
Пример #22
0
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!module_config::can_i('view', 'Settings')) {
    redirect_browser(_BASE_HREF);
}
print_heading('Settings');
module_config::print_settings_form(array(array('key' => 'payment_method_other_enabled', 'default' => 0, 'type' => 'checkbox', 'description' => 'Enable Payment Method'), array('key' => 'payment_method_other_enabled_default', 'default' => 1, 'type' => 'checkbox', 'description' => 'Available By Default On Invoices', 'help' => 'If this option is enabled, all new invoices will have this payment method available. If this option is disabled, it will have to be enabled on individual invoices.'), array('key' => 'payment_method_other_label', 'default' => 'Other', 'type' => 'text', 'description' => 'Name this payment method')));
print_heading('Templates');
echo module_template::link_open_popup('paymethod_other');
echo module_template::link_open_popup('paymethod_other_details');
Пример #23
0
 public static function email_invoice_to_customer($invoice_id, $debug = false)
 {
     // this is a copy of some of the code in invoie_admin_email.php
     // used in the CRON job when sending out automated emails.
     $invoice = module_invoice::get_invoice($invoice_id);
     // template for sending emails.
     // are we sending the paid one? or the dueone.
     $template_name = '';
     $template_prefix = isset($invoice['invoice_template_email']) && strlen($invoice['invoice_template_email']) ? $invoice['invoice_template_email'] : 'invoice_email';
     if (isset($invoice['credit_note_id']) && $invoice['credit_note_id']) {
         $template_name = 'credit_note_email';
     } else {
         if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
             $template_name = $template_prefix . '_paid';
         } else {
             if ($invoice['overdue'] && $invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                 $template_name = $template_prefix . '_overdue';
             } else {
                 $template_name = $template_prefix . '_due';
             }
         }
     }
     $template_name = hook_filter_var('invoice_email_template', $template_name, $invoice_id, $invoice);
     if (class_exists('module_company', false) && isset($invoice_data['company_id']) && (int) $invoice_data['company_id'] > 0) {
         module_company::set_current_company_id($invoice_data['company_id']);
     }
     $template = module_template::get_template_by_key($template_name);
     if (!$template || $template->template_key != $template_name) {
         // backup default templates incase someone has chosen a template that doesn't exist (eg: created invoice_email_MINE_due but not invoice_email_MINE_paid )
         $template_prefix = 'invoice_email';
         if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
             $template_name = $template_prefix . '_paid';
         } else {
             if ($invoice['overdue'] && $invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                 $template_name = $template_prefix . '_overdue';
             } else {
                 $template_name = $template_prefix . '_due';
             }
         }
     }
     $replace = module_invoice::get_replace_fields($invoice_id, $invoice);
     if (defined('_BLOCK_EMAILS') && _BLOCK_EMAILS) {
         $pdf = false;
     } else {
         $pdf = module_invoice::generate_pdf($invoice_id);
     }
     $send_email_to = array();
     $to = array();
     if ($invoice['customer_id']) {
         $customer = module_customer::get_customer($invoice['customer_id']);
         $replace['customer_name'] = $customer['customer_name'];
         if ($invoice['user_id']) {
             // this invoice has a manually assigned user, only send the invoice to this user.
             // todo: should we also send to accounts? not sure - see if peopel complain
             $primary = module_user::get_user($invoice['user_id']);
             if ($primary) {
                 $send_email_to[] = $primary;
             }
         } else {
             $to = module_user::get_contacts(array('customer_id' => $invoice['customer_id']));
             // hunt for 'accounts' extra field
             $field_to_find = strtolower(module_config::c('accounts_extra_field_name', 'Accounts'));
             foreach ($to as $contact) {
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact['user_id']));
                 foreach ($extras as $e) {
                     if (strtolower($e['extra_key']) == $field_to_find) {
                         // this is the accounts contact - woo!
                         $send_email_to[] = $contact;
                     }
                 }
             }
             if (!count($send_email_to) && $customer['primary_user_id']) {
                 $primary = module_user::get_user($customer['primary_user_id']);
                 if ($primary) {
                     $send_email_to[] = $primary;
                 }
             }
         }
     } else {
         if ($invoice['member_id']) {
             $member = module_member::get_member($invoice['member_id']);
             $to = array($member);
             $replace['customer_name'] = $member['first_name'];
         } else {
             $to = array();
         }
     }
     $template->assign_values($replace);
     $html = $template->render('html');
     // send an email to this user.
     $email = module_email::new_email();
     $email->replace_values = $replace;
     // todo: send to all customer contacts ?
     if ($send_email_to) {
         foreach ($send_email_to as $send_email_t) {
             if (!empty($send_email_t['user_id'])) {
                 $email->set_to('user', $send_email_t['user_id']);
             } else {
                 if (!empty($send_email_t['email'])) {
                     $email->set_to_manual($send_email_t['email']);
                 }
             }
         }
     } else {
         foreach ($to as $t) {
             if (!empty($t['user_id'])) {
                 $email->set_to('user', $t['user_id']);
             } else {
                 if (!empty($t['email'])) {
                     $email->set_to_manual($t['email']);
                 }
             }
             break;
             // only 1? todo: all?
         }
     }
     $email->set_bcc_manual(module_config::c('admin_email_address', ''), '');
     //$email->set_from('user',); // nfi
     $email->set_subject($template->description);
     // do we send images inline?
     $email->set_html($html);
     if ($pdf) {
         $email->add_attachment($pdf);
     }
     $email->invoice_id = $invoice_id;
     $email->customer_id = $invoice['customer_id'];
     $email->prevent_duplicates = true;
     if ($email->send($debug)) {
         // it worked successfully!!
         // record a log on the invoice when it's done.
         self::email_sent(array('invoice_id' => $invoice_id, 'template_name' => $template_name));
         return true;
     } else {
         /// log err?
         return false;
     }
 }
Пример #24
0
 public static function process_password_reset()
 {
     // grab our email template and send it to this email address.
     $email = trim(strtolower($_REQUEST['email']));
     $success = false;
     if (strlen($email) > 4 && strpos($email, '@')) {
         $users = module_user::get_users(array('email' => $email));
         $contacts = module_user::get_contacts(array('email' => $email));
         $users = array_merge($users, $contacts);
         foreach ($users as $user) {
             // send auto login link for this user.
             if (strtolower($user['email']) == $email) {
                 $template = module_template::get_template_by_key('password_reset');
                 $template->assign_values($user);
                 if ($user['customer_id']) {
                     $url = module_user::link_open_contact($user['user_id'], false, $user, true);
                 } else {
                     $url = module_user::link_open($user['user_id'], false, $user, true);
                 }
                 $url .= (strpos($url, '?') ? '&' : '?') . 'reset_password='******'user_id']);
                 $url .= '&auto_login='******'user_id']);
                 $template->assign_values(array('auto_login_url' => $url));
                 $html = $template->render('html');
                 $email = module_email::new_email();
                 $email->replace_values = $user;
                 $email->set_to('user', $user['user_id']);
                 $email->set_subject($template->description);
                 // do we send images inline?
                 $email->set_html($html);
                 if ($email->send()) {
                     // it worked successfully!!
                     $success = true;
                 } else {
                     /// log err?
                     echo 'failed to send email, sorry';
                     exit;
                 }
             }
         }
     }
     if ($success || !module_config::c('password_reset_debug', 0)) {
         set_message('Please check your email for password reset instructions.');
     } else {
         echo 'No users found matching ' . htmlspecialchars($email);
         exit;
     }
     redirect_browser(_BASE_HREF);
 }
Пример #25
0
         <td align="center">
             <a href="{ITEM_PAYMENT_RECEIPT_URL}" target="_blank">{l:View Receipt}</a>
         </td>
     </tr>
 </table>
 <?php 
 module_template::init_template('invoice_payment_history_basic', ob_get_clean(), 'Used when displaying the invoice payment history in the basic invoice template.', 'code');
 $t = false;
 if (isset($invoice_template_suffix) && strlen($invoice_template_suffix) > 0) {
     $t = module_template::get_template_by_key('invoice_payment_history' . $invoice_template_suffix);
     if (!$t->template_id) {
         $t = false;
     }
 }
 if (!$t) {
     $t = module_template::get_template_by_key('invoice_payment_history');
 }
 $replace = array();
 if (!isset($mode) || $mode == 'html') {
     $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 = '';
Пример #26
0
        }
    }
} else {
    // show normal unsubscribe form. asking for their email address.
    if (isset($_REQUEST['email']) && trim($_REQUEST['email'])) {
        $email = htmlspecialchars(strtolower(trim($_REQUEST['email'])));
        if (!module_newsletter::unsubscribe_member_via_email($email)) {
            echo 'Unsubscribe failed... Please enter a valid email address.';
            exit;
        }
        // is the newsletter module giving us a subscription redirection?
        if (module_config::c('newsletter_unsubscribe_redirect', '')) {
            redirect_browser(module_config::c('newsletter_unsubscribe_redirect', ''));
        }
        // or display a message.
        $template = module_template::get_template_by_key('newsletter_unsubscribe_done');
        $data['email'] = $email;
        $template->page_title = htmlspecialchars(_l('Unsubscribe'));
        $template->assign_values($data);
        echo $template->render('pretty_html');
        exit;
    }
    $template = module_template::get_template_by_key('newsletter_unsubscribe');
    $data['email'] = '';
    // to be sure to be sure
    $template->page_title = htmlspecialchars(_l('Unsubscribe'));
    $template->assign_values($data);
    echo $template->render('pretty_html');
    exit;
}
// show different templates.
Пример #27
0
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
if (!$quote_safe) {
    die('failed');
}
if (!module_quote::can_i('edit', 'Quotes')) {
    die('no perms');
}
$quote_id = (int) $_REQUEST['quote_id'];
$quote = module_quote::get_quote($quote_id);
// template for sending emails.
// are we sending the paid one? or the dueone.
//$template_name = 'quote_email';
$template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'quote_email';
$template = module_template::get_template_by_key($template_name);
$quote['total_amount_print'] = dollar($quote['total_amount'], true, $quote['currency_id']);
$quote['total_amount_due_print'] = dollar($quote['total_amount_due'], true, $quote['currency_id']);
$quote['quote_name'] = $quote['name'];
$quote['from_name'] = module_security::get_loggedin_name();
$quote['quote_url'] = module_quote::link_public($quote_id);
ob_start();
include module_theme::include_ucm('includes/plugin_quote/template/quote_task_list.php');
$public_html = ob_get_clean();
$quote['task_list'] = $public_html;
/*ob_start();
$quote_data = $quote;
$ignore_task_hook=true;
$for_email=true;
include('quote_public.php');
$quote['quote_tasks'] = ob_get_clean();*/
Пример #28
0
 public static function template_handle_save($template_id, $data)
 {
     // check if we're savniga company id and that this user has access to this company, and permissions to edit templates.
     $company_id = isset($_REQUEST['company_id']) ? (int) $_REQUEST['company_id'] : false;
     if ($company_id) {
         $company = self::get_company($company_id);
         if ($company) {
             $existing_template = module_template::get_template($template_id);
             if ($existing_template && $existing_template['template_id'] == $template_id) {
                 // we're saving a template for this particular company.
                 // if it's an empty template content then we remove this company template so it reverts to the system default.
                 if (isset($data['content']) && !strlen(trim($data['content']))) {
                     delete_from_db('company_template', array('company_id', 'template_id'), array($company_id, $template_id));
                     set_message('Company template successfully reset to default');
                     redirect_browser(module_template::link_open($template_id));
                 } else {
                     $sql = 'REPLACE INTO `' . _DB_PREFIX . "company_template` SET company_id = " . (int) $company_id . ", `template_id` = " . (int) $template_id . ", `description` = '" . mysql_real_escape_string(isset($data['description']) ? $data['description'] : '') . "', `content` = '" . mysql_real_escape_string(isset($data['content']) ? $data['content'] : '') . "', `wysiwyg` = '" . mysql_real_escape_string(isset($data['wysiwyg']) ? $data['wysiwyg'] : '') . "'";
                     query($sql);
                     set_message('Unique company template successfully updated');
                     redirect_browser(module_template::link_open($template_id) . '&company_id=' . $company_id);
                 }
             }
         }
     }
 }
Пример #29
0
        echo '<strong>{' . htmlspecialchars($key) . '}</strong>';
        if ($val && !is_array($val)) {
            echo ' ' . htmlspecialchars($val);
        }
        echo '</li>';
    }
} else {
}
?>

	        </ul>
            <br/><br/>

        </td>
    </tr>


    </tbody>
</table>

    <?php 
$fieldset_data = array('heading' => array('type' => 'h2', 'main' => true, 'title' => 'Edit Template'), 'elements_before' => ob_get_clean());
echo module_form::generate_fieldset($fieldset_data);
unset($fieldset_data);
$form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !(module_template::can_i('delete', 'Templates') && (int) $template_id > 0), 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link('template', array('template_id' => false)) . "';")));
echo module_form::generate_form_actions($form_actions);
?>


</form>
Пример #30
0
    </tr>
    </thead>
    <tbody>
    <?php 
$c = 0;
foreach ($templates as $template) {
    $template = module_template::get_template($template['template_id']);
    ?>

        <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
            <td class="row_action">
	            <?php 
    echo module_template::link_open($template['template_id'], true);
    ?>

            </td>
			<td>
				<?php 
    echo htmlspecialchars($template['description']);
    ?>

			</td>
        </tr>
	<?php 
}
?>

  </tbody>