Skip to content

Commit

Permalink
ajustes nos contatos de chamadas
Browse files Browse the repository at this point in the history
  • Loading branch information
humbertocruz committed Apr 10, 2013
1 parent 73c3a9a commit cee2298
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 467 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Config/core.php
Config/database.php
tmp/*
webroot/backps_dir/*
29 changes: 28 additions & 1 deletion Controller/BackupsController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
<?php
class BackupsController extends AppController {
public function index() {
$bkps = array();
if ($handle = opendir(WWW_ROOT.'/backups_dir')) {
/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
array_push($bkps, array('arquivo'=>$entry,'tam'=>0));
}
closedir($handle);
}
$this->set('backups', $bkps);
}
}

public function gerar_arq() {
exec('tar cf '.WWW_ROOT.'/backups_dir/arq_'.date('Y_m_d_H_i_s').'.tar.gz '.ROOT, $saida);
$this->redirect('/backups');
}

public function gerar_db() {
App::uses('ConnectionManager', 'Model');
$dataSource = ConnectionManager::getDataSource('default');
$username = $dataSource->config['login'];
$passw = $dataSource->config['password'];
$host = $dataSource->config['host'];
$database = $dataSource->config['database'];
//echo 'mysqldump -h '.$host.' -u '.$username.' -p'.$passw.' '.$database.' > '.WWW_ROOT.'/backups_dir/db_'.date('Y_m_d_H_i_s').'.tar.gz ';
exec('mysqldump -h '.$host.' -u '.$username.' -p'.$passw.' '.$database.' > '.WWW_ROOT.'/backups_dir/db_'.date('Y_m_d_H_i_s').'.tar.gz ', $saida, $status);
pr($status);
//$this->redirect('/backups');
}
}
1 change: 1 addition & 0 deletions Controller/ChamadasController.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public function add($chamada_id = 0, $pedido_id = 0) {
$this->set('filter_data', $filter_data);

$this->_variables('Adiciona Chamada');

}

public function edit($id = null, $pedido_id = 0) {
Expand Down
24 changes: 23 additions & 1 deletion View/Backups/index.ctp
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
Backups
<div class="row">
<div class="page-header">
<h3>Backups</h3>
</div>
<table class="table table-bordered">
<tr>
<th>Arquivo</th>
<th>Tamanho</th>
</tr>
<?php foreach($backups as $bkp) {
if (strstr($bkp['arquivo'], 'tar.gz')) { ?>
<tr>
<td><a href="<?php echo '/backups_dir/'.$bkp['arquivo']; ?>"><?php echo $bkp['arquivo']; ?></a></td>
<td><?php echo number_format( (filesize(WWW_ROOT.'/backups_dir/'.$bkp['arquivo'])/1024/1024) ) .' MB';?></td>
</tr>
<?php } } ?>
</table>
<div class="form-actions">
<a class="btn btn-danger" href="/backups/gerar_arq">Novo Backup Arquivos</a>
<a class="btn btn-danger" href="/backups/gerar_db">Novo Backup Banco</a>
</div>

</div>
102 changes: 19 additions & 83 deletions View/Chamadas/add.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ $sess_models = AppController::_sess_models();
<script>
$(document).ready(function(){
var contatos_instituicao = new Array();

$('.btns').button();
$('.btI').click(function(){
$('.opt-fornecedor').addClass('hide');
Expand All @@ -237,112 +237,48 @@ $sess_models = AppController::_sess_models();
});
$('#fld_fornecedor_id').change(function(){
contatos_from('fornecedor');
chamadas_from('fornecedor');
});
function chamadas_from(deonde) {
if ($('#fld_'+deonde+'_id').val() != null) {
$.ajax({
'url':'/chamadas/carrega_chamadas/'+deonde+'/'+$('#fld_'+deonde+'_id').val(),
'success': function(data) {
$('.chamadas_table').html(data);
$('#fld_contato_id').change();
}
});
}
}
$('#fld_contato_id').change(function(){
atualiza_edita_contato( $(this).val() );
//contatos_fones();
//contatos_emails();
});

function atualiza_edita_contato(value){
$('#btn-edita-contato').data('idContatoInstituicao', value);
}

$('#btn-edita-contato').click(function(){
//location.href = 'system/belongsTo/'. encodeURI( 'contatos/edit/'+$(this).data('idContato')+'/'+$(this).data('idChamada') );
$('form#form_Chamada').attr('action','/systems/belongsTo/form_data' );
$('form#form_Chamada').prepend('<input type="hidden" name="data[form_data]" value="/contatos/edit/'+$(this).data('idContatoInstituicao')+'/'+$(this).data('idChamada')+'">');
$('form#form_Chamada').submit();
});

function contatos_from(deonde) {
contato_id = 0;
if ($('#fld_'+deonde+'_id').val() != null) {
$.ajax({
'dataType':'html',
'url':'/chamadas/contatos_from/'+deonde+'/'+$('#fld_'+deonde+'_id').val(),
'success': function(data) {
console.log(data);
$('#contatos-table').html(data);
//$('#btn-edita-contato').data('idContato', parseInt( data[0]['Contato']['id'] ));
$('#fld_contato_id').change();
$('#list-contatos').html(data);
contato_show_table();
}
});
}
}

$('#bt-addContato').click(function() {
$('#fld_contato_instituicao_id').val( $('#fld_instituicao_id').val() );
$.ajax({
'url':'/chamadas/addContatoChamada',
'data':$('#frm-addContato').serialize(),
'type':'POST',
'success': function(data){
$('#modal-novo-contato').modal('hide');
$('#fld_instituicao_id').change();
}
});
});
$('#bt-addContatoFone').click(function() {
$('#fld_addFone_contato_id').val( $('#fld_contato_id').val() );
$.ajax({
'url':'/chamadas/addContatoFone',
'data':$('#frm-addContatoFone').serialize(),
'type':'POST',
'success': function(data){
$('#modal-novo-telefone').modal('hide');
$('#fld_contato_id').change();
}
});
});
$('#bt-addContatoEmail').click(function() {
$('#fld_addEmail_contato_id').val( $('#fld_contato_id').val() );
$.ajax({
'url':'/chamadas/addContatoEmail',
'data':$('#frm-addContatoEmail').serialize(),
'type':'POST',
'success': function(data){
$('#modal-novo-email').modal('hide');
$('#fld_contato_id').change();
}
});
$('#ChamadasTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
});

function contatos_fones() {
$.ajax({
'dataType':'json',
'url':'/chamadas/contatos_fones/'+$('#fld_contato_id').val(),
'success': function(data) {
var fones = '';
$.each(data, function(i, item) {
fones+= item['ContatosFone']['fone']+' - '+item['TiposFone']['nome']+'\n';
});
$('#fld_contato_fones').val(fones);
}
});
}
function contatos_emails() {
$.ajax({
'dataType':'json',
'url':'/chamadas/contatos_emails/'+$('#fld_contato_id').val(),
'success': function(data) {
var emails = '';
$.each(data, function(i, item) {
emails+= item['ContatosEmail']['email']+'\n';
});
$('#fld_contato_emails').val(emails);
}
});
function contato_show_table() {
$('.contato-table').hide();
contato_id = $('#contato-select').val();
$('#contato-table-'+contato_id).show();
}

$('#contato-select').live('change', function() {
contato_show_table();
} );

contato_show_table();

});
</script>
Loading

0 comments on commit cee2298

Please sign in to comment.