function stampaFormaz($SuffissoDB, $numMese, $anno)
 {
     $dbModel = new OpDbModelOpDb();
     $Data = new DataModelData();
     $formazioni = $dbModel->leggiFormaz($SuffissoDB, $numMese, $anno);
     if ($formazioni == NULL) {
         return "Date formazioni non ancora inserite";
     } else {
         $html = '';
         $Sett = $Data->getInfo('GiorniSettimana');
         $giorniMese = $Data->days_in_month($numMese, $anno);
         $t = 0;
         for ($n = 0; $n <= $giorniMese; $n++) {
             if ($formazioni[$n] != '0' && $formazioni[$n] != NULL) {
                 $g = $Sett[date("w", strtotime("{$anno}-{$numMese}-{$n}"))];
                 $html .= "\t\t\t";
                 if ($t % 2 == 0) {
                     $html .= "<span class=\"color\">";
                 }
                 $html .= "<span class=\"giorni\">" . $n . " " . $g . "</span> ";
                 if (strcasecmp($formazioni[$n], "noNote") == '0') {
                     $html .= "\n\t\t\t<br /> \n";
                 } else {
                     $html .= $formazioni[$n] . "\n\t\t\t<br /> \n";
                 }
                 if ($t % 2 == 0) {
                     $html .= "</span>";
                 }
                 $t++;
             }
         }
         return $html;
     }
 }
Ejemplo n.º 2
0
 public function servizi($mese, $anno)
 {
     $model = new TurniServiziModelTurniServizi();
     $modelData = new DataModelData();
     $modelDB = new OpDBModelOpDB();
     $giorni_servizio = $model->getServizi();
     $giorni_settimana = $modelData->getInfo('GiorniSettimana');
     $giorni_del_mese = $modelData->days_in_month($mese, $anno);
     $servizi_nel_mese = array_fill(1, $giorni_del_mese, 0);
     $servizi_nel_mese[0] = '0';
     $UltimiDelMese = array_fill(0, 6, 0);
     //Se uno dei giorni è settato come "Solo ultimo del mese" cerca qual'è l'ultimo
     // di quei giorni nel mese.
     for ($t = 0; $t <= 6; $t++) {
         if ($t < 6) {
             $S = $giorni_settimana[$t + 1];
         } else {
             $S = $giorni_settimana[0];
         }
         if (strcasecmp($giorni_servizio[$t], 'Ultimo' . $S) == '0') {
             for ($n = 1; $n <= $giorni_del_mese; $n++) {
                 $g = $giorni_settimana[date("w", strtotime("{$anno}-{$mese}-{$n}"))];
                 if (strcasecmp($g, $S) == '0') {
                     $UltimiDelMese[$t] = $n;
                 }
             }
         }
     }
     //crea un array in cui inserisce i giorni di servizio
     for ($n = 1; $n <= $giorni_del_mese; $n++) {
         for ($t = 0; $t <= 6; $t++) {
             $g = $giorni_settimana[date("w", strtotime("{$anno}-{$mese}-{$n}"))];
             if (strcasecmp($giorni_servizio[$t], $g) == '0') {
                 $servizi_nel_mese[$n] = $g;
             }
             if (strcasecmp($giorni_servizio[$t], 'Ultimo' . $g) == '0') {
                 if ($n == $UltimiDelMese[$t]) {
                     $servizi_nel_mese[$n] = $g;
                 }
             }
         }
     }
     //controlla se ci sono altri servizi nel DB
     $servizi_in_db = $modelDB->serviziInDb($mese, $anno);
     if ($servizi_in_db != NULL) {
         for ($n = 0; $n <= $giorni_del_mese; $n++) {
             if ($servizi_in_db[$n] != '0') {
                 $servizi_nel_mese[$n] = $servizi_in_db[$n];
             }
         }
     }
     return $servizi_nel_mese;
 }
