예제 #1
0
    private function _output_block($facebook_data, $level)
    {
        if (!isset($facebook_data['picture']) && isset($facebook_data['attachment'], $facebook_data['attachment']['type'], $facebook_data['attachment']['media']['image']['src'])) {
            $facebook_data['picture'] = $facebook_data['attachment']['media']['image']['src'];
            $facebook_data['link'] = isset($facebook_data['attachment']['url']) ? $facebook_data['attachment']['url'] : false;
        }
        if (isset($facebook_data['comments'])) {
            $comments = $this->get_comments($facebook_data['comments']);
        } else {
            $comments = array();
        }
        //echo '<pre>';print_r($facebook_data);echo '</pre>';
        if ($facebook_data['message'] !== false) {
            ?>
		<div class="facebook_comment">
			<div class="facebook_comment_picture">
				<?php 
            if (isset($facebook_data['from']['id'])) {
                ?>
				<img src="//graph.facebook.com/<?php 
                echo $facebook_data['from']['id'];
                ?>
/picture">
				<?php 
            }
            ?>
			</div>
			<div class="facebook_comment_header">
				<?php 
            echo isset($facebook_data, $facebook_data['from']) ? ucm_facebook::format_person($facebook_data['from']) : 'N/A';
            ?>
				<span><?php 
            $time = strtotime(isset($facebook_data['updated_time']) ? $facebook_data['updated_time'] : (isset($facebook_data['created_time']) ? $facebook_data['created_time'] : false));
            echo $time ? ' @ ' . print_date($time, true) : '';
            // todo - better this! don't call on every comment, load list in main loop and pass through all results.
            if (isset($facebook_data['user_id']) && $facebook_data['user_id']) {
                echo ' (sent by ' . module_user::link_open($facebook_data['user_id'], true) . ')';
            } else {
                if (isset($facebook_data['id']) && $facebook_data['id']) {
                    $exists = get_single('social_facebook_message_comment', array('facebook_id', 'social_facebook_message_id'), array($facebook_data['id'], $this->social_facebook_message_id));
                    if ($exists && isset($exists['user_id']) && $exists['user_id']) {
                        echo ' (sent by ' . module_user::link_open($exists['user_id'], true) . ')';
                    }
                }
            }
            ?>
				</span>
			</div>
			<div class="facebook_comment_body">
				<?php 
            if (isset($facebook_data['picture']) && $facebook_data['picture']) {
                ?>
				<div class="facebook_picture">
					<?php 
                if (isset($facebook_data['link']) && $facebook_data['link']) {
                    ?>
 <a href="<?php 
                    echo htmlspecialchars($facebook_data['link']);
                    ?>
" target="_blank"> <?php 
                }
                ?>
					<img src="<?php 
                echo htmlspecialchars($facebook_data['picture']);
                ?>
">
					<?php 
                if (isset($facebook_data['link']) && $facebook_data['link']) {
                    ?>
 </a> <?php 
                }
                ?>
				</div>
				<?php 
            }
            ?>
				<div>
					<?php 
            echo forum_text($facebook_data['message']);
            ?>
				</div>
			</div>
			<div class="facebook_comment_actions">
				<?php 
            if ($this->can_reply && ($this->get('type') != 'conversation' && $level == 2)) {
                ?>
					<a href="#" class="facebook_reply_button"><?php 
                _e('Reply');
                ?>
</a>
				<?php 
            }
            ?>
			</div>
		</div>
		<?php 
        }
        ?>
		<div class="facebook_comment_replies">
		<?php 
        //if(strpos($facebook_data['message'],'picture')){
        //echo '<pre>'; print_r($facebook_data); echo '</pre>';
        //}
        if (count($comments)) {
            // recursively print out our comments!
            //$comments = array_reverse($comments);
            foreach ($comments as $comment) {
                $this->_output_block($comment, $level + 1);
            }
        }
        if ($this->can_reply && isset($facebook_data['id']) && $facebook_data['id'] && ($this->get('type') == 'conversation' && $level == 1 || $this->get('type') != 'conversation' && $level <= 2)) {
            $this->reply_box($facebook_data['id'], $level);
        }
        ?>
		</div>
		<?php 
    }
예제 #2
0
        if ($ticket['user_id'] && !isset($c[$ticket['user_id']])) {
            // this option isn't in the listing. add it in.
            $c[$ticket['user_id']] = $create_user['name'] . ' ' . $create_user['last_name'];
            if ($create_user['customer_id'] >= 0) {
                $c[$ticket['user_id']] .= ' ' . _l('(under different customer)');
            } else {
                // user not assigned to a customer.
            }
        }
        echo print_select_box($c, 'change_user_id', $ticket['user_id']);
    } else {
        //
        if ($create_user['customer_id']) {
            echo module_user::link_open_contact($ticket['user_id'], true, array(), true);
        } else {
            echo module_user::link_open($ticket['user_id'], true, array(), true);
        }
        echo ' ' . htmlspecialchars($create_user['email']);
    }
}));
$fieldset_data['elements'][] = array('title' => _l('Type/Department'), 'fields' => array(array('type' => 'select', 'name' => 'ticket_type_id', 'value' => $ticket['ticket_type_id'], 'options' => module_ticket::get_types(), 'blank' => module_ticket::can_edit_tickets(), 'options_array_id' => 'name')));
if (class_exists('module_faq', false) && module_config::c('ticket_faq_link', 1) && module_faq::get_faq_products() > 0) {
    $fieldset_data['elements'][] = array('title' => _l('Product'), 'fields' => array(function () use($ticket, $ticket_id) {
        if (module_ticket::can_edit_tickets()) {
            echo print_select_box(module_faq::get_faq_products_rel(), 'faq_product_id', $ticket['faq_product_id']);
            _h('Use this to link a ticket to a product. Set products in Settings > FAQ. This allows you to have different FAQ items for different products. Users are shown the FAQ items before submitting a support ticket.');
        } else {
            echo friendly_key(module_faq::get_faq_products_rel(), $ticket['faq_product_id']);
        }
        // show a button that does a jquery popup with the list of faq items and an option to create new one.
        //if(module_faq::can_i('edit','FAQ')){                                                                            echo ' ';
예제 #3
0
        </td>
    </tr>
    <tr>
        <th>
            <?php 
_e('Last Decryption:');
?>
        </th>
        <td>
            <?php 
$last = get_multiple('encrypt_access', array('encrypt_id' => $encrypt_id, 'status' => 2), 'encrypt_access_id', 'exact', 'encrypt_access_id DESC');
if (!$last) {
    _e('N/A');
} else {
    $last = array_shift($last);
    _e('By %s at %s from %s', module_user::link_open($last['create_user_id'], true), print_date($last['date_created'], true), preg_replace('#^(\\d*\\.\\d*).*$#', '$1.**.**', $last['create_ip_address']));
}
?>
        </td>
    </tr>
    <!-- <tr>
        <th>
            <?php 
_e('Raw Value:');
?>
        </th>
        <td>
            <textarea name="data" rows="7" cols="60" id="raw_value"><?php 
echo $encrypt['data'];
?>
</textarea>
예제 #4
0
    });
}
if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) {
    $columns['quote_customer'] = array('title' => 'Customer', 'callback' => function ($quote) {
        echo module_customer::link_open($quote['customer_id'], true);
    });
}
$columns['quote_type'] = array('title' => 'Type', 'callback' => function ($quote) {
    echo htmlspecialchars($quote['type']);
});
$columns['quote_status'] = array('title' => 'Status', 'callback' => function ($quote) {
    echo htmlspecialchars($quote['status']);
});
if (module_config::c('quote_allow_staff_assignment', 1)) {
    $columns['quote_staff'] = array('title' => 'Staff Member', 'callback' => function ($quote) {
        echo module_user::link_open($quote['user_id'], true);
    });
}
if (module_job::can_i('view', 'Jobs')) {
    $job_ids = array();
    $columns['job'] = array('title' => 'Job', 'callback' => function ($quote) use(&$job_ids) {
        $job_ids = array();
        foreach (module_job::get_jobs(array('quote_id' => $quote['quote_id'])) as $job) {
            $job = module_job::get_job($job['job_id']);
            if (!$job) {
                continue;
            }
            echo module_job::link_open($job['job_id'], true);
            $job_ids[] = $job['job_id'];
            echo " ";
            echo '<span class="';
예제 #5
0
파일: file.php 프로젝트: sgh1986915/php-crm
    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
 </td>
    <?php 
}
?>
</tr>
<?php 
if ($show_split_hours) {
    ?>
    <tr class="task_editting task_row_<?php 
    echo $task_id;
    ?>
">
    <td></td>
    <td style="text-align: right">
       <?php 
    _e('Staff Settings for: %s', module_user::link_open($task_data['user_id'], true));
    ?>
        <input type="hidden" name="job_task[<?php 
    echo $task_id;
    ?>
][staff_split]" value="1">
    </td>
    <td>
        <?php 
    if ($task_data['staff_hours'] != 0) {
        if ($task_data['manual_task_type'] == _TASK_TYPE_HOURS_AMOUNT && function_exists('decimal_time_out')) {
            $hours_value = decimal_time_out($task_data['staff_hours']);
        } else {
            $hours_value = number_out($task_data['staff_hours'], true);
        }
    } else {
예제 #7
0
        ?>
 class="sendemail_customer"> <?php 
        _e('Yes, send email to customer contact %s', module_user::link_open($user_id, true, array(), true));
        ?>
        <?php 
        echo $user_id == $customer['primary_user_id'] ? _l('(primary)') : '';
        ?>
        <?php 
    }
    foreach ($send_to_staff_ids as $staff_id => $checked) {
        // we are the admin, sending an email to assigned staff member
        ?>
        <br/>
        <input type="checkbox" name="sendemail_staff[]" value="<?php 
        echo $staff_id;
        ?>
" <?php 
        echo $checked ? 'checked="checked"' : '';
        ?>
 class="sendemail_staff"> <?php 
        _e('Yes, send email to staff %s', module_user::link_open($staff_id, true, array(), true));
        ?>
    <?php 
    }
    if (!module_security::is_logged_in()) {
        echo '</div>';
    }
    ?>
    </div>
    <?php 
}
예제 #8
0
"
								    class="img-circle" alt="User Image">
						    </div>
					    <?php 
                }
                ?>

					    <div class="pull-left info">
						    <p><?php 
                _e('Welcome');
                echo '<br/>';
                echo htmlspecialchars($user['name']);
                ?>
</p>
						    <a href="<?php 
                echo module_user::link_open(module_security::get_loggedin_id());
                ?>
"><i
								    class="fa fa-user"></i> <?php 
                _e('Edit Profile');
                ?>
</a> <br/>
						    <a href="#" onclick="return false;"><i
								    class="fa fa-calendar"></i> <?php 
                echo _l('%s %s%s of %s %s', _l(date('D')), date('j'), _l(date('S')), _l(date('F')), date('Y'));
                ?>

						    </a>
					    </div>
				    </div>
				    <?php 
예제 #9
0
 /**
  * @static
  * @param $args
  * @return array
  *
  * The newsletter system requests updated customer / user data from this group plugin.
  * It does this when building the member list, and also 
  */
 public static function newsletter_callback($args)
 {
     if (!isset($args['owner_table']) || !$args['owner_table']) {
         return array();
     }
     switch ($args['owner_table']) {
         case 'user':
             if ((int) $args['owner_id'] > 0) {
                 $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name";
                 $sql .= " , pu.user_id ";
                 $sql .= " , c.customer_id ";
                 $sql .= " ,c.credit ";
                 $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
                 $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
                 $sql .= ' FROM `' . _DB_PREFIX . "user` pu";
                 $sql .= " LEFT JOIN `" . _DB_PREFIX . "customer` c ON pu.customer_id = c.customer_id";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
                 $sql .= " WHERE pu.user_id = " . (int) $args['owner_id'];
                 $user = qa1($sql);
                 if (!is_array($user) || !isset($user['user_id']) || !$user['user_id']) {
                     return false;
                 }
                 if (isset($args['basic']) && $args['basic']) {
                     return $user;
                 }
                 //                    $name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name']));
                 //                    $user['first_name'] = array_shift($name_parts);
                 //                    $user['last_name'] = implode(' ',$name_parts);
                 // get extras for the user.
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
                 // get extras for the customer.
                 if (isset($user['customer_id']) && $user['customer_id'] > 0) {
                     $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
                     foreach ($extras as $extra) {
                         if (!strlen(trim($extra['extra']))) {
                             continue;
                         }
                         $key = $extra['extra_key'];
                         $x = 1;
                         while (isset($user[$key])) {
                             $key = $extra['extra_key'] . $x;
                             $x++;
                         }
                         $user[$key] = trim($extra['extra']);
                     }
                 }
                 if ($user['customer_id']) {
                     $user['_edit_link'] = module_user::link_open_contact($user['user_id'], false, $user);
                 } else {
                     $user['_edit_link'] = module_user::link_open($user['user_id'], false, $user);
                 }
                 return $user;
             }
             break;
         case 'customer':
             if (module_config::c('newsletter_send_all_customer_contacts', 1)) {
                 // update - we use the above 'user' callback and return a listing for each contact in the array.
                 // using the special _multi flag hack to tell our newsletter plugin that this result contains multiple entries.
                 $users = array('_multi' => true);
                 $sql = "SELECT u.user_id FROM `" . _DB_PREFIX . "user` u WHERE u.customer_id = " . (int) $args['owner_id'];
                 $contacts = qa($sql);
                 foreach ($contacts as $contact) {
                     $data_args = array('owner_id' => $contact['user_id'], 'owner_table' => 'user');
                     $users[$contact['user_id']] = self::newsletter_callback($data_args);
                     if ($users[$contact['user_id']]) {
                         $users[$contact['user_id']]['data_args'] = json_encode($data_args);
                     }
                 }
                 return $users;
             } else {
                 $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name";
                 $sql .= " ,c.credit ";
                 $sql .= " , pu.user_id ";
                 $sql .= " , c.customer_id ";
                 $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
                 $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
                 $sql .= " FROM `" . _DB_PREFIX . "customer` c ";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
                 $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id";
                 $sql .= " WHERE c.customer_id = " . (int) $args['owner_id'];
                 $user = qa1($sql);
                 if (!$user || !isset($user['customer_id'])) {
                     return array();
                 }
                 //$name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name']));
                 //$user['first_name'] = array_shift($name_parts);
                 //$user['last_name'] = implode(' ',$name_parts);
                 if (isset($args['basic']) && $args['basic']) {
                     return $user;
                 }
                 // get extras for the customer.
                 $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
                 if (isset($user['user_id']) && $user['user_id'] > 0) {
                     // get extras for the user.
                     $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                     foreach ($extras as $extra) {
                         if (!strlen(trim($extra['extra']))) {
                             continue;
                         }
                         $key = $extra['extra_key'];
                         $x = 1;
                         while (isset($user[$key])) {
                             $key = $extra['extra_key'] . $x;
                             $x++;
                         }
                         $user[$key] = trim($extra['extra']);
                     }
                 }
                 $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user);
                 return $user;
             }
         case 'website':
             $sql = "SELECT c.customer_name AS company_name";
             $sql .= " ,c.credit ";
             $sql .= " ,w.name AS website_name";
             $sql .= " ,w.url AS website_url";
             $sql .= " , pu.user_id ";
             $sql .= " , c.customer_id ";
             $sql .= " , pu.name AS user_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`";
             $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code ";
             $sql .= " FROM `" . _DB_PREFIX . "website` w ";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "customer` c ON w.customer_id = c.customer_id";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'";
             $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id";
             $sql .= " WHERE w.website_id = " . (int) $args['owner_id'];
             $user = qa1($sql);
             $name_parts = explode(" ", preg_replace('/\\s+/', ' ', $user['user_name']));
             $user['first_name'] = array_shift($name_parts);
             $user['last_name'] = implode(' ', $name_parts);
             if (isset($args['basic']) && $args['basic']) {
                 return $user;
             }
             // get extras for the website.
             $extras = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $args['owner_id']));
             foreach ($extras as $extra) {
                 if (!strlen(trim($extra['extra']))) {
                     continue;
                 }
                 $key = $extra['extra_key'];
                 $x = 1;
                 while (isset($user[$key])) {
                     $key = $extra['extra_key'] . $x;
                     $x++;
                 }
                 $user[$key] = trim($extra['extra']);
             }
             // then get extras for the company
             $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id']));
             foreach ($extras as $extra) {
                 if (!strlen(trim($extra['extra']))) {
                     continue;
                 }
                 $key = $extra['extra_key'];
                 $x = 1;
                 while (isset($user[$key])) {
                     $key = $extra['extra_key'] . $x;
                     $x++;
                 }
                 $user[$key] = trim($extra['extra']);
             }
             if (isset($user['user_id']) && $user['user_id'] > 0) {
                 // get extras for the user.
                 $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id']));
                 foreach ($extras as $extra) {
                     if (!strlen(trim($extra['extra']))) {
                         continue;
                     }
                     $key = $extra['extra_key'];
                     $x = 1;
                     while (isset($user[$key])) {
                         $key = $extra['extra_key'] . $x;
                         $x++;
                     }
                     $user[$key] = trim($extra['extra']);
                 }
             }
             $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user);
             return $user;
         case 'ticket':
             //echo 'Getting ticket for '.$args['owner_id'] . ' and basic is '.var_export($args['basic'],true);exit;
             return module_ticket::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
         case 'member':
             return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
         case 'newsletter_subscription':
             return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']);
     }
     return array();
 }
        echo htmlspecialchars($ticket_account['email']);
        ?>
                    </td>
                    <td>
                        <?php 
        echo htmlspecialchars(isset($types[$ticket_account['default_type']]) ? $types[$ticket_account['default_type']]['name'] : $ticket_account['default_type']);
        ?>
                    </td>
                    <td>
                        <?php 
        echo module_customer::link_open($ticket_account['default_customer_id'], true);
        ?>
                    </td>
                    <td>
                        <?php 
        echo module_user::link_open($ticket_account['default_user_id'], true);
        ?>
                    </td>
                    <td>
                        <?php 
        echo print_date($ticket_account['last_checked']);
        ?>
                    </td>
                </tr>
            <?php 
    }
    ?>
        </tbody>
    </table>

