本文整理汇总了PHP中get_multiple函数的典型用法代码示例。如果您正苦于以下问题:PHP get_multiple函数的具体用法?PHP get_multiple怎么用?PHP get_multiple使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_multiple函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _l
<tr>
<th>
<?php
echo _l('Configuration Key');
?>
</th>
<th>
<?php
echo _l('Configuration Value');
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach (get_multiple('config', false, 'key', 'exact', '`key`') as $config) {
if (isset($config['key']) && isset($config['key'][0]) && $config['key'][0] == '_') {
continue;
}
?>
<tr>
<th>
<?php
echo $config['key'];
?>
</th>
<td>
<span data-name="config[<?php
echo htmlspecialchars($config['key']);
?>
]" class="config_variable"><?php
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:config_settings.php
示例2: htmlspecialchars
</td><td>
<input type="text" name="invoice_invoice_payment[<?php
echo $invoice_payment_id;
?>
][method]" value="<?php
echo htmlspecialchars($invoice_payment_data['method']);
?>
" size="20">
</td>
<td nowrap="">
<?php
echo '<input type="text" name="invoice_invoice_payment[' . $invoice_payment_id . '][amount]" value="' . number_out($invoice_payment_data['amount']) . '" id="' . $invoice_payment_id . 'invoice_paymentamount" class="currency">';
?>
<?php
echo print_select_box(get_multiple('currency', '', 'currency_id'), 'invoice_invoice_payment[' . $invoice_payment_id . '][currency_id]', $invoice_payment_data['currency_id'], '', false, 'code');
?>
</td>
<td>
<?php
$notes = '';
$details = false;
if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) {
$details = @unserialize($invoice_payment_data['data']);
if ($details && isset($details['custom_notes'])) {
$notes = $details['custom_notes'];
}
}
?>
开发者ID:sgh1986915,项目名称:php-crm,代码行数:30,代码来源:invoice_admin_edit.php
示例3: get_notes
public static function get_notes($search = false)
{
return get_multiple("note", $search, "note_id", "exact", "note_id");
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:4,代码来源:note.php
示例4: print_table_data
public static function print_table_data($owner_table, $owner_id)
{
if (self::can_i('view', 'Extra Fields') && isset(self::$column_headers[$owner_table])) {
$extra_data = get_multiple('extra', array('owner_table' => $owner_table, 'owner_id' => $owner_id), 'extra_key');
foreach (self::$column_headers[$owner_table] as $column_header) {
?>
<td>
<?php
echo isset($extra_data[$column_header['key']]) ? forum_text($extra_data[$column_header['key']]['extra']) : '';
?>
</td>
<?php
}
}
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:17,代码来源:extra.php
示例5: get_data
public function get_data()
{
if (count($this->_get_data_cache)) {
return $this->_get_data_cache;
}
$file = false;
if ($this->file_id > 0) {
$file = get_single("file", "file_id", $this->file_id);
}
// check user has permissions to view this file.
// for now we just base this on the customer id check
if ($file) {
// staff listing
$staff = get_multiple('file_user_rel', array('file_id' => $file['file_id']), 'user_id');
$file['staff_ids'] = array_keys($staff);
$file['type'] = isset($file['file_url']) && $file['file_url'] ? 'remote' : (isset($file['bucket']) && $file['bucket'] ? 'bucket' : 'upload');
if ($this->do_permissions) {
switch (module_file::get_file_data_access()) {
case _FILE_ACCESS_ALL:
// all files, no limits on SQL here
break;
case _FILE_ACCESS_JOBS:
$jobs = module_job::get_jobs(array(), array('columns' => 'u.job_id AS id'));
if (!$file['job_id'] || !isset($jobs[$file['job_id']])) {
$file = false;
}
break;
case _FILE_ACCESS_ME:
if ($file['create_user_id'] != module_security::get_loggedin_id()) {
$file = false;
}
break;
case _FILE_ACCESS_ASSIGNED:
if (!in_array(module_security::get_loggedin_id(), $file['staff_ids'])) {
$file = false;
}
break;
case _FILE_ACCESS_CUSTOMERS:
default:
if (class_exists('module_customer', false)) {
//added for compat in newsletter system that doesn't have customer module
$customer_permission_check = module_customer::get_customer($file['customer_id']);
if ($customer_permission_check['customer_id'] != $file['customer_id']) {
$file = false;
}
}
}
// file data access switch
}
}
if (!$file) {
$file = array('new' => true, 'type' => 'upload', 'file_id' => 0, 'customer_id' => isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : 0, 'job_id' => isset($_REQUEST['job_id']) ? $_REQUEST['job_id'] : 0, 'quote_id' => isset($_REQUEST['quote_id']) ? $_REQUEST['quote_id'] : 0, 'description' => '', 'status' => module_config::c('file_default_status', 'Uploaded'), 'file_name' => '', 'file_url' => '', 'staff_ids' => array(), 'bucket' => 0, 'bucket_parent_file_id' => 0, 'approved_time' => 0);
}
$this->_get_data_cache = $file;
return $file;
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:56,代码来源:file.php
示例6: get_product_categories
public static function get_product_categories($search = array())
{
return get_multiple("product_category", $search, "product_category_id", "fuzzy", "product_category_name");
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:4,代码来源:product.php
示例7: get_datas
function get_datas($search = false)
{
return get_multiple("data_record", $search, "data_record_id", "fuzzy");
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:4,代码来源:data.php
示例8: output_block
//.........这里部分代码省略.........
</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
}
}
}
}
}
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:twitter.class.php
示例9: upload
function upload($save_path, $custom_upload_max_filesize, $key, $type = array('jpg', 'jpeg', 'gif', 'png'))
{
$return_data = array();
//获取phpini配置文件里面的upload_max_filesize值
$phpini = ini_get('upload_max_filesize');
//获取phpini配置文件里面的upload_max_filesize值的单位
$phpini_unit = strtoupper(substr($phpini, -1));
//获取phpini配置文件里面的upload_max_filesize值的数字部分
$phpini_number = substr($phpini, 0, -1);
//计算出转换成字节应该乘以的倍数
$phpini_multiple = get_multiple($phpini_unit);
//转换成字节
$phpini_bytes = $phpini_number * $phpini_multiple;
$custom_unit = strtoupper(substr($custom_upload_max_filesize, -1));
$custom_number = substr($custom_upload_max_filesize, 0, -1);
$custom_multiple = get_multiple($custom_unit);
$custom_bytes = $custom_number * $custom_multiple;
if ($custom_bytes > $phpini_bytes) {
$return_data['error'] = '传入的$custom_upload_max_filesize大于PHP配置文件里面的' . $phpini;
$return_data['return'] = false;
return $return_data;
}
$arr_errors = array(1 => '上传的文件超过了 php.ini中 upload_max_filesize 选项限制的值', 2 => '上传文件的大小超过了 HTML 表单中 MAX_FILE_SIZE 选项指定的值', 3 => '文件只有部分被上传', 4 => '没有文件被上传', 6 => '找不到临时文件夹', 7 => '文件写入失败');
if (!isset($_FILES[$key]['error'])) {
$return_data['error'] = '由于未知原因导致,上传失败,请重试!';
$return_data['return'] = false;
return $return_data;
}
if ($_FILES[$key]['error'] != 0) {
$return_data['error'] = $arr_errors[$_FILES['error']];
$return_data['return'] = false;
return $return_data;
}
if (!is_uploaded_file($_FILES[$key]['tmp_name'])) {
$return_data['error'] = '您上传的文件不是通过 HTTP POST方式上传的!';
$return_data['return'] = false;
return $return_data;
}
if ($_FILES[$key]['size'] > $custom_bytes) {
$return_data['error'] = '上传文件的大小超过了程序作者限定的' . $custom_upload_max_filesize;
$return_data['return'] = false;
return $return_data;
}
$arr_filename = pathinfo($_FILES[$key]['name']);
if (!isset($arr_filename['extension'])) {
$arr_filename['extension'] = '';
}
if (!in_array($arr_filename['extension'], $type)) {
$return_data['error'] = '上传文件的后缀名必须是' . implode(',', $type) . '这其中的一个';
$return_data['return'] = false;
return $return_data;
}
if (!file_exists($save_path)) {
if (!mkdir($save_path, 0777, true)) {
$return_data['error'] = '上传文件保存目录创建失败,请检查权限!';
$return_data['return'] = false;
return $return_data;
}
}
$new_filename = str_replace('.', '', uniqid(mt_rand(100000, 999999), true));
if ($arr_filename['extension'] != '') {
$new_filename .= ".{$arr_filename['extension']}";
}
$save_path = rtrim($save_path, '/') . '/';
if (!move_uploaded_file($_FILES[$key]['tmp_name'], $save_path . $new_filename)) {
$return_data['error'] = '临时文件移动失败,请检查权限!';
$return_data['return'] = false;
return $return_data;
}
$return_data['save_path'] = $save_path . $new_filename;
$return_data['filename'] = $new_filename;
$return_data['return'] = true;
return $return_data;
}
开发者ID:sakuraliu,项目名称:bbs,代码行数:74,代码来源:upload.inc.php
示例10: get_groups_search
public static function get_groups_search($search = false)
{
$groups = get_multiple('group_member', $search);
foreach ($groups as $group_id => $group) {
// find the group name for this group.
$groups[$group_id] = array_merge($group, self::get_group($group['group_id']));
}
return $groups;
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:9,代码来源:group.php
示例11: get_languages_attributes
public static function get_languages_attributes()
{
$all = array();
$language_files = glob(_UCM_FOLDER . 'includes/plugin_language/custom/*.php');
if (is_array($language_files)) {
foreach ($language_files as $language) {
$language = strtolower(str_replace('.php', '', basename($language)));
if ($language[0] == '_') {
continue;
}
$all[$language] = array('language_name' => $language, 'language_code' => $language);
}
}
$language_files = glob(_UCM_FOLDER . 'includes/plugin_language/labels/*.php');
if (is_array($language_files)) {
foreach ($language_files as $language) {
$language = strtolower(str_replace('.php', '', basename($language)));
if ($language[0] == '_') {
continue;
}
$all[$language] = array('language_name' => $language, 'language_code' => $language);
}
}
if (self::is_language_db_enabled()) {
foreach ($all as $language_code => $language) {
// does this language code exist in the database?
$language_db = get_single('language', 'language_code', $language_code);
if (!$language_db || $language_db['language_code'] != $language_code) {
update_insert('language_id', false, 'language', array('language_code' => $language['language_code'], 'language_name' => $language['language_name']));
}
}
// now we get any language attributes from the database and overwrite the old file based ones with those.
foreach (get_multiple('language', false, 'language_id', 'exact', 'language_code') as $language) {
if (isset($all[strtolower($language['language_code'])])) {
// this language exists in the old file based method.
$all[strtolower($language['language_code'])] = $language;
} else {
// this is a language that only exists in the new database translation method.
$all[strtolower($language['language_code'])] = $language;
}
// todo - well, not sure about the above. maybe we do some update here and remove the old files ??? move everything to the database or something?? meh..
}
}
return $all;
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:45,代码来源:language.php
示例12: htmlspecialchars
echo htmlspecialchars($invoice['total_tax_rate']);
?>
" style="width:35px;">%
</td>
</tr>
<tr>
<th>
<?php
echo _l('Currency');
?>
</th>
<td>
<?php
echo print_select_box(get_multiple('currency', '', 'currency_id'), 'currency_id', $invoice['currency_id'], '', false, 'code');
?>
</td>
</tr>
<tr>
<th>
<?php
echo _l('Hourly Rate');
?>
</th>
<td>
<?php
echo currency('<input type="text" name="hourly_rate" class="currency" value="' . $invoice['hourly_rate'] . '">', true, $invoice['currency_id']);
echo _h('This hourly rate will be applied to all manual tasks (tasks that did not come from jobs) in this invoice');
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:invoice_admin_credit.php
示例13: _e
<th class="width2">
<?php
_e('Menu Item');
?>
</th>
<th>
<?php
_e('Position');
?>
</th>
</tr>
</thead>
<tbody>
<?php
$c = 0;
foreach (get_multiple('config') as $config) {
if (preg_match('#_menu_order_(.*)#', $config['key'], $matches)) {
?>
<tr class="<?php
echo $c++ % 2 ? 'odd' : 'even';
?>
">
<td>
<?php
echo $matches[1];
?>
</td>
<td>
<input type="text" name="save_config[<?php
echo $matches[0];
?>
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:config_menu.php
示例14: get_faq
public static function get_faq($faq_id)
{
$faq = get_single('faq', 'faq_id', $faq_id);
// get linked ids
$faq['faq_product_ids'] = array();
foreach (get_multiple('faq_product_rel', array('faq_id' => $faq_id)) as $product) {
$faq['faq_product_ids'][$product['faq_product_id']] = $product['faq_product_id'];
}
return $faq;
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:10,代码来源:faq.php
示例15: get_encrypt_keys
public static function get_encrypt_keys()
{
return get_multiple('encrypt_key', false, 'encrypt_key_id');
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:4,代码来源:encrypt.php
示例16: _e
if ($currency['currency_id'] == module_config::c('default_currency_id', 1)) {
_e('(default)');
}
?>
</td>
<td>
<?php
echo htmlspecialchars($currency['symbol']);
?>
</td>
<td>
<?php
echo dollar(1234.56, true, $currency['currency_id']);
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</form>
<?php
$currencies = array();
foreach (get_multiple('currency', '', 'currency_id') as $currency) {
$currencies[$currency['currency_id']] = $currency['code'] . ' ' . $currency['symbol'];
}
$settings = array(array('key' => 'default_currency_id', 'default' => '1', 'type' => 'select', 'description' => 'Default currency to use throughout the system', 'options' => $currencies));
module_config::print_settings_form($settings);
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:31,代码来源:currency.php
示例17: get_templates
public static function get_templates($search = array())
{
if (self::db_table_exists('template')) {
// useto be sorted by template_id
return get_multiple("template", $search, "template_id", "exact", "template_key ASC");
} else {
return array();
}
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:9,代码来源:template.php
示例18: get_change_requests
public static function get_change_requests($search = array())
{
return get_multiple("change_request", $search, "change_request_id", "exact", "name");
}
开发者ID:sgh1986915,项目名称:php-crm,代码行数:4,代码来源:change_request.php
示例19: hook_job_task_after
public static function hook_job_task_after($hook, $job_id, $task_id, $job_data, $task_data)
{
$comments = get_multiple('job_discussion', array('job_id' => $job_id, 'task_id' => $task_id), 'job_discussion_id', 'exact', 'job_discussion_id');
if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 1) {
// disabled & hidden.
return;
}
if ($job_data && isset($job_data['job_discussion']) && $job_data['job_discussion'] == 2 && count($comments) == 0) {
// disabled & shown.
return;
}
if (isset($_POST['job_discussion_add_job_id']) && isset($_POST['job_discussion_add_task_id']) && $_POST['job_discussion_add_job_id'] == $job_id && $_POST['job_discussion_add_task_id'] == $task_id && isset($_POST['note']) && strlen($_POST['note'])) {
$x = 0;
while (ob_get_level() && $x++ < 10) {
ob_end_clean();
}
$current_user_id = module_security::get_loggedin_id();
$customer = module_customer::get_customer($job_data['customer_id']);
if (!$current_user_id) {
if ($job_data['customer_id'] && $customer['primary_user_id']) {
$current_user_id = $customer['primary_user_id'];
}
}
$result = array();
// adding a new note.
$job_discussion_id = update_insert('job_discussion_id', 0, 'job_discussion', array('job_id' => $job_id, 'task_id' => $task_id, 'user_id' => $current_user_id, 'note' => $_POST['note']));
$result['job_discussion_id'] = $job_discussion_id;
$result['count'] = count($comments) + 1;
$tasks = module_job::get_tasks($job_id);
$result['email_customer'] = array();
if (isset($_POST['sendemail_customer']) && is_array($_POST['sendemail_customer'])) {
//$_POST['sendemail_customer'] == 'yes' && $customer['primary_user_id']){
// send email to customer primary user id.
$customer_contacts = module_user::get_contacts(array('customer_id' => $job_data['customer_id']));
foreach ($_POST['sendemail_customer'] as $user_id) {
$user_id = (int) $user_id;
if ($user_id && isset($customer_contacts[$user_id])) {
// we can email this user.
$user = module_user::get_user($user_id, false);
if ($user && $user['user_id'] == $user_id) {
$values = array_merge($user, $job_data);
$values['job_url'] = module_job::link_public($job_id);
$values['job_url'] .= (strpos($values['job_url'], '?') === false ? '?' : '&') . 'discuss=' . $task_id . '#discuss' . $task_id;
$values['job_name'] = $job_data['name'];
$values['customer_name'] = $user['name'] . ' ' . $user['last_name'];
$values['note'] = $_POST['note'];
//todo: no order if no showning numbers
$values['task_name'] = '#' . $tasks[$task_id]['task_order'] . ': ' . $tasks[$task_id]['description'];
$template = module_template::get_template_by_key('job_discussion_email_customer');
$template->assign_values($values);
$html = $template->render('html');
$email = module_email::new_email();
$email->replace_values = $values;
$email->set_to('user', $user['user_id']);
$email->set_from('user', $current_user_id);
$email->set_subject($template->description);
// do we send images inline?
$email->set_html($html);
if ($email->send()) {
// it worked successfully!!
$result['email_customer'][] = $user['user_id'];
} else {
/// log err?
}
}
}
}
/*$user = module_user::get_user($customer['primary_user_id'],false);
if($user['user_id'] == $customer['primary_user_id']){
$values = array_merge($user,$job_data);
$values['job_url'] = module_job::link_public($job_id);
$values['job_url'] .= (strpos($values['job_url'],'?')===false ? '?' : '&').'discuss='.$task_id.'#discuss'.$task_id;
$values['job_name'] = $job_data['name'];
$values['customer_name'] = $user['name'].' '.$user['last_name'];
$values['note'] = $_POST['note'];
//todo: no order if no showning numbers
$values['task_name'] = '#'.$tasks[$task_id]['task_order'].': '.$tasks[$task_id]['description'];
$template = module_template::get_template_by_key('job_discussion_email_customer');
$template->assign_values($values);
$html = $template->render('html');
$email = module_email::new_email();
$email->replace_values = $values;
$email->set_to('user',$user['user_id']);
$email->set_from('user',$current_user_id);
$email->set_subject($template->description);
// do we send images inline?
$email->set_html($html);
if($email->send()){
// it worked successfully!!
$result['email_customer'] = 1;
}else{
/// log err?
$result['email_customer'] = 0;
}
}else{
// log error?
$result['email_customer'] = 0;
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:job_discussion.php
示例20: save_quote
public static function save_quote($quote_id, $data)
{
if (isset($data['customer_id']) && $data['customer_id'] > 0) {
// check we have access to this customer from this quote.
$customer_check = module_customer::get_customer($data['customer_id']);
if (!$customer_check || $customer_check['customer_id'] != $data['customer_id']) {
unset($data['customer_id']);
}
}
if (isset($data['website_id']) && $data['website_id']) {
$website = module_website::get_website($data['website_id']);
if ($website && (int) $website['website_id'] > 0 && $website['website_id'] == $data['website_id']) {
// website exists.
// make this one match the website customer_id, or set teh website customer_id if it doesn't have any.
if ((int) $website['customer_id'] > 0) {
if ($data['customer_id'] > 0 && $data['customer_id'] != $website['customer_id']) {
set_message('Changed this Quote to match the Website customer');
}
$data['customer_id'] = $website['customer_id'];
} else {
if (isset($data['customer_id']) && $data['customer_id'] > 0) {
// set the website customer id to this as well.
update_insert('website_id', $website['website_id'], 'website', array('customer_id' => $data['customer_id']));
}
}
}
}
if ((int) $quote_id > 0) {
$original_quote_data = self::get_quote($quote_id, false);
if (!$original_quote_data || $original_quote_data['quote_id'] != $quote_id) {
$original_quote_data = array();
$quote_id = false;
}
} else {
$original_quote_data = array();
$quote_id = false;
}
// check create permissions.
if (!$quote_id && !self::can_i('create', 'Quotes')) {
// user not allowed to create quotes.
set_error('Unable to create new Quotes');
redirect_browser(self::link_open(false));
}
if (!(int) $quote_id && module_config::c('quote_name_incrementing', 0)) {
// incrememnt next quote number on save.
$quote_number = module_config::c('quote_name_incrementing_next', 1);
module_config::save_config('quote_name_incrementing_next', $quote_number + 1);
}
$quote_id = update_insert("quote_id", $quote_id, "quote", $data);
$return = false;
if ($quote_id) {
hook_handle_callback('quote_save', $quote_id);
// save the quote tax rates (copied from invoice.php)
if (isset($data['tax_ids']) && isset($data['tax_names']) && $data['tax_percents']) {
$existing_taxes = get_multiple('quote_tax', array('quote_id' => $quote_id), 'quote_tax_id', 'exact', 'order');
$order = 1;
foreach ($data['tax_ids'] as $key => $val) {
if (isset($data['tax_percents'][$key]) && $data['tax_percents'][$key] == 0) {
// we are not saving this particular tax item because it has a 0% tax rate
} else {
if ((int) $val > 0 && isset($existing_taxes[$val])) {
// this means we are trying to update an existing record on the quote_tax table, we confirm this id matches this quote.
$quote_tax_id = $val;
unset($existing_taxes[$quote_tax_id]);
// so we know which ones to remove from the end.
} else {
$quote_tax_id = false;
// create new record
}
$quote_tax_data = array('quote_id' => $quote_id, 'percent' => isset($data['tax_percents'][$key]) ? $data['tax_percents'][$key] : 0, 'amount' => 0, 'name' => isset($data['tax_names'][$key]) ? $data['tax_names'][$key] : 'TAX', 'order' => $order++, 'increment' => isset($data['tax_increment_checkbox']) && $data['tax_increment_checkbox'] ? 1 : 0);
$quote_tax_id = update_insert('quote_tax_id', $quote_tax_id, 'quote_tax', $quote_tax_data);
}
}
foreach ($existing_taxes as $existing_tax) {
delete_from_db('quote_tax', array('quote_id', 'quote_tax_id'), array($quote_id, $existing_tax['quote_tax_id']));
}
}
module_cache::clear('quote');
$return = array('quote_id' => $quote_id, 'task_result' => self::save_quote_tasks($quote_id, $data));
$check_completed = true;
switch ($return['task_result']['status']) {
case 'created':
// we added a new task.
break;
case 'deleted':
// we deleted a task.
break;
case 'edited':
// we changed a task (ie: completed?);
break;
default:
// nothing changed.
// $check_completed = false;
break;
}
if ($check_completed) {
self::update_quote_completion_status($quote_id);
}
if ($original_quote_data) {
// we check if the hourly rate has changed
//.........这里部分代码省略.........
开发者ID:sgh1986915,项目名称:php-crm,代码行数:101,代码来源:quote.php
注:本文中的get_multiple函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论