Merge remote-tracking branch 'calcms/master'

* create-events: localization
* create-events.cgi: optionally select series
This commit is contained in:
Milan
2023-03-26 20:53:18 +02:00
9 changed files with 140 additions and 28 deletions

View File

@@ -548,8 +548,9 @@ sub getDatesWithoutEvent ($$) {
return unless defined $options->{till};
my $dbh = db::connect($config);
my $cond = $options->{series_id} ? 'and sd.series_id = ?' : '';
my $query = q{
my $query = qq{
SELECT sd.*
FROM calcms_series_dates sd LEFT JOIN calcms_events e
on (sd.start = e.start)
@@ -557,12 +558,17 @@ sub getDatesWithoutEvent ($$) {
and sd.exclude != 1
and sd.project_id = ?
and sd.studio_id = ?
$cond
and sd.start > ?
and sd.end < ?
order by sd.start
};
my $bind_values = [ $options->{project_id}, $options->{studio_id}, $options->{from}, $options->{till} ];
my $bind_values = [
$options->{project_id}, $options->{studio_id},
$options->{series_id} ? $options->{series_id} : (),
$options->{from}, $options->{till}
];
my $entries = db::get( $dbh, $query, $bind_values );
return $entries;

View File

@@ -27,4 +27,3 @@ AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/plain

View File

@@ -86,6 +86,8 @@ sub show_events {
$params->{events} = $events;
$params->{total} = scalar(@$events);
$params->{action} = 'show';
$params->{loc} =
localization::get( $config, { user => $params->{presets}->{user}, file => 'create-events' } );
template::process( $config, 'print', $params->{template}, $params );
}
@@ -114,6 +116,8 @@ sub create_events {
$params->{events} = $events;
$params->{total} = scalar(@$events);
$params->{action} = 'created';
$params->{loc} =
localization::get( $config, { user => $params->{presets}->{user}, file => 'create-events' } );
template::process( $config, 'print', $params->{template}, $params );
}
@@ -130,6 +134,7 @@ sub getDates {
my $project_id = $params->{project_id};
my $studio_id = $params->{studio_id};
my $series_id = $params->{series_id};
my $from_date = $params->{from_date};
my $till_date = $params->{till_date};
my $duration = $params->{duration};
@@ -154,13 +159,15 @@ sub getDates {
{
project_id => $project_id,
studio_id => $studio_id,
$series_id ? (series_id => $series_id) : (),
from => $from_date,
till => $till_date
till => $till_date,
}
);
my $series = series::get( $config, {
project_id => $project_id,
studio_id => $studio_id
studio_id => $studio_id,
$series_id ? (series_id => $series_id) : ()
});
my %series_by_id = map { $_->{series_id} => $_ } @$series;
for my $date (@$dates) {
@@ -209,7 +216,7 @@ sub check_params {
$checked->{exclude} = 0;
$checked->{duration} = 28;
entry::set_numbers( $checked, $params, [
'id', 'project_id', 'studio_id', 'duration']);
'id', 'project_id', 'studio_id', 'series_id', 'duration']);
$checked->{"duration".$checked->{duration}}='selected="selected"';
if ( defined $checked->{studio_id} ) {

View File

@@ -0,0 +1,11 @@
@charset "UTF-8";
#content td.label {
max-width: none;
}
#content #seriesContainer {
max-width: 80ch;
overflow:clip;
text-overflow: ellipsis;
}

View File

@@ -0,0 +1,18 @@
function selectChangeSeries(resultSelector){
var url='select-series.cgi?' + new URLSearchParams({
project_id : getProjectId(),
studio_id : getStudioId(),
series_id : getUrlParameter('series_id'),
resultElemId: resultSelector,
selectSeries: 1,
}).toString();
updateContainer('seriesContainer', url, function(){
$('#selectSeries').removeClass('panel');
var series_id = $('input[name=series_id]').val();
if (series_id.length) $("option[value='"+series_id+"']").attr('selected','selected');
});
}
$(document).ready(function() {
selectChangeSeries('select_series_id');
});

View File

@@ -0,0 +1,30 @@
msgid "title"
msgstr "Geplante Sendungen anlegen"
msgid "create_till"
msgstr "Zeitraum"
msgid "show_button"
msgstr "Vorschau"
msgid "create_button"
msgstr "Anlegen"
msgid "today"
msgstr "Heute"
msgid "1week"
msgstr "1 Woche"
msgid "2week"
msgstr "2 Wochen"
msgid "3week"
msgstr "3 Wochen"
msgid "4week"
msgstr "4 Wochen"
msgid "8week"
msgstr "8 Wochen"

View File

@@ -0,0 +1,30 @@
msgid "title"
msgstr "Create events from schedule"
msgid "create_till"
msgstr "Create Until"
msgid "show_button"
msgstr "Preview"
msgid "create_button"
msgstr "Create Events"
msgid "today"
msgstr "Today"
msgid "1week"
msgstr "1 week"
msgid "2week"
msgstr "2 weeks"
msgid "3week"
msgstr "3 weeks"
msgid "4week"
msgstr "4 weeks"
msgid "8week"
msgstr "8 weeks"

View File

@@ -39,3 +39,4 @@ msgstr "image"
msgid "label_stream"
msgstr "stream"

View File

@@ -1,32 +1,41 @@
<TMPL_IF .allow.read_event> <script type="text/javascript">
<TMPL_IF .getBack>
$(document).ready(function() {
getBack()
});
</TMPL_IF>
<TMPL_IF .allow.read_event>
<script type="text/javascript">
<TMPL_IF .getBack>
$(document).ready(function() {
getBack()
});
</TMPL_IF>
</script>
<h1>create events from schedule</h1>
<script src="js/create-events.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/create-events.css" type="text/css" />
<script>
var series_id=0;
</script>
<h1><TMPL_VAR loc.title></h1>
<div class="panel">
<form id="create_event_form" method="post">
<input type="hidden" name="project_id"
value="<TMPL_VAR .project_id>"> <input type="hidden"
name="studio_id" value="<TMPL_VAR .studio_id>"> schedule events for
<input type="hidden" name="project_id" value="<TMPL_VAR .project_id>">
<input type="hidden" name="studio_id" value="<TMPL_VAR .studio_id>">
<input type="hidden" id="select_series_id" name="series_id" value="<TMPL_VAR .series_id>">
<TMPL_VAR loc.create_till>
<select name="duration">
<option value="1" <TMPL_VAR duration1>>today</option>
<option value="7" <TMPL_VAR duration7>>1 week</option>
<option value="14" <TMPL_VAR duration14>>2 weeks</option>
<option value="21" <TMPL_VAR duration21>>3 weeks</option>
<option value="28" <TMPL_VAR duration28>>4 weeks</option>
<option value="56" <TMPL_VAR duration56>>8 weeks</option>
<option value="1" <TMPL_VAR duration1>><TMPL_VAR loc.today></option>
<option value="7" <TMPL_VAR duration7>><TMPL_VAR loc.1week></option>
<option value="14" <TMPL_VAR duration14>><TMPL_VAR loc.2week></option>
<option value="21" <TMPL_VAR duration21>><TMPL_VAR loc.3week></option>
<option value="28" <TMPL_VAR duration28>><TMPL_VAR loc.4week></option>
<option value="56" <TMPL_VAR duration56>><TMPL_VAR loc.8week></option>
</select>
<div id="seriesContainer"></div>
<TMPL_IF .allow.read_event>
<button target="_blank" type='submit' name="action" value="show_events">Show schedule</button>
<button target="_blank" type='submit' name="action" value="show_events"><TMPL_VAR loc.show_button></button>
</TMPL_IF>
<TMPL_IF .allow.assign_series_events>
<button target="_blank" type='submit' name="action"
value="create_events">Create events</button>
<button target="_blank" type='submit' name="action" value="create_events"><TMPL_VAR loc.create_button></button>
</TMPL_IF>
</form>
</div>
@@ -45,8 +54,9 @@
</TMPL_LOOP> </view>
</div>
</body>
</html>
</body>
</html>
<TMPL_ELSE> missing permission to read events
<TMPL_ELSE>
missing permission to read events
</TMPL_IF>