Ejemplo n.º 3
0
 function serviziInDb($m, $a, $tabella)
 {
     //restituisce i servizi in quel mese già inseriti nel db
     $data = new DataModelData();
     $giorniMese = $data->days_in_month($m, $a);
     $clownInServ = array_fill(1, $giorniMese, 0);
     $servExtra = array_fill(1, $giorniMese, 0);
     //Se il mese (e il giorno) è minore di 9 aggiungi uno zero
     if ($giorno <= 9) {
         $giorno = "0" . $giorno;
     }
     if ($m <= 9) {
         $m = "0" . $m;
     }
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query = "SELECT * FROM `{$tabella}` WHERE  YEAR(Data) = {$a} AND MONTH(Data) = {$m} ORDER BY DAY(Data)";
     $db->setQuery($query);
     $db->query();
     $rows = $db->loadObjectList();
     if ($rows != NULL) {
         foreach ($rows as $row) {
             $tmp = explode('-', $row->Data);
             $giorno = $tmp[2];
             if ($giorno <= 9) {
                 $giorno = substr($giorno, 1);
             }
             $clownInServ[$giorno] = $row->Nomi;
             $servExtra[$giorno] = $row->Altro;
         }
         $tmp[0] = $clownInServ;
         $tmp[1] = $servExtra;
         return $tmp;
     } else {
         return NULL;
     }
 }
Ejemplo n.º 4
0
 function leggiFormazioni($mFrom, $aFrom, $mTo, $aTo)
 {
     $model = new FormazioniModelFormazioni();
     $modelData = new DataModelData();
     $suff_db = $model->getSuffissoDB();
     $tabella = "#__formazioni_" . $suff_db;
     //if($mFrom<=9){$mFrom = "0".$mFrom;}
     //if($mTo<=9){$mTo = "0".$mTo;}
     $gTo = $modelData->days_in_month($mTo, $aTo);
     $giorni_settimana = $modelData->getInfo('GiorniSettimana');
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $query = "SELECT * FROM `{$tabella}` WHERE  DATA >= '{$aFrom}-{$mFrom}-1' AND DATA <= '{$aTo}-{$mTo}-{$gTo}' ORDER BY DATA ";
     $db->setQuery($query);
     $db->query();
     $rows = $db->loadObjectList();
     //array di mesi intercorrenti tra $mFrom e $mTo (1,mese,0,  1,mese,0  ecc..):
     $a_Tmp = $aFrom;
     $m_Tmp = $mFrom;
     $data_fine = "{$mTo}-{$aTo}";
     for ($i = 0; strcasecmp("{$m_Tmp}-{$a_Tmp}", $data_fine) != '0'; $i++) {
         $array_formazioni[$i] = 1;
         $i++;
         $array_formazioni[$i] = $modelData->meseFromNumToText($m_Tmp);
         $array_formazioni[$i] .= " {$a_Tmp}";
         $i++;
         $array_formazioni[$i] = 0;
         $m_Tmp++;
         if ($m_Tmp == 13) {
             $m_Tmp = 1;
             $a_Tmp++;
         }
         // mese restante - da fare prima che si chiuda il ciclo for
         if (strcasecmp("{$m_Tmp}-{$a_Tmp}", $data_fine) == '0') {
             $i++;
             $array_formazioni[$i] = 1;
             $i++;
             $array_formazioni[$i] = $modelData->meseFromNumToText($m_Tmp);
             $array_formazioni[$i] .= " {$a_Tmp}";
             $i++;
             $array_formazioni[$i] = 0;
         }
     }
     if ($rows == NULL) {
         //NESSUNA FORMAZIONE TROVATA,
         $formazioni[0] = $array_formazioni;
         $formazioni[1] = $array_formazioni;
         $formazioni[2] = $array_formazioni;
         return $formazioni;
     } else {
         $i = 0;
         foreach ($rows as $row) {
             $date_formazioni_db[$i] = $row->Data;
             $note_formazioni_db[$i] = $row->Note;
             $presenze_formazioni_db[$i] = $row->Presenze;
             $i++;
         }
         $m = 0;
         $t = 0;
         for ($n = 0; $n < count($array_formazioni); $n++) {
             $date_formazioni[$t] = $array_formazioni[$n];
             $note_formazioni[$t] = $array_formazioni[$n];
             $presenze_formazioni[$t] = $array_formazioni[$n];
             $t++;
             if (isset($date_formazioni_db[$m])) {
                 $data = explode('-', $date_formazioni_db[$m]);
                 $mese = $data[1];
                 $mese = $modelData->meseFromNumToText($mese);
                 $anno = $data[0];
                 while (strcasecmp("{$mese} {$anno}", $array_formazioni[$n]) == 0) {
                     $date_formazioni[$t] = $date_formazioni_db[$m];
                     $note_formazioni[$t] = $note_formazioni_db[$m];
                     $presenze_formazioni[$t] = $presenze_formazioni_db[$m];
                     $m++;
                     $data = explode('-', $date_formazioni_db[$m]);
                     $mese = $data[1];
                     $mese = $modelData->meseFromNumToText($mese);
                     $anno = $data[0];
                     $t++;
                 }
             }
         }
         //formatta le date per le select:
         $index = 0;
         for ($i = 0; $i < count($date_formazioni); $i++) {
             if ($date_formazioni[$i] != '0' && $date_formazioni[$i] != '1' && $date_formazioni[$i - 1] != '1') {
                 $data = explode('-', $date_formazioni[$i]);
                 if ($data[2] <= 9) {
                     $data[2] = substr($data[2], 1);
                 }
                 if ($data[1] <= 9) {
                     $data[1] = substr($data[1], 1);
                 }
                 $date_formazioni_formattate[$index] = $data[2] . " " . $modelData->meseFromNumToText($data[1]);
                 $index++;
             }
         }
         $formazioni[0] = $date_formazioni;
         $formazioni[1] = $note_formazioni;
         $formazioni[2] = $presenze_formazioni;
         $formazioni[3] = $date_formazioni_formattate;
         return $formazioni;
     }
 }
