コード例 #1
0
ファイル: job.php プロジェクト: sgh1986915/php-crm
 public static function get_jobs($search = array(), $return_options = array())
 {
     // limit based on customer id
     /*if(!isset($_REQUEST['customer_id']) || !(int)$_REQUEST['customer_id']){
     			return array();
     		}*/
     $cache_key = 'get_jobs_' . md5(serialize(array($search, $return_options)));
     if ($cached_item = module_cache::get('job', $cache_key)) {
         return $cached_item;
     }
     $cache_timeout = module_config::c('cache_objects', 60);
     // build up a custom search sql query based on the provided search fields
     $sql = "SELECT ";
     if (isset($return_options['columns'])) {
         $sql .= $return_options['columns'];
     } else {
         $sql .= "u.*,u.job_id AS id ";
         $sql .= ", u.name AS name ";
         $sql .= ", c.customer_name ";
         if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
             $sql .= ", w.name AS website_name";
             // for export
         }
         $sql .= ", us.name AS staff_member";
         // for export
     }
     $from = " FROM `" . _DB_PREFIX . "job` u ";
     $from .= " LEFT JOIN `" . _DB_PREFIX . "customer` c USING (customer_id)";
     if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
         $from .= " LEFT JOIN `" . _DB_PREFIX . "website` w ON u.website_id = w.website_id";
         // for export
     }
     $from .= " LEFT JOIN `" . _DB_PREFIX . "user` us ON u.user_id = us.user_id";
     // for export
     $where = " WHERE 1 ";
     if (is_array($return_options) && isset($return_options['custom_where'])) {
         // put in return options so harder to push through from user end.
         $where .= $return_options['custom_where'];
     }
     if (isset($search['generic']) && $search['generic']) {
         $str = mysql_real_escape_string($search['generic']);
         $where .= " AND ( ";
         $where .= " u.name LIKE '%{$str}%' ";
         //OR ";
         //$where .= " u.url LIKE '%$str%'  ";
         $where .= ' ) ';
     }
     if (isset($search['date_start_after']) && $search['date_start_after'] !== '' && $search['date_start_after'] !== false) {
         $date = input_date($search['date_start_after']);
         $where .= " AND u.`date_start` >= '" . mysql_real_escape_string($date) . "'";
     }
     if (isset($search['date_start_before']) && $search['date_start_before'] !== '' && $search['date_start_before'] !== false) {
         $date = input_date($search['date_start_before']);
         $where .= " AND u.`date_start` != '0000-00-00' AND u.`date_start` <= '" . mysql_real_escape_string($date) . "'";
     }
     if (isset($search['task_due_after']) && $search['task_due_after'] !== '' && $search['task_due_after'] !== false) {
         $date = input_date($search['task_due_after']);
         if (!strpos($from, 'task`')) {
             $from .= " LEFT JOIN `" . _DB_PREFIX . "task` ts ON u.job_id = ts.job_id ";
         }
         $where .= " AND ts.`date_due` >= '" . mysql_real_escape_string($date) . "'";
     }
     if (isset($search['task_due_before']) && $search['task_due_before'] !== '' && $search['task_due_before'] !== false) {
         $date = input_date($search['task_due_before']);
         if (!strpos($from, 'task`')) {
             $from .= " LEFT JOIN `" . _DB_PREFIX . "task` ts ON u.job_id = ts.job_id ";
         }
         $where .= " AND ts.`date_due` != '0000-00-00' AND ts.`date_due` <= '" . mysql_real_escape_string($date) . "'";
     }
     if (isset($search['user_id']) && $search['user_id'] !== '' && $search['user_id'] !== false && (int) $search['user_id'] > 0) {
         $user_id = (int) $search['user_id'];
         if (!strpos($from, 'task`')) {
             $from .= " LEFT JOIN `" . _DB_PREFIX . "task` ts ON u.job_id = ts.job_id ";
         }
         $where .= " AND ( u.`user_id` = {$user_id} OR `ts`.`user_id` = {$user_id} ) ";
     }
     if (strpos($sql, 'ts.') && !strpos($from, 'task')) {
         $from .= " LEFT JOIN `" . _DB_PREFIX . "task` ts ON u.job_id = ts.job_id ";
     }
     if (isset($search['group_id']) && trim($search['group_id'])) {
         $str = (int) $search['group_id'];
         $from .= " LEFT JOIN `" . _DB_PREFIX . "group_member` gm ON (u.job_id = gm.owner_id)";
         $where .= " AND (gm.group_id = '{$str}' AND gm.owner_table = 'job')";
     }
     if (isset($search['extra_fields']) && is_array($search['extra_fields']) && class_exists('module_extra', false)) {
         $extra_fields = array();
         foreach ($search['extra_fields'] as $key => $val) {
             if (strlen(trim($val))) {
                 $extra_fields[$key] = trim($val);
             }
         }
         if (count($extra_fields)) {
             $from .= " LEFT JOIN `" . _DB_PREFIX . "extra` ext ON (ext.owner_id = u.job_id)";
             //AND ext.owner_table = 'customer'
             $where .= " AND (ext.owner_table = 'job' AND ( ";
             foreach ($extra_fields as $key => $val) {
                 $val = mysql_real_escape_string($val);
                 $key = mysql_real_escape_string($key);
                 $where .= "( ext.`extra` LIKE '%{$val}%' AND ext.`extra_key` = '{$key}') OR ";
             }
             $where = rtrim($where, ' OR');
             $where .= ' ) )';
         }
     }
     foreach (array('customer_id', 'website_id', 'renew_job_id', 'status', 'type', 'date_start', 'date_quote', 'quote_id') as $key) {
         if (isset($search[$key]) && $search[$key] !== '' && $search[$key] !== false) {
             $str = mysql_real_escape_string($search[$key]);
             if ($str[0] == '!') {
                 // hack for != sql searching.
                 $str = ltrim($str, '!');
                 $where .= " AND u.`{$key}` != '{$str}'";
             } else {
                 $where .= " AND u.`{$key}` = '{$str}'";
             }
         }
     }
     if (isset($search['completed']) && (int) $search['completed'] > 0) {
         switch ($search['completed']) {
             case 1:
                 // both complete and not complete jobs, dont modify query
                 break;
             case 2:
                 // only completed jobs.
                 $where .= " AND u.date_completed != '0000-00-00'";
                 break;
             case 3:
                 // only non-completed jobs.
                 $where .= " AND u.date_completed = '0000-00-00'";
                 break;
             case 4:
                 // only quoted jobs
                 $where .= " AND u.date_start = '0000-00-00' AND u.date_quote != '0000-00-00'";
                 break;
             case 5:
                 // only not started jobs
                 $where .= " AND u.date_start = '0000-00-00'";
                 break;
         }
     }
     if (isset($return_options['custom_group_by'])) {
         $group_order = $return_options['custom_group_by'];
     } else {
         $group_order = ' GROUP BY u.job_id ORDER BY u.name';
     }
     switch (self::get_job_access_permissions()) {
         case _JOB_ACCESS_ALL:
             break;
         case _JOB_ACCESS_ASSIGNED:
             // only assigned jobs!
             $from .= " LEFT JOIN `" . _DB_PREFIX . "task` t ON u.job_id = t.job_id ";
             $where .= " AND (u.user_id = " . (int) module_security::get_loggedin_id() . " OR t.user_id = " . (int) module_security::get_loggedin_id() . ")";
             break;
         case _JOB_ACCESS_CUSTOMER:
             // tie in with customer permissions to only get jobs from customers we can access.
             $customers = module_customer::get_customers();
             if (count($customers)) {
                 $where .= " AND u.customer_id IN ( ";
                 foreach ($customers as $customer) {
                     $where .= $customer['customer_id'] . ', ';
                 }
                 $where = rtrim($where, ', ');
                 $where .= " ) ";
             }
             break;
     }
     // tie in with customer permissions to only get jobs from customers we can access.
     switch (module_customer::get_customer_data_access()) {
         case _CUSTOMER_ACCESS_ALL:
             // all customers! so this means all jobs!
             break;
         case _CUSTOMER_ACCESS_ALL_COMPANY:
         case _CUSTOMER_ACCESS_CONTACTS:
         case _CUSTOMER_ACCESS_TASKS:
         case _CUSTOMER_ACCESS_STAFF:
             $valid_customer_ids = module_security::get_customer_restrictions();
             if (count($valid_customer_ids)) {
                 $where .= " AND ( u.customer_id = 0 OR u.customer_id IN ( ";
                 foreach ($valid_customer_ids as $valid_customer_id) {
                     $where .= (int) $valid_customer_id . ", ";
                 }
                 $where = rtrim($where, ', ');
                 $where .= " )";
                 $where .= " )";
             }
     }
     $sql = $sql . $from . $where . $group_order;
     //        echo $sql;print_r(debug_backtrace());exit;
     $result = qa($sql);
     //module_security::filter_data_set("job",$result);
     module_cache::put('job', $cache_key, $result, $cache_timeout);
     return $result;
     //		return get_multiple("job",$search,"job_id","fuzzy","name");
 }
