Advertisement
slothcreative

library InscurrFactory.php

Feb 1st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.66 KB | None | 0 0
  1. <?php
  2. if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  3.  
  4. class InscurrFactory {
  5.  
  6.     private $_ci;
  7.  
  8.     function __construct()
  9.     {
  10.         //When the class is constructed get an instance of codeigniter so we can access it locally
  11.         $this->_ci =& get_instance();
  12.         //Include the user_model so we can use it
  13.         $this->_ci->load->model("SingOff_Model");
  14.        
  15.     }
  16.  
  17.     public function insertcurr() {
  18.         $this->_ci->load->helper('form');
  19.         //Are we getting an individual user or are we getting them all
  20.             $query = $this->_ci->db->query('SELECT MAX(progressivo) as progress, MAX(id) as maxid from curriculum');
  21.             //Getting an individual user
  22.            
  23.             foreach ($query->result() as $row){
  24.                 $prog = $row->progress;
  25.                 $id = $row->maxid;
  26.             }
  27.             $idprovnasc = $this->_ci->input->post('cpnascita');
  28.             $idprovres = $this->_ci->input->post('cpresidenza');
  29.             $idprovdom = $this->_ci->input->post('cpdomicilio');
  30.             $query = $this->_ci->db->query('SELECT id from curriculum where codicefiscale = "'.$this->_ci->input->post('ccodfis').'"');
  31.             if ($query->num_rows() > 0) {
  32.                 return FALSE;
  33.             }else{
  34.                
  35.                 foreach ($query->result() as $row){
  36.                     $idprovdom = $row->provincia;
  37.                 }  
  38.                 if ($this->_ci->input->post('ccinglese') != 0){//$_SESSION['ccinglese'] != 0){
  39.                     $corsoinglese = 0;
  40.                 }else{
  41.                     $corsoinglese = 1;
  42.                 }
  43.                 if ($this->_ci->input->post('ccfrancese') != 0){
  44.                     $corsofrancese = 0;
  45.                 }else{
  46.                     $corsofrancese = 1;
  47.                 }
  48.                 if ($this->_ci->input->post('ccspagnolo') != 0){
  49.                     $corsospagnolo = 0;
  50.                 }else{
  51.                     $corsospagnolo = 1;
  52.                 }
  53.                 if ($this->_ci->input->post('cctedesco') != 0){
  54.                     $corsotedesco = 0;
  55.                 }else{
  56.                     $corsotedesco = 1;
  57.                 }
  58.                 if (isset($_SESSION['logged_in']['id'])){
  59.                     $idsel = $_SESSION['logged_in']['id'];
  60.                 }else{
  61.                     $idsel = $_SESSION['idreg'];
  62.                 }
  63.                 $query = $this->_ci->db->query('SELECT nome from utenti where id = "'.$idsel.'"');//.$_SESSION['logged_in']['id'].'"');
  64.                 if ($query->num_rows() > 0) {
  65.                     foreach ($query->result() as $row){
  66.                         $nomecognome = explode(" ", $row->nome);
  67.                         $nomeins = $nomecognome[0]; // piece1
  68.                         $cognomeins= $nomecognome[1]; // piece2
  69.                     }
  70.                 }
  71.                 if ($this->_ci->session->userdata('email')){
  72.                         $mailreg = $this->_ci->session->userdata('email');
  73.                     }else{
  74.                         $mailreg = $_SESSION['mailreg'];
  75.                     }
  76.                
  77.                 $data = array(
  78.                     'nome'=>$nomeins,
  79.                     'cognome'=>$cognomeins,
  80.                     'sesso'=>$this->_ci->input->post('csesso'),
  81.                     'datanascita'=>date("Y-m-d", strtotime($this->_ci->input->post('cdnascita'))),
  82.                     'luogonascita'=>$this->_ci->input->post('ccnascita'),
  83.                     'provincianascita'=>$idprovnasc,
  84.                     'statonascita'=>$this->_ci->input->post('csnascita'),
  85.                     'indirizzoresidenza'=>$this->_ci->input->post('ciresidenza'),
  86.                     'capresidenza'=>$this->_ci->input->post('ccapresidenza'),
  87.                     'cittaresidenza'=>$this->_ci->input->post('ccresidenza'),
  88.                     'provinciaresidenza'=>$idprovres,
  89.                     'statoresidenza'=>$this->_ci->input->post('csresidenza'),
  90.                     'indirizzodomicilio'=>$this->_ci->input->post('cidomicilio'),
  91.                     'capdomicilio'=>$this->_ci->input->post('ccapdomicilio'),
  92.                     'cittadomicilio'=>$this->_ci->input->post('ccdomicilio'),
  93.                     'provinciadomicilio'=> $idprovdom,
  94.                     'statodomicilio'=>$this->_ci->input->post('csdomicilio'),
  95.                     'cittadinanza'=>$this->_ci->input->post('ccittadinanza'),
  96.                     'permessosoggiorno'=>$this->_ci->input->post('psoggiorno'),
  97.                     'codicefiscale'=>$this->_ci->input->post('ccodfis'),
  98.                     'partitaiva'=>$this->_ci->input->post('cpiva'),
  99.                     'telefono'=>$this->_ci->input->post('ctel'),
  100.                     'telefono2'=>' ',
  101.                     'cellulare'=>$this->_ci->input->post('ccel'),
  102.                     'cellulare2'=>' ',
  103.                     //'email'=>$this->_ci->input->post('cemail'),
  104.                     'email'=>$mailreg,
  105.                     'email2'=>' ',
  106.                     'patente'=>$this->_ci->input->post('cpatente'),
  107.                     'automunito'=>$this->_ci->input->post('automunito'),
  108.                     'altezza'=>$this->_ci->input->post('caltezza'),
  109.                     'peso'=>$this->_ci->input->post('cpeso'),
  110.                     'tagliamaglia'=>$this->_ci->input->post('cmaglia'),
  111.                     'tagliagonnapantaloni'=>$this->_ci->input->post('cpantalone'),
  112.                     'misurascarpe'=>$this->_ci->input->post('cscarpe'),
  113.                     'certificatoHACCP'=>$this->_ci->input->post('haccpsino'),
  114.                     'titolostudio'=>$this->_ci->input->post('titolo'),
  115.                     'voto'=>$this->_ci->input->post('cvoto'),
  116.                     'master'=>$this->_ci->input->post('mastersino'),
  117.                     'inglese'=>$this->_ci->input->post('cinglese'),
  118.                     'francese'=>$this->_ci->input->post('cfrancese'),
  119.                     'spagnolo'=>$this->_ci->input->post('cspagnolo'),
  120.                     'tedesco'=>$this->_ci->input->post('ctedesco'),
  121.                     'altralingua'=>$this->_ci->input->post('caltra'),
  122.                     'conoscenzaaltralingua'=>$this->_ci->input->post('caltraliv'),
  123.                     'corsoinglese'=>$corsoinglese,
  124.                     'corsofrancese'=>$corsofrancese,
  125.                     'corsospagnolo'=>$corsospagnolo,
  126.                     'corsotedesco'=>$corsotedesco,
  127.                     'livellocorsoinglese'=>$this->_ci->input->post('ccinglese'),
  128.                     'livellocorsofrancese'=>$this->_ci->input->post('ccfrancese'),
  129.                     'livellocorsospagnolo'=>$this->_ci->input->post('ccspagnolo'),
  130.                     'livellocorsotedesco'=>$this->_ci->input->post('cctedesco'),
  131.                     'corsoaltralingua'=>$this->_ci->input->post('ccaltra'),
  132.                     'livellocorsoaltralingua'=>$this->_ci->input->post('ccaltraliv'),
  133.                     'esperienza'=>$this->_ci->input->post('esperienza'),
  134.                     'anniesperienza'=>$this->_ci->input->post('caesperienza'),
  135.                     'addettovendita'=>$this->_ci->input->post('addvendite'),
  136.                     'allestitore'=>$this->_ci->input->post('allestitore'),
  137.                     'hostess'=>$this->_ci->input->post('hostess'),
  138.                     'hostessecm'=>$this->_ci->input->post('hostessecm'),
  139.                     'hostessfiera'=>$this->_ci->input->post('hostessfiera'),
  140.                     'promoter'=>$this->_ci->input->post('promoter'),
  141.                     'steward'=>$this->_ci->input->post('steward'),
  142.                     'modello'=>$this->_ci->input->post('modello'),
  143.                     'merchandiser'=>$this->_ci->input->post('merchandiser'),
  144.                     'musicista'=>$this->_ci->input->post('cmusicista'),
  145.                     'altrafigura'=>$this->_ci->input->post('espaltro'),
  146.                     'agenzialavorato'=>$this->_ci->input->post('cespprec'),
  147.                     //'foto1'=>$this->_ci->input->post('pic1'),
  148.                     'foto1'=>$_SESSION['pic1'],
  149.                     //'curriculum'=>$this->_ci->input->post('currfile'),
  150.                     'curriculum'=>$_SESSION['currfile'],
  151.                     'password'=>$this->_ci->input->post('cpassword'),
  152.                     //'foto2'=>$this->_ci->input->post('pic2'),
  153.                     'foto2'=>$_SESSION['pic2'],
  154.                     //'foto3'=>$this->_ci->input->post('pic3'),
  155.                     'foto3'=>$_SESSION['pic3'],
  156.                     'progressivo'=>'$prog',
  157.                     'codice'=>' ',
  158.                     'noteinterne'=>' ');
  159.                     //print_r($data); die;
  160.                 $query = $this->_ci->db->insert('curriculum', $data);
  161.                 $query = $this->_ci->db->query('UPDATE utenti SET idcurr = \''.$this->_ci->db->insert_id().'\' where id = "'.$idsel.'"');
  162.                 $_SESSION['logged_in']['idcurr'] = $this->_ci->db->insert_id();
  163.                 if ($this->_ci->db->affected_rows() > 0) {
  164.                     $this->_ci->load->library('email');
  165.                     $this->_ci->email->set_mailtype("html");
  166.                     $this->_ci->email->set_newline("\r\n");
  167.                     $this->_ci->email->set_crlf("\r\n");
  168.                     $this->_ci->email->from('noreply@animania.it');
  169.                     if ($this->_ci->session->userdata('email')){
  170.                         $this->_ci->email->to($this->_ci->session->userdata('email')); // change it to yours
  171.                         $corpomess = 'Ciao,<br> La tua registrazione su Animania.it è stata accettata.<br> Le credenziali per accedere sono:<br>Username: '.$this->_ci->session->userdata('email').'<br> Password: '.$this->_ci->session->userdata('password').'<br> Animania.it ti augura una buona giornata! ';
  172.                     }else{
  173.                         $this->_ci->email->to($_SESSION['mailreg']);
  174.                         $corpomess = 'Ciao,<br> La tua registrazione su Animania.it è stata accettata.<br> Le credenziali per accedere sono:<br>Username: '.$_SESSION['mailreg'].'<br> Password: '.$_SESSION['passreg'].'<br> Animania.it ti augura una buona giornata! ';
  175.                     }
  176.                     //$this->email->to('ciro.latela@gmail.com'); // change it to yours
  177.                     $this->_ci->email->subject('Registrazione su Animania.it');
  178.                     //$corpomess = 'Ciao,<br> La tua registrazione su Animania.it è stata accettata.<br> Le credenziali per accedere sono:<br>Username: '.$this->session->userdata('email').'<br> Password: '.$this->session->userdata('password').'<br> Animania.it ti augura una buona giornata! ';
  179.                     $this->_ci->email->message($corpomess);
  180.                     if ($this->_ci->email->send()) {
  181.                         //$this->_ci->load->view('successreg');
  182.                         return TRUE;
  183.                     } else {
  184.                         show_error($this->_ci->email->print_debugger());
  185.                         return FALSE;
  186.                     }
  187.                    
  188.                 }else{
  189.                     return FALSE;
  190.                 }          
  191.             }  
  192.     }
  193.    
  194.     public function updatecurr() {
  195.         $this->_ci->load->helper('form');
  196.         $idprovnasc = $this->_ci->input->post('cpnascita');
  197.         $idprovres = $this->_ci->input->post('cpresidenza');
  198.         $idprovdom = $this->_ci->input->post('cpdomicilio');
  199.             if ($this->_ci->input->post('ccinglese') != 0){//$_SESSION['ccinglese'] != 0){
  200.                 $corsoinglese = 0;
  201.             }else{
  202.                 $corsoinglese = 1;
  203.             }
  204.             if ($this->_ci->input->post('ccfrancese') != 0){
  205.                 $corsofrancese = 0;
  206.             }else{
  207.                 $corsofrancese = 1;
  208.             }
  209.             if ($this->_ci->input->post('ccspagnolo') != 0){
  210.                 $corsospagnolo = 0;
  211.             }else{
  212.                 $corsospagnolo = 1;
  213.             }
  214.             if ($this->_ci->input->post('cctedesco') != 0){
  215.                 $corsotedesco = 0;
  216.             }else{
  217.                 $corsotedesco = 1;
  218.             }
  219.             if (!isset($_SESSION['currfile'])){
  220.                 $curr = $this->_ci->input->post('currfile');
  221.             }else{
  222.                 $curr = $_SESSION['currfile'];
  223.             }
  224.             if (!isset($_SESSION['pic1'])){
  225.                 $pic1 = $this->_ci->input->post('pic1');
  226.             }else{
  227.                 $pic1 = $_SESSION['pic1'];
  228.             }
  229.            
  230.             if (!isset($_SESSION['pic2'])){
  231.                 $pic2 = $this->_ci->input->post('pic2');
  232.             }else{
  233.                 $pic2 = $_SESSION['pic2'];
  234.             }
  235.             if (!isset($_SESSION['pic3'])){
  236.                 $pic3 = $this->_ci->input->post('pic3');
  237.             }else{
  238.                 $pic3 = $_SESSION['pic3'];
  239.             }
  240.             //echo 'foto3: >'.$pic3.'<';
  241.             $data = array(
  242.                 'nome'=>$this->_ci->input->post('cnome'),
  243.                 'cognome'=>$this->_ci->input->post('ccognome'),
  244.                 'sesso'=>$this->_ci->input->post('csesso'),
  245.                 'datanascita'=>date("Y-m-d", strtotime($this->_ci->input->post('cdnascita'))),
  246.                 'luogonascita'=>$this->_ci->input->post('ccnascita'),
  247.                 'provincianascita'=>$idprovnasc,
  248.                 'statonascita'=>$this->_ci->input->post('csnascita'),
  249.                 'indirizzoresidenza'=>$this->_ci->input->post('ciresidenza'),
  250.                 'capresidenza'=>$this->_ci->input->post('ccapresidenza'),
  251.                 'cittaresidenza'=>$this->_ci->input->post('ccresidenza'),
  252.                 'provinciaresidenza'=>$idprovres,
  253.                 'statoresidenza'=>$this->_ci->input->post('csresidenza'),
  254.                 'indirizzodomicilio'=>$this->_ci->input->post('cidomicilio'),
  255.                 'capdomicilio'=>$this->_ci->input->post('ccapdomicilio'),
  256.                 'cittadomicilio'=>$this->_ci->input->post('ccdomicilio'),
  257.                 'provinciadomicilio'=> $idprovdom,
  258.                 'statodomicilio'=>$this->_ci->input->post('csdomicilio'),
  259.                 'cittadinanza'=>$this->_ci->input->post('ccittadinanza'),
  260.                 'permessosoggiorno'=>$this->_ci->input->post('psoggiorno'),
  261.                 'codicefiscale'=>$this->_ci->input->post('ccodfis'),
  262.                 'partitaiva'=>$this->_ci->input->post('cpiva'),
  263.                 'telefono'=>$this->_ci->input->post('ctel'),
  264.                 'telefono2'=>' ',
  265.                 'cellulare'=>$this->_ci->input->post('ccel'),
  266.                 'cellulare2'=>' ',
  267.                 'email'=>$_SESSION['logged_in']['user'],
  268.                 'email2'=>' ',
  269.                 'patente'=>$this->_ci->input->post('cpatente'),
  270.                 'automunito'=>$this->_ci->input->post('automunito'),
  271.                 'altezza'=>$this->_ci->input->post('caltezza'),
  272.                 'peso'=>$this->_ci->input->post('cpeso'),
  273.                 'tagliamaglia'=>$this->_ci->input->post('cmaglia'),
  274.                 'tagliagonnapantaloni'=>$this->_ci->input->post('cpantalone'),
  275.                 'misurascarpe'=>$this->_ci->input->post('cscarpe'),
  276.                 'certificatoHACCP'=>$this->_ci->input->post('haccpsino'),
  277.                 'titolostudio'=>$this->_ci->input->post('titolo'),
  278.                 'voto'=>$this->_ci->input->post('cvoto'),
  279.                 'master'=>$this->_ci->input->post('mastersino'),
  280.                 'inglese'=>$this->_ci->input->post('cinglese'),
  281.                 'francese'=>$this->_ci->input->post('cfrancese'),
  282.                 'spagnolo'=>$this->_ci->input->post('cspagnolo'),
  283.                 'tedesco'=>$this->_ci->input->post('ctedesco'),
  284.                 'altralingua'=>$this->_ci->input->post('caltra'),
  285.                 'conoscenzaaltralingua'=>$this->_ci->input->post('caltraliv'),
  286.                 'corsoinglese'=>$corsoinglese,
  287.                 'corsofrancese'=>$corsofrancese,
  288.                 'corsospagnolo'=>$corsospagnolo,
  289.                 'corsotedesco'=>$corsotedesco,
  290.                 'livellocorsoinglese'=>$this->_ci->input->post('ccinglese'),
  291.                 'livellocorsofrancese'=>$this->_ci->input->post('ccfrancese'),
  292.                 'livellocorsospagnolo'=>$this->_ci->input->post('ccspagnolo'),
  293.                 'livellocorsotedesco'=>$this->_ci->input->post('cctedesco'),
  294.                 'corsoaltralingua'=>$this->_ci->input->post('ccaltra'),
  295.                 'livellocorsoaltralingua'=>$this->_ci->input->post('ccaltraliv'),
  296.                 'esperienza'=>$this->_ci->input->post('esperienza'),
  297.                 'anniesperienza'=>$this->_ci->input->post('caesperienza'),
  298.                 'addettovendita'=>$this->_ci->input->post('addvendite'),
  299.                 'allestitore'=>$this->_ci->input->post('allestitore'),
  300.                 'hostess'=>$this->_ci->input->post('hostess'),
  301.                 'hostessecm'=>$this->_ci->input->post('hostessecm'),
  302.                 'hostessfiera'=>$this->_ci->input->post('hostessfiera'),
  303.                 'promoter'=>$this->_ci->input->post('promoter'),
  304.                 'steward'=>$this->_ci->input->post('steward'),
  305.                 'modello'=>$this->_ci->input->post('modello'),
  306.                 'merchandiser'=>$this->_ci->input->post('merchandiser'),
  307.                 'musicista'=>$this->_ci->input->post('cmusicista'),
  308.                 'altrafigura'=>$this->_ci->input->post('espaltro'),
  309.                 'agenzialavorato'=>$this->_ci->input->post('cespprec'),
  310.                 'foto1'=>$pic1,
  311.                 'curriculum'=>$curr,
  312.                 'foto2'=>$pic2,
  313.                 'foto3'=>$pic3,
  314.                 'progressivo'=>$this->_ci->input->post('prog'),
  315.                 'codice'=>' ',
  316.                 'noteinterne'=>$this->_ci->input->post('note')
  317.                 );
  318.             $query = $this->_ci->db->update('curriculum', $data, array('id' => $_SESSION['logged_in']['idcurr']));
  319.             if ($this->_ci->db->affected_rows() > 0) {
  320.                 return TRUE;
  321.             }else{
  322.                 $errore = $this->_ci->db->error();
  323.                 echo 'query: '.$this->_ci->db->last_query();
  324.                 echo 'codice: '.$errore['code'].'<br>';
  325.                 echo 'messaggio: '.$errore['message'];
  326.                 //print_r($this->_ci->db->error());
  327.                 //echo 'Codice: '.$this->_ci->db->_error_number();
  328.                 //echo 'Errore: '.$this->_ci->db->_error_message();
  329.                 return FALSE;
  330.             }          
  331.     }
  332.    
  333.  
  334.     public function createObjectFromData($row) {
  335.         $provincia = new Prov_Model();
  336.         $provincia->setId($row->id);
  337.         $provincia->setIdregione($row->idregione);
  338.         $provincia->setProvincia($row->provincia);
  339.         $provincia->setSigla($row->sigla);
  340.         $provincia->setRegione($row->regione);
  341.        
  342.         return $provincia;
  343.     }
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement