public function showForm($id = -1)
 {
     $this->prepareForm($id, array('method' => 'post', 'action' => 'backup/adicionar'));
     SystemHelper::addHiddenfield('', 'usuario_id_criacao', FUTURI_Session::getUserID());
     SystemHelper::addHiddenfield('', 'dt_criacao', date('Y-m-d H:i:s'));
     echo "<div class='ls-tab-content ls-active' id='infos'>";
     echo "<table class='easy-form-table'>";
     echo "<tr>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Nome', 'required' => true, 'name' => 'nome_backup'));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<b>Opções do backup</b>";
     echo "<div class='ls-box'>";
     echo "<table class='easy-form-table'>";
     echo "<tr>";
     echo "<td>";
     SystemHelper::addYesNoToggle(array('label' => 'Banco de dados', 'name' => 'incluir_banco_dados', 'value' => 1, 'checked' => $this->fields['incluir_banco_dados']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addYesNoToggle(array('label' => 'Fotos casting/trabalhos', 'name' => 'incluir_casting_fotos', 'value' => 1, 'checked' => $this->fields['incluir_casting_fotos']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addYesNoToggle(array('label' => 'Documentos', 'name' => 'incluir_documentos', 'value' => 1, 'checked' => $this->fields['incluir_documentos']));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</div>";
     echo "</div>";
     $this->addButtons();
 }
 function __construct($id = -1)
 {
     parent::__construct();
     $this->controller = $this;
     $this->load->helper("loader");
     $this->load->helper("javascript_loader");
     $this->load->helper("stylesheet_loader");
     $this->load->helper("system");
     $this->load->helper("alert");
     $this->load->helper("url_helper");
     // check if user is authenticated
     if (get_class($this) != "Login" && get_class($this) != "User" && !FUTURI_Session::isLogged()) {
         redirect(base_url() . "login");
     }
     // Code Igniter native Helper and library
     //$this->load->helper(array('form', 'url'));
     //$this->load->library('form_validation');
     include_once "FUTURI_Component.php";
     $this->modelName = strtolower($this->getType()) . "_model";
     $this->load->model($this->modelName);
     //, "loadedModel");
     $model_class = $this->getType() . "_Model";
     $this->loadedModel = new $model_class();
     if (!defined("ROOT_PATH")) {
         define("ROOT_PATH", "");
     }
     if (!defined("NO_JS")) {
         SystemHelper::setJSROOTPATH(ROOT_PATH);
         $JS = new JavascriptLoader(ROOT_PATH);
         $JS->loadCores();
         $JS->loadPlugins();
     }
     if (!defined("NO_CSS")) {
         $CSS = new StylesheetLoader(ROOT_PATH);
         $CSS->loadStyles();
     }
     include_once "application/controllers/Permission.php";
     $this->objectID = $id;
     $this->defineLeftMenu();
     $this->defineActionOptions();
     $this->definePagerLimits();
     if ($this->objectID > 0 && isset($this->loadedModel)) {
         //print_r($this->loadedModel);
         $this->loadObjectDataFields();
     }
 }
 public function beforeAdd($FORMDATA)
 {
     if (isset($FORMDATA['param_name'])) {
         $this->addToAfterData("param_name", $FORMDATA["param_name"]);
         $this->addToAfterData("param_displayname", $FORMDATA["param_displayname"]);
         $this->addToAfterData("param_type", $FORMDATA["param_type"]);
         $this->addToAfterData("param_default", $FORMDATA["param_default"]);
         $this->addToAfterData("param_userinput", $FORMDATA["param_userinput"]);
         unset($FORMDATA["param_name"]);
         unset($FORMDATA["param_displayname"]);
         unset($FORMDATA["param_type"]);
         unset($FORMDATA["param_default"]);
         unset($FORMDATA["param_userinput"]);
     }
     if ($this->objectID < 0) {
         $FORMDATA["usuario_id_criacao"] = FUTURI_Session::get("user_info")["id"];
         $FORMDATA["dt_criacao"] = date('Y-m-d H:i:s');
         $FORMDATA["tipo_grafico"] = "bar";
     }
     return $FORMDATA;
 }
 public function showPage($selected = '')
 {
     if (!FUTURI_Session::isUserAdmin()) {
         $this->load->view("nopermission_admin");
     }
     $this->load->view("admin_header", array('selected' => $selected));
     switch ($selected) {
         case "usuarios":
             include "application/controllers/User.php";
             define_constants();
             $userController = new User();
             $userController->showListPage('', 10, false);
             break;
         case "estatisticas":
             break;
         case "backups":
             include "application/controllers/Backup.php";
             define_constants();
             $backupController = new Backup();
             $backupController->showListPage('', 10, false);
             break;
         case "configs":
             $this->load->view("admin_configs", array("object_handler" => $this));
             break;
         case "relatorios":
             include "application/controllers/Report.php";
             define_constants();
             $reportController = new Report();
             $reportController->showListPage('', 10, false);
             break;
         case "graficos":
             include "application/controllers/Chart.php";
             define_constants();
             $chartController = new Chart();
             $chartController->showListPage('', 10, false);
             break;
     }
 }
 public function afterUpdate()
 {
     $this->afterAdd();
     if ($this->fields['id'] == FUTURI_Session::getUserID()) {
         FUTURI_Session::set("user_info", $this->fields);
     }
 }
						$dt2_compare = new DateTime(date('Y-m-d'));
						$idade = date_diff($dt1_compare, $dt2_compare);
						
						echo "<tr class='".$is_hidden."'>";
							echo "<td class='hidden'>".$dia_niver."</td>";
							echo "<td>".$castInfo['nome_completo']." (<b>".$idade->y." anos</b>)</td>";
						echo "</tr>";
					}*/
?>

<title>Easycasting - Principal</title>
<div class="welcome-dashboard">
	<div class="welcome-title">
		<div><i class="ls-ico-dashboard"></i> Início</div>
		<div class="welcome-subtitle">Bem vindo ao Easycasting, <strong><?php 
echo FUTURI_Session::get("user_info")["nome_exibicao"];
?>
</strong></div>
	</div>
	
	<div class="welcome-dashboard-wrapper">
			<div class="row ls-overflow-hidden">
				<div class="col-md-6 col-sm-6">
					<div class="ls-box ls-board-box">
						<header class="ls-info-header">
							<h2 class="ls-title-3 col-md-12 ls-ico-stats">
								Trabalhos Mensais
								<small>Realizações de trabalhos mensais</small>
							</h2>
						</header>
						<div class="row">
?>
</strong>
						<span><br><?php 
echo FUTURI_Session::get("user_info")['email'];
?>
</span>
					</span>
					<i class='fa fa-caret-down'></i></a>
					<div class="userMenuHolder">
						<ul class='userMenuOptions'>
							<li><a href='<?php 
echo base_url() . "usuario/perfil/" . FUTURI_Session::get("user_info")["id"];
?>
' class='systemAction' data-popup_title='Meus Dados'><i class='fa fa-pencil-square-o'></i> Meus dados</a></li>
							<li><a href='<?php 
echo base_url() . "usuario/trocarSenha/" . FUTURI_Session::get("user_info")["id"];
?>
' class='systemAction' data-popup_title='Alterar senha'><i class='fa fa-unlock'></i> Alterar senha</a></li>
							<li><a href='<?php 
echo base_url() . "sair";
?>
'><i class='fa fa-sign-out'></i> Logout</a></li>
						</ul>
					</div>
				</div>
			</div>		
			<div class="appHeaderMenu">
				<ul class='appHeaderMenuOptions'>
					<li><a href='<?php 
echo base_url() . "inicio";
?>
 public static function havePermission($permName = '', $user_id = -1)
 {
     include_once "application/models/Permission_model.php";
     $permModel = new Permission_Model();
     if ($user_id > 0) {
         include_once "User.php";
         $user = new User($user_id);
         $is_admin = $user->fields['administrador'];
     } else {
         $is_admin = FUTURI_Session::isUserAdmin();
         $user_id = FUTURI_Session::getUserID();
     }
     $have_count = count($permModel->getObjects(array("where" => "usuario_id = '" . $user_id . "' AND nome_permissao = '" . $permName . "'")));
     return $have_count || $is_admin;
 }
if (!is_dir($view_folder)) {
    if (!empty($view_folder) && is_dir(APPPATH . $view_folder . DIRECTORY_SEPARATOR)) {
        $view_folder = APPPATH . $view_folder;
    } elseif (!is_dir(APPPATH . 'views' . DIRECTORY_SEPARATOR)) {
        header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
        echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
        exit(3);
        // EXIT_CONFIG
    } else {
        $view_folder = APPPATH . 'views';
    }
}
if (($_temp = realpath($view_folder)) !== FALSE) {
    $view_folder = $_temp . DIRECTORY_SEPARATOR;
} else {
    $view_folder = rtrim($view_folder, '/\\') . DIRECTORY_SEPARATOR;
}
define('VIEWPATH', $view_folder);
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
include_once "application/core/FUTURI_Session.php";
FUTURI_Session::initialize();
// interfaces includes
include_once "application/core/FUTURI_Registerbox.php";
include_once "application/core/FUTURI_Component.php";
require_once BASEPATH . 'core/CodeIgniter.php';
 public function logout()
 {
     FUTURI_Session::finalize();
     SystemHelper::executeJavascript("window.location = '" . base_url() . "login" . "'");
 }
?>
"><a href='<?php 
echo base_url() . "trabalhos";
?>
'><i class='fa fa-tags'></i>Trabalhos</a></li>
					<li class="<?php 
echo $selected == "graficos_relatorios" ? "submenuSelected" : "";
?>
">
						<a href='<?php 
echo base_url() . "graficos_relatorios";
?>
'><i class='fa fa-bar-chart-o'></i>Relatórios & Gráficos</a>
					</li>
					<?php 
if (FUTURI_Session::isUserAdmin()) {
    /*<li class="<?php echo ($selected == "relatorios" ? "submenuSelected" : "");?>"><a href='<?php echo base_url()."relatorios";?>'><i class='fa fa-copy'></i>Relatórios</a></li> */
    ?>
						<li class="<?php 
    echo $selected == "admin" ? "submenuSelected" : "";
    ?>
"><a href='<?php 
    echo base_url() . "admin";
    ?>
'><i class='fa fa-sitemap'></i>Administração</a></li>
					<?php 
}
?>
				</ul>
			</div>
		</aside>
 public function showForm($id = -1)
 {
     $this->prepareForm($id, array('method' => 'post', 'action' => $id > 0 ? 'trabalho/atualizar/' . $id : 'trabalho/adicionar'));
     if ($this->objectID < 0) {
         SystemHelper::addHiddenfield('', 'dt_criacao', date('Y-m-d H:i:s'));
         SystemHelper::addHiddenfield('', 'usuario_id_criacao', FUTURI_Session::getUserID());
     }
     echo "<div id='infos' class='ls-tab-content ls-active' role='tabpanel'>";
     echo "<table class='easy-form-table'>";
     echo "<tr>";
     echo "<td colspan='2'>";
     $status_options = array();
     $this->load->model("taskstatus_model");
     foreach ($this->taskstatus_model->getObjects() as $index => $stInfo) {
         $status_options[] = array("value" => $stInfo['id'], "label" => $stInfo['nome']);
     }
     SystemHelper::addCombobox(array('label' => 'Status', 'name' => 'status', 'options' => $status_options, 'value' => $this->fields['status']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='5'>";
     SystemHelper::addRadioGroup(array('label' => 'Empresa', 'name' => 'empresa_id', 'options' => $this->empresas_options, 'value' => $this->fields['empresa_id']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='2'>";
     SystemHelper::addTextfield(array('label' => 'Nome do evento', 'name' => 'nome_evento', 'required' => true, 'value' => $this->fields['nome_evento']));
     echo "</td>";
     echo "<td colspan='3'>";
     $client_options = array();
     $this->load->model("client_model");
     foreach ($this->client_model->getObjects() as $index => $cliInfo) {
         $client_options[] = array("value" => $cliInfo['id'], "label" => $cliInfo['nome_fantasia']);
     }
     SystemHelper::addCombobox(array('label' => 'Cliente', 'name' => 'cliente_id', 'required' => true, 'options' => $client_options, 'value' => $this->fields['cliente_id']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td colspan='2'>";
     SystemHelper::addDatefield(array('label' => 'Data de início', 'name' => 'dt_inicio', 'width' => '120px', 'value' => SystemHelper::convertDateFromUS($this->fields['dt_inicio']), 'useIcon' => true));
     echo "</td>";
     echo "<td colspan='3'>";
     SystemHelper::addDatefield(array('label' => 'Data de término', 'name' => 'dt_termino', 'width' => '120px', 'value' => SystemHelper::convertDateFromUS($this->fields['dt_termino']), 'useIcon' => true));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Custo real (R$)', 'name' => 'custo_real', 'mask' => 'ls-mask-money', 'value' => $this->fields['custo_real']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Lucro (R$)', 'name' => 'lucro', 'mask' => 'ls-mask-money', 'value' => $this->fields['lucro']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Margem Contrib(%)', 'name' => 'margem_contrib', 'mask' => 'ls-mask-percent', 'align' => 'right', 'value' => $this->fields['margem_contrib']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Extras (R$)', 'name' => 'despesas_extras', 'mask' => 'ls-mask-money', 'value' => $this->fields['despesas_extras']));
     echo "</td>";
     echo "<td>";
     SystemHelper::addTextfield(array('label' => 'Total (R$)', 'name' => 'valor_total', 'required' => true, 'mask' => 'ls-mask-money', 'value' => $this->fields['valor_total']));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     SystemHelper::addLargeTextfield(array('label' => 'Observações', 'name' => 'observacoes', 'rows' => 8, 'value' => $this->fields['observacoes']));
     echo "</div>";
     echo "<div id='efetivo' class='ls-tab-content' role='tabpanel'>";
     include "TaskCasting.php";
     include "Casting.php";
     include "BankAccount.php";
     $this->task_casting = new TaskCasting();
     $add_button = $this->task_casting->getActionOptions()["add"];
     $base_url = $add_button["url"];
     $add_button["url"] = $base_url . "/promotor";
     $promotores = array();
     $supervisores = array();
     $produtores = array();
     $this->load->model("taskcasting_model");
     $this->taskcasting_model = new Taskcasting_Model();
     $remove_bt = array('icon' => 'ls-ico-close', 'url' => '#', 'label' => '', 'onClick' => '$futuri.removeCastingOrProductTask(this);');
     //$this->taskcasting_model->debugMode = true;
     foreach ($this->taskcasting_model->getObjects(array("where" => "trabalho_id = " . $this->objectID)) as $index => $promInfo) {
         $this->casting = new Casting($promInfo['promotor_id']);
         $this->bank_account = new BankAccount($promInfo['promotor_conta_banco_id']);
         $hidden = "<input type='hidden' name='trabalho_select_casting[]' value='" . $promInfo['promotor_id'] . "'>";
         $hidden2 = "<input type='hidden' name='trabalho_select_bank[]' value='" . $promInfo['promotor_conta_banco_id'] . "'>";
         $hidden3 = "<input type='hidden' name='trabalho_select_valor[]' value='" . $promInfo['promotor_valor_recebido'] . "'>";
         switch ($this->casting->fields['funcao_id']) {
             case TaskCasting::CASTINGJOB_PROMOTER_ID:
                 $promotores[] = array($hidden . $this->casting->fields['nome_completo'], $hidden3 . $promInfo['promotor_valor_recebido'], $hidden2 . $this->bank_account->fields['banco_nome'], $this->bank_account->fields['banco_agencia'], $this->bank_account->fields['banco_conta'], array("remove_button" => $remove_bt));
                 break;
             case TaskCasting::CASTINGJOB_SUPERVISOR_ID:
                 $supervisores[] = array($hidden . $this->casting->fields['nome_completo'], $hidden3 . $promInfo['promotor_valor_recebido'], $hidden2 . $this->bank_account->fields['banco_nome'], $this->bank_account->fields['banco_agencia'], $this->bank_account->fields['banco_conta'], array("remove_button" => $remove_bt));
                 break;
             case TaskCasting::CASTINGJOB_PRODUCER_ID:
                 $produtores[] = array($hidden . $this->casting->fields['nome_completo'], $hidden3 . $promInfo['promotor_valor_recebido'], $hidden2 . $this->bank_account->fields['banco_nome'], $this->bank_account->fields['banco_agencia'], $this->bank_account->fields['banco_conta'], array("remove_button" => $remove_bt));
                 break;
         }
     }
     $headers = array('Nome', 'Valor recebido', 'Banco', 'Agencia', 'Conta', '');
     $this->task_casting->showListPanel(array('title' => 'Promotores', 'hideNoneRowsMsg' => true, 'id' => 'task_promotores', 'headers' => $headers, 'list' => $promotores, 'add_button' => $add_button));
     $add_button["url"] = $base_url . "/supervisor";
     $this->task_casting->showListPanel(array('title' => 'Supervisores', 'id' => 'task_supervisores', 'hideNoneRowsMsg' => true, 'headers' => $headers, 'list' => $supervisores, 'add_button' => $add_button));
     $add_button["url"] = $base_url . "/produtor";
     $this->task_casting->showListPanel(array('title' => 'Produtores', 'id' => 'task_produtores', 'hideNoneRowsMsg' => true, 'headers' => $headers, 'list' => $produtores, 'add_button' => $add_button));
     echo "<table class='easy-form-table'>";
     echo "<tr>";
     echo "</tr>";
     echo "</table>";
     echo "</div>";
     echo "<div id='produtos_servicos' class='ls-tab-content' role='tabpanel'>";
     include "Product.php";
     include "TaskProduct.php";
     $this->products = new TaskProduct();
     $this->load->model("taskproduct_model");
     $produtos = array();
     $this->taskproduct_model = new Taskproduct_Model();
     foreach ($this->taskproduct_model->getObjects(array("where" => "trabalho_id = '" . $this->objectID . "'")) as $ind => $prodInfo) {
         $this->product = new Product($prodInfo['produto_id']);
         $produtos[] = array("<input type='hidden' name='trabalho_select_produto[]' value='" . $prodInfo['produto_id'] . "'>" . $this->product->fields['nome'], "<input type='hidden' name='trabalho_select_quantidade[]' value='" . $prodInfo['produto_quantidade'] . "'>" . $prodInfo['produto_quantidade'], array("remove_button" => $remove_bt));
     }
     $this->products->showListPanel(array('title' => 'Produtos/Serviços', 'hideNoneRowsMsg' => true, 'id' => 'task_produtos', 'list' => $produtos, 'headers' => array('Nome', 'Quantidade', ''), 'add_button' => $this->products->getActionOptions()["add"]));
     echo "</div>";
     $this->addButtons();
 }