Guest User

Untitled

a guest
Jan 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.78 KB | None | 0 0
  1. <?php
  2. header("Access-Control-Allow-Origin:*");
  3. header("Content-Type: application/html; charset=UTF-8");
  4.  
  5. $banco="mysql:host=mysql01.cartorioalianca1.hospedagemdesites.ws;dbname=cartorioalianca1";
  6. $user="cartorioalianca1";
  7. $pass="cart04071978";
  8.  
  9. //RECUPERAÇÃO DO FORMULÁRIO
  10. $data = file_get_contents("php://input");
  11. $data = json_decode($data);
  12.  
  13.  
  14. // TRANSFORMA OS DADOS
  15. $id = trim($id);
  16. $dados; // RECEBE ARRAY PARA RETORNO
  17.  
  18. // INSERE OS DADOS
  19. @$db = new PDO($banco,$user,$pass);
  20.  
  21. //VERIFICAR SE TEM CONEXÃO
  22.  
  23. if($db){
  24. $sql = "DELETE FROM pesquisa WHERE id=".$data;
  25. $query = $db->prepare($sql);
  26. $query ->execute();
  27.  
  28. };
  29.  
  30. (function() {
  31. "use strict";
  32.  
  33. angular.module("myApp").controller("initCtrl", function($scope, Soli, Data, $filter, $ionicPopup, $ionicModal, $location, DBLocal){
  34. $scope.home = "Cartório Aliança";
  35. $scope.home1 = "Acesso Rápido às Pesquisas";
  36. $scope.respostas = "Resultados";
  37. $scope.pesquisa1 = "Pesquisa de Satisfação";
  38. $scope.pesquisa2 = "A sua opnião é importante para nós!";
  39. $scope.pesquisa3 = "Escolha uma opção de cada pergunta e depois aperte em enviar para avalia nosso atendimento e serviços.";
  40. $scope.pergunta1 = "1- A pessoa que atendeu você foi rápida e clara?";
  41. $scope.pergunta2 = "2- A pessoa que atendeu você foi educada?";
  42. $scope.pergunta3 = "3- Como você avalia o jeito que o cartório pede, recebe e emite documentos? (Segurança Jurídica)";
  43. $scope.pergunta4 = "4- Como você avalia a organização do cartório?";
  44. $scope.pergunta5 = "5- Como você avalia a limpeza do cartório?";
  45. $scope.pergunta6 = "6- Como você avalia as campanhas e ações sociais do cartório? (Natal, Plantio de Árvores, Campanhas de Saúde)";
  46. $scope.identidade = "DIGITE SEU NOME NO CAMPO ABAIXO CASO QUEIRA SE IDENTIFICAR, OU APENAS DEIXE EM BRANCO"
  47. $scope.identidade1 = "DIGITE SEU NOME, TELEFONE E EMAIL NOS CAMPOS ABAIXO CASO QUEIRA SE IDENTIFICAR, OU APENAS DEIXE-OS EM BRANCO"
  48. $scope.pesquisa_seq1 = "Pesquisa de Segmentação";
  49. $scope.pesquisa_seq2 = "Queremos saber quem você é, para ainda melhor servi-lo!";
  50. $scope.pesquisa_seq3 = "Escolha uma opção na pergunta que mais nos conte sobre você!.";
  51. $scope.pergunta_seq1 = "1- Qual sua escolaridade?";
  52. $scope.pergunta_seq2 = "2- Você tem renda familiar de:";
  53. $scope.pergunta_seq3 = "3- Como você acessa a internet?";
  54. $scope.pergunta_seq4 = "4- Onde você trabalha?";
  55. $scope.pergunta_seq5 = "5- Com que frequência você precisa do cartório?";
  56. $scope.pergunta_seq6 = "6- Como você mora?";
  57.  
  58. $scope.resposta_pesq = "Resultado da Pesquisa de Satisfação";
  59. $scope.resposta_seg = "Resultado da Pesquisa de Segmentação";
  60. $scope.perfil = "Perfil do Pesquisado em Satisfação";
  61. $scope.perfil2 = "Perfil do Pesquisado em Segmentação";
  62. $scope.today = new Date();
  63. $scope.contatos = [];
  64. $scope.segment = [];
  65.  
  66.  
  67. //login -->
  68. DBLocal.localdb();
  69.  
  70. var nome = "soliney";
  71. var senha = "123456";
  72.  
  73. //INSERINDO DADOS LOCALMENTE
  74. //DBLocal.db.transaction(function(res){
  75. //res.executeSql("INSERT INTO USER(nome,senha) VALUES(?,?);", [nome, senha]);
  76. //});
  77.  
  78. //RECUPERANDO DADO LOCAL
  79.  
  80. //DBLocal.db.transaction(function(res){
  81. //var q = "SELECT*FROM USER";
  82. //res.executeSql(q, null, function(i, data){
  83. // $scope.nome = "Olá " + data.rows.item(0).nome;
  84. //});
  85. // });
  86.  
  87. // LOGOFF
  88. //DBLocal.db.transaction(function(res){
  89. //res.executeSql("DELETE FROM USER WHERE nome = ?;",[nome]);
  90.  
  91. //});
  92.  
  93.  
  94. // IMPRIMIR DADOS -->
  95. var getData = function(){
  96. var params = {
  97. counter:$scope.contatos.length,
  98. token:"1f3d2gs3f2fg3as2fdg3re2t1we46er45"
  99. };
  100.  
  101. Data.getData(params).success(function(data){
  102. $scope.contatos = data;
  103.  
  104. }).error(function(data){
  105. console.log(data? data : "Não foi possivel acessar o servidor");
  106. });
  107. };
  108.  
  109.  
  110. // ABRIR MODAL-->
  111.  
  112. $ionicModal.fromTemplateUrl('views/cadastro.html',{
  113. scope: $scope,
  114. animation: 'slide-in-up'
  115. }).then(function(modal) {
  116. $scope.modal = modal;
  117. });
  118.  
  119. $scope.abreModal = function(){
  120. $scope.modal.show();
  121. };
  122.  
  123. $scope.fechaModal = function(){
  124. $scope.modal.hide();
  125. location.reload();
  126. };
  127.  
  128.  
  129. // ABRIR MODAL 2-->
  130.  
  131. $ionicModal.fromTemplateUrl('views/cadastro_2.html',{
  132. scope: $scope,
  133. animation: 'slide-in-up'
  134. }).then(function(modal1) {
  135. $scope.modal1 = modal1;
  136. });
  137.  
  138. $scope.abreModal1 = function(){
  139. $scope.modal1.show();
  140. };
  141.  
  142. $scope.fechaModal1 = function(){
  143. $scope.modal1.hide();
  144. location.reload();
  145. };
  146.  
  147.  
  148. getData();
  149.  
  150. // IMPRIMIR DADOS -->
  151. var getSoli = function(){
  152. var params = {
  153. counter:$scope.segment.length,
  154. token:"1f3d2gs3f2fg3as2fdg3re2t1we46ss45"
  155. };
  156.  
  157. Soli.getSoli(params).success(function(data){
  158. $scope.segment = data;
  159.  
  160. }).error(function(data){
  161. console.log(data? data : "Não foi possivel acessar o servidor");
  162. });
  163. };
  164.  
  165.  
  166. getSoli();
  167.  
  168. //CADASTRO
  169.  
  170. $scope.cadastroRespostas = function(cadastro){
  171. Data.setData(cadastro).success(function(data){
  172.  
  173. }).error(function(data){
  174. alert(data);
  175. });
  176. console.log(cadastro);
  177.  
  178. };
  179.  
  180.  
  181. //PERFIL PESQUISA
  182. $scope.perfilUsuario = function(id){
  183. $scope.usuarioPerfil = $scope.contatos.filter(function(element){
  184. return element.id == id;
  185. });
  186. console.log($scope.usuarioPerfil);
  187. $location.path("/menu/perfil");
  188. };
  189.  
  190.  
  191.  
  192. //DELETA CADASTRO PESQUISA
  193. $scope.deletarPerfil = function(contato){
  194. $scope.deletedTodo = contato;
  195.  
  196. var myPopup = $ionicPopup.show({
  197.  
  198. title: 'Tem certeza que deseja deletar a pesquisa?',
  199. subTitle: 'Atenção: Depois de deletado não poderá ser recuperado',
  200. scope: $scope,
  201. buttons: [
  202. { text: 'Cancelar' },
  203. {
  204. text: '<b>OK</b>',
  205. type: 'button-balanced',
  206. onTap: function(e) {
  207. if (!$scope.deletedTodo.contatos) {
  208. Data.deleteData(contato.id).success(function(data){
  209. }).error(function(data){
  210. alert(data);
  211. });
  212. console.log(contato);
  213. location.reload();
  214.  
  215. };
  216. }
  217. }
  218. ]
  219. });
  220. }
  221.  
  222. //EDITA CADASTRO PESQUISA
  223. $scope.editTodo = function(usuario){
  224. $scope.editedTodo = usuario;
  225. var toDoTemplate = '<input type="text" ng-model="editedTodo.nome" value="req.nome"></br><input type="tel" ng-model="editedTodo.tel" value="req.tel"></br><input type="emal" ng-model="editedTodo.email" value="req.email"></br>'
  226.  
  227. var myPopup = $ionicPopup.show({
  228. template: toDoTemplate,
  229. title: 'Edite o contato',
  230. subTitle: 'modificando o contato',
  231. scope: $scope,
  232. buttons: [
  233. { text: 'Cancelar' },
  234. {
  235. text: '<b>Salvar</b>',
  236. type: 'button-positive',
  237. onTap: function(e) {
  238. if (!$scope.editedTodo.usuari1) {
  239. Data.updateData(usuario).success(function(data){
  240.  
  241. }).error(function(data){
  242. alert(data);
  243. });
  244. console.log(usuario);
  245.  
  246. };
  247. }
  248. }
  249. ]
  250. });
  251. }
  252.  
  253. //CADASTRO SEGMENTAÇÃO
  254. $scope.cadastroSegmentacao = function(cadastro){
  255. Soli.setSoli(cadastro).success(function(data){
  256.  
  257. }).error(function(data){
  258. alert(data);
  259. });
  260. console.log(cadastro);
  261.  
  262. };
  263.  
  264.  
  265. //PERFIL SEGMENTAÇÃO
  266. $scope.perfilsegm = function(id){
  267. $scope.segmPerfil = $scope.segment.filter(function(element){
  268. return element.id_seg == id;
  269. });
  270. console.log($scope.segmPerfil);
  271. $location.path("/menu/perfil_seg");
  272. };
  273.  
  274. //EDITA CADASTRO SEGMENTAÇÃO
  275. $scope.editSeg = function(segm){
  276. $scope.editedSeg = segm;
  277. var toDosTemplate = '<input type="text" ng-model="editedSeg.nome" value="req.nome">'
  278.  
  279. var myPopup = $ionicPopup.show({
  280. template: toDosTemplate,
  281. title: 'Edite o contato de Segmentação',
  282. subTitle: 'modificando o contato',
  283. scope: $scope,
  284. buttons: [
  285. { text: 'Cancelar' },
  286. {
  287. text: '<b>Salvar</b>',
  288. type: 'button-positive',
  289. onTap: function(e) {
  290. if (!$scope.editedSeg.segms) {
  291. Soli.updateSegData(segm).success(function(datas){
  292.  
  293. }).error(function(datas){
  294. alert(datas);
  295. });
  296. console.log(segm);
  297.  
  298. };
  299. }
  300. }
  301. ]
  302. });
  303. }
  304.  
  305.  
  306.  
  307.  
  308. //DELETA CADASTRO SEGMENTAÇÃO
  309. $scope.deletarSeg = function(contato){
  310. $scope.deletedSeg = contato;
  311.  
  312. var myPopup = $ionicPopup.show({
  313.  
  314. title: 'Tem certeza que deseja deletar a pesquisa?',
  315. subTitle: 'Atenção: Depois de deletado não poderá ser recuperado',
  316. scope: $scope,
  317. buttons: [
  318. { text: 'Cancelar' },
  319. {
  320. text: '<b>OK</b>',
  321. type: 'button-balanced',
  322. onTap: function(e) {
  323. if (!$scope.deletedSeg.segment) {
  324. Soli.deleteSoli(contato.id_seg).success(function(data){
  325.  
  326. }).error(function(data){
  327. alert(data);
  328. });
  329. console.log(contato);
  330. location.reload();
  331.  
  332. };
  333. }
  334. }
  335. ]
  336. });
  337. }
  338.  
  339.  
  340.  
  341. $scope.fechar = function() {
  342. ionic.Platform.exitApp();
  343. };
  344.  
  345. });
  346.  
  347. })();
  348.  
  349. (function(){
  350. "use strict";
  351. angular.module("myApp").value("Config",{
  352. getUrl:"http://cartorioalianca.com.br/api1/"
  353. });
  354.  
  355. angular.module("myApp").service("Data", function($http, Config){
  356. //recuperação de dados
  357. this.getData = function(params){
  358. return $http({
  359. method:"POST",
  360. url:Config.getUrl+"apiRecupera.php",
  361. data:params,
  362. headers:{
  363. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  364. }
  365. });
  366. };
  367.  
  368.  
  369. //CADASTROS
  370. this.setData = function(dados){
  371. return $http({
  372. method:"POST",
  373. url:Config.getUrl+"apiCadastro.php",
  374. data:dados,
  375. headers:{
  376. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  377. }
  378.  
  379. });
  380. };
  381.  
  382. //UPDATE CADASTROS
  383. this.updateData = function(data){
  384. return $http({
  385. method:"POST",
  386. url:Config.getUrl+"apiUpdate.php",
  387. data:data,
  388. headers:{
  389. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  390. }
  391.  
  392. });
  393. };
  394.  
  395.  
  396. //DELETA CADASTROS
  397. this.deleteData = function(id){
  398. return $http({
  399. method:"POST",
  400. url:Config.getUrl+"apideleta.php",
  401. data:id,
  402. headers:{
  403. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  404. }
  405. });
  406. };
  407.  
  408. });
  409.  
  410. angular.module("myApp").service("Soli", function($http, Config){
  411. //recuperação de dados
  412. this.getSoli = function(params){
  413. return $http({
  414. method:"POST",
  415. url:Config.getUrl+"apiRecuperaSeg.php",
  416. data:params,
  417. headers:{
  418. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  419. }
  420. });
  421. };
  422.  
  423. //CADASTROS
  424. this.setSoli = function(dados){
  425. return $http({
  426. method:"POST",
  427. url:Config.getUrl+"apiSegmentacao.php",
  428. data:dados,
  429. headers:{
  430. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  431. }
  432.  
  433. });
  434. };
  435.  
  436. //UPDATE SEGMENTAÇÃO
  437. this.updateSegData = function(datas){
  438. return $http({
  439. method:"POST",
  440. url:Config.getUrl+"apiUpdateSeg.php",
  441. data:datas,
  442. headers:{
  443. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  444. }
  445. });
  446. };
  447.  
  448. //DELETA CADASTROS SEGUIMENTAÇÃO
  449. this.deleteSoli = function(id_seg){
  450. return $http({
  451. method:"POST",
  452. url:Config.getUrl+"apideletaSeg.php",
  453. data:id_seg,
  454. headers:{
  455. 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8;'
  456. }
  457. });
  458. };
  459.  
  460. });
  461. })();
Add Comment
Please, Sign In to add comment