コード例 #2
0
                    ?>
>
                            <label for="paymethodallowed<?php 
                    echo $x;
                    ?>
"><?php 
                    echo $payment_method->get_payment_method_name();
                    ?>
</label> <br/>
                            <?php 
                    $x++;
                }
            }
        }
    }));
    if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
        $fieldset_data['elements'][] = array('title' => module_config::c('project_name_single', 'Website'), 'fields' => array(function () use(&$invoice) {
            $website_ids = isset($invoice['website_ids']) && is_array($invoice['website_ids']) ? $invoice['website_ids'] : (isset($invoice['website_ids']) ? explode(',', $invoice['website_ids']) : array());
            if (!$invoice['website_id']) {
                $invoice['website_id'] = array_shift($website_ids);
            }
            if (module_invoice::can_i('edit', 'Invoices')) {
                $c = array();
                // change between websites within this customer?
                // or websites all together?
                $res = module_website::get_websites(array('customer_id' => isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : ($invoice['customer_id'] ? $invoice['customer_id'] : false)));
                //$res = module_website::get_websites();
                while ($row = array_shift($res)) {
                    $c[$row['website_id']] = $row['name'];
                }
                echo print_select_box($c, 'website_id', $invoice['website_id']);
コード例 #3
0
ファイル: quote.php プロジェクト: sgh1986915/php-crm
 public static function get_quotes($search = array(), $return_options = array())
 {
     // limit based on customer id
     /*if(!isset($_REQUEST['customer_id']) || !(int)$_REQUEST['customer_id']){
     			return array();
     		}*/
     $cache_key = 'get_quotes_' . md5(serialize(array($search, $return_options)));
     if ($cached_item = module_cache::get('quote', $cache_key)) {
         return $cached_item;
     }
     $cache_timeout = module_config::c('cache_objects', 60);
     // build up a custom search sql query based on the provided search fields
     $sql = "SELECT ";
     if (isset($return_options['columns'])) {
         $sql .= $return_options['columns'];
     } else {
         $sql .= "u.*,u.quote_id AS id ";
         $sql .= ", u.name AS name ";
         $sql .= ", c.customer_name ";
         if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
             $sql .= ", w.name AS website_name";
             // for export
         }
         $sql .= ", us.name AS staff_member";
         // for export
     }
     $from = " FROM `" . _DB_PREFIX . "quote` u ";
     $from .= " LEFT JOIN `" . _DB_PREFIX . "customer` c USING (customer_id)";
     if (class_exists('module_website', false) && module_website::is_plugin_enabled()) {
         $from .= " LEFT JOIN `" . _DB_PREFIX . "website` w ON u.website_id = w.website_id";
         // for export
     }
     $from .= " LEFT JOIN `" . _DB_PREFIX . "user` us ON u.user_id = us.user_id";
     // for export
     $where = " WHERE 1 ";
     if (is_array($return_options) && isset($return_options['custom_where'])) {
         // put in return options so harder to push through from user end.
         $where .= $return_options['custom_where'];
     }
     if (isset($search['generic']) && $search['generic']) {
         $str = mysql_real_escape_string($search['generic']);
         $where .= " AND ( ";
         $where .= " u.name LIKE '%{$str}%' ";
         //OR ";
         //$where .= " u.url LIKE '%$str%'  ";
         $where .= ' ) ';
     }
     foreach (array('customer_id', 'website_id', 'status', 'type', 'date_create') as $key) {
         if (isset($search[$key]) && $search[$key] !== '' && $search[$key] !== false) {
             $str = mysql_real_escape_string($search[$key]);
             if ($str[0] == '!') {
                 // hack for != sql searching.
                 $str = ltrim($str, '!');
                 $where .= " AND u.`{$key}` != '{$str}'";
             } else {
                 $where .= " AND u.`{$key}` = '{$str}'";
             }
         }
     }
     if (isset($search['ticket_id']) && (int) $search['ticket_id'] > 0) {
         // join on the ticket_quote_rel tab.e
         $from .= " LEFT JOIN `" . _DB_PREFIX . "ticket_quote_rel` tqr USING (quote_id)";
         $where .= " AND tqr.ticket_id = " . (int) $search['ticket_id'];
     }
     if (isset($search['accepted']) && (int) $search['accepted'] > 0) {
         switch ($search['accepted']) {
             case 1:
                 // both complete and not complete quotes, dont modify query
                 break;
             case 2:
                 // only completed quotes.
                 $where .= " AND u.date_approved != '0000-00-00'";
                 break;
             case 3:
                 // only non-completed quotes.
                 $where .= " AND u.date_approved = '0000-00-00'";
                 break;
         }
     }
     $group_order = ' GROUP BY u.quote_id ORDER BY u.name';
     switch (self::get_quote_access_permissions()) {
         case _QUOTE_ACCESS_ALL:
             break;
         case _QUOTE_ACCESS_ASSIGNED:
             // only assigned quotes!
             $from .= " LEFT JOIN `" . _DB_PREFIX . "quote_task` t ON u.quote_id = t.quote_id ";
             $where .= " AND (u.user_id = " . (int) module_security::get_loggedin_id() . " OR t.user_id = " . (int) module_security::get_loggedin_id() . ")";
             break;
         case _QUOTE_ACCESS_CUSTOMER:
             // tie in with customer permissions to only get quotes from customers we can access.
             $customers = module_customer::get_customers();
             if (count($customers)) {
                 $where .= " AND u.customer_id IN ( ";
                 foreach ($customers as $customer) {
                     $where .= $customer['customer_id'] . ', ';
                 }
                 $where = rtrim($where, ', ');
                 $where .= " ) ";
             }
             break;
     }
     // tie in with customer permissions to only get quotes from customers we can access.
     switch (module_customer::get_customer_data_access()) {
         case _CUSTOMER_ACCESS_ALL:
             // all customers! so this means all quotes!
             break;
         case _CUSTOMER_ACCESS_ALL_COMPANY:
         case _CUSTOMER_ACCESS_CONTACTS:
         case _CUSTOMER_ACCESS_TASKS:
         case _CUSTOMER_ACCESS_STAFF:
             $valid_customer_ids = module_security::get_customer_restrictions();
             if (count($valid_customer_ids)) {
                 $where .= " AND ( u.customer_id = 0 OR u.customer_id IN ( ";
                 foreach ($valid_customer_ids as $valid_customer_id) {
                     $where .= (int) $valid_customer_id . ", ";
                 }
                 $where = rtrim($where, ', ');
                 $where .= " )";
                 $where .= " )";
             }
     }
     $sql = $sql . $from . $where . $group_order;
     //        echo $sql;print_r(debug_backtrace());exit;
     $result = qa($sql);
     //module_security::filter_data_set("quote",$result);
     module_cache::put('quote', $cache_key, $result, $cache_timeout);
     return $result;
     //		return get_multiple("quote",$search,"quote_id","fuzzy","name");
 }
コード例 #4
0
            function customer_admin_email_generate_invoice_list($invoices, $customer_id)
            {
                ob_start();
                $colspan = 9;
                $colspan2 = 0;
                $invoice_total = array();
                $invoice_total_due = array();
                foreach ($invoices as $invoice) {
                    if (!isset($invoice_total[$invoice['currency_id']])) {
                        $invoice_total[$invoice['currency_id']] = 0;
                    }
                    if ($invoice['c_total_amount'] == 0) {
                        $invoice = module_invoice::get_invoice($invoice['invoice_id']);
                    }
                    $invoice_total[$invoice['currency_id']] += $invoice['c_total_amount'];
                    if (!isset($invoice_total_due[$invoice['currency_id']])) {
                        $invoice_total_due[$invoice['currency_id']] = 0;
                    }
                    $invoice_total_due[$invoice['currency_id']] += $invoice['c_total_amount_due'];
                }
                $table_manager = module_theme::new_table_manager();
                $columns = array();
                $columns['invoice_number'] = array('title' => 'Invoice Number', 'callback' => function ($invoice) {
                    //echo module_invoice::link_open($invoice['invoice_id'],true,$invoice);
                    echo '<a href="' . module_invoice::link_public($invoice['invoice_id']) . '">' . htmlspecialchars($invoice['name']) . '</a>';
                }, 'cell_class' => 'row_action');
                $columns['invoice_status'] = array('title' => 'Status', 'callback' => function ($invoice) {
                    echo htmlspecialchars($invoice['status']);
                });
                $columns['invoice_create_date'] = array('title' => 'Create Date', 'callback' => function ($invoice) {
                    if (!$invoice['date_create'] || $invoice['date_create'] == '0000-00-00') {
                        //echo print_date($invoice['date_created']);
                    } else {
                        echo print_date($invoice['date_create']);
                    }
                });
                $columns['invoice_due_date'] = array('title' => 'Due Date', 'callback' => function ($invoice) {
                    if ((!$invoice['date_paid'] || $invoice['date_paid'] == '0000-00-00') && strtotime($invoice['date_due']) < time()) {
                        echo '<span class="error_text">';
                        echo print_date($invoice['date_due']);
                        echo '</span>';
                    } else {
                        echo print_date($invoice['date_due']);
                    }
                });
                $columns['invoice_sent_date'] = array('title' => 'Sent Date', 'callback' => function ($invoice) {
                    if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') {
                        ?>

				            <?php 
                        echo print_date($invoice['date_sent']);
                        ?>

				        <?php 
                    } else {
                        ?>

				            <span class="error_text"><?php 
                        _e('Not sent');
                        ?>
</span>
				        <?php 
                    }
                });
                $columns['invoice_paid_date'] = array('title' => 'Paid Date', 'callback' => function ($invoice) {
                    if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') {
                        ?>

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

				        <?php 
                    } else {
                        if ($invoice['date_cancel'] && $invoice['date_cancel'] != '0000-00-00') {
                            ?>

				            <span class="error_text"><?php 
                            _e('Cancelled');
                            ?>
</span>
				        <?php 
                        } else {
                            if ($invoice['overdue']) {
                                ?>

				            <span class="error_text" style="font-weight: bold; text-decoration: underline;"><?php 
                                _e('Overdue');
                                ?>
</span>
				        <?php 
                            } else {
                                ?>

				            <span class="error_text"><?php 
                                _e('Not paid');
                                ?>
</span>
				        <?php 
                            }
                        }
                    }
                });
                if (class_exists('module_website', false) && module_website::is_plugin_enabled() && module_website::can_i('view', module_config::c('project_name_plural', 'Websites'))) {
                    $colspan++;
                    $columns['invoice_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($invoice) {
                        if (isset($invoice['website_ids'])) {
                            foreach ($invoice['website_ids'] as $website_id) {
                                if ((int) $website_id > 0) {
                                    echo module_website::link_open($website_id, true);
                                    echo '<br/>';
                                }
                            }
                        }
                    });
                }
                $columns['invoice_job'] = array('title' => 'Job', 'callback' => function ($invoice) {
                    foreach ($invoice['job_ids'] as $job_id) {
                        if ((int) $job_id > 0) {
                            //echo module_job::link_open($job_id,true);
                            $job_data = module_job::get_job($job_id);
                            echo '<a href="' . module_job::link_public($job_id) . '">' . htmlspecialchars($job_data['name']) . '</a>';
                            if ($job_data['date_start'] && $job_data['date_start'] != '0000-00-00' && $job_data['date_renew'] && $job_data['date_renew'] != '0000-00-00') {
                                _e(' (%s to %s)', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew']))));
                            }
                            echo "<br/>\n";
                        }
                    }
                    hook_handle_callback('invoice_admin_list_job', $invoice['invoice_id']);
                });
                if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
                    $colspan++;
                    $columns['invoice_customer'] = array('title' => 'Customer', 'callback' => function ($invoice) {
                        echo module_customer::link_open($invoice['customer_id'], true);
                    });
                }
                $columns['c_invoice_total'] = array('title' => 'Invoice Total', 'callback' => function ($invoice) {
                    echo dollar($invoice['total_amount'], true, $invoice['currency_id']);
                });
                $columns['c_invoice_total_due'] = array('title' => 'Amount Due', 'callback' => function ($invoice) {
                    echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']);
                    ?>

				        <?php 
                    if ($invoice['total_amount_credit'] > 0) {
                        ?>

				        <span class="success_text"><?php 
                        echo _l('Credit: %s', dollar($invoice['total_amount_credit'], true, $invoice['currency_id']));
                        ?>
</span>
				            <?php 
                    }
                });
                if (class_exists('module_extra', false)) {
                    ob_start();
                    $colspan2 += module_extra::print_table_header('invoice');
                    // used in the footer calc.
                    ob_end_clean();
                    $table_manager->display_extra('invoice', function ($invoice) {
                        module_extra::print_table_data('invoice', $invoice['invoice_id']);
                    });
                }
                $table_manager->set_columns($columns);
                $table_manager->row_callback = function ($row_data) {
                    // load the full vendor data before displaying each row so we have access to more details
                    if (isset($row_data['invoice_id']) && (int) $row_data['invoice_id'] > 0) {
                        return module_invoice::get_invoice($row_data['invoice_id']);
                    }
                    return array();
                };
                $table_manager->set_rows($invoices);
                if (module_config::c('invoice_list_show_totals', 1)) {
                    $footer_rows = array();
                    foreach ($invoice_total + $invoice_total_due as $currency_id => $foo) {
                        $currency = get_single('currency', 'currency_id', $currency_id);
                        $footer_rows[] = array('invoice_number' => array('data' => '<strong>' . _l('%s Totals:', $currency && isset($currency['code']) ? $currency['code'] : '') . '</strong>', 'cell_colspan' => $colspan - 2, 'cell_class' => 'text-right'), 'c_invoice_total' => array('data' => '<strong>' . dollar(isset($invoice_total[$currency_id]) ? $invoice_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'c_invoice_total_due' => array('data' => '<strong>' . dollar(isset($invoice_total_due[$currency_id]) ? $invoice_total_due[$currency_id] : 0, true, $currency_id) . '</strong>'), 'row_bulk_action' => array('data' => ' ', 'cell_colspan' => $colspan2));
                    }
                    $table_manager->set_footer_rows($footer_rows);
                }
                $table_manager->pagination = false;
                $table_manager->print_table();
                return ob_get_clean();
            }
コード例 #5
0
ファイル: customer.php プロジェクト: sgh1986915/php-crm
 public function external_hook($hook)
 {
     switch ($hook) {
         case 'public_signup_form':
             $signup_form = module_template::get_template_by_key('customer_signup_form_wrapper');
             $signup_form->page_title = $signup_form->description;
             $signup_form->assign_values(array('signup_form' => self::get_customer_signup_form_html()));
             echo $signup_form->render('pretty_html');
             exit;
         case 'public_signup':
             // sign out if testing.
             if (module_security::is_logged_in()) {
                 set_message('Logged out due to signup');
                 module_security::logout();
             }
             $result = array('messages' => array());
             function customer_signup_complete($result)
             {
                 if (isset($_REQUEST['via_ajax'])) {
                     echo json_encode($result);
                 } else {
                     echo implode('<br/>', $result['messages']);
                 }
                 exit;
             }
             if (!module_config::c('customer_signup_allowed', 0)) {
                 $result['error'] = 1;
                 $result['messages'][] = 'Customer signup disabled';
                 customer_signup_complete($result);
             }
             //recaptcha on signup form.
             if (module_config::c('captcha_on_signup_form', 0)) {
                 if (!module_captcha::check_captcha_form()) {
                     $result['error'] = 1;
                     $result['messages'][] = 'Captcha fail, please go back and enter correct captcha code.';
                     customer_signup_complete($result);
                 }
             }
             $customer = isset($_POST['customer']) && is_array($_POST['customer']) ? $_POST['customer'] : array();
             $contact = isset($_POST['contact']) && is_array($_POST['contact']) ? $_POST['contact'] : array();
             $contact_extra = isset($contact['extra']) && is_array($contact['extra']) ? $contact['extra'] : array();
             $contact_group = isset($contact['group_ids']) && is_array($contact['group_ids']) ? $contact['group_ids'] : array();
             $customer_extra = isset($customer['extra']) ? $customer['extra'] : array();
             $customer_group = isset($customer['group_ids']) && is_array($customer['group_ids']) ? $customer['group_ids'] : array();
             $address = isset($_POST['address']) ? $_POST['address'] : array();
             $website = isset($_POST['website']) ? $_POST['website'] : array();
             $website_extra = isset($website['extra']) ? $website['extra'] : array();
             $website_group = isset($website['group_ids']) && is_array($website['group_ids']) ? $website['group_ids'] : array();
             $job = isset($_POST['job']) ? $_POST['job'] : array();
             $job_extra = isset($job['extra']) ? $job['extra'] : array();
             $subscription = isset($_POST['subscription']) ? $_POST['subscription'] : array();
             // sanatise possibly problematic fields:
             // customer:
             $allowed = array('name', 'last_name', 'customer_name', 'email', 'phone', 'mobile', 'extra', 'type');
             foreach ($customer as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($customer[$key]);
                 }
             }
             if (isset($customer['type']) && $customer['type'] != _CUSTOMER_TYPE_NORMAL && $customer['type'] != _CUSTOMER_TYPE_LEAD) {
                 unset($customer['type']);
             }
             // added multiple contact support in the form of arrays.
             $contact_fields = array('name', 'last_name', 'email', 'phone');
             if (module_config::c('customer_signup_password', 0)) {
                 $contact_fields[] = 'password';
             }
             foreach ($contact_fields as $multi_value) {
                 if (isset($contact[$multi_value])) {
                     if (!is_array($contact[$multi_value])) {
                         $contact[$multi_value] = array($contact[$multi_value]);
                     }
                 } else {
                     if (isset($customer[$multi_value])) {
                         $contact[$multi_value] = array($customer[$multi_value]);
                     } else {
                         $contact[$multi_value] = array();
                     }
                 }
             }
             $valid_contact_email = false;
             $name_fallback = false;
             $primary_email = false;
             foreach ($contact['email'] as $contact_key => $email) {
                 if (!$name_fallback && isset($contact['name'][$contact_key])) {
                     $name_fallback = $contact['name'][$contact_key];
                 }
                 $contact['email'][$contact_key] = filter_var(strtolower(trim($email)), FILTER_VALIDATE_EMAIL);
                 if ($contact['email'][$contact_key]) {
                     $valid_contact_email = true;
                     if (!$primary_email) {
                         $primary_email = $contact['email'][$contact_key];
                         // set the primary contact details here by adding them to the master customer array
                         foreach ($contact_fields as $primary_contact_field) {
                             $customer[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                             unset($contact[$primary_contact_field][$contact_key]);
                         }
                     }
                 }
             }
             // start error checking / required fields
             if (!isset($customer['customer_name']) || !strlen($customer['customer_name'])) {
                 $customer['customer_name'] = $name_fallback;
             }
             if (!strlen($customer['customer_name'])) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide a customer name.";
             }
             if (!$valid_contact_email || !$primary_email) {
                 $result['error'] = 1;
                 $result['messages'][] = "Failed, please go back and provide an email address.";
             }
             // check all posted required fields.
             function check_required($postdata, $messages = array())
             {
                 if (is_array($postdata)) {
                     foreach ($postdata as $key => $val) {
                         if (strpos($key, '_required') && strlen($val)) {
                             $required_key = str_replace('_required', '', $key);
                             if (!isset($postdata[$required_key]) || !$postdata[$required_key]) {
                                 $messages[] = 'Required field missing: ' . htmlspecialchars($val);
                             }
                         }
                         if (is_array($val)) {
                             $messages = check_required($val, $messages);
                         }
                     }
                 }
                 return $messages;
             }
             $messages = check_required($_POST);
             if (count($messages)) {
                 $result['error'] = 1;
                 $result['messages'] = array_merge($result['messages'], $messages);
             }
             if (isset($result['error'])) {
                 customer_signup_complete($result);
             }
             // end error checking / required fields.
             // check if this customer already exists in the system, based on email address
             $customer_id = false;
             $creating_new = true;
             $_REQUEST['user_id'] = 0;
             if (isset($customer['email']) && strlen($customer['email']) && !module_config::c('customer_signup_always_new', 0)) {
                 $users = module_user::get_contacts(array('email' => $customer['email']));
                 foreach ($users as $user) {
                     if (isset($user['customer_id']) && (int) $user['customer_id'] > 0) {
                         // this user exists as a customer! yey!
                         // add them to this listing.
                         $customer_id = $user['customer_id'];
                         $creating_new = false;
                         $_REQUEST['user_id'] = $user['user_id'];
                         // dont let signups update existing passwords.
                         if (isset($customer['password'])) {
                             unset($customer['password']);
                         }
                         if (isset($customer['new_password'])) {
                             unset($customer['new_password']);
                         }
                     }
                 }
             }
             $_REQUEST['extra_customer_field'] = array();
             $_REQUEST['extra_user_field'] = array();
             module_extra::$config['allow_new_keys'] = false;
             module_extra::$config['delete_existing_empties'] = false;
             // save customer extra fields.
             if (count($customer_extra)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_extra as $key => $val) {
                     $_REQUEST['extra_customer_field'][] = array('key' => $key, 'val' => $val);
                 }
             }
             // save customer and customer contact details:
             $customer_id = $this->save_customer($customer_id, $customer);
             if (!$customer_id) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: failed to create customer.';
                 customer_signup_complete($result);
             }
             $customer_data = module_customer::get_customer($customer_id);
             // todo - merge primary and secondary contact/extra/group saving into a single loop
             if (!$customer_data['primary_user_id']) {
                 $result['error'] = 1;
                 $result['messages'][] = 'System error: Failed to create customer contact.';
                 customer_signup_complete($result);
             } else {
                 $role_id = module_config::c('customer_signup_role', 0);
                 if ($role_id > 0) {
                     module_user::add_user_to_role($customer_data['primary_user_id'], $role_id);
                 }
                 // save contact extra data (repeated below for additional contacts)
                 if (isset($contact_extra[0]) && count($contact_extra[0])) {
                     $_REQUEST['extra_user_field'] = array();
                     foreach ($contact_extra[0] as $key => $val) {
                         $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                     }
                     module_extra::save_extras('user', 'user_id', $customer_data['primary_user_id']);
                 }
                 // save contact groups
                 if (isset($contact_group[0]) && count($contact_group[0])) {
                     foreach ($contact_group[0] as $group_id => $tf) {
                         if ($tf) {
                             module_group::add_to_group($group_id, $customer_data['primary_user_id'], 'user');
                         }
                     }
                 }
             }
             foreach ($contact['email'] as $contact_key => $email) {
                 // add any additional contacts to the customer.
                 $users = module_user::get_contacts(array('email' => $email, 'customer_id' => $customer_id));
                 if (count($users)) {
                     // this contact already exists for this customer, dont update/change it.
                     continue;
                 }
                 $new_contact = array('customer_id' => $customer_id);
                 foreach ($contact_fields as $primary_contact_field) {
                     $new_contact[$primary_contact_field] = isset($contact[$primary_contact_field][$contact_key]) ? $contact[$primary_contact_field][$contact_key] : '';
                 }
                 // dont let additional contacts have passwords.
                 if (isset($new_contact['password'])) {
                     unset($new_contact['password']);
                 }
                 if (isset($new_contact['new_password'])) {
                     unset($new_contact['new_password']);
                 }
                 global $plugins;
                 $contact_user_id = $plugins['user']->create_user($new_contact, 'signup');
                 if ($contact_user_id) {
                     $role_id = module_config::c('customer_signup_role', 0);
                     if ($role_id > 0) {
                         module_user::add_user_to_role($contact_user_id, $role_id);
                     }
                     // save contact extra data  (repeated below for primary contacts)
                     if (isset($contact_extra[$contact_key]) && count($contact_extra[$contact_key])) {
                         $_REQUEST['extra_user_field'] = array();
                         foreach ($contact_extra[$contact_key] as $key => $val) {
                             $_REQUEST['extra_user_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('user', 'user_id', $contact_user_id);
                     }
                     // save contact groups
                     if (isset($contact_group[$contact_key]) && count($contact_group[$contact_key])) {
                         foreach ($contact_group[$contact_key] as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $contact_user_id, 'user');
                             }
                         }
                     }
                 }
             }
             if (count($customer_group)) {
                 // format the address so "save_customer" handles the save for us
                 foreach ($customer_group as $group_id => $tf) {
                     if ($tf) {
                         module_group::add_to_group($group_id, $customer_id, 'customer');
                     }
                 }
             }
             $note_keys = array('customer', 'website', 'job', 'address', 'subscription');
             $note_text = _l('Customer signed up from Signup Form:');
             $note_text .= "\n\n";
             foreach ($note_keys as $note_key) {
                 $note_text .= "\n" . ucwords(_l($note_key)) . "\n";
                 if (isset($_POST[$note_key]) && is_array($_POST[$note_key])) {
                     foreach ($_POST[$note_key] as $post_key => $post_val) {
                         $note_text .= "\n - " . _l($post_key) . ": ";
                         if (is_array($post_val)) {
                             foreach ($post_val as $p => $v) {
                                 $note_text .= "\n  - - " . _l($p) . ': ' . $v;
                             }
                         } else {
                             $note_text .= $post_val;
                         }
                     }
                 }
             }
             $note_data = array('note_id' => false, 'owner_id' => $customer_id, 'owner_table' => 'customer', 'note_time' => time(), 'note' => $note_text, 'rel_data' => module_customer::link_open($customer_id), 'reminder' => 0, 'user_id' => 0);
             update_insert('note_id', false, 'note', $note_data);
             // save customer address fields.
             if (count($address)) {
                 $address_db = module_address::get_address($customer_id, 'customer', 'physical');
                 $address_id = $address_db && isset($address_db['address_id']) ? (int) $address_db['address_id'] : false;
                 $address['owner_id'] = $customer_id;
                 $address['owner_table'] = 'customer';
                 $address['address_type'] = 'physical';
                 // we have post data to save, write it to the table!!
                 module_address::save_address($address_id, $address);
             }
             // website:
             $allowed = array('url', 'name', 'extra', 'notes');
             foreach ($website as $key => $val) {
                 if (!in_array($key, $allowed)) {
                     unset($website[$key]);
                 }
             }
             $website['url'] = isset($website['url']) ? strtolower(trim($website['url'])) : '';
             $website_id = 0;
             if (count($website) && class_exists('module_website', false) && module_website::is_plugin_enabled()) {
                 if (strlen($website['url'])) {
                     // see if website already exists, don't create or update existing one for now.
                     $existing_websites = module_website::get_websites(array('customer_id' => $customer_id, 'url' => $website['url']));
                     foreach ($existing_websites as $existing_website) {
                         $website_id = $existing_website['website_id'];
                     }
                 }
                 //   echo $website_id;echo $website['url']; print_r($website_extra);exit;
                 if (!$website_id) {
                     $website_data = module_website::get_website($website_id);
                     $website_data['url'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['name'] = isset($website['url']) ? $website['url'] : 'N/A';
                     $website_data['customer_id'] = $customer_id;
                     $website_id = update_insert('website_id', false, 'website', $website_data);
                     // save website extra data.
                     if ($website_id && count($website_extra)) {
                         $_REQUEST['extra_website_field'] = array();
                         foreach ($website_extra as $key => $val) {
                             $_REQUEST['extra_website_field'][] = array('key' => $key, 'val' => $val);
                         }
                         module_extra::save_extras('website', 'website_id', $website_id);
                     }
                     if ($website_id && isset($website['notes']) && strlen($website['notes'])) {
                         // add notes to this website.
                         $note_data = array('note_id' => false, 'owner_id' => $website_id, 'owner_table' => 'website', 'note_time' => time(), 'note' => $website['notes'], 'rel_data' => module_website::link_open($website_id), 'reminder' => 0, 'user_id' => $customer_data['primary_user_id']);
                         $note_id = update_insert('note_id', false, 'note', $note_data);
                     }
                 }
                 if ($website_id) {
                     if (count($website_group)) {
                         // format the address so "save_customer" handles the save for us
                         foreach ($website_group as $group_id => $tf) {
                             if ($tf) {
                                 module_group::add_to_group($group_id, $website_id, 'website');
                             }
                         }
                     }
                 }
             }
             // generate jobs for this customer.
             $job_created = array();
             if ($job && isset($job['type']) && is_array($job['type'])) {
                 if (module_config::c('customer_signup_any_job_type', 0)) {
                     foreach ($job['type'] as $type_name) {
                         // we have a match in our system. create the job.
                         $job_data = module_job::get_job(false);
                         $job_data['type'] = $type_name;
                         if (!$job_data['name']) {
                             $job_data['name'] = $type_name;
                         }
                         $job_data['website_id'] = $website_id;
                         $job_data['customer_id'] = $customer_id;
                         $job_id = update_insert('job_id', false, 'job', $job_data);
                         // todo: add default tasks for this job type.
                         $job_created[] = $job_id;
                     }
                 } else {
                     foreach (module_job::get_types() as $type_id => $type) {
                         foreach ($job['type'] as $type_name) {
                             if ($type_name == $type) {
                                 // we have a match in our system. create the job.
                                 $job_data = module_job::get_job(false);
                                 $job_data['type'] = $type;
                                 if (!$job_data['name']) {
                                     $job_data['name'] = $type;
                                 }
                                 $job_data['website_id'] = $website_id;
                                 $job_data['customer_id'] = $customer_id;
                                 $job_id = update_insert('job_id', false, 'job', $job_data);
                                 // todo: add default tasks for this job type.
                                 $job_created[] = $job_id;
                             }
                         }
                     }
                 }
                 if (count($job_created) && count($job_extra)) {
                     // save job extra data.
                     foreach ($job_created as $job_created_id) {
                         if ($job_created_id && count($job_extra)) {
                             $_REQUEST['extra_job_field'] = array();
                             foreach ($job_extra as $key => $val) {
                                 $_REQUEST['extra_job_field'][] = array('key' => $key, 'val' => $val);
                             }
                             module_extra::save_extras('job', 'job_id', $job_created_id);
                         }
                     }
                 }
             }
             // save files against customer
             $uploaded_files = array();
             if (isset($_FILES['customerfiles']) && isset($_FILES['customerfiles']['tmp_name'])) {
                 foreach ($_FILES['customerfiles']['tmp_name'] as $file_id => $tmp_file) {
                     if (is_uploaded_file($tmp_file)) {
                         // save to file module for this customer
                         $file_name = basename($_FILES['customerfiles']['name'][$file_id]);
                         if (strlen($file_name)) {
                             $file_path = 'includes/plugin_file/upload/' . md5(time() . $file_name);
                             if (move_uploaded_file($tmp_file, $file_path)) {
                                 // success! write to db.
                                 $file_data = array('customer_id' => $customer_id, 'job_id' => current($job_created), 'website_id' => $website_id, 'status' => module_config::c('file_default_status', 'Uploaded'), 'pointers' => false, 'description' => "Uploaded from Customer Signup form", 'file_time' => time(), 'file_name' => $file_name, 'file_path' => $file_path, 'file_url' => false);
                                 $file_id = update_insert('file_id', false, 'file', $file_data);
                                 $uploaded_files[] = $file_id;
                             }
                         }
                     }
                 }
             }
             // we create subscriptions for this customer/website (if none already exist)
             $subscription['subscription_name'] = array();
             $subscription['subscription_invoice'] = array();
             if (class_exists('module_subscription', false) && module_subscription::is_plugin_enabled() && isset($subscription['for']) && isset($subscription['subscriptions'])) {
                 if ($subscription['for'] == 'website' && $website_id > 0) {
                     $owner_table = 'website';
                     $owner_id = $website_id;
                 } else {
                     $owner_table = 'customer';
                     $owner_id = $customer_id;
                 }
                 $available_subscriptions = module_subscription::get_subscriptions();
                 $members_subscriptions = module_subscription::get_subscriptions_by($owner_table, $owner_id);
                 foreach ($subscription['subscriptions'] as $subscription_id => $tf) {
                     if (isset($available_subscriptions[$subscription_id])) {
                         if (isset($members_subscriptions[$subscription_id])) {
                             // we don't allow a member to sign up to the same subscription twice (just yet)
                         } else {
                             $subscription['subscription_name'][$subscription_id] = $available_subscriptions[$subscription_id]['name'];
                             $start_date = date('Y-m-d');
                             $start_modifications = module_config::c('customer_signup_subscription_start', '');
                             if ($start_modifications == 'hidden') {
                                 $start_modifications = isset($_REQUEST['customer_signup_subscription_start']) ? $_REQUEST['customer_signup_subscription_start'] : '';
                             }
                             if (!empty($start_modifications)) {
                                 $start_date = date('Y-m-d', strtotime($start_modifications));
                             }
                             $sql = "INSERT INTO `" . _DB_PREFIX . "subscription_owner` SET ";
                             $sql .= " owner_id = '" . (int) $owner_id . "'";
                             $sql .= ", owner_table = '" . mysql_real_escape_string($owner_table) . "'";
                             $sql .= ", subscription_id = '" . (int) $subscription_id . "'";
                             $sql .= ", start_date = '{$start_date}'";
                             query($sql);
                             module_subscription::update_next_due_date($subscription_id, $owner_table, $owner_id, true);
                             // and the same option here to send a subscription straight away upon signup
                             if (module_config::c('subscription_send_invoice_straight_away', 0)) {
                                 global $plugins;
                                 $plugins['subscription']->run_cron();
                                 // check if there are any invoices for this subscription
                                 $history = module_subscription::get_subscription_history($subscription_id, $owner_table, $owner_id);
                                 if (count($history) > 0) {
                                     foreach ($history as $h) {
                                         if ($h['invoice_id']) {
                                             $invoice_data = module_invoice::get_invoice($h['invoice_id']);
                                             if ($invoice_data['date_cancel'] != '0000-00-00') {
                                                 continue;
                                             }
                                             $subscription['subscription_invoice'][] = '<a href="' . module_invoice::link_public($h['invoice_id']) . '">' . _l('Invoice #%s for %s', htmlspecialchars($invoice_data['name']), dollar($invoice_data['total_amount'], true, $invoice_data['currency_id'])) . '</a>';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if (!count($subscription['subscription_name'])) {
                 $subscription['subscription_name'][] = _l('N/A');
             }
             if (!count($subscription['subscription_invoice'])) {
                 $subscription['subscription_invoice'][] = _l('N/A');
             }
             $subscription['subscription_name'] = implode(', ', $subscription['subscription_name']);
             $subscription['subscription_invoice'] = implode(', ', $subscription['subscription_invoice']);
             // email the admin when a customer signs up.
             $values = array_merge($customer, $customer_extra, $website, $website_extra, $address, $subscription);
             $values['customer_name'] = $customer['customer_name'];
             $values['CUSTOMER_LINK'] = module_customer::link_open($customer_id);
             $values['CUSTOMER_NAME_LINK'] = module_customer::link_open($customer_id, true);
             if ($website_id) {
                 $values['WEBSITE_LINK'] = module_website::link_open($website_id);
                 $values['WEBSITE_NAME_LINK'] = module_website::link_open($website_id, true);
             } else {
                 $values['WEBSITE_LINK'] = _l('N/A');
                 $values['WEBSITE_NAME_LINK'] = _l('N/A');
             }
             $values['JOB_LINKS'] = '';
             if (count($job_created)) {
                 $values['JOB_LINKS'] .= 'The customer created ' . count($job_created) . ' jobs in the system: <br>';
                 foreach ($job_created as $job_created_id) {
                     $values['JOB_LINKS'] .= module_job::link_open($job_created_id, true) . "<br>\n";
                 }
             } else {
                 $values['JOB_LINKS'] = _l('N/A');
             }
             if (count($uploaded_files)) {
                 $values['uploaded_files'] = 'The customer uploaded ' . count($uploaded_files) . " files:<br>\n";
                 foreach ($uploaded_files as $uploaded_file) {
                     $values['uploaded_files'] .= module_file::link_open($uploaded_file, true) . "<br>\n";
                 }
             } else {
                 $values['uploaded_files'] = 'No files were uploaded';
             }
             $values['WEBSITE_NAME'] = isset($website['url']) ? $website['url'] : 'N/A';
             if (!$creating_new) {
                 $values['system_note'] = "Note: this signup updated the existing customer record in the system.";
             } else {
                 $values['system_note'] = "Note: this signup created a new customer record in the system.";
             }
             $customer_signup_template = module_config::c('customer_signup_email_admin_template', 'customer_signup_email_admin');
             if (isset($_REQUEST['customer_signup_email_admin_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_admin_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to_manual(module_config::c('customer_signup_admin_email', module_config::c('admin_email_address')));
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             $customer_signup_template = module_config::c('customer_signup_email_welcome_template', 'customer_signup_email_welcome');
             if (isset($_REQUEST['customer_signup_email_welcome_template'])) {
                 $customer_signup_template = $_REQUEST['customer_signup_email_welcome_template'];
             }
             if ($customer_signup_template) {
                 $template = module_template::get_template_by_key($customer_signup_template);
                 if ($template->template_id) {
                     $template->assign_values($values);
                     $html = $template->render('html');
                     $email = module_email::new_email();
                     $email->customer_id = $customer_id;
                     $email->replace_values = $values;
                     $email->set_subject($template->description);
                     $email->set_to('user', $customer_data['primary_user_id']);
                     // do we send images inline?
                     $email->set_html($html);
                     if ($email->send()) {
                         // it worked successfully!!
                     } else {
                         /// log err?
                     }
                 }
             }
             //todo: optional redirect to url
             if (isset($_REQUEST['via_ajax'])) {
                 echo json_encode(array('success' => 1, 'customer_id' => $customer_id));
                 exit;
             }
             if (module_config::c('customer_signup_redirect', '')) {
                 redirect_browser(module_config::c('customer_signup_redirect', ''));
             }
             // load up the thank you template.
             $template = module_template::get_template_by_key('customer_signup_thank_you_page');
             $template->page_title = _l("Customer Signup");
             foreach ($values as $key => $val) {
                 if (!is_array($val)) {
                     $values[$key] = htmlspecialchars($val);
                 }
             }
             $template->assign_values($values);
             echo $template->render('pretty_html');
             exit;
             break;
     }
 }
コード例 #6
0
                ?>
</span>
        <?php 
            } else {
                ?>

            <span class="error_text"><?php 
                _e('Not paid');
                ?>
</span>
        <?php 
            }
        }
    }
});
if (class_exists('module_website', false) && module_website::is_plugin_enabled() && module_website::can_i('view', module_config::c('project_name_plural', 'Websites'))) {
    $colspan++;
    $columns['invoice_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($invoice) {
        if (isset($invoice['website_ids'])) {
            foreach ($invoice['website_ids'] as $website_id) {
                if ((int) $website_id > 0) {
                    echo module_website::link_open($website_id, true);
                    echo '<br/>';
                }
            }
        }
    });
}
if (module_job::is_plugin_enabled() && module_job::can_i('view', 'Jobs')) {
    $columns['invoice_job'] = array('title' => 'Job', 'callback' => function ($invoice) {
        foreach ($invoice['job_ids'] as $job_id) {
コード例 #7
0
ファイル: website.php プロジェクト: sgh1986915/php-crm
 public function init()
 {
     $this->links = array();
     $this->website_types = array();
     $this->module_name = "website";
     $this->module_position = 16;
     $this->version = 2.265;
     //2.265 - 2015-03-24 - import notes via csv
     //2.264 - 2015-01-23 - hook for custom data integration
     //2.263 - 2014-08-13 - website notes show summary of linked items
     //2.262 - 2014-07-31 - responsive improvements
     //2.21 - fix for customer id not getting saved.
     //2.22 - delete customer from a group
     //2.23 - theme include support.
     //2.24 - hooks for change request plugin
     //2.241 - got CSV import working nicely
     //2.242 - urlify added for better url field support
     //2.243 - bug fix in swapping customers
     //2.244 - bug fix for job currency in "edit website" page
     //2.245 - extra fields update - show in main listing option
     //2.246 - extra fields update - show in main listing option
     //2.247 - customer link fix permissions
     //2.248 - improved quick search
     //2.249 - https support in website links.
     //2.25 - 2013-04-10 - new customer permissions
     //2.251 - 2013-05-28 - email template tag improvements
     //2.252 - 2013-06-18 - customer signup fixes
     //2.253 - 2013-06-21 - permission update
     //2.254 - 2013-08-29 - support for recurring website subscriptions - eg: hosting
     //2.255 - 2013-08-29 - support for recurring website subscriptions - eg: hosting
     //2.256 - 2013-10-04 - option to disable website plugin
     //2.257 - 2013-11-15 - working on new UI
     //2.258 - 2014-03-19 - demo fix
     //2.259 - 2014-04-15 - show quotes in website view
     //2.26 - 2014-06-11 - quote/website permission fix
     //2.261 - 2014-07-02 - permission improvement
     if ($this->can_i('view', module_config::c('project_name_plural', 'Websites')) && module_website::is_plugin_enabled()) {
         hook_add('website_list', 'module_website::hook_filter_var_website_list');
         /*$this->ajax_search_keys = array(
               _DB_PREFIX.'website' => array(
                   'plugin' => 'website',
                   'search_fields' => array(
                       'url',
                       'name',
                   ),
                   'key' => 'website_id',
                   'title' => _l(module_config::c('project_name_single','Website').': '),
               ),
           );*/
         // only display if a customer has been created.
         if (isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] && $_REQUEST['customer_id'] != 'new') {
             // how many websites?
             $websites = $this->get_websites(array('customer_id' => $_REQUEST['customer_id']));
             $name = module_config::c('project_name_plural', 'Websites');
             if (count($websites)) {
                 $name .= " <span class='menu_label'>" . count($websites) . "</span> ";
             }
             $this->links[] = array("name" => $name, "p" => "website_admin", 'args' => array('website_id' => false), 'holder_module' => 'customer', 'holder_module_page' => 'customer_admin_open', 'menu_include_parent' => 0, 'icon_name' => 'globe');
         }
         $this->links[] = array("name" => module_config::c('project_name_plural', 'Websites'), "p" => "website_admin", 'args' => array('website_id' => false), 'icon_name' => 'globe');
     }
 }