Ejemplo n.º 5
0
 function stampaDateMese($m, $a, $serviziNelMese, $SuffissoDB)
 {
     //funzione principale che ritorna l'html da stampare
     require_once JPATH_COMPONENT . DS . 'models' . DS . 'opdb.php';
     $dbModel = new OpDbModelOpDb();
     $Data = new DataModelData();
     $tabella = '#__servizi_' . $SuffissoDB;
     $tmp = $dbModel->serviziInDb($m, $a, $tabella);
     $servExtra = $tmp[1];
     $GiorniMese = $Data->days_in_month($m, $a);
     $GiorniSettimana = $Data->getInfo('GiorniSettimana');
     $mesi = $Data->getInfo('MesiAnno');
     $mese = $mesi[$m];
     $t = 0;
     for ($n = 1; $n < $GiorniMese; $n++) {
         $data = $a . "-" . $m . "-" . $n;
         if ($servExtra[$n] != NULL && strcasecmp($servExtra[$n], '0') != 0 && strcasecmp($serviziNelMese[$n], '0') == 0) {
             //Servizio "speciale"
             $html[$t] = "<br />" . $GiorniSettimana[date("w", strtotime($data))] . " {$n} {$mese}";
             $t++;
         } else {
             if (strcasecmp($serviziNelMese[$n], '0') != 0) {
                 // Servizio normale
                 $html[$t] = "<br />" . $GiorniSettimana[date("w", strtotime($data))] . " {$n} {$mese}";
                 if ($servExtra[$n] != '0' && $servExtra[$n] != NULL) {
                     $html[$t] .= " ({$servExtra[$n]})";
                 } else {
                     $html[$t] .= "</span>";
                 }
                 $t++;
             }
         }
     }
     return $html;
 }