<?php 
예제 #11
0
                // load the full customer data before displaying each row so we have access to more details
                $row_data['id'] = $row_data['owner_table'] . ' #' . $row_data['owner_id'];
                $row_data['name'] = 'N/A';
                if (is_callable('module_' . basename($row_data['owner_table']) . '::link_open') && $row_data['owner_id']) {
                    eval("\$row_data['name'] = module_" . basename($row_data['owner_table']) . "::link_open(" . $row_data['owner_id'] . ",true);");
                }
                $row_data['created'] = '';
                if ($row_data['create_user_id']) {
                    $row_data['created'] .= module_user::link_open($row_data['create_user_id'], true);
                }
                if ($row_data['date_created']) {
                    $row_data['created'] .= ' on ' . $row_data['date_created'];
                }
                $row_data['updated'] = '';
                if ($row_data['update_user_id']) {
                    $row_data['updated'] .= module_user::link_open($row_data['update_user_id'], true);
                }
                if ($row_data['date_updated']) {
                    $row_data['updated'] .= ' on ' . $row_data['date_updated'];
                }
                return $row_data;
            };
            $table_manager->set_rows($extra_values);
            $table_manager->pagination = false;
            $table_manager->print_table();
        }
    }
} else {
    ?>

예제 #12
0
             $value = isset($data['date_created']) && $data['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data['date_created'])) : _l('N/A');
             break;
         case 'updated_date_time':
             $value = isset($data['date_updated']) && $data['date_updated'] != '0000-00-00 00:00:00' ? print_date(strtotime($data['date_updated']), true) : (isset($data['date_created']) && $data['date_created'] != '0000-00-00 00:00:00' ? print_date(strtotime($data['date_created']), true) : _l('N/A'));
             break;
         case 'updated_date':
             $value = isset($data['date_updated']) && $data['date_updated'] != '0000-00-00 00:00:00' ? print_date(strtotime($data['date_updated']), false) : (isset($data['date_created']) && $data['date_created'] != '0000-00-00 00:00:00' ? print_date(strtotime($data['date_created']), false) : _l('N/A'));
             break;
         case 'updated_time':
             $value = isset($data['date_updated']) && $data['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data['date_updated'])) : (isset($data['date_created']) && $data['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data['date_created'])) : _l('N/A'));
             break;
         case 'created_by':
             $value = isset($data['create_user_id']) && (int) $data['create_user_id'] > 0 ? module_user::link_open($data['create_user_id'], true) : _l('N/A');
             break;
         case 'updated_by':
             $value = isset($data['update_user_id']) && (int) $data['update_user_id'] > 0 ? module_user::link_open($data['update_user_id'], true) : (isset($data['create_user_id']) && (int) $data['create_user_id'] > 0 ? module_user::link_open($data['create_user_id'], true) : _l('N/A'));
             break;
     }
 } else {
     switch ($settings['field_type']) {
         case 'encrypted':
             $value = '*******';
             break;
         case 'wysiwyg':
             $value = module_security::purify_html($value);
             break;
         case 'select':
             // todo - do this for the other field types as well..
             $settings['value'] = $value;
             $value = $module->get_form_element($settings, true, $data);
             break;
예제 #13
0
function listCalendarByRange($sd, $ed)
{
    $ret = array();
    $ret['events'] = array();
    $ret["issort"] = true;
    $ret["start"] = php2JsTime($sd);
    $ret["end"] = php2JsTime($ed);
    $ret['error'] = null;
    $calendar_data_access = module_calendar::get_calendar_data_access();
    // hook into things like jobs and stuff who want to return calendar entries.
    $hook_results = hook_handle_callback('calendar_events', $sd, $ed);
    if (is_array($hook_results) && count($hook_results)) {
        foreach ($hook_results as $hook_result) {
            if (is_array($hook_result)) {
                foreach ($hook_result as $result) {
                    // format our hook results to match our bad (indexed) array,
                    // will update that array in the future
                    /*$calendar_events[] = array(
                          'subject' => $job['name'],
                          'customer_id' => $job['customer_id'],
                          'start_time' => $job['date_start'],
                          'user_id' => $job['user_id'],
                          'description' => 'Test Description',
                          'link' => module_job::link_open($job['job_id'],true,$job),
                      );*/
                    $staff_names = array();
                    if (isset($result['staff_ids']) && count($result['staff_ids'])) {
                        switch ($calendar_data_access) {
                            case _CALENDAR_ACCESS_ALL:
                                break;
                            case _CALENDAR_ACCESS_ASSIGNED:
                            default:
                                $current_user = module_security::get_loggedin_id();
                                if (!in_array($current_user, $result['staff_ids'])) {
                                    continue 2;
                                }
                                break;
                        }
                        foreach ($result['staff_ids'] as $staff_id) {
                            $staff_names[] = module_user::link_open($staff_id, true);
                        }
                    }
                    $staff_names = implode(', ', $staff_names);
                    $result[0] = false;
                    // no calendar ID at the moment
                    $result[1] = $result['subject'];
                    $result[2] = php2JsTime($result['start_time']);
                    $result[3] = php2JsTime(isset($result['end_time']) ? $result['end_time'] : $result['start_time']);
                    $result[4] = !isset($result['all_day']) || $result['all_day'];
                    $result[5] = 0;
                    $result[6] = 0;
                    $result[7] = 0;
                    //col
                    $result[8] = 2;
                    $result[9] = 0;
                    $result[10] = 0;
                    $result[13] = $result['customer_id'];
                    $result[12] = $result['link'];
                    $result[14] = isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] != $result['customer_id'] ? 'chip-fade' : '';
                    $result['staff'] = $staff_names;
                    $ret['events'][] = $result;
                }
            }
        }
    }
    try {
        $sql = "select * from `" . _DB_PREFIX . "calendar` where `start` >= '" . mysql_real_escape_string($sd) . "' AND `start` <= '" . mysql_real_escape_string($ed) . "'";
        //  echo $sql;
        $rows = qa($sql);
        foreach ($rows as $row) {
            //$ret['events'][] = $row;
            //$attends = $row->AttendeeNames;
            //if($row->OtherAttendee){
            //  $attends .= $row->OtherAttendee;
            //}
            //echo $row->StartTime;
            $more_than_1_day = date('Ymd', $row['start']) == date('Ymd', $row['end']) ? 0 : 1;
            $customer_name = $customer_link = '';
            if ($row['customer_id'] > 0) {
                $customer_data = module_customer::get_customer($row['customer_id'], true, true);
                if (!$customer_data || $customer_data['customer_id'] != $row['customer_id']) {
                    $row['customer_id'] = 0;
                } else {
                    switch ($calendar_data_access) {
                        case _CALENDAR_ACCESS_ALL:
                            break;
                        case _CALENDAR_ACCESS_ASSIGNED:
                        default:
                            if (isset($customer_data['_no_access'])) {
                                continue 2;
                            }
                            break;
                    }
                    $customer_name = $customer_data['customer_name'];
                    $customer_link = module_customer::link_open($row['customer_id'], true, $customer_data);
                }
            }
            $calendar_event = module_calendar::get_calendar($row['calendar_id']);
            $staff_names = array();
            if (count($calendar_event['staff_ids'])) {
                switch ($calendar_data_access) {
                    case _CALENDAR_ACCESS_ALL:
                        break;
                    case _CALENDAR_ACCESS_ASSIGNED:
                    default:
                        $current_user = module_security::get_loggedin_id();
                        if (!in_array($current_user, $calendar_event['staff_ids'])) {
                            continue 2;
                        }
                        break;
                }
                foreach ($calendar_event['staff_ids'] as $staff_id) {
                    $staff_names[] = module_user::link_open($staff_id, true);
                }
            }
            $staff_names = implode(', ', $staff_names);
            $ret['events'][] = array(0 => $row['calendar_id'], 1 => $row['subject'], 2 => php2JsTime($row['start']), 3 => php2JsTime($row['end']), 4 => $row['is_all_day'], 5 => $more_than_1_day, 6 => 0, 7 => $row['color'], 8 => 1, 9 => '', 10 => '', 11 => $customer_name, 12 => $customer_link, 13 => $row['customer_id'], 14 => isset($_REQUEST['customer_id']) && $_REQUEST['customer_id'] != $row['customer_id'] ? 'chip-fade' : '', 'staff' => $staff_names);
        }
    } catch (Exception $e) {
        $ret['error'] = $e->getMessage();
    }
    // build bubble content based on event data:
    foreach ($ret['events'] as $event_id => $event) {
        if (!isset($event['bubble'])) {
            $ret['events'][$event_id]['bubble'] = '<div id="bbit-cs-buddle" style="z-index: 1080; width: 400px;visibility:hidden;" class="bubble"><table class="bubble-table" cellSpacing="0" cellPadding="0"><tbody><tr><td class="bubble-cell-side"><div id="tl1" class="bubble-corner"><div class="bubble-sprite bubble-tl"></div></div><td class="bubble-cell-main"><div class="bubble-top"></div><td class="bubble-cell-side"><div id="tr1" class="bubble-corner"><div class="bubble-sprite bubble-tr"></div></div>  <tr><td class="bubble-mid" colSpan="3"><div style="overflow: hidden" id="bubbleContent1"><div><div></div><div class="cb-root"><table class="cb-table" cellSpacing="0" cellPadding="0"><tbody>' . '<tr>' . '<td class="cb-value"><div class="textbox-fill-wrapper"><div class="textbox-fill-mid"><div id="bbit-cs-what" title="' . htmlspecialchars(_l('View Details')) . '" class="textbox-fill-div lk" style="cursor:pointer;">' . htmlspecialchars($event[1]) . '</div></div></div></td></tr><tr><td class=cb-value><div id="bbit-cs-buddle-timeshow"></div></td>' . '</tr>' . '<tr><td class=cb-value><div id="bbit-cs-customer-link">' . _l('Customer: %s', $event[12] ? $event[12] : _l('N/A')) . '</div></td></tr>' . (isset($event['other_details']) && strlen($event['other_details']) ? '<tr><td class=cb-value><div id="bbit-cs-customer-link">' . $event['other_details'] . '</div></td></tr>' : '') . '<tr><td class=cb-value><div id="bbit-cs-staff-link">' . _l('Staff: %s', $event['staff'] ? $event['staff'] : _l('N/A')) . '</div></td></tr>' . '</tbody></table>' . ($event[8] == 1 ? '<div class="bbit-cs-split"><input id="bbit-cs-id" type="hidden" value=""/>' . (module_calendar::can_i('delete', 'Calendar') ? '[ <span id="bbit-cs-delete" class="lk">' . htmlspecialchars(_l('Delete')) . '</span> ]&nbsp;' : '') . (module_calendar::can_i('edit', 'Calendar') ? ' <span id="bbit-cs-editLink" class="lk">' . htmlspecialchars(_l('Edit Event')) . ' </span>' : '') . '</div> ' : '') . '</div></div></div><tr><td><div id="bl1" class="bubble-corner"><div class="bubble-sprite bubble-bl"></div></div><td><div class="bubble-bottom"></div><td><div id="br1" class="bubble-corner"><div class="bubble-sprite bubble-br"></div></div></tr></tbody></table><div id="bubbleClose2" class="bubble-closebutton"></div><div id="prong1" class="prong"><div class=bubble-sprite></div></div></div>';
        }
    }
    return $ret;
}
예제 #14
0
파일: user.php 프로젝트: sgh1986915/php-crm
 public function process()
 {
     if (_DEMO_MODE && isset($_REQUEST['user_id']) && (int) $_REQUEST['user_id'] > 0 && (int) $_REQUEST['user_id'] <= 4) {
         set_error('Sorry no changes to demo users. Please create a new user.');
         redirect_browser($this->link_open($_REQUEST['user_id']));
     }
     $errors = array();
     if (isset($_REQUEST['butt_del_contact']) && $_REQUEST['butt_del_contact'] && $_REQUEST['user_id'] && $_REQUEST['user_id'] != 1 && self::can_i('delete', 'Contacts', 'Customer')) {
         $data = self::get_user($_REQUEST['user_id']);
         if (module_form::confirm_delete('user_id', "Really delete contact: " . $data['name'], self::link_open_contact($_REQUEST['user_id']))) {
             $this->delete_user($_REQUEST['user_id']);
             set_message("Contact deleted successfully");
             redirect_browser(module_customer::link_open($data['customer_id']));
         }
     } else {
         if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['user_id'] && self::can_i('delete', 'Users', 'Config')) {
             $data = self::get_user($_REQUEST['user_id']);
             if (module_form::confirm_delete('user_id', "Really delete user: "******"User deleted successfully");
                 redirect_browser(self::link_open(false));
             }
         } else {
             if ("save_user" == $_REQUEST['_process']) {
                 $user_id = (int) $_REQUEST['user_id'];
                 if ($user_id == 1 && module_security::get_loggedin_id() != 1) {
                     set_error('Sorry, only the Administrator can access this page.');
                     redirect_browser(_UCM_HOST . _BASE_HREF);
                 }
                 // check create permissions.
                 $use_master_key = $this->get_contact_master_key();
                 // are we creating or editing a user?
                 if (!$user_id) {
                     $method = 'create';
                 } else {
                     $method = 'edit';
                     $existing_user = module_user::get_user($user_id, true, false);
                     if (!$existing_user || $existing_user['user_id'] != $user_id) {
                         $user_id = false;
                         $method = 'create';
                     }
                 }
                 if (isset($_POST[$use_master_key]) && $_POST[$use_master_key]) {
                     if (!module_user::can_i($method, 'Contacts', 'Customer')) {
                         set_error('No permissions to ' . $method . ' contacts');
                         redirect_browser(module_customer::link_open($_POST['customer_id']));
                     }
                 } else {
                     if (!module_user::can_i($method, 'Users', 'Config')) {
                         set_error('No permissions to ' . $method . ' users');
                         redirect_browser(module_user::link_open(false));
                     }
                 }
                 $user_id = $this->save_user($user_id, $_POST);
                 if ($use_master_key && isset($_REQUEST[$use_master_key]) && $_REQUEST[$use_master_key]) {
                     set_message("Customer contact saved successfully");
                     redirect_browser($this->link_open_contact($user_id));
                 } else {
                     set_message("User saved successfully");
                     redirect_browser($this->link_open($user_id));
                 }
             }
         }
     }
     /*else if("save_contact" == $_REQUEST['_process']){
     			$user_id = $this->save_contact($_POST['user_id'],$_POST);
     			$_REQUEST['_redirect'] = $this->link_open_contact(false);
     			if($user_id){
     				set_message("Contact saved successfully");
     			}else{
     				// todo error creating contact
     			}
     		}*/
     if (!count($errors)) {
         redirect_browser($_REQUEST['_redirect']);
         exit;
     }
     print_error($errors, true);
 }
