<?php if (isset($_GET['evento_id']) && ($evento = get_post($_GET['evento_id'])) && $evento->post_status == 'pay_pending_review') { $cdata = get_contrato_inscricao($evento->ID); $valor = $cdata['valor']; $porcentagem = $cdata['porcentagem']; $contrato = $cdata['contrato']; $total_tnb = is_numeric($valor) && is_numeric($porcentagem) ? $valor * $porcentagem / 100 : 0; $total_tnb = number_format($total_tnb, 2); ?> <script type="text/javascript"> new function($) { $.fn.getCursorPosition = function() { var pos = 0; var el = $(this).get(0); // IE Support if (document.selection) { el.focus(); var Sel = document.selection.createRange(); var SelLength = document.selection.createRange().text.length; Sel.moveStart('character', -el.value.length); pos = Sel.text.length - SelLength; } // Firefox support else if (el.selectionStart || el.selectionStart == '0') pos = el.selectionStart; return pos; } } (jQuery);
?> </div> <input type='button' onclick="jQuery('#evento-contrato-form-action').val('contrato-oportunidade-aceitar'); jQuery('#evento-contrato-form').submit();" value="<?php _e('aceitar e publicar este evento', 'tnb'); ?> " /> <input type='button' onclick="jQuery('#evento-contrato-form-action').val('contrato-oportunidade-recusar'); jQuery('#evento-contrato-form').submit();" value="<?php _e('recusar', 'tnb'); ?> " /> </div> <?php } elseif ($event->post_status == 'publish' && get_contrato_inscricao($event->ID)) { $contrato = get_contrato_inscricao($event->ID); ?> <strong class='alignright'><a href='javascript:void(0);' onclick='jQuery("#<?php echo $event->ID; ?> -contrato").dialog({title: "<?php echo sprintf(__('Contrato para oportunidade %s', 'tnb'), $event->post_title); ?> ",width: "900px"});'><?php _e('visualizar contrato', 'tnb'); ?> </a></strong> <div id='<?php echo $event->ID; ?>
<?php require_once '../../../../../wp-load.php'; if (!current_user_can('manage_options')) { die('sem permissao'); } if (!isset($_GET['evento_id'])) { die('contrato não encontrado.'); } $contrato = get_contrato_inscricao($_GET['evento_id']); echo nl2br(get_contrato_inscricao_substituido($_GET['evento_id'], $contrato['valor'], $contrato['porcentagem'], $contrato['contrato']));
_e('aguardando aceitação do contrato', 'tnb'); ?> </strong></li> <?php } ?> <?php } elseif ($post->post_status == 'pay_pending_review') { ?> <li><strong><?php _e('aguardando a revisão do editor', 'tnb'); ?> </strong></li> <?php } elseif (get_contrato_inscricao($post->ID)) { $contrato = get_contrato_inscricao($post->ID); ?> <li> <strong><a href='javascript:void(0);' onclick='jQuery("#<?php echo $post->ID; ?> -contrato").dialog({title: "<?php echo sprintf(__('Contrato para oportunidade %s', 'tnb'), $post->post_title); ?> ",width: "900px"});'><?php _e('visualizar contrato', 'tnb'); ?> </a></strong> <div id='<?php echo $post->ID; ?>
// Se um super evento for marcado como inativo, é preciso desativar todos os eventos filhos e comunicar seus produtores $subEventosParaDesativar = get_posts("post_type=eventos&post_parent={$event->ID}&post_status=publish&numberposts=-1"); foreach ($subEventosParaDesativar as $subEventoDesativar) { $subEventoDesativar->post_status = 'draft'; wp_update_post($subEventoDesativar); do_action('tnb_subevento_desativado_por_superevento', $event, $subEventoDesativar); } } $event->post_title = strip_tags($_POST['post_title']); $post = array('post_title' => $event->post_title, 'post_content' => strip_tags($_POST['post_content']), 'post_type' => 'eventos', 'post_status' => $_POST['post_status'], 'post_parent' => $_POST['superevento'] == 'yes' ? 0 : $_POST['post_parent']); if (!$event->post_name) { $post_name = sanitize_title_with_dashes($event->post_title); $post['post_name'] = tnb_unique_event_slug($post_name, $post['ID']); } if ($event->ID) { if ($_POST['evento_inscricao_cobrada'] && !get_contrato_inscricao($event->ID)) { $post['post_status'] = 'pay_pending_review'; } $post['ID'] = $event->ID; wp_update_post($post); } else { if ($_POST['evento_inscricao_cobrada']) { // CRIANDO EVENTO COM COBRANÇA $post['post_status'] = 'pay_pending_review'; $post['ID'] = wp_insert_post($post); $novo_evento_cobranca = true; } else { // CRIANDO EVENTO SEM COBRANÇA $post['ID'] = wp_insert_post($post); } if ($post['post_parent'] != 0) {
function pagamento_substitui_substituicoes($texto, $evento_id, $valor = null, $porcentagem = null, $artista = null) { $evento = get_post($evento_id); $edata = get_oportunidades_data($evento_id); $produtor = get_user_by('id', $evento->post_author); $paises = get_paises(); $estados = get_estados(); $edata = (object) $edata; if (is_null($valor) || is_null($porcentagem)) { $contrato = get_contrato_inscricao($evento_id); if (is_null($valor)) { $valor = $contrato['valor']; } if (is_null($porcentagem)) { $porcentagem = $contrato['porcentagem']; } } $substituicoes = array('{produtor-cadastro-id}' => $produtor->ID, '{produtor-cadastro-data}' => $produtor->user_registered, '{produtor-nome}' => $produtor->display_name, '{produtor-documento}' => $produtor->cnpj ? $produtor->cnpj : $produtor->cpf, '{produtor-email}' => $produtor->user_email, '{produtor-telefone}' => $produtor->telefone, '{produtor-pais}' => $paises[$produtor->origem_pais], '{produtor-estado}' => $produtor->origem_pais == 'BR' ? $estados[strtolower($produtor->origem_estado)] : $produtor->origem_estado, '{produtor-cidade}' => $produtor->origem_cidade, '{produtor-url}' => get_author_posts_url($evento->post_author), '{produtor-link}' => '<a href="' . get_author_posts_url($evento->post_author) . '">' . $produtor->display_name . '</a>', '{evento-nome}' => $evento->post_title, '{evento-descricao}' => $evento->post_content, '{evento-inicio}' => $edata->br_inicio, '{evento-fim}' => $edata->br_fim, '{evento-inscricao-inicio}' => $edata->br_insc_inicio, '{evento-inscricao-fim}' => $edata->br_insc_fim, '{evento-estabelecimento}' => $edata->local, '{evento-pais}' => $paises[$edata->sigla_pais], '{evento-estado}' => $edata->sigla_pais == 'BR' ? $estados[strtolower($edata->estado)] : $edata->estado, '{evento-cidade}' => $edata->cidade, '{evento-url}' => get_permalink($evento_id), '{evento-link}' => '<a href="' . get_permalink($evento_id) . '">' . $evento->post_title . '</a>', '{contrato-valor}' => get_valor_monetario($valor), '{contrato-porcentagem}' => $porcentagem . '%', '{contrato-porcentagem-produtor}' => 100 - $porcentagem . '%', '{contrato-valor-tnb}' => get_valor_monetario($valor * $porcentagem / 100)); if ($artista) { $substituicoes += array('{artista-nome}' => $artista->display_name, '{artista-url}' => get_author_posts_url($artista->ID), '{artista-link}' => '<a href="' . get_author_posts_url($artista->ID) . '">' . $artista->display_name . '</a>'); } else { $substituicoes += array('{artista-nome}' => '', '{artista-url}' => '', '{artista-link}' => ''); } foreach ($substituicoes as $de => $para) { $texto = str_replace($de, $para, $texto); } return $texto; }