diff options
author | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-04-12 23:34:32 +0200 |
---|---|---|
committer | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-04-12 23:34:32 +0200 |
commit | 512511df29423fc943b566bc20d997cd20ee9e03 (patch) | |
tree | f5531d5ed96b965fb8d08ec4df74a61c9b0834b3 /includes/admin/views | |
parent | 58238e7325920be68f3468c81115c8ddcf01c2f4 (diff) | |
download | gigologadmin-512511df29423fc943b566bc20d997cd20ee9e03.tar.gz gigologadmin-512511df29423fc943b566bc20d997cd20ee9e03.tar.bz2 gigologadmin-512511df29423fc943b566bc20d997cd20ee9e03.zip |
Moved a lot of concert related logic from import/admin into the GiglogAdmin_Concert
Diffstat (limited to 'includes/admin/views')
-rw-r--r-- | includes/admin/views/giglog_admin_page.php | 90 | ||||
-rw-r--r-- | includes/admin/views/giglog_import_gigs.php | 24 |
2 files changed, 57 insertions, 57 deletions
diff --git a/includes/admin/views/giglog_admin_page.php b/includes/admin/views/giglog_admin_page.php index 9322c9a..8deba81 100644 --- a/includes/admin/views/giglog_admin_page.php +++ b/includes/admin/views/giglog_admin_page.php @@ -41,8 +41,8 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { <p><?php echo GiglogAdmin_AdminPage::get_filters() ?></p> <p><?php echo GiglogAdmin_AdminPage::get_concerts() ?></p> - </div> - <?php + </div> + <?php if (current_user_can('administrator')) echo(GiglogAdmin_AdminPage::editforms()); //not sure why it doesn't show without the echo? } @@ -84,7 +84,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { $select .= '</select>'; return($select); } - + static function get_filters() { $cities = array_merge(["ALL"], GiglogAdmin_Venue::all_cities()); @@ -133,48 +133,36 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { return $select; } - + static function editforms() { global $wpdb; - $cid = filter_input(INPUT_POST, "cid"); - if(($_POST['edit']=="EDIT")&&!empty($cid)) - { - $query = "SELECT * FROM wpg_concerts where id = ".$cid; - $results = $wpdb->get_results($query); - foreach($results as $row) - { - $band = $row -> band; - $venue = $row-> venue; - $cdate = $row ->wpgconcert_date; - $ticket = $row->wpgconcert_tickets; - $link = $row->wpgconcert_event; - } - - } + $cid = filter_input(INPUT_POST, "cid"); + $c = GiglogAdmin_Concert::find_or_create($cid,'','','','',''); + $content='<form method="POST" action="" class="concedit" > Form to create/edit concerts, bands, venues<br>' - .'<input type="hidden" name="pid" value="' .$cid. '" />' - .'<label for="band">Band:</label>'.GiglogAdmin_AdminPage::get_allbands($band).'<br>' - .'<label for="venue">Venue:</label>'.GiglogAdmin_AdminPage::get_allvenues($venue).'<br>' - .'<label for="cdate">Date:</label><input type="date" id="cdate" name="cdate" value="'.$cdate.'"><br>' - .'<label for="ticket">Tickets:</label><input type="text" id="ticket" name="ticket" value="'.$ticket.'"><br>' - .'<label for="eventurl">Event link:</label><input type="text" id="eventurl" name="eventurl" value="'.$link.'"><br>'; - if ($band=='') //actions differ if we update or create a concert, hence two buttons needed + .'<input type="hidden" name="pid" value="' .$c->id(). '" />' + .'<label for="band">Band:</label>'.GiglogAdmin_AdminPage::get_allbands($c->band()).'<br>' + .'<label for="venue">Venue:</label>'.GiglogAdmin_AdminPage::get_allvenues($c->venue()).'<br>' + .'<label for="cdate">Date:</label><input type="date" id="cdate" name="cdate" value="'.$c->cdate().'"><br>' + .'<label for="ticket">Tickets:</label><input type="text" id="ticket" name="ticket" value="'.$c->tickets().'"><br>' + .'<label for="eventurl">Event link:</label><input type="text" id="eventurl" name="eventurl" value="'.$c->eventlink().'"><br>'; + if ($c->band()=='') //actions differ if we update or create a concert, hence two buttons needed $content.='<p><input type="submit" name="newconcert" value="Create New Concert"></p>'; - else + else $content.='<p><input type="submit" name="editconcert" value="Edit Concert"></p>'; $content.='</form>'; - + $content.='<form method="POST" action="" class="bandedit" ><br>' .'<label for="bandname">Band Name:</label><input type="text" id="bandname" name="bandname"><br>' .'<label for="eventurl">Band Country:</label>'.GiglogAdmin_AdminPage::get_countries().'<br>' .'<p><input type="submit" name="newband" value="Create New Band"></p>' .'</form>'; - + $content.='<form method="POST" action="" class="bandedit" ><br>' .'<label for="bandname">Venue Name:</label><input type="text" id="venuename" name="venuename"><br>' .'<label for="eventurl">Venue City:</label><input type="text" id="venuecity" name="venuecity"><br>' .'<p><input type="submit" name="newvenue" value="Create New Venue"></p>' - .'</form>'; + .'</form>'; return $content; } @@ -302,7 +290,7 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { // return the table return $content; } - + static function update() { @@ -342,49 +330,49 @@ if ( !class_exists( 'GiglogAdmin_AdminPage' ) ) { //$url2=$_SERVER['REQUEST_URI']; //doesn't seem to be needed actually, leaving here just in case //header("Refresh: 1; URL=$url2"); //reload page } - + if(isset($_POST['newconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo '<script language="javascript">alert("You are missing a value, concert was not created"); </script>'; - else - { + else + { GiglogAdmin_Concert::create($_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo '<script language="javascript">alert("Yey, concert created"); </script>'; - } + } } if(isset($_POST['editconcert'])) { IF (empty($_POST['selectband']) || empty($_POST['selectvenueadmin']) || empty($_POST['cdate']) || empty($_POST['ticket']) || empty($_POST['eventurl'])) echo '<script language="javascript">alert("You are missing a value, concert was not updated"); </script>'; - else - { + else + { GiglogAdmin_Concert::updatec($_POST['pid'],$_POST['selectband'], $_POST['selectvenueadmin'], $_POST['cdate'], $_POST['ticket'], $_POST['eventurl']); echo '<script language="javascript">alert("Yey, concert updated"); </script>'; - } - } - + } + } + if(isset($_POST['newband'])) { - IF (empty($_POST['bandname'])) //country is not checked as it is set to Norway by default + IF (empty($_POST['bandname'])) //country is not checked as it is set to Norway by default echo '<script language="javascript">alert("You are missing a value, band was not created"); </script>'; - else - { - GiglogAdmin_Band::create($_POST['bandname'],$_POST['selectcountry']); + else + { + GiglogAdmin_Band::create($_POST['bandname'],$_POST['selectcountry']); echo '<script language="javascript">alert("Yey, band created"); </script>'; - } + } } - + if(isset($_POST['newvenue'])) { IF (empty($_POST['venuename']) || empty($_POST['venuecity'])) echo '<script language="javascript">alert("You are missing a value, venue was not created"); </script>'; - else - { - GiglogAdmin_Venue::create($_POST['venuename'],$_POST['venuecity']); + else + { + GiglogAdmin_Venue::create($_POST['venuename'],$_POST['venuecity']); echo '<script language="javascript">alert("Yey, venue created"); </script>'; - } - } + } + } } static function assignconcert($p1, $c) diff --git a/includes/admin/views/giglog_import_gigs.php b/includes/admin/views/giglog_import_gigs.php index 04b2351..d0520e7 100644 --- a/includes/admin/views/giglog_import_gigs.php +++ b/includes/admin/views/giglog_import_gigs.php @@ -85,7 +85,7 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { if (is_numeric($venue)) $newconcert[1] = $venue; else { - $v = GiglogAdmin_Venue::find_or_create($venue,'Oslo'); + $v = GiglogAdmin_Venue::find_or_create($venue,'Oslo'); //phase 666 of the project should maybe consider both city and band country when creating concerts/importing files $newconcert[1] = $v->id(); } @@ -98,22 +98,34 @@ if ( !class_exists( 'GiglogAdmin_ImportGigsPage' ) ) { . ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1] . ', CONCERTDATE ' . $condate); } else { - $id = GiglogAdmin_Concert::create( + $id = GiglogAdmin_Concert::find_or_create( + '', $newconcert[0], $newconcert[1], $condate, $ticketlink, - $eventlink); - + $eventlink); + error_log( 'NEW CONCERT ADDED: ' - . ' ID: ' . $id + . ' ID: ' . $id->id() . ' BAND ' . $band . ' with band ID ' . $newconcert[0] . ', VENUE ' . $venue . ' with venue ID ' . $newconcert[1] . ', CONCERTDATE ' . $condate . ', Ticket LINK ' . $ticketlink . ', Event LINK ' . $eventlink); - GiglogAdmin_Concertlogs::add($id); + GiglogAdmin_Concertlogs::add($id->id()); + + /*the last line can be replaced by a trigger + CREATE TRIGGER `insertIntoPhotoLogs` AFTER INSERT ON `wpg_concerts` + FOR EACH ROW INSERT INTO wpg_concertlogs ( + wpg_concertlogs.id, + wpg_concertlogs.wpgcl_concertid, + wpg_concertlogs.wpgcl_status) + + VALUES + (null, new.id, 1) + */ } } } |