예제 #15
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);
 }
예제 #16
0
}
print_heading($heading);
?>



<form action="" method="post">

<?php 
$search_bar = array('elements' => array('name' => array('title' => _l('Users Name:'), 'field' => array('type' => 'text', 'name' => 'search[generic]', 'value' => isset($search['generic']) ? $search['generic'] : ''))));
echo module_form::search_bar($search_bar);
/** START TABLE LAYOUT **/
$table_manager = module_theme::new_table_manager();
$columns = array();
$columns['name'] = array('title' => 'Users Name', 'callback' => function ($user) {
    echo module_user::link_open($user['user_id'], true);
}, 'cell_class' => 'row_action');
$columns['email'] = array('title' => 'Email Address', 'callback' => function ($user) {
    echo htmlspecialchars($user['email']);
});
$columns['role'] = array('title' => 'Role / Permissions', 'callback' => function ($user) use($roles) {
    if ($user['user_id'] == 1) {
        echo _l('Everything');
    } else {
        if (isset($user['roles']) && $user['roles']) {
            foreach ($user['roles'] as $role) {
                echo $roles[$role['security_role_id']]['name'];
            }
        }
    }
});
예제 #17
0
    $columns['file_customer'] = array('title' => 'Customer', 'callback' => function ($file) {
        echo module_customer::link_open($file['customer_id'], true);
    });
}
if (class_exists('module_job', false)) {
    $columns['file_job'] = array('title' => 'Job', 'callback' => function ($file) {
        echo module_job::link_open($file['job_id'], true);
    });
}
if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) {
    $columns['file_quote'] = array('title' => 'Quote', 'callback' => function ($file) {
        echo module_quote::link_open($file['quote_id'], true);
    });
}
$columns['file_date_added'] = array('title' => 'Date Added', 'callback' => function ($file) {
    echo _l('%s by %s', print_date($file['date_created']), module_user::link_open($file['create_user_id'], true));
});
if (module_file::can_i('edit', 'Files')) {
    $columns['file_action'] = array('title' => ' ', 'callback' => function ($file) {
        echo '<input type="checkbox" name="bulk_operation[' . $file['file_id'] . ']" value="yes">';
    });
}
if (class_exists('module_extra', false)) {
    $table_manager->display_extra('file', function ($file) {
        module_extra::print_table_data('file', $file['file_id']);
    });
}
$table_manager->set_columns($columns);
$table_manager->row_callback = function ($row_data) {
    // load the full file data before displaying each row so we have access to more details
    if (isset($row_data['file_id']) && (int) $row_data['file_id'] > 0) {
예제 #18
0
    public function output_block($level)
    {
        if (!$this->get('social_twitter_message_id') || $level < -3) {
            return;
        }
        $twitter_data = @json_decode($this->get('data'), true);
        // any previous messages?
        if ($level <= 0) {
            if ($this->get('reply_to_id')) {
                // this tweet is a reply to a previous tweet!
                ?>
				<div class="twitter_previous_messages">
					<?php 
                $reply_message = new ucm_twitter_message($this->twitter_account, $this->get('reply_to_id'));
                $reply_message->output_block($level - 1);
                ?>
				</div>
				<?php 
            } else {
                if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                    // find previous message(s)
                    $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                    $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                    if ($from && $to) {
                        $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time <= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` DESC LIMIT 1";
                        $previous = qa1($sql);
                        if ($previous && $previous['social_twitter_message_id']) {
                            ?>
						<div class="twitter_previous_messages twitter_direct">
							<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $previous['social_twitter_message_id']);
                            $reply_message->output_block($level - 1);
                            ?>
						</div>
						<?php 
                        }
                    }
                }
            }
        }
        $message_from = isset($twitter_data['user']) ? $twitter_data['user'] : (isset($twitter_data['sender']) ? $twitter_data['sender'] : false);
        if ($this->get('summary')) {
            if ($message_from && $this->get('type') != _TWITTER_MESSAGE_TYPE_DIRECT) {
                $message_from['tweet_id'] = isset($twitter_data['id_str']) ? $twitter_data['id_str'] : false;
            }
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            ?>
			<div class="twitter_comment <?php 
            echo $level != 0 ? ' twitter_comment_clickable' : 'twitter_comment_current';
            ?>
" data-id="<?php 
            echo $this->social_twitter_message_id;
            ?>
" data-link="<?php 
            echo module_social_twitter::link_open_twitter_message($this->get('social_twitter_id'), $this->social_twitter_message_id);
            ?>
" data-title="<?php 
            echo _l('Tweet');
            ?>
">
				<div class="twitter_comment_picture">
					<?php 
            if (isset($twitter_data['user']['id_str'])) {
                $pic = array('screen_name' => isset($twitter_data['user']['screen_name']) ? $twitter_data['user']['screen_name'] : '', 'image' => isset($twitter_data['user']['profile_image_url_https']) ? $twitter_data['user']['profile_image_url_https'] : '');
            } else {
                if (isset($twitter_data['sender']['id_str'])) {
                    $pic = array('screen_name' => isset($twitter_data['sender']['screen_name']) ? $twitter_data['sender']['screen_name'] : '', 'image' => isset($twitter_data['sender']['profile_image_url_https']) ? $twitter_data['sender']['profile_image_url_https'] : '');
                } else {
                    $pic = false;
                }
            }
            if ($pic) {
                ?>
						<img src="<?php 
                echo $pic['image'];
                ?>
">
						<?php 
            }
            ?>
				</div>
				<div class="twitter_comment_header">
					<?php 
            _e('From:');
            echo ' ';
            echo $message_from ? ucm_twitter::format_person($message_from) : 'N/A';
            ?>
					<span><?php 
            $time = strtotime($this->get('message_time'));
            echo $time ? ' @ ' . print_date($time, true) : '';
            if ($this->get('user_id')) {
                echo ' (sent by ' . module_user::link_open($this->get('user_id'), true) . ')';
            }
            ?>
					</span>
				</div>
				<div class="twitter_comment_body">
					<?php 
            if (isset($twitter_data['entities']['media']) && is_array($twitter_data['entities']['media'])) {
                foreach ($twitter_data['entities']['media'] as $media) {
                    if ($media['type'] == 'photo') {
                        ?>
								<div class="twitter_picture">
									<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 <a
										href="<?php 
                            echo htmlspecialchars($media['url']);
                            ?>
"
										target="_blank"> <?php 
                        }
                        ?>
										<img src="<?php 
                        echo htmlspecialchars($media['media_url_https']);
                        ?>
">
										<?php 
                        if (isset($media['url']) && $media['url']) {
                            ?>
 </a> <?php 
                        }
                        ?>
								</div>
							<?php 
                    }
                }
            }
            ?>
					<div>
						<?php 
            echo forum_text($this->get('summary'));
            ?>
					</div>
					<div class="twitter_comment_stats">
						<?php 
            $data = @json_decode($this->get('data'), true);
            //print_r($data);
            if ($data && (isset($data['retweet_count']) && $data['retweet_count'] > 0 || isset($data['favorite_count']) && $data['favorite_count'] > 0)) {
                if (isset($data['retweet_count']) && $data['retweet_count'] > 0) {
                    echo _l('Retweets: %s', $data['retweet_count']);
                }
                echo ' ';
                if (isset($data['favorite_count']) && $data['favorite_count'] > 0) {
                    echo _l('Favorites: %s', $data['favorite_count']);
                }
            }
            ?>
					</div>
				</div>
				<div class="twitter_comment_actions">
					<?php 
            if ($this->can_reply) {
                ?>
						<a href="#" class="twitter_reply_button"><?php 
                _e('Reply');
                ?>
</a>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
        ?>
		<?php 
        if ($level == 0) {
            ?>
			<div class="twitter_comment_replies">
			<?php 
            //if(strpos($twitter_data['message'],'picture')){
            //echo '<pre>'; print_r($twitter_data); echo '</pre>';
            //}
            if ($this->can_reply) {
                $this->reply_box($level, $message_from);
            }
            ?>
			</div>
		<?php 
        }
        if ($level >= 0) {
            // any follow up messages?
            if ($this->get('type') == _TWITTER_MESSAGE_TYPE_DIRECT) {
                $from = preg_replace('#[^0-9]#', '', $this->get('twitter_from_id'));
                $to = preg_replace('#[^0-9]#', '', $this->get('twitter_to_id'));
                if ($from && $to) {
                    $sql = "SELECT * FROM `" . _DB_PREFIX . "social_twitter_message` WHERE `type` = " . _TWITTER_MESSAGE_TYPE_DIRECT . " AND message_time >= " . (int) $this->get('message_time') . " AND social_twitter_message_id != " . (int) $this->social_twitter_message_id . " AND ( (`twitter_from_id` = {$from} AND `twitter_to_id` = {$to}) OR (`twitter_from_id` = {$to} AND `twitter_to_id` = {$from}) ) ORDER BY `message_time` ASC LIMIT 1";
                    $next = qa1($sql);
                    if ($next && $next['social_twitter_message_id']) {
                        ?>
						<div class="twitter_next_messages twitter_direct">
							<?php 
                        $reply_message = new ucm_twitter_message($this->twitter_account, $next['social_twitter_message_id']);
                        $reply_message->output_block($level + 1);
                        ?>
						</div>
						<?php 
                    }
                }
            } else {
                $next = get_multiple('social_twitter_message', array('social_twitter_id' => $this->twitter_account->get('social_twitter_id'), 'reply_to_id' => $this->social_twitter_message_id), 'social_twitter_message_id');
                if ($next) {
                    foreach ($next as $n) {
                        // this tweet is a reply to a previous tweet!
                        if ($n['social_twitter_message_id']) {
                            ?>
							<div class="twitter_next_messages">
								<?php 
                            $reply_message = new ucm_twitter_message($this->twitter_account, $n['social_twitter_message_id']);
                            $reply_message->output_block($level + 1);
                            ?>
							</div>
							<?php 
                        }
                    }
                }
            }
        }
    }
예제 #19
0
파일: data.php 프로젝트: sgh1986915/php-crm
    function get_form_element($element, $viewing_revision = false, $data_record = array())
    {
        $has_write_access = !$viewing_revision;
        // convert our data field to an element.
        $element['name'] = isset($element['name']) && !empty($element['name']) ? $element['name'] : 'data_field[' . $element['data_field_id'] . ']';
        $element['id'] = 'data_field_' . $element['data_field_id'] . '';
        $element['type'] = $element['field_type'];
        if (!isset($element['value'])) {
            $element['value'] = '';
        }
        if (!$has_write_access) {
            //$element['disabled'] = 'disabled';
            $element['class'] = 'data_field_view';
        }
        $highlight = false;
        $this->ajax_edit = false;
        $input_name = $element['name'];
        if (!$input_name) {
            return false;
        }
        if (isset($element['id']) && $element['id']) {
            $input_id = $element['id'];
        } else {
            $element['id'] = $input_name;
            $input_id = $input_name;
        }
        //if(!$value && isset($_REQUEST[$input_name]))$value = $_REQUEST[$input_name];
        if (!$element['value']) {
            $element['value'] = $element['default'];
        }
        if (!is_array($element['value'])) {
            //$value=htmlspecialchars($value);
        }
        if (!isset($element['class'])) {
            $element['class'] = '';
        }
        $attr = $attr_other = '';
        if ($has_write_access) {
            if ($element['type'] == 'radio' || $element['type'] == 'checkbox_list') {
                // hacky!
                if ($element['required']) {
                    $attr_other .= ' class="form_field form_field_required"';
                } else {
                    $attr_other .= ' class="form_field"';
                }
            } else {
                $element['class'] .= " form_field";
                if ($element['required']) {
                    $element['class'] .= " form_field_required";
                }
            }
            switch ($element['type']) {
                case 'date':
                    $element['class'] .= " date_field";
                    if (!isset($element['size']) || !$element['size']) {
                        $element['size'] = 8;
                    }
                    if (strtolower($element['value']) == 'now') {
                        $element['value'] = print_date(time());
                    }
                    break;
                case 'datetime':
                    $element['class'] .= " date_time_field";
                    if (!isset($element['size']) || !$element['size']) {
                        $element['size'] = 12;
                    }
                    if (strtolower($element['value']) == 'now') {
                        $element['value'] = print_date(time(), true);
                    }
                    break;
            }
        }
        switch ($element['type']) {
            case 'checkbox_list':
            case 'radio':
                $element['attributes'] = array();
                foreach (explode("\n", trim($element['field_data'])) as $line) {
                    $line = trim($line);
                    if (preg_match('/^attributes=/', $line)) {
                        $line = preg_replace('/^attributes=/', '', $line);
                        $element['attributes'] = explode("|", $line);
                        break;
                    }
                }
                break;
            case 'select':
                if (!isset($element['attributes']) || !is_array($element['attributes']) || !count($element['attributes'])) {
                    $element['attributes'] = array();
                    foreach (explode("\n", trim($element['field_data'])) as $line) {
                        $line = trim($line);
                        if (preg_match('/^attributes=/', $line)) {
                            $line = preg_replace('/^attributes=/', '', $line);
                            if (preg_match('#hook:([\\w_]+)$#', $line, $matches)) {
                                // see if we get anything back from this hook.
                                $attributes = array();
                                $attributes = hook_filter_var($matches[1], $attributes, $element);
                                if (is_array($attributes)) {
                                    $element['attributes'] = $attributes;
                                } else {
                                    $element['attributes'] = array('Unable to call hook: ' . $matches[1]);
                                }
                            } else {
                                $element['attributes'] = explode("|", $line);
                            }
                            break;
                        }
                    }
                }
                break;
        }
        if (!isset($element['style'])) {
            $element['style'] = '';
        }
        // we have to apply some custom width/height styles if they exist.
        $width = $height = false;
        foreach (explode("\n", trim($element['field_data'])) as $line) {
            $line = trim($line);
            if (preg_match('/^width=/', $line)) {
                $line = preg_replace('/^width=/', '', $line);
                $width = (int) $line;
            }
            if (preg_match('/^height=/', $line)) {
                $line = preg_replace('/^height=/', '', $line);
                $height = (int) $line;
            }
        }
        if (!$height && $height < _MIN_INPUT_HEIGHT) {
            $height = _MIN_INPUT_HEIGHT;
        }
        switch ($element['type']) {
            case 'text':
            case 'date':
            case 'datetime':
                if ($width) {
                    $element['style'] .= 'width:' . $width . 'px; ';
                }
                break;
            case 'radio':
                if ($width) {
                    $attr_other .= ' style="width:' . $width . 'px; "';
                }
                break;
            case 'textarea':
            case 'textbox':
                if ($width) {
                    $element['style'] .= 'width:' . $width . 'px; ';
                }
                if ($has_write_access && $height) {
                    $element['style'] .= 'height:' . $height . 'px; ';
                }
                break;
        }
        if (isset($element['width'])) {
            unset($element['width']);
        }
        if (isset($element['height'])) {
            unset($element['height']);
        }
        if (isset($element['multiple']) && $element['multiple']) {
            $element['multiple'] = true;
            // pass 'multiple' through to the UCM form builder which should handle everything
            $value_unserialize = @unserialize($element['value']);
            if (is_array($value_unserialize)) {
                $element['values'] = $value_unserialize;
                // 'values' is used in the UCM field generation tool
            }
            $element['name'] = $element['name'] . '[]';
        } else {
            $element['multiple'] = false;
        }
        if (!$has_write_access && $element['multiple'] && isset($element['values']) && is_array($element['values'])) {
            $element['value'] = $element['values'];
        }
        if (is_array($element['value']) && count($element['value'])) {
            $all_values = $element['value'];
        } else {
            $all_values = array($element['value']);
        }
        if ($element['type'] == 'checkbox_list') {
            $test = @unserialize($element['value']);
            if (is_array($test) && count($test)) {
                $all_values = array($test);
            } else {
                $all_values = array($element['value']);
            }
        }
        if ($element['type'] == "cancel" && !isset($element['onclick'])) {
            $element['onclick'] = "history.go(-1);";
        }
        if ($highlight) {
            $element['class'] .= " form_field_highlight";
        }
        /*if(!$has_write_access){
        			$element['class'] .= ' form_disabled';
        		}*/
        $attribute_keys = array('class', 'disabled', 'onclick', 'onfocus', 'onmouseup', 'onmousedown', 'onchange', 'size', 'cols', 'rows', 'width', 'style');
        foreach ($element as $key => $val) {
            if (!is_array($val) && !trim($val)) {
                continue;
            }
            if (in_array(strtolower($key), $attribute_keys)) {
                if (in_array(strtolower($key), array('size', 'cols', 'rows', 'width', 'height')) && (int) $val == 0) {
                    continue;
                }
                $attr .= ' ' . $key . '="' . $val . '"';
            }
        }
        // check for default values, these are cleared when submitting the form
        if ($element['default']) {
            $has_default = true;
        }
        $real_input_id = $input_id;
        $real_input_name = $input_name;
        ob_start();
        foreach ($all_values as $value_key => $value) {
            if (!$has_write_access) {
                // disabled.
                if (isset($width) && $width && $element['type'] != 'encrypted') {
                    echo '<span ' . $attr;
                    echo ' style="width:' . $width . 'px;"';
                    echo '>&nbsp;';
                }
                // display value differently depending on value type.
                switch ($element['type']) {
                    case 'checkbox_list':
                        $other = '';
                        if (is_array($value)) {
                            if (isset($value['other_val'])) {
                                $other = $value['other_val'];
                                unset($value['other_val']);
                            }
                            echo implode(', ', array_keys($value));
                        }
                        echo ' ' . $other;
                        break;
                    case 'select':
                        if (isset($element['attributes'])) {
                            $attributes = $element['attributes'];
                        } else {
                            $attributes = array();
                        }
                        if (isset($attributes[0])) {
                            $new_attributes = array();
                            foreach ($attributes as $aid => $a) {
                                $new_attributes[$aid + 1] = $a;
                            }
                            $attributes = $new_attributes;
                        }
                        if (isset($attributes[$value])) {
                            echo $attributes[$value];
                        }
                        break;
                    case 'textarea':
                    case 'textbox':
                        echo nl2br(htmlspecialchars($value));
                        break;
                    case 'file':
                        if ($value) {
                            $file_data = @unserialize($value);
                            $file_link = 'includes/plugin_data/upload/' . $file_data['file'];
                            if (is_file($file_link)) {
                                $download_link = self::link_public_file_download($data_record['data_record_id'], $data_record['data_type_id'], $element['data_field_group_id'], $element['data_field_id']);
                                echo '<a href="' . $download_link . '" target="_blank">' . $file_data['name'] . '</a>';
                            } else {
                                echo 'File Not Found';
                            }
                        }
                        break;
                    case 'wysiwyg':
                        echo module_security::purify_html($value);
                        break;
                    case 'encrypted':
                        if (class_exists('module_encrypt', false)) {
                            ob_start();
                            $element['type'] = 'text';
                            module_form::generate_form_element($element);
                            $enc_html = ob_get_clean();
                            echo module_encrypt::parse_html_input('custom_data', $enc_html, false);
                        }
                        break;
                    case 'created_date_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A');
                        break;
                    case 'created_date':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A');
                        break;
                    case 'created_time':
                        echo isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A');
                        break;
                    case 'updated_date_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], true) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], true) : _l('N/A'));
                        break;
                    case 'updated_date':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? print_date($data_record['date_updated'], false) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? print_date($data_record['date_created'], false) : _l('N/A'));
                        break;
                    case 'updated_time':
                        echo isset($data_record['date_updated']) && $data_record['date_updated'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_updated'])) : (isset($data_record['date_created']) && $data_record['date_created'] != '0000-00-00 00:00:00' ? date(module_config::c('time_format', 'g:ia'), strtotime($data_record['date_created'])) : _l('N/A'));
                        break;
                    case 'created_by':
                        echo isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A');
                        break;
                    case 'updated_by':
                        echo isset($data_record['update_user_id']) && (int) $data_record['update_user_id'] > 0 ? module_user::link_open($data_record['update_user_id'], true) : (isset($data_record['create_user_id']) && (int) $data_record['create_user_id'] > 0 ? module_user::link_open($data_record['create_user_id'], true) : _l('N/A'));
                        break;
                    case 'url':
                        echo '<a href="' . htmlspecialchars($value) . '" target="_blank">' . htmlspecialchars($value) . '</a>';
                        break;
                    default:
                        echo htmlspecialchars($value);
                        break;
                }
                if (isset($width) && $width && $element['type'] != 'encrypted') {
                    echo '&nbsp;</span>';
                }
            } else {
                // update for UCM: use the ucm form generator
                if (isset($element['default']) && $element['default'] && !$element['value']) {
                    $element['value'] = $element['default'];
                }
                switch ($element['type']) {
                    case 'wysiwyg':
                        $element['options']['inline'] = false;
                        module_form::generate_form_element($element);
                        break;
                    case "radio":
                        $has_val = false;
                        foreach ($element['attributes'] as $attribute) {
                            $this_input_id = $input_id . preg_replace('/[^a-zA-Z]/', '', $attribute);
                            ?>

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

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

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

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

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

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

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

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

						<a href="mailto:<?php 
                        echo $value;
                        ?>
">&raquo;</a>
					<?php 
                    }
                }
            }
            // editable
            echo '&nbsp;';
        }
        // foreach all values
        //${$element_id} = ob_get_clean();
        // we just print the html for now
        return ob_get_clean();
    }
예제 #20
0
        $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);
        ?>

                        <?php 
        if (module_file::can_i('delete', 'File Comments') || $item['create_user_id'] == module_security::get_loggedin_id()) {
            ?>

                        <a href="#" onclick="if(confirm('<?php 
            echo _l('Really remove this comment?');
            ?>
')){$('#delete_file_comment_id').val('<?php 
            echo $item['file_comment_id'];
            ?>
예제 #21
0
    <?php 
            if (module_security::getcred()) {
                ?>

    <div id="left">

        <div class="media user-media">
            <div class="media-body">
                <h5 class="media-heading"><?php 
                $user = module_user::get_user(module_security::get_loggedin_id());
                _e('Welcome %s', htmlspecialchars($user['name']));
                ?>
</h5>
                <ul class="list-unstyled user-info">
                    <li><small><i class="fa fa-user"></i> <a href="<?php 
                echo module_user::link_open($_SESSION['_user_id']);
                ?>
"><?php 
                _e('Edit Profile');
                ?>
</a></small></li>
	                <?php 
                $header_buttons = array();
                if (module_security::is_logged_in()) {
                    $header_buttons = hook_filter_var('header_buttons', $header_buttons);
                }
                foreach ($header_buttons as $header_button) {
                    ?>

			        <li>
				        <small><i class="fa fa-<?php 
예제 #22
0
        echo $task_id;
        ?>
">
									</div>
								</div>
							</div>
							<?php 
    }
}
$x = 0;
foreach ($comments as $comment) {
    ?>
						<div class="panel panel-default">
							<div class="panel-heading">
								<h3 class="panel-title"><?php 
    echo $comment['user_id'] ? module_user::link_open($comment['user_id'], true, array(), true) : 'Unknown';
    ?>
 <small><?php 
    echo print_date($comment['date_created'], true);
    ?>
</small></h3>
							</div>
							<div class="panel-body">
								<?php 
    echo forum_text($comment['note']);
    ?>
							</div>
						</div>
						<?php 
    $x++;
}
예제 #23
0
$title = 'User Details';
include module_theme::include_ucm('includes/plugin_user/pages/contact_admin_form.php');
if (module_config::c('users_have_address', 0)) {
    ob_start();
    handle_hook("address_block", $module, "physical", "user", "user_id");
    $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Address'), 'elements_before' => ob_get_clean());
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
}
if ((int) $user_id > 0) {
    //handle_hook("note_list",$module,"user","user_id",$user_id);
    if (class_exists('module_note', false) && module_note::is_plugin_enabled()) {
        module_note::display_notes(array('title' => 'User Notes', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => $module->link_open($user_id)));
    }
    if (class_exists('module_group', false) && module_group::is_plugin_enabled()) {
        module_group::display_groups(array('title' => 'User Groups', 'owner_table' => 'user', 'owner_id' => $user_id, 'view_link' => module_user::link_open($user_id)));
    }
}
hook_handle_callback('layout_column_half', 2);
if (is_file('includes/plugin_user/pages/user_admin_edit_login.php')) {
    include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_login.php');
}
if (is_file('includes/plugin_user/pages/user_admin_edit_staff.php')) {
    include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_staff.php');
}
if (is_file('includes/plugin_user/pages/user_admin_edit_company.php')) {
    include module_theme::include_ucm('includes/plugin_user/pages/user_admin_edit_company.php');
}
hook_handle_callback('layout_column_half', 'end');
$form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save User')), array('ignore' => !($user_id != 1 && module_user::can_i('delete', 'Users', 'Config')), '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_open(false) . "';")));
echo module_form::generate_form_actions($form_actions);
예제 #24
0
                $staff_messages[] = $message;
            }
            if (!isset($staff_tickets[$message['ticket_id']])) {
                $staff_tickets[$message['ticket_id']] = array();
            }
            $staff_tickets[$message['ticket_id']][] = $message;
        }
    }
    ?>
            <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
                <td class="row_action" nowrap="">
                    <?php 
    echo module_user::link_open($staff_member['user_id'], true);
    ?>
                </td>
	            <td>
		            <?php 
    echo count($staff_messages);
    ?>
 in <?php 
    echo count($staff_tickets);
    ?>
 tickets
	            </td>
	            <td>
		            <?php 
    echo count($staff_private_messages);
    ?>
예제 #25
0
</td>
                    <td><?php 
    echo htmlspecialchars($n['subject']);
    ?>
</td>
                    <td><?php 
    $headers = unserialize($n['headers']);
    if (isset($headers['to']) && is_array($headers['to'])) {
        foreach ($headers['to'] as $to) {
            echo $to['email'] . ' ';
        }
    }
    ?>
</td>
                    <td><?php 
    echo module_user::link_open($n['create_user_id'], true);
    ?>
</td>
                </tr>
            <?php 
}
?>
        </tbody>
    </table>
    <div style="min-height: 10px;">
        <?php 
echo $pagination['page_numbers'] > 1 ? $pagination['links'] : '';
?>
    </div>
</div>
<?php 
예제 #26
0
 public function handle_hook($hook, &$calling_module = false, $show_all = false)
 {
     switch ($hook) {
         case 'dashboard_widgets':
             // see finance for example of widget usage.
             break;
         case "home_alerts":
             $cache_timeout = module_config::c('cache_objects', 60);
             $cache_key = 'home_alerts_' . module_security::get_loggedin_id();
             $alerts = array();
             if ($show_all || module_config::c('quote_alerts', 1)) {
                 // find any quotes that are past the due date and dont have a finished date.
                 $key = _l('Unapproved Quote');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('quote' => _l('Quote Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'date' => _l('Sent Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns, 'sort' => array('time' => 'DESC')));
                 }
                 if ($cached_alerts = module_cache::get('quote', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Quote Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     if (module_config::c('quote_dashboard_show_all_unapproved', 1)) {
                         $quotes = self::get_quotes(array(), array('custom_where' => " AND u.date_approved = '0000-00-00'"));
                     } else {
                         $quotes = self::get_quotes(array(), array('custom_where' => " AND u.date_approved = '0000-00-00' AND u.date_create <= '" . date('Y-m-d', strtotime('-' . module_config::c('alert_days_in_future', 5) . ' days')) . "'"));
                     }
                     foreach ($quotes as $quote_data) {
                         // permission check:
                         //                            $quote_data = self::get_quote($task['quote_id']);
                         //                            if(!$quote_data || $quote_data['quote_id']!=$task['quote_id'])continue;
                         $alert_res = process_alert($quote_data['date_create'], 'temp');
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($quote_data['quote_id'], false, $quote_data);
                             $alert_res['name'] = $quote_data['name'];
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($alert_res['date']);
                             $alert_res['group'] = $key;
                             $alert_res['quote'] = $this->link_open($quote_data['quote_id'], true, $quote_data);
                             $alert_res['customer'] = $quote_data['customer_id'] ? module_customer::link_open($quote_data['customer_id'], true) : _l('N/A');
                             $alert_res['website'] = $quote_data['website_id'] ? module_website::link_open($quote_data['website_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $quote_data['user_id'] ? module_user::link_open($quote_data['user_id'], true) : _l('N/A');
                             $alert_res['date'] = print_date($alert_res['date']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts['quoteincomplete' . $quote_data['quote_id']] = $alert_res;
                         }
                     }
                     module_cache::put('quote', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             return $alerts;
             break;
     }
     return false;
 }
예제 #27
0
    $total['job_count'] += $staff_report['job_count'];
    $total['task_count'] += $staff_report['task_count'];
    $total['tasks_complete'] += $staff_report['tasks_complete'];
    $total['hours_logged'] += $staff_report['hours_logged'];
    $total['hours_billed'] += $staff_report['hours_billed'];
    $total['amount_billed'] += $staff_report['amount_billed'];
    $total['amount_invoiced'] += $staff_report['amount_invoiced'];
    ?>

    <tr class="<?php 
    echo $c++ % 2 ? "odd" : "even";
    ?>
">
        <td>
            <?php 
    echo module_user::link_open($staff_report['user_id'], true);
    ?>

        </td>
        <td>
            <?php 
    echo $staff_report['job_count'];
    ?>

        </td>
        <td>
            <?php 
    echo $staff_report['task_count'];
    ?>

        </td>
예제 #28
0
파일: job.php 프로젝트: sgh1986915/php-crm
 public function handle_hook($hook, &$calling_module = false, $show_all = false)
 {
     switch ($hook) {
         case 'dashboard_widgets':
             // see finance for example of widget usage.
             break;
         case "home_alerts":
             $cache_timeout = module_config::c('cache_objects', 60);
             $cache_key = 'home_alerts_' . module_security::get_loggedin_id();
             $alerts = array();
             /*if(module_config::c('job_task_alerts',1)){
                   // find out any overdue tasks or jobs.
                   $sql = "SELECT t.*,p.name AS job_name FROM `"._DB_PREFIX."task` t ";
                   $sql .= " LEFT JOIN `"._DB_PREFIX."job` p USING (job_id) ";
                   $sql .= " WHERE t.date_due != '0000-00-00' AND t.date_due <= '".date('Y-m-d',strtotime('+'.module_config::c('alert_days_in_future',5).' days'))."' AND ((t.hours = 0 AND t.completed = 0) OR t.completed < t.hours)";
                   $tasks = qa($sql);
                   foreach($tasks as $task){
                       $alert_res = process_alert($task['date_due'], _l('Job: %s',$task['job_name']));
                       if($alert_res){
                           $alert_res['link'] = $this->link_open($task['job_id']);
                           $alert_res['name'] = $task['description'];
                           $alerts[] = $alert_res;
                       }
                   }
               }*/
             if ($show_all || module_config::c('job_alerts', 1)) {
                 // find any jobs that are past the due date and dont have a finished date.
                 $key = _l('Incomplete Job');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'progress' => _l('Job Progress'), 'assigned_staff' => _l('Staff'), 'date' => _l('Due Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns, 'sort' => array('time' => 'DESC')));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     //                        $sql = "SELECT * FROM `"._DB_PREFIX."job` p ";
                     //                        $sql .= " WHERE p.date_due != '0000-00-00' AND p.date_due <= '".date('Y-m-d',strtotime('+'.module_config::c('alert_days_in_future',5).' days'))."' AND p.date_completed = '0000-00-00'";
                     //                        $tasks = qa($sql);
                     $jobs = self::get_jobs(array(), array('custom_where' => " AND u.date_due != '0000-00-00' AND u.date_due <= '" . date('Y-m-d', strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days')) . "' AND u.date_completed = '0000-00-00'"));
                     foreach ($jobs as $job_data) {
                         // permission check:
                         //                            $job_data = self::get_job($task['job_id']);
                         //                            if(!$job_data || $job_data['job_id']!=$task['job_id'])continue;
                         $alert_res = process_alert($job_data['date_due'], 'temp');
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($job_data['job_id'], false, $job_data);
                             $alert_res['name'] = $job_data['name'];
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($alert_res['date']);
                             $alert_res['group'] = $key;
                             $alert_res['job'] = $this->link_open($job_data['job_id'], true, $job_data);
                             $alert_res['customer'] = $job_data['customer_id'] ? module_customer::link_open($job_data['customer_id'], true) : _l('N/A');
                             $alert_res['website'] = $job_data['website_id'] ? module_website::link_open($job_data['website_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $job_data['user_id'] ? module_user::link_open($job_data['user_id'], true) : _l('N/A');
                             $alert_res['progress'] = $job_data['total_percent_complete'] * 100 . '%';
                             $alert_res['date'] = print_date($alert_res['date']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts['jobincomplete' . $job_data['job_id']] = $alert_res;
                         }
                     }
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key . ' #2'));
                     // find any jobs that haven't started yet (ie: have a start date, but no completed tasks)
                     //                        $sql = "SELECT * FROM `"._DB_PREFIX."job` p ";
                     //                        $sql .= " WHERE p.date_completed = '0000-00-00' AND p.date_start != '0000-00-00' AND p.date_start <= '".date('Y-m-d',strtotime('+'.module_config::c('alert_days_in_future',5).' days'))."'";
                     //                        $jobs = qa($sql);
                     $jobs = self::get_jobs(array(), array('custom_where' => " AND u.date_completed = '0000-00-00' AND u.date_due = '0000-00-00' AND u.date_start != '0000-00-00' AND u.date_start <= '" . date('Y-m-d', strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days')) . "'"));
                     foreach ($jobs as $job_data) {
                         //$job_data = self::get_job($job['job_id']);
                         //if(!$job_data || $job_data['job_id']!=$job['job_id'])continue;
                         /*$job_started=true;
                                                     if(module_config::c('job_start_alerts_old',0)){
                                                         $tasks = self::get_tasks($job['job_id']);
                                                         $job_started = false;
                                                         foreach($tasks as $task){
                                                             if($task['fully_completed']){
                                                                 $job_started = true;
                                                                 break;
                                                             }
                                                         }
                                                     }
                                                     if(!$job_started){
                         
                                                         $alert_res = process_alert($job['date_start'], _l('Job Not Started'));
                                                         if($alert_res){
                                                             $alert_res['link'] = $this->link_open($job['job_id'],false,$job);
                                                             $alert_res['name'] = $job['name'];
                                                             $alerts[] = $alert_res;
                                                         }
                                                     }else{*/
                         // do the same alert as above.
                         if (!isset($this_alerts['jobincomplete' . $job_data['job_id']])) {
                             $alert_res = process_alert($job_data['date_start'], $key);
                             if ($alert_res) {
                                 $alert_res['link'] = $this->link_open($job_data['job_id'], false, $job_data);
                                 $alert_res['name'] = $job_data['name'];
                                 // new dashboard alert layout here:
                                 $alert_res['time'] = strtotime($alert_res['date']);
                                 $alert_res['group'] = $key;
                                 $alert_res['job'] = $this->link_open($job_data['job_id'], true, $job_data);
                                 $alert_res['customer'] = $job_data['customer_id'] ? module_customer::link_open($job_data['customer_id'], true) : _l('N/A');
                                 $alert_res['website'] = $job_data['website_id'] ? module_website::link_open($job_data['website_id'], true) : _l('N/A');
                                 $alert_res['assigned_staff'] = $job_data['user_id'] ? module_user::link_open($job_data['user_id'], true) : _l('N/A');
                                 $alert_res['progress'] = $job_data['total_percent_complete'] * 100 . '%';
                                 $alert_res['date'] = print_date($alert_res['date']);
                                 $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                                 $this_alerts['jobincomplete' . $job_data['job_id']] = $alert_res;
                             }
                         }
                         /* }*/
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             if (module_config::c('job_allow_quotes', 0) && ($show_all || module_config::c('job_quote_alerts', 1))) {
                 // find any jobs that dont have a start date yet.
                 $key = _l('Pending Job Quote');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'date' => _l('Quoted Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     //$sql = "SELECT * FROM `"._DB_PREFIX."job` p ";
                     //$sql .= " WHERE p.date_quote != '0000-00-00' AND p.date_start = '0000-00-00'";
                     //$tasks = qa($sql);
                     $jobs = self::get_jobs(array('date_start' => '0000-00-00', 'date_quote' => '!0000-00-00'));
                     foreach ($jobs as $job_data) {
                         //$job_data = self::get_job($task['job_id']);
                         //if(!$job_data || $job_data['job_id']!=$task['job_id'])continue;
                         $alert_res = process_alert($job_data['date_quote'], $key);
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($job_data['job_id'], false, $job_data);
                             $alert_res['name'] = $job_data['name'];
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($job_data['date_quote']);
                             $alert_res['group'] = $key;
                             $alert_res['job'] = $this->link_open($job_data['job_id'], true, $job_data);
                             $alert_res['customer'] = $job_data['customer_id'] ? module_customer::link_open($job_data['customer_id'], true) : _l('N/A');
                             $alert_res['website'] = $job_data['website_id'] ? module_website::link_open($job_data['website_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $job_data['user_id'] ? module_user::link_open($job_data['user_id'], true) : _l('N/A');
                             //$alert_res['progress'] = ($job_data['total_percent_complete'] * 100).'%';
                             $alert_res['date'] = print_date($alert_res['date']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts[] = $alert_res;
                         }
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             if ($show_all || module_config::c('job_invoice_alerts', 1)) {
                 // find any completed jobs that don't have an invoice.
                 $key = _l('Please Generate Invoice');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'invoicable_amount' => _l('Invoiceable Amount'), 'date' => _l('Completed Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     $sql = "SELECT j.* FROM `" . _DB_PREFIX . "job` j ";
                     $from = " LEFT JOIN `" . _DB_PREFIX . "task` t USING (job_id) ";
                     $from .= " LEFT JOIN `" . _DB_PREFIX . "invoice_item` ii ON t.task_id = ii.task_id ";
                     $from .= " LEFT JOIN `" . _DB_PREFIX . "invoice` i ON ii.invoice_id = i.invoice_id  ";
                     $where = " WHERE i.invoice_id IS NULL AND (j.date_completed != '0000-00-00')";
                     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 (j.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 j.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 ( j.customer_id = 0 OR j.customer_id IN ( ";
                                 foreach ($valid_customer_ids as $valid_customer_id) {
                                     $where .= (int) $valid_customer_id . ", ";
                                 }
                                 $where = rtrim($where, ', ');
                                 $where .= " )";
                                 $where .= " )";
                             }
                     }
                     $res = qa($sql . $from . $where . " GROUP BY j.job_id");
                     foreach ($res as $job) {
                         if (!isset($job['c_total_amount_invoicable']) || $job['c_total_amount_invoicable'] < 0) {
                             $this->update_job_completion_status($job['job_id']);
                             // seed the cache
                             $job = $this->get_job($job['job_id']);
                         }
                         //$job = $this->get_job($r['job_id']);
                         //if($job && $job['job_id'] == $r['job_id'] && $job['total_amount_invoicable'] > 0 && module_invoice::can_i('create','Invoices')){
                         if (isset($job['c_total_amount_invoicable']) && $job['c_total_amount_invoicable'] > 0 && module_invoice::can_i('create', 'Invoices')) {
                             $alert_res = process_alert($job['date_completed'], $key);
                             if ($alert_res) {
                                 $alert_res['link'] = $this->link_open($job['job_id'], false, $job);
                                 $alert_res['name'] = $job['name'];
                                 // new dashboard alert layout here:
                                 $alert_res['time'] = strtotime($job['date_completed']);
                                 $alert_res['group'] = $key;
                                 $alert_res['job'] = $this->link_open($job['job_id'], true, $job);
                                 $alert_res['customer'] = $job['customer_id'] ? module_customer::link_open($job['customer_id'], true) : _l('N/A');
                                 $alert_res['website'] = $job['website_id'] ? module_website::link_open($job['website_id'], true) : _l('N/A');
                                 $alert_res['assigned_staff'] = $job['user_id'] ? module_user::link_open($job['user_id'], true) : _l('N/A');
                                 $alert_res['invoicable_amount'] = currency($job['c_total_amount_invoicable'], true, $job['currency_id']);
                                 //$alert_res['progress'] = ($job['total_percent_complete'] * 100).'%';
                                 $alert_res['date'] = print_date($alert_res['date']);
                                 $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                                 $this_alerts[] = $alert_res;
                             }
                         }
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             if ($show_all || module_config::c('job_renew_alerts', 1)) {
                 // find any jobs that have a renew date soon and have not been renewed.
                 $key = _l('Job Renewal Pending');
                 $key_auto = _l('Automatic Job Renewal Pending');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'renewal_period' => _l('Period'), 'date_create' => _l('Created Date'), 'date' => _l('Renewal Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns));
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'renewal_period' => _l('Period'), 'date_create' => _l('Created Date'), 'date' => _l('Renewal Date'), 'renew_invoice' => _l('Automatic Invoice'), 'days' => _l('Day Count'));
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key_auto, array('columns' => $columns));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     /*$sql = "SELECT p.* FROM `"._DB_PREFIX."job` p ";
                       $sql .= " WHERE p.date_renew != '0000-00-00'";
                       $sql .= " AND p.date_renew <= '".date('Y-m-d',strtotime('+'.module_config::c('alert_days_in_future',5).' days'))."'";
                       $sql .= " AND (p.renew_job_id IS NULL OR p.renew_job_id = 0)";
                       $res = qa($sql);*/
                     $res = self::get_jobs(array(), array('custom_where' => " AND  u.date_renew != '0000-00-00' AND u.date_renew <= '" . date('Y-m-d', strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days')) . "' AND (u.renew_job_id IS NULL OR u.renew_job_id = 0)"));
                     foreach ($res as $job) {
                         //$job = self::get_job($r['job_id']);
                         //if(!$job || $job['job_id']!=$r['job_id'])continue;
                         if ($job['renew_auto']) {
                             $alert_res = process_alert($job['date_renew'], $key_auto);
                         } else {
                             $alert_res = process_alert($job['date_renew'], $key);
                         }
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($job['job_id'], false, $job);
                             $alert_res['name'] = $job['name'];
                             $alert_res['renewal_period'] = _l('N/A');
                             // work out renewal period
                             if ($job['date_start'] && $job['date_start'] != '0000-00-00') {
                                 $time_diff = strtotime($job['date_renew']) - strtotime($job['date_start']);
                                 if ($time_diff > 0) {
                                     $diff_type = 'day';
                                     $days = round($time_diff / 86400);
                                     if ($days >= 365) {
                                         $time_diff = round($days / 365, 1);
                                         $diff_type = 'year';
                                     } else {
                                         $time_diff = $days;
                                     }
                                     $alert_res['renewal_period'] = $time_diff . ' ' . $diff_type;
                                 }
                             }
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($job['date_renew']);
                             if ($job['renew_auto']) {
                                 $alert_res['group'] = $key_auto;
                                 $alert_res['renew_invoice'] = $job['renew_invoice'] ? _l('Yes') : _l('No');
                             } else {
                                 $alert_res['group'] = $key;
                             }
                             $alert_res['job'] = $this->link_open($job['job_id'], true, $job);
                             $alert_res['customer'] = $job['customer_id'] ? module_customer::link_open($job['customer_id'], true) : _l('N/A');
                             $alert_res['website'] = $job['website_id'] ? module_website::link_open($job['website_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $job['user_id'] ? module_user::link_open($job['user_id'], true) : _l('N/A');
                             //$alert_res['progress'] = ($job['total_percent_complete'] * 100).'%';
                             $alert_res['date_create'] = print_date($job['date_start']);
                             $alert_res['date'] = print_date($job['date_renew']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts[] = $alert_res;
                         }
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             if ($show_all || module_config::c('job_approval_alerts', 1)) {
                 $job_task_creation_permissions = self::get_job_task_creation_permissions();
                 if ($job_task_creation_permissions == _JOB_TASK_CREATION_WITHOUT_APPROVAL) {
                     // find any jobs that have tasks requiring approval
                     $key = _l('Tasks Require Approval');
                     if (class_exists('module_dashboard', false)) {
                         $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'task_count' => _l('Tasks to Approve'), 'date' => _l('Task Date'), 'days' => _l('Day Count'));
                         if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                             unset($columns['website']);
                         }
                         if (!module_customer::can_i('view', 'Customers')) {
                             unset($columns['customer']);
                         }
                         module_dashboard::register_group($key, array('columns' => $columns));
                     }
                     if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                         $alerts = array_merge($alerts, $cached_alerts);
                     } else {
                         module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                         $this_alerts = array();
                         $sql = "SELECT p.job_id,p.name, t.date_updated, t.date_created, COUNT(t.task_id) AS approval_count FROM `" . _DB_PREFIX . "job` p ";
                         $sql .= " LEFT JOIN `" . _DB_PREFIX . "task` t ON p.job_id = t.job_id";
                         $sql .= " WHERE t.approval_required = 1";
                         $sql .= " GROUP BY p.job_id ";
                         $res = qa($sql);
                         foreach ($res as $r) {
                             $job = self::get_job($r['job_id']);
                             if (!$job || $job['job_id'] != $r['job_id']) {
                                 continue;
                             }
                             $alert_res = process_alert($r['date_updated'] && $r['date_updated'] != '0000-00-00' ? $r['date_updated'] : $r['date_created'], $key);
                             if ($alert_res) {
                                 $alert_res['link'] = $this->link_open($r['job_id'], false, $r);
                                 $alert_res['name'] = $r['name'];
                                 // new dashboard alert layout here:
                                 $alert_res['time'] = strtotime($r['date_updated'] && $r['date_updated'] != '0000-00-00' ? $r['date_updated'] : $r['date_created']);
                                 $alert_res['group'] = $key;
                                 $alert_res['job'] = $this->link_open($job['job_id'], true, $job);
                                 $alert_res['customer'] = $job['customer_id'] ? module_customer::link_open($job['customer_id'], true) : _l('N/A');
                                 $alert_res['website'] = $job['website_id'] ? module_website::link_open($job['website_id'], true) : _l('N/A');
                                 $alert_res['assigned_staff'] = $job['user_id'] ? module_user::link_open($job['user_id'], true) : _l('N/A');
                                 //$alert_res['progress'] = ($job['total_percent_complete'] * 100).'%';
                                 $alert_res['task_count'] = $r['approval_count'];
                                 $alert_res['date'] = print_date($alert_res['time']);
                                 $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                                 $this_alerts[] = $alert_res;
                             }
                         }
                         module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                         $alerts = array_merge($alerts, $this_alerts);
                     }
                 }
                 // find any rejected tasks
                 $key = _l('Tasks Have Been Rejected');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer'), 'website' => module_config::c('project_name_single', 'Website'), 'assigned_staff' => _l('Staff'), 'task_count' => _l('Tasks Rejected'), 'date' => _l('Task Date'), 'days' => _l('Day Count'));
                     if (!class_exists('module_website', false) || !module_website::is_plugin_enabled()) {
                         unset($columns['website']);
                     }
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     $sql = "SELECT p.job_id,p.name, t.date_updated, t.date_created, COUNT(t.task_id) AS approval_count FROM `" . _DB_PREFIX . "job` p ";
                     $sql .= " LEFT JOIN `" . _DB_PREFIX . "task` t ON p.job_id = t.job_id";
                     $sql .= " WHERE t.approval_required = 2";
                     $sql .= " GROUP BY p.job_id ";
                     $res = qa($sql);
                     foreach ($res as $r) {
                         $job = self::get_job($r['job_id']);
                         if (!$job || $job['job_id'] != $r['job_id']) {
                             continue;
                         }
                         $alert_res = process_alert($r['date_updated'] && $r['date_updated'] != '0000-00-00' ? $r['date_updated'] : $r['date_created'], $key);
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($r['job_id'], false, $r);
                             $alert_res['name'] = $r['name'];
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($r['date_updated'] && $r['date_updated'] != '0000-00-00' ? $r['date_updated'] : $r['date_created']);
                             $alert_res['group'] = $key;
                             $alert_res['job'] = $this->link_open($job['job_id'], true, $job);
                             $alert_res['customer'] = $job['customer_id'] ? module_customer::link_open($job['customer_id'], true) : _l('N/A');
                             $alert_res['website'] = $job['website_id'] ? module_website::link_open($job['website_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $job['user_id'] ? module_user::link_open($job['user_id'], true) : _l('N/A');
                             //$alert_res['progress'] = ($job['total_percent_complete'] * 100).'%';
                             $alert_res['task_count'] = $r['approval_count'];
                             $alert_res['date'] = print_date($alert_res['time']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts[] = $alert_res;
                         }
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             if (module_security::can_user(module_security::get_loggedin_id(), 'Show Dashboard Todo List')) {
                 $key = _l('Job Todo');
                 if (class_exists('module_dashboard', false)) {
                     $columns = array('job' => _l('Job Title'), 'customer' => _l('Customer Name'), 'progress' => _l('Task Progress'), 'task' => _l('Task Description'), 'assigned_staff' => _l('Staff'), 'date' => _l('Due Date'), 'days' => _l('Day Count'));
                     if (!module_customer::can_i('view', 'Customers')) {
                         unset($columns['customer']);
                     }
                     module_dashboard::register_group($key, array('columns' => $columns));
                 }
                 if ($cached_alerts = module_cache::get('job', $cache_key . $key)) {
                     $alerts = array_merge($alerts, $cached_alerts);
                 } else {
                     module_debug::log(array('title' => 'Job Home Alerts: ', 'data' => " starting: " . $key));
                     $this_alerts = array();
                     $todo_list = self::get_tasks_todo();
                     $x = 0;
                     foreach ($todo_list as $todo_item) {
                         if ($todo_item['hours_completed'] > 0) {
                             if ($todo_item['hours'] > 0) {
                                 $percentage = round($todo_item['hours_completed'] / $todo_item['hours'], 2);
                                 $percentage = min(1, $percentage);
                             } else {
                                 $percentage = 1;
                             }
                         } else {
                             $percentage = 0;
                         }
                         $job_data = module_job::get_job($todo_item['job_id'], false);
                         $alert_res = process_alert($todo_item['date_due'], 'temp');
                         if ($alert_res) {
                             $alert_res['link'] = $this->link_open($todo_item['job_id'], false, $job_data);
                             $alert_res['name'] = $percentage * 100 . '% ' . $todo_item['description'];
                             $alert_res['item'] = $job_data['name'];
                             // new dashboard alert layout here:
                             $alert_res['time'] = strtotime($alert_res['date']);
                             $alert_res['group'] = $key;
                             $alert_res['job'] = $this->link_open($todo_item['job_id'], true, $job_data);
                             $alert_res['customer'] = $job_data['customer_id'] ? module_customer::link_open($job_data['customer_id'], true) : _l('N/A');
                             $alert_res['assigned_staff'] = $todo_item['user_id'] ? module_user::link_open($todo_item['user_id'], true) : _l('N/A');
                             $alert_res['progress'] = $percentage * 100 . '%';
                             $alert_res['task'] = htmlspecialchars($todo_item['description']);
                             $alert_res['date'] = $alert_res['warning'] ? '<span class="important">' . print_date($alert_res['date']) . '</span>' : print_date($alert_res['date']);
                             $alert_res['days'] = $alert_res['warning'] ? '<span class="important">' . $alert_res['days'] . '</span>' : $alert_res['days'];
                             $this_alerts[] = $alert_res;
                         }
                     }
                     module_cache::put('job', $cache_key . $key, $this_alerts, $cache_timeout);
                     $alerts = array_merge($alerts, $this_alerts);
                 }
             }
             return $alerts;
             break;
     }
     return false;
 }
예제 #29
0
파일: note.php 프로젝트: sgh1986915/php-crm
 function handle_hook($hook, $calling_module = false, $owner_table = false, $key_name = false, $key_value = false, $rel_data = false)
 {
     switch ($hook) {
         case "home_alerts":
             $alerts = array();
             if (module_config::c('allow_note_reminders', 1)) {
                 // find any jobs that are past the due date and dont have a finished date.
                 $key = _l('Note Reminder');
                 if (class_exists('module_dashboard', false)) {
                     module_dashboard::register_group($key, array('columns' => array('name' => _l('Reminder'), 'type' => _l('Type'), 'full_link' => _l('Link'), 'date' => _l('Date'), 'days' => _l('Date'))));
                 }
                 $sql = "SELECT * FROM `" . _DB_PREFIX . "note` n ";
                 $sql .= " WHERE n.`reminder` = 1 AND n.note_time < " . (int) strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days') . "";
                 $sql .= " AND ( n.`user_id` = 0 OR n.`user_id` = " . module_security::get_loggedin_id() . ")";
                 $sql .= " ORDER BY n.note_time ASC";
                 $tasks = qa($sql);
                 foreach ($tasks as $task) {
                     $alert_res = process_alert(date('Y-m-d', $task['note_time']), $key);
                     if ($alert_res) {
                         $alert_res['link'] = $task['rel_data'];
                         // fix for linking when changing folder.
                         $alert_res['type'] = _l(ucwords($task['owner_table']));
                         switch ($task['owner_table']) {
                             case 'user':
                                 $user = module_user::get_user($task['owner_id']);
                                 if ($user['customer_id'] || $user['vendor_id']) {
                                     $alert_res['link'] = module_user::link_open_contact($task['owner_id'], false, $user);
                                     $alert_res['full_link'] = module_user::link_open_contact($task['owner_id'], true, $user);
                                     $alert_res['type'] = _l('Contact');
                                 } else {
                                     $alert_res['link'] = module_user::link_open($task['owner_id'], false, $user);
                                     $alert_res['full_link'] = module_user::link_open($task['owner_id'], true, $user);
                                 }
                                 break;
                             case 'invoice':
                                 $invoice_data = module_invoice::get_invoice($task['owner_id'], true);
                                 if (!$invoice_data || !isset($invoice_data['invoice_id']) || $invoice_data['invoice_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_invoice::link_open($task['owner_id'], false, $invoice_data);
                                 $alert_res['full_link'] = module_invoice::link_open($task['owner_id'], true, $invoice_data);
                                 break;
                             case 'quote':
                                 $quote_data = module_quote::get_quote($task['owner_id'], true);
                                 if (!$quote_data || !isset($quote_data['quote_id']) || $quote_data['quote_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_quote::link_open($task['owner_id'], false, $quote_data);
                                 $alert_res['full_link'] = module_quote::link_open($task['owner_id'], true, $quote_data);
                                 break;
                             case 'website':
                                 $website_data = module_website::get_website($task['owner_id']);
                                 if (!$website_data || !isset($website_data['website_id']) || $website_data['website_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_website::link_open($task['owner_id'], false);
                                 $alert_res['full_link'] = module_website::link_open($task['owner_id'], true);
                                 break;
                             case 'customer':
                                 $customer_data = module_customer::get_customer($task['owner_id']);
                                 if (!$customer_data || !isset($customer_data['customer_id']) || $customer_data['customer_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_customer::link_open($task['owner_id'], false, $customer_data);
                                 $alert_res['full_link'] = module_customer::link_open($task['owner_id'], true, $customer_data);
                                 break;
                             case 'vendor':
                                 $vendor_data = module_vendor::get_vendor($task['owner_id']);
                                 if (!$vendor_data || !isset($vendor_data['vendor_id']) || $vendor_data['vendor_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_vendor::link_open($task['owner_id'], false, $vendor_data);
                                 $alert_res['full_link'] = module_vendor::link_open($task['owner_id'], true, $vendor_data);
                                 break;
                             case 'job':
                                 $job_data = module_job::get_job($task['owner_id']);
                                 if (!$job_data || !isset($job_data['job_id']) || $job_data['job_id'] != $task['owner_id']) {
                                     continue 2;
                                 }
                                 $alert_res['link'] = module_job::link_open($task['owner_id'], false, $job_data);
                                 $alert_res['full_link'] = module_job::link_open($task['owner_id'], true, $job_data);
                                 break;
                                 // todo - add others.
                         }
                         $alert_res['name'] = $task['note'];
                         $alert_res['date'] = print_date($alert_res['date']);
                         $alert_res['time'] = $task['note_time'];
                         $alerts[] = $alert_res;
                     }
                 }
             }
             return $alerts;
             break;
             /*case "note_list":
             				if($owner_id && $owner_id != 'new'){
             
             					$note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id));
             					foreach($note_items as &$note_item){
             						// do it in loop here because of $this issues in static method below.
             						// instead of include file below.
             						$note_item['html'] = $this->print_note($note_item['note_id']);
             					}
             					include("pages/note_list.php");
             				}else{
             					echo 'Please save first before creating notes.';
             				}
             				break;*/
         /*case "note_list":
         				if($owner_id && $owner_id != 'new'){
         
         					$note_items = $this->get_notes(array("owner_table"=>$owner_table,"owner_id"=>$owner_id));
         					foreach($note_items as &$note_item){
         						// do it in loop here because of $this issues in static method below.
         						// instead of include file below.
         						$note_item['html'] = $this->print_note($note_item['note_id']);
         					}
         					include("pages/note_list.php");
         				}else{
         					echo 'Please save first before creating notes.';
         				}
         				break;*/
         case "note_delete":
             // find the key we are saving this address against.
             $owner_id = (int) $key_value;
             if (!$owner_id || $owner_id == 'new') {
                 // find one in the post data.
                 if (isset($_REQUEST[$key_name])) {
                     $owner_id = $_REQUEST[$key_name];
                 }
             }
             $note_hash = md5($owner_id . '|' . $owner_table);
             // just for posting unique arrays.
             if ($owner_table && $owner_id) {
                 $this->note_delete($owner_table, $owner_id);
             }
             break;
     }
 }
                            </span>  <br/>
                            <?php 
        }
        ?>

                        <?php 
        if (module_config::c('ticket_show_user_details', 1) && module_ticket::can_edit_tickets()) {
            ?>

                            <span>
                                <?php 
            if (isset($ticket_message['create_user_id']) && (int) $ticket_message['create_user_id'] > 0) {
                ?>

                                    <strong><?php 
                echo module_user::link_open($ticket_message['create_user_id'], true);
                ?>
</strong>
                                <?php 
            }
            if (isset($ticket_message['status_id']) && $ticket_message['status_id'] > 0) {
                echo ' ';
                _e('changed ticket status to %s', '<strong>' . friendly_key(module_ticket::get_statuses(), $ticket_message['status_id']) . '</strong>');
            }
            ?>

                            </span><br/>
                        <?php 
        }
        ?>