Fix filelist_and_upload
This commit is contained in:
parent
e698c479f7
commit
dc3f035d26
18
actions.php
18
actions.php
|
@ -39,13 +39,12 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
|||
else {
|
||||
// UPLOAD
|
||||
if (filter('op') == 'link_file' && !empty($_FILES) && !empty($_FILES['blob']['name'])) {
|
||||
|
||||
$nome = filter('nome_allegato');
|
||||
$nome = !empty($nome) ? $nome : $_FILES['blob']['name'];
|
||||
|
||||
|
||||
$src = $_FILES['blob']['tmp_name'];
|
||||
$f = pathinfo($_FILES['blob']['name']);
|
||||
|
||||
|
||||
/*
|
||||
$allowed = [
|
||||
// Image formats
|
||||
|
@ -166,25 +165,18 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
|||
do {
|
||||
$filename = random_string().'.'.$f['extension'];
|
||||
} while (file_exists($upload_dir.'/'.$filename));
|
||||
|
||||
|
||||
|
||||
// Creazione file fisico
|
||||
if (move_uploaded_file($src, $upload_dir.'/'.$filename)) {
|
||||
|
||||
$dbo->insert('zz_files', [
|
||||
$dbo->insert('zz_files', [
|
||||
'nome' => $nome,
|
||||
'filename' => $filename,
|
||||
'original' => $_FILES['blob']['name'],
|
||||
'id_module' => $id_module,
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => $id_plugin,
|
||||
'id_plugin' => !empty($id_plugin) ? $id_plugin : null,
|
||||
]);
|
||||
|
||||
/*$dbo->query('INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')');
|
||||
|
||||
echo 'INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')';
|
||||
exit;*/
|
||||
|
||||
$_SESSION['infos'][] = tr('File caricato correttamente!');
|
||||
} else {
|
||||
$_SESSION['errors'][] = tr('Errore durante il caricamento del file!');
|
||||
|
|
|
@ -9,26 +9,24 @@ namespace HTMLBuilder\Manager;
|
|||
*/
|
||||
class FileManager implements ManagerInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Gestione "filelist_and_upload".
|
||||
/**
|
||||
* Gestione "filelist_and_upload".
|
||||
* Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false", "ajax": "true" )}.
|
||||
*
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
||||
public function manage($options)
|
||||
{
|
||||
$options['readonly'] = ($options['readonly']=='true') ? true : false;
|
||||
$options['readonly'] = ($options['readonly'] == 'true') ? true : false;
|
||||
$options['ajax'] = isset($options['ajax']) ? $options['ajax'] : false;
|
||||
$options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true;
|
||||
$options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true;
|
||||
$options['label'] = isset($options['label']) ? $options['label'] : tr('Nuovo allegato').':';
|
||||
|
||||
$dbo = \Database::getConnection();
|
||||
|
||||
$result .= '
|
||||
$result .= '
|
||||
<div id="attachments_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'" >
|
||||
<a name="attachments_'.rand().'"></a>';
|
||||
|
||||
|
@ -42,10 +40,13 @@ $result .= '
|
|||
}
|
||||
|
||||
// Visualizzo l'elenco di file già caricati
|
||||
if (!empty($options['id_plugin']))
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record='.prepare($options['id_record']).' AND id_plugin='.prepare($options['id_plugin']));
|
||||
else
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record='.prepare($options['id_record']).' AND id_plugin = 0');
|
||||
$query = 'SELECT * FROM zz_files WHERE id_module='.prepare($options['id_module']).' AND id_record = '.prepare($options['id_record']).' AND id_plugin ';
|
||||
if (!empty($options['id_plugin'])) {
|
||||
$query .= ' = '.prepare($options['id_plugin']);
|
||||
} else {
|
||||
$query .= 'IS NULL';
|
||||
}
|
||||
$rs = $dbo->fetchArray($query);
|
||||
|
||||
if (!empty($rs)) {
|
||||
$result .= '
|
||||
|
@ -66,37 +67,41 @@ $result .= '
|
|||
</td>
|
||||
<td>'.\Translator::timestampToLocale($r['created_at']).'</td>
|
||||
<td class="text-center">
|
||||
|
||||
|
||||
<a class="btn btn-sm btn-primary" href="'.ROOTDIR.'/actions.php?id_module='.$options['id_module'].'&op=download_file&id='.$r['id'].'&filename='.$r['filename'].'" target="_blank">
|
||||
<i class="fa fa-download"></i>
|
||||
</a>';
|
||||
|
||||
|
||||
//Anteprime supportate dal browser
|
||||
// <iframe src=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."\" allowfullscreen=\"\" webkitallowfullscreen=\"\" frameborder=\"0\" width=\"100%\" height=\"550\"></iframe>
|
||||
$extension = end((explode('.', $r['nome'])));
|
||||
$supported_extensions = ['pdf','jpg','png','gif','jpeg','bmp'];
|
||||
if ( in_array($extension, $supported_extensions)){
|
||||
$result .= "
|
||||
<div class='hide' id='view-".$r['id']."' >
|
||||
<object data=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."#view=fitH&scrollbar=0&toolbar=0&navpanes=0\" type=\"application/".$extension."\" allowfullscreen=\"\" webkitallowfullscreen=\"\" width=\"100%\" height=\"550\">
|
||||
alt : <a href=\"".ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename']."\">".$r['filename']."</a>
|
||||
<span>plugin ".$extension." mancante.</span>
|
||||
</object>
|
||||
</div>
|
||||
<button class=\"btn btn-sm btn-info\" data-target=\"#bs-popup\" type=\"button\" data-title=\"".htmlentities($r['nome'], ENT_QUOTES, "UTF-8")." <small><em>(".$r['filename'].")</em></small>\" data-href=\"#view-".$r['id']."\" ><i class='fa fa-eye'></i></button>";
|
||||
}else{
|
||||
$result .= "<button class=\"btn btn-sm btn-default\" title=\"".tr('Anteprima file non disponibile').".\" onclick=\"alert('".tr('Anteprima file di tipo "'.$extension.'" non supportata.')."');\" ><i class='fa fa-eye'></i></button>\n";
|
||||
}
|
||||
|
||||
if (!$options['readonly']){
|
||||
$result .= '
|
||||
|
||||
// Anteprime supportate dal browser
|
||||
$extension = end((explode('.', $r['original'])));
|
||||
$supported_extensions = ['pdf', 'jpg', 'png', 'gif', 'jpeg', 'bmp'];
|
||||
if (in_array($extension, $supported_extensions)) {
|
||||
$result .= '
|
||||
<div class="hide" id="view-'.$r['id'].'">
|
||||
<object data="'.ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename'].'#view=fitH&scrollbar=0&toolbar=0&navpanes=0" type="application/'.$extension.'" allowfullscreen="" webkitallowfullscreen="" width="100%" height="550">
|
||||
alt : <a href="'.ROOTDIR.'/files/'.\Modules::get($options['id_module'])['directory'].'/'.$r['filename'].'">'.$r['filename'].'</a>
|
||||
<span>plugin '.$extension.' mancante.</span>
|
||||
</object>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-sm btn-info" data-target="#bs-popup" type="button" data-title="'.htmlentities($r['nome'], ENT_QUOTES, 'UTF-8').' <small><em>('.$r['filename'].')</em></small>" data-href="#view-'.$r['id'].'" >
|
||||
<i class="fa fa-eye"></i>
|
||||
</button>';
|
||||
} else {
|
||||
$result .= '
|
||||
<button class="btn btn-sm btn-default" title="'.tr('Anteprima file non disponibile').'." onclick="alert(\''.tr('Anteprima file di tipo "'.$extension.'" non supportata.').'\');" >
|
||||
<i class="fa fa-eye"></i>
|
||||
</button>';
|
||||
}
|
||||
|
||||
if (!$options['readonly']) {
|
||||
$result .= '
|
||||
<a class="btn btn-sm btn-danger ask" data-backto="record-edit" data-msg="'.tr('Vuoi eliminare questo file?').'" data-op="unlink_file" data-id="'.$r['id'].'" data-filename="'.$r['filename'].'">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>';
|
||||
}
|
||||
|
||||
$result .= '
|
||||
}
|
||||
|
||||
$result .= '
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
@ -105,25 +110,23 @@ $result .= '
|
|||
</table>
|
||||
<div class="clearfix"></div>
|
||||
<br>';
|
||||
}else{
|
||||
//in caso di readonly, se non è stato caricato nessun allegato mostro almeno box informativo
|
||||
if ($options['readonly']){
|
||||
$result .= '
|
||||
} else {
|
||||
// In caso di readonly, se non è stato caricato nessun allegato mostro almeno box informativo
|
||||
if ($options['readonly']) {
|
||||
$result .= '
|
||||
<div class="alert alert-info" style="margin-bottom:0px;" >
|
||||
<i class="fa fa-info-circle"></i>
|
||||
'.tr('Nessun allegato è stato caricato', []).'.
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$options['readonly']){
|
||||
|
||||
// Form per l'upload di un nuovo file
|
||||
$result .= '
|
||||
if (!$options['readonly']) {
|
||||
// Form per l'upload di un nuovo file
|
||||
$result .= '
|
||||
<b>'.$options['label'].'</b>
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-lg-4">
|
||||
{[ "type": "text", "placeholder": "'.tr('Nome').'", "name": "nome_allegato", "id": "nome_allegato_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'" ]}
|
||||
</div>
|
||||
|
@ -131,17 +134,17 @@ $result .= '
|
|||
<div class="col-lg-6">
|
||||
{[ "type": "file", "placeholder": "'.tr('File').'", "name": "blob", "id": "blob_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'", "required": 0 ]}
|
||||
</div>';
|
||||
|
||||
$result .= '
|
||||
|
||||
$result .= '
|
||||
<div class="col-lg-2 text-right">
|
||||
<button type="button" class="btn btn-success" onclick="saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').' ( $(this) );">
|
||||
<i class="fa fa-upload"></i> '.tr('Carica').'
|
||||
</button>
|
||||
</div>';
|
||||
|
||||
$result .= '
|
||||
|
||||
$result .= '
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
$result .= '
|
||||
<script>
|
||||
|
@ -161,7 +164,7 @@ $result .= '
|
|||
form_data.append("id_plugin","'.$options['id_plugin'].'");
|
||||
|
||||
prev_html = btn.html();
|
||||
btn.html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>'.tr("Attendere...").'");
|
||||
btn.html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>'.tr('Attendere...').'");
|
||||
btn.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
|
@ -173,17 +176,17 @@ $result .= '
|
|||
dataType : "html",
|
||||
data: form_data,
|
||||
success: function(data) {
|
||||
|
||||
|
||||
btn.html(prev_html);
|
||||
btn.prop("disabled", false);';
|
||||
|
||||
if (($options['ajax'])) {
|
||||
$result .= '$("#attachments_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").load( globals.rootdir + "/ajax.php?op=list_attachments&id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '&id_plugin='.$options['id_plugin'].'#tab_'.$options['id_plugin'] : '').'" );';
|
||||
}else{
|
||||
$result .= 'location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";';
|
||||
}
|
||||
|
||||
$result .= '},
|
||||
|
||||
if (($options['ajax'])) {
|
||||
$result .= '$("#attachments_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").load( globals.rootdir + "/ajax.php?op=list_attachments&id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '&id_plugin='.$options['id_plugin'].'#tab_'.$options['id_plugin'] : '').'" );';
|
||||
} else {
|
||||
$result .= 'location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";';
|
||||
}
|
||||
|
||||
$result .= '},
|
||||
error: function(data) {
|
||||
alert(data);
|
||||
}
|
||||
|
@ -200,4 +203,4 @@ $result .= '
|
|||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,80 +4,64 @@ include_once __DIR__.'/../../core.php';
|
|||
|
||||
$height = '80';
|
||||
|
||||
if (isset($_SESSION['period']['month'])) {
|
||||
$period = explode(' ', $_SESSION['period']['month']);
|
||||
$month = $period[0];
|
||||
$year = $period[1];
|
||||
|
||||
if (isset( $_SESSION['period']['month'] )){
|
||||
|
||||
$period = explode(" ", $_SESSION['period']['month']);
|
||||
$month = $period[0];
|
||||
$year = $period[1];
|
||||
$months = ['Gennaio' => '01', 'Febbraio' => '02', 'Marzo' => '03', 'Aprile' => '04', 'Maggio' => '05', 'Giugno' => '06', 'Luglio' => '07', 'Agosto' => '08', 'Settembre' => '09', 'Ottobre' => '10', 'Novembre' => '11', 'Dicembre' => '12'];
|
||||
$month = $months[$month];
|
||||
|
||||
$months = array( 'Gennaio' => '01', 'Febbraio' => '02', 'Marzo' => '03','Aprile' => '04','Maggio' => '05','Giugno' => '06','Luglio' => '07','Agosto' => '08','Settembre' => '09','Ottobre' => '10','Novembre' => '11','Dicembre' => '12');
|
||||
$month = $months[$month];
|
||||
|
||||
$title = $_SESSION['period']['month'];
|
||||
|
||||
|
||||
//numero di giorni nel mese
|
||||
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year)+1;
|
||||
$title = $_SESSION['period']['month'];
|
||||
|
||||
$mindate = $year.'-'.$month.'-'.'01';
|
||||
$maxdate = $year.'-'.$month.'-'.$maxday;
|
||||
//numero di giorni nel mese
|
||||
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1;
|
||||
|
||||
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
|
||||
|
||||
$mindate = $year.'-'.$month.'-'.'01';
|
||||
$maxdate = $year.'-'.$month.'-'.$maxday;
|
||||
|
||||
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
|
||||
}
|
||||
|
||||
if (isset( $_SESSION['period']['week'] )){
|
||||
|
||||
$period = explode(" ", $_SESSION['period']['week']);
|
||||
|
||||
$day = $period[0];
|
||||
|
||||
if (count($period) == 5){
|
||||
|
||||
$maxmonth = $period[3];
|
||||
$maxday_ = $period[2];
|
||||
|
||||
$month = $period[3];
|
||||
$year = $period[4];
|
||||
|
||||
}
|
||||
|
||||
if (count($period) == 6){
|
||||
|
||||
$maxmonth = $period[1];
|
||||
$maxday_ = $period[3];
|
||||
|
||||
$month = $period[4];
|
||||
$year = $period[5];
|
||||
|
||||
|
||||
}
|
||||
if (isset($_SESSION['period']['week'])) {
|
||||
$period = explode(' ', $_SESSION['period']['week']);
|
||||
|
||||
$months = array( 'gen' => '01', 'feb' => '02', 'mar' => '03','apr' => '04','mag' => '05','giu' => '06','lug' => '07','ago' => '08','set' => '09','ott' => '10','nov' => '11','dic' => '12');
|
||||
$month = $months[$month];
|
||||
$maxmonth = $months[$maxmonth];
|
||||
|
||||
$title = $_SESSION['period']['week'];
|
||||
|
||||
|
||||
//numero di giorni nel mese
|
||||
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year)+1;
|
||||
$day = $period[0];
|
||||
|
||||
$mindate = $year.'-'.$month.'-'.$day;
|
||||
$maxdate = $year.'-'.$maxmonth.'-'.$maxday_;
|
||||
|
||||
|
||||
//aggiungo un giorno
|
||||
$maxdate = date('Y-m-d',date(strtotime("+1 day", strtotime($maxdate))));
|
||||
|
||||
if (count($period) == 5) {
|
||||
$maxmonth = $period[3];
|
||||
$maxday_ = $period[2];
|
||||
|
||||
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
|
||||
$month = $period[3];
|
||||
$year = $period[4];
|
||||
}
|
||||
|
||||
if (count($period) == 6) {
|
||||
$maxmonth = $period[1];
|
||||
$maxday_ = $period[3];
|
||||
|
||||
$month = $period[4];
|
||||
$year = $period[5];
|
||||
}
|
||||
|
||||
$months = ['gen' => '01', 'feb' => '02', 'mar' => '03', 'apr' => '04', 'mag' => '05', 'giu' => '06', 'lug' => '07', 'ago' => '08', 'set' => '09', 'ott' => '10', 'nov' => '11', 'dic' => '12'];
|
||||
$month = $months[$month];
|
||||
$maxmonth = $months[$maxmonth];
|
||||
|
||||
$title = $_SESSION['period']['week'];
|
||||
|
||||
//numero di giorni nel mese
|
||||
$maxday = cal_days_in_month(CAL_GREGORIAN, $month, $year) + 1;
|
||||
|
||||
$mindate = $year.'-'.$month.'-'.$day;
|
||||
$maxdate = $year.'-'.$maxmonth.'-'.$maxday_;
|
||||
|
||||
//aggiungo un giorno
|
||||
$maxdate = date('Y-m-d', date(strtotime('+1 day', strtotime($maxdate))));
|
||||
|
||||
$where = ' (in_interventi_tecnici.orario_inizio) <= '.prepare($maxdate).' AND (in_interventi_tecnici.orario_inizio) >= '.prepare($mindate).' AND ';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$report_name = sanitizeFilename('dashboard_'.$year.'_'.$month.'.pdf');
|
||||
|
||||
//$date_start = $_SESSION['period_start'];
|
||||
|
@ -86,216 +70,155 @@ $stati = (array) $_SESSION['dashboard']['idstatiintervento'];
|
|||
$tipi = (array) $_SESSION['dashboard']['idtipiintervento'];
|
||||
$tecnici = (array) $_SESSION['dashboard']['idtecnici'];
|
||||
|
||||
|
||||
|
||||
|
||||
//in_interventi_tecnici.idintervento, colore, in_interventi_tecnici.id, idtecnico, orario_inizio, orario_fine,(SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS nome_tecnico, (SELECT colore FROM an_anagrafiche WHERE idanagrafica=idtecnico) AS colore_tecnico,
|
||||
$query = 'SELECT DAY(in_interventi_tecnici.orario_inizio) AS giorno, orario_inizio AS data, GROUP_CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) SEPARATOR \'<br>\') AS cliente FROM in_interventi_tecnici INNER JOIN (in_interventi LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento) ON in_interventi_tecnici.idintervento=in_interventi.id WHERE '.$where.' idtecnico IN('.implode(',', $tecnici).') AND in_interventi.idstatointervento IN('.implode(',', $stati).') AND in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') '.Modules::getAdditionalsQuery('Interventi')." GROUP BY giorno ORDER BY CAST(giorno AS UNSIGNED)";
|
||||
$query = 'SELECT DAY(in_interventi_tecnici.orario_inizio) AS giorno, orario_inizio AS data, GROUP_CONCAT((SELECT ragione_sociale FROM an_anagrafiche WHERE idanagrafica=in_interventi.idanagrafica) SEPARATOR \'<br>\') AS cliente FROM in_interventi_tecnici INNER JOIN (in_interventi LEFT OUTER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento) ON in_interventi_tecnici.idintervento=in_interventi.id WHERE '.$where.' idtecnico IN('.implode(',', $tecnici).') AND in_interventi.idstatointervento IN('.implode(',', $stati).') AND in_interventi_tecnici.idtipointervento IN('.implode(',', $tipi).') '.Modules::getAdditionalsQuery('Interventi').' GROUP BY giorno ORDER BY CAST(giorno AS UNSIGNED)';
|
||||
|
||||
//echo $query;
|
||||
|
||||
|
||||
$sessioni = $dbo->fetchArray($query);
|
||||
|
||||
|
||||
|
||||
|
||||
//echo $query;
|
||||
$rs = array();
|
||||
for ($i=0; $i<33;$i++){
|
||||
|
||||
$rs[$sessioni[$i]['giorno']]['cliente'] = $sessioni[$i]['cliente'];
|
||||
$rs[$sessioni[$i]['giorno']]['data'] = $sessioni[$i]['data'];
|
||||
|
||||
$rs = [];
|
||||
for ($i = 0; $i < 33; ++$i) {
|
||||
$rs[$sessioni[$i]['giorno']]['cliente'] = $sessioni[$i]['cliente'];
|
||||
$rs[$sessioni[$i]['giorno']]['data'] = $sessioni[$i]['data'];
|
||||
}
|
||||
|
||||
function showMonth($month, $year, &$rs, &$height)
|
||||
{
|
||||
$date = mktime(12, 0, 0, $month, 1, $year);
|
||||
$daysInMonth = date('t', $date);
|
||||
// calculate the position of the first day in the calendar (sunday = 1st column, etc)
|
||||
$offset = (date('w', $date) - 1) % 7;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function showMonth($month, $year, &$rs, &$height){
|
||||
|
||||
$date = mktime(12, 0, 0, $month, 1, $year);
|
||||
$daysInMonth = date("t", $date);
|
||||
// calculate the position of the first day in the calendar (sunday = 1st column, etc)
|
||||
$offset = (date("w", $date)-1)%7;
|
||||
|
||||
if ($offset<0){
|
||||
$offset = 7+$offset;
|
||||
}
|
||||
|
||||
|
||||
//echo $date."<br>";
|
||||
//echo date("w", $date)."<br>";
|
||||
//echo $offset;
|
||||
|
||||
$rows = 1;
|
||||
|
||||
//echo "<h1>Displaying calendar for " . date("F Y", $date) . "</h1>\n";
|
||||
$header = array();
|
||||
$row = array();
|
||||
|
||||
|
||||
//$table .= "<table border=\"1\">\n";
|
||||
//echo "\t<tr><th>Su</th><th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th></tr>";
|
||||
// $table .= "\t<tr><th>Lun</th><th>Mar</th><th>Mer</th><th>Gio</th><th>Ven</th><th>Sab</th><th>Dom</th></tr>";
|
||||
|
||||
|
||||
|
||||
//$header[$rows] = "\n\t<tr>";
|
||||
//$row[$rows] = "\n\t<tr>";
|
||||
|
||||
//giorni prima
|
||||
for($i = 1; $i <= $offset; $i++){
|
||||
|
||||
|
||||
|
||||
$current_month = $month;
|
||||
if($current_month==1){
|
||||
|
||||
$current_month = 12;
|
||||
$current_year = $year-1;
|
||||
}else{
|
||||
|
||||
$current_month = $month-1;
|
||||
$current_year = $year;
|
||||
if ($offset < 0) {
|
||||
$offset = 7 + $offset;
|
||||
}
|
||||
|
||||
$lastdateofmonth=date('t',$current_month);
|
||||
|
||||
//$lastdate = $lastdateofmonth."/".$current_month."/".$current_year;
|
||||
|
||||
|
||||
$day = (($lastdateofmonth-$offset)+($i));
|
||||
$weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf("%02d", $day))));
|
||||
$weekdays = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
$header[$rows] .= "<th>".tr($weekday.' '.(sprintf("%02d", $day)).'/'.(sprintf("%02d", $current_month)), [], ['upper' => true])."</th>\n";
|
||||
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b></td>\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//giorni del mese
|
||||
for($day = 1; $day <= $daysInMonth; $day++){
|
||||
|
||||
|
||||
if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
|
||||
|
||||
// $table .= "\t<tr><th>Lun ".$day."</th><th>Mar ".($day+1)."</th><th>Mer ".($day+2)."</th><th>Gio ".($day+3)."</th><th>Ven ".($day+4)."</th><th>Sab ".($day+5)."</th><th>Dom ".($day+6)."</th></tr>";
|
||||
//echo $date."<br>";
|
||||
//echo date("w", $date)."<br>";
|
||||
//echo $offset;
|
||||
|
||||
// $header[$rows] .= "</tr>\n\t<tr>";
|
||||
//$row[$rows] .= "</tr>\n\t<tr>";
|
||||
|
||||
$rows++;
|
||||
|
||||
$rows = 1;
|
||||
|
||||
//echo "<h1>Displaying calendar for " . date("F Y", $date) . "</h1>\n";
|
||||
$header = [];
|
||||
$row = [];
|
||||
|
||||
//$table .= "<table border=\"1\">\n";
|
||||
//echo "\t<tr><th>Su</th><th>M</th><th>Tu</th><th>W</th><th>Th</th><th>F</th><th>Sa</th></tr>";
|
||||
// $table .= "\t<tr><th>Lun</th><th>Mar</th><th>Mer</th><th>Gio</th><th>Ven</th><th>Sab</th><th>Dom</th></tr>";
|
||||
|
||||
//$header[$rows] = "\n\t<tr>";
|
||||
//$row[$rows] = "\n\t<tr>";
|
||||
|
||||
//giorni prima
|
||||
for ($i = 1; $i <= $offset; ++$i) {
|
||||
$current_month = $month;
|
||||
if ($current_month == 1) {
|
||||
$current_month = 12;
|
||||
$current_year = $year - 1;
|
||||
} else {
|
||||
$current_month = $month - 1;
|
||||
$current_year = $year;
|
||||
}
|
||||
|
||||
$lastdateofmonth = date('t', $current_month);
|
||||
|
||||
//$lastdate = $lastdateofmonth."/".$current_month."/".$current_year;
|
||||
|
||||
$day = (($lastdateofmonth - $offset) + ($i));
|
||||
$weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf('%02d', $day))));
|
||||
$weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica'];
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
$header[$rows] .= '<th>'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])."</th>\n";
|
||||
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b></td>\n";
|
||||
}
|
||||
|
||||
|
||||
$weekday = date('l', strtotime($year.'-'.$month.'-'.(sprintf("%02d", $day))));
|
||||
$weekdays = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
$header[$rows] .= "<th>" . tr($weekday.' '.(sprintf("%02d", $day)).'/'.$month, [], ['upper' => true]) ."</th>\n";
|
||||
if (empty($rs[$day]['cliente'])){
|
||||
$rs[$day]['cliente'] = ' ';
|
||||
}
|
||||
|
||||
|
||||
$row[$rows] .= "<td style='height:".$height."px' >". "<b>".$rs[$day]['cliente']."</b></td>\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//$i = 1;
|
||||
//giorni dopo
|
||||
//while( ($day + $offset) <= $rows * 7){
|
||||
|
||||
for($i = 1; ($day + $offset) <= ($rows * 7); $i++){
|
||||
|
||||
$current_month = $month;
|
||||
if($current_month==12){
|
||||
//giorni del mese
|
||||
for ($day = 1; $day <= $daysInMonth; ++$day) {
|
||||
if (($day + $offset - 1) % 7 == 0 && $day != 1) {
|
||||
// $table .= "\t<tr><th>Lun ".$day."</th><th>Mar ".($day+1)."</th><th>Mer ".($day+2)."</th><th>Gio ".($day+3)."</th><th>Ven ".($day+4)."</th><th>Sab ".($day+5)."</th><th>Dom ".($day+6)."</th></tr>";
|
||||
|
||||
$current_month = 1;
|
||||
$current_year = $year+1;
|
||||
}else{
|
||||
// $header[$rows] .= "</tr>\n\t<tr>";
|
||||
//$row[$rows] .= "</tr>\n\t<tr>";
|
||||
|
||||
$current_month = $month+1;
|
||||
$current_year = $year;
|
||||
++$rows;
|
||||
}
|
||||
|
||||
$weekday = date('l', strtotime($year.'-'.$month.'-'.(sprintf('%02d', $day))));
|
||||
$weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica'];
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
$header[$rows] .= '<th>'.tr($weekday.' '.(sprintf('%02d', $day)).'/'.$month, [], ['upper' => true])."</th>\n";
|
||||
if (empty($rs[$day]['cliente'])) {
|
||||
$rs[$day]['cliente'] = ' ';
|
||||
}
|
||||
|
||||
$row[$rows] .= "<td style='height:".$height."px' >".'<b>'.$rs[$day]['cliente']."</b></td>\n";
|
||||
}
|
||||
|
||||
//$lastdateofmonth = date('t',$current_month);
|
||||
|
||||
//$lastdate = $lastdateofmonth."/".$current_month."/".$current_year;
|
||||
|
||||
|
||||
$weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf("%02d", $i))));
|
||||
$weekdays = array( 'Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'','Thursday' => 'Giovedi\'','Friday' => 'Venerdi\'','Saturday' => 'Sabato','Sunday' => 'Domenica');
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
//$i = 1;
|
||||
//giorni dopo
|
||||
//while( ($day + $offset) <= $rows * 7){
|
||||
|
||||
$header[$rows] .= "<th> ".tr($weekday.' '.(sprintf("%02d", $i)).'/'.(sprintf("%02d", $current_month)), [], ['upper' => true])." </th>\n";
|
||||
//$row[$rows] .= "<td> ".($offset+$day)."<br>".($rows * 7)." </td>\n";
|
||||
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b> </td>\n";
|
||||
|
||||
|
||||
$day++;
|
||||
for ($i = 1; ($day + $offset) <= ($rows * 7); ++$i) {
|
||||
$current_month = $month;
|
||||
if ($current_month == 12) {
|
||||
$current_month = 1;
|
||||
$current_year = $year + 1;
|
||||
} else {
|
||||
$current_month = $month + 1;
|
||||
$current_year = $year;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//$header[$rows] .= "</tr>";
|
||||
//$row[$rows] .= "</tr>";
|
||||
|
||||
//print_r($header);
|
||||
//echo "<br>";
|
||||
//print_r($row);
|
||||
|
||||
echo '<table class="table table-bordered">\n';
|
||||
|
||||
//creo righe
|
||||
for ($i=1; $i<=count($row);$i++){
|
||||
|
||||
echo "<tr>\n";
|
||||
echo $header[$i];
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo $row[$i];
|
||||
echo "</tr>\n";
|
||||
}
|
||||
//$lastdateofmonth = date('t',$current_month);
|
||||
|
||||
echo '</table>';
|
||||
|
||||
|
||||
//$table .= "</table>\n";
|
||||
//$lastdate = $lastdateofmonth."/".$current_month."/".$current_year;
|
||||
|
||||
$weekday = date('l', strtotime($current_year.'-'.$current_month.'-'.(sprintf('%02d', $i))));
|
||||
$weekdays = ['Monday' => 'Lunedi\'', 'Tuesday' => 'Martedi\'', 'Wednesday' => 'Mercoledi\'', 'Thursday' => 'Giovedi\'', 'Friday' => 'Venerdi\'', 'Saturday' => 'Sabato', 'Sunday' => 'Domenica'];
|
||||
$weekday = $weekdays[$weekday];
|
||||
|
||||
$header[$rows] .= '<th> '.tr($weekday.' '.(sprintf('%02d', $i)).'/'.(sprintf('%02d', $current_month)), [], ['upper' => true])." </th>\n";
|
||||
//$row[$rows] .= "<td> ".($offset+$day)."<br>".($rows * 7)." </td>\n";
|
||||
$row[$rows] .= "<td style=\"background:lightgray;\" ><b> </b> </td>\n";
|
||||
|
||||
++$day;
|
||||
}
|
||||
|
||||
//$header[$rows] .= "</tr>";
|
||||
//$row[$rows] .= "</tr>";
|
||||
|
||||
//print_r($header);
|
||||
//echo "<br>";
|
||||
//print_r($row);
|
||||
|
||||
echo '<table class="table table-bordered">\n';
|
||||
|
||||
//creo righe
|
||||
for ($i = 1; $i <= count($row); ++$i) {
|
||||
echo "<tr>\n";
|
||||
echo $header[$i];
|
||||
echo "</tr>\n";
|
||||
|
||||
echo "<tr>\n";
|
||||
echo $row[$i];
|
||||
echo "</tr>\n";
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
|
||||
//$table .= "</table>\n";
|
||||
|
||||
|
||||
//echo $table;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Intestazione tabella per righe
|
||||
echo "
|
||||
<h3 class='text-bold'>".tr('Calendario _PERIOD_', [
|
||||
'_PERIOD_' => $title
|
||||
], ['upper' => true])."</h3>";
|
||||
'_PERIOD_' => $title,
|
||||
], ['upper' => true]).'</h3>';
|
||||
|
||||
|
||||
showMonth($month,$year,$rs, $height);
|
||||
showMonth($month, $year, $rs, $height);
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<?php
|
||||
|
||||
$format = (isset( $_SESSION['settings']['format'] )) ? $_SESSION['settings']['format'] : 'A4';
|
||||
$orientation = (isset( $_SESSION['settings']['orientation'] )) ? $_SESSION['settings']['orientation'] : 'L';
|
||||
$format = (isset($_SESSION['settings']['format'])) ? $_SESSION['settings']['format'] : 'A4';
|
||||
$orientation = (isset($_SESSION['settings']['orientation'])) ? $_SESSION['settings']['orientation'] : 'L';
|
||||
|
||||
return [
|
||||
'format' => $format,
|
||||
'orientation' => $orientation,
|
||||
// 'header-height' => 0,
|
||||
'format' => $format,
|
||||
'orientation' => $orientation,
|
||||
// 'header-height' => 0,
|
||||
];
|
||||
|
|
|
@ -212,3 +212,6 @@ UPDATE `or_statiordine` SET `completato` = '1' WHERE `or_statiordine`.`id` IN( 2
|
|||
-- Campi per note aggiuntive in ddt e ordini
|
||||
ALTER TABLE `or_ordini` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`;
|
||||
ALTER TABLE `dt_ddt` ADD `note_aggiuntive` TEXT NOT NULL AFTER `note`;
|
||||
|
||||
-- Fix id_plugin (zz_files)
|
||||
UPDATE `zz_files` SET `id_plugin` = NULL WHERE `id_plugin` = 0;
|
||||
|
|
Loading…
Reference in New Issue