Ejemplo n.º 6
0
 function aggClown($nome, $giorno, $mese, $anno)
 {
     //aggiunge il clown nel database
     $modelData = new DataModelData();
     $limit = $modelData->days_in_month($mese, $anno);
     if ($giorno > $limit) {
         return 1;
     }
     $nome = trim($nome);
     //Elimina gli spazi vuoti da inizio e fine
     $nome = str_replace(' ', '_', $nome);
     //Sostituisce gli spazi in mezzo con '_'
     $model = new TurniServiziModelTurniServizi();
     $suff_db = $model->getSuffissoDB();
     $tabella = "#__servizi_" . $suff_db;
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     //Se il mese (e il giorno) è minore di 9 aggiungi uno zero
     if ($giorno <= 9 && strlen($giorno) < 2) {
         $giorno = "0" . $giorno;
     }
     if ($mese <= 9 && strlen($mese) < 2) {
         $mese = "0" . $mese;
     }
     //Verifica se esiste già la tabella con il campo di quel mese e giorno o, se esiste, se è vuota
     $query = "SELECT * FROM `{$tabella}` WHERE  YEAR(Data) = {$anno} AND MONTH(Data)= {$mese} AND DAY(Data) = {$giorno}";
     $db->setQuery($query);
     $db->query();
     $rows = $db->loadObjectList();
     //recupera la mail del clown:
     $elenco = $this->leggiElencoClowns();
     $nomiClown = $elenco['nomiClowns'];
     $mail = $elenco['mail'];
     for ($i = 0; $i < count($nomiClown); $i++) {
         if (strcasecmp($nome, $nomiClown[$i]) == '0') {
             $mail_clown = $mail[$i];
         }
     }
     //Richiama la mail per poter inviare una notifica allo staff e prepara il contenuto
     $mail_staff = $model->getMailStaff();
     $mail_bcc = $model->getMailBcc();
     // Headers, subject e message staff
     $headers_staff .= "From: Gestione Servizi Online - vipsardegna.it <*****@*****.**>\r\n";
     $headers_staff .= "Reply-To: " . $mail_clown . "\r\n";
     $headers_staff .= "Bcc: " . $mail_bcc . "\r\n";
     $subject_staff = "Conferma inserimento clown " . $nome . " in un servizio";
     $message_staff .= "Ciao staff Ospedale!\n\n" . $nome . " e' stato aggiunto/a nel servizio del giorno " . $giorno . " " . $modelData->meseFromNumToText($mese) . ".\n\n";
     $message_staff .= "Un messaggio di notifica e' gia' stato inviato al suo indirizzo " . $mail_clown . " al quale potete scrivere rispondendo a questa mail. \n\n";
     $message_staff .= "Grazie, \nil servizio online di gestione turni automatico di Split.\n\n";
     // Headers, subject e message clown
     $headers_clown .= "From: Gestione Servizi Online - vipsardegna.it <*****@*****.**>\r\n";
     $headers_clown .= "Reply-To: " . $mail_staff . "\r\n";
     $subject_clown = "Clown " . $nome . ", sei stato aggiunto/a in un servizio";
     $message_clown .= "Ciao " . $nome . ", il tuo nome e' stato aggiunto nel servizio del giorno " . $giorno . " " . $modelData->meseFromNumToText($mese) . ".\n\n";
     $message_clown .= "Per comunicare con lo staff ospedale puoi scrivere all'indirizzo " . $mail_staff . " oppure rispondere a quesa mail. \n\n";
     $message_clown .= "Grazie, \nil servizio online di gestione turni automatico di Split.\n\n";
     if ($rows == NULL) {
         $query = 'CREATE TABLE IF NOT EXISTS ' . $tabella . '( `Data` DATE NOT NULL, `Nomi` VARCHAR(250), `Etichetta` VARCHAR(50) )';
         $db->setQuery($query);
         $db->query();
         //inserisce i dati (per la prima volta)
         $query = "INSERT INTO `{$tabella}` (Data, Nomi, Etichetta) VALUES (\"{$anno}-{$mese}-{$giorno}\", \"{$nome}\", NULL )";
         $db->setQuery($query);
         $db->query();
         mail($mail_staff, $subject_staff, $message_staff, $headers_staff);
         //mail allo staff
         mail($mail_clown, $subject_clown, $message_clown, $headers_clown);
         //mail al clown
         return 0;
     } else {
         foreach ($rows as $row) {
             $nomi = $row->Nomi;
             $etichetta = $row->Etichetta;
         }
         $nomi_esplosi = explode(' ', $nomi);
         //se c'è "-" vuol dire che il servizio è vuoto ma etichettato. Inserisci il nome del clown al posto del "-"
         if (strcasecmp($nomi_esplosi[0], '-') == '0') {
             //fa l'update del campo
             $query = "UPDATE {$tabella} SET Nomi='{$nome}' WHERE YEAR(Data) = {$anno} AND MONTH(Data)= {$mese} AND DAY(Data) = {$giorno}";
             $db->setQuery($query);
             $db->query();
             mail($mail_staff, $subject_staff, $message_staff, $headers_staff);
             //mail allo staff
             mail($mail_clown, $subject_clown, $message_clown, $headers_clown);
             //mail al clown
             return 0;
         } else {
             //controlla che il clown non sia già in quel servizio.
             for ($n = 0; $n < count($nomi_esplosi); $n++) {
                 if (strcasecmp($nomi_esplosi[$n], $nome) == '0') {
                     return '1';
                 }
             }
             $nomiNuovo = $nomi . " " . $nome;
             //fa l'update del campo
             $query = "UPDATE {$tabella} SET Nomi='{$nomiNuovo}' WHERE YEAR(Data) = {$anno} AND MONTH(Data)= {$mese} AND DAY(Data) = {$giorno}";
             $db->setQuery($query);
             $db->query();
             mail($mail_staff, $subject_staff, $message_staff, $headers_staff);
             //mail allo staff
             mail($mail_clown, $subject_clown, $message_clown, $headers_clown);
             //mail al clown
             return 0;
         }
     }
 }