Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:liip/ushahidi-plugins-mobile

  • Loading branch information...
commit b71009fbdf876da763573f016626beadb9c03a4f 2 parents 3e42166 + 59cf0d8
lejoe authored
Showing with 29 additions and 9 deletions.
  1. +20 −3 controllers/mobile/reports.php
  2. +9 −6 views/mobile/reports_submit.php
View
23 controllers/mobile/reports.php
@@ -132,6 +132,7 @@ public function submit($saved = false)
(
'incident_title' => '',
'incident_description' => '',
+ /*
'incident_month' => '',
'incident_day' => '',
'incident_year' => '',
@@ -140,8 +141,9 @@ public function submit($saved = false)
'incident_ampm' => '',
'latitude' => '',
'longitude' => '',
+ */
'location_name' => '',
- 'country_id' => '',
+ //'country_id' => '',
'incident_category' => array(),
);
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
@@ -159,12 +161,14 @@ public function submit($saved = false)
// Initialize Default Values
+ /*
$form['incident_month'] = date('m');
$form['incident_day'] = date('d');
$form['incident_year'] = date('Y');
$form['incident_hour'] = "12";
$form['incident_minute'] = "00";
$form['incident_ampm'] = "pm";
+ */
// initialize custom field array
// $form['custom_field'] = $this->_get_custom_form_fields($id,'',true);
//GET custom forms
@@ -188,6 +192,7 @@ public function submit($saved = false)
// Add some rules, the input field, followed by a list of checks, carried out in order
$post->add_rules('incident_title', 'required', 'length[3,200]');
$post->add_rules('incident_description', 'required');
+ /*
$post->add_rules('incident_month', 'required', 'numeric', 'between[1,12]');
$post->add_rules('incident_day', 'required', 'numeric', 'between[1,31]');
$post->add_rules('incident_year', 'required', 'numeric', 'length[4,4]');
@@ -208,8 +213,10 @@ public function submit($saved = false)
// Validate for maximum and minimum latitude values
$post->add_rules('latitude', 'between[-90,90]');
$post->add_rules('longitude', 'between[-180,180]');
+ */
$post->add_rules('location_name', 'required', 'length[3,200]');
+ /*
//XXX: Hack to validate for no checkboxes checked
if (!isset($_POST['incident_category'])) {
$post->incident_category = "";
@@ -219,6 +226,7 @@ public function submit($saved = false)
{
$post->add_rules('incident_category.*', 'required', 'numeric');
}
+ */
// Geocode Location
if ( empty($_POST['latitude']) AND empty($_POST['longitude'])
@@ -271,12 +279,14 @@ public function submit($saved = false)
$incident->incident_title = $post->incident_title;
$incident->incident_description = $post->incident_description;
+ /*
$incident_date = $post->incident_year."-".$post->incident_month."-".$post->incident_day;
$incident_time = $post->incident_hour
.":".$post->incident_minute
.":00 ".$post->incident_ampm;
$incident->incident_date = date( "Y-m-d H:i:s", strtotime($incident_date . " " . $incident_time) );
- $incident->incident_dateadd = date("Y-m-d H:i:s",time());
+ */
+ $incident->incident_dateadd = $incident->incident_date = date("Y-m-d H:i:s",time());
$incident->save();
// STEP 3: SAVE CATEGORIES
@@ -311,10 +321,15 @@ public function submit($saved = false)
$this->template->content->errors = $errors;
$this->template->content->form_error = $form_error;
$this->template->content->categories = $this->_get_categories($form['incident_category']);
-
+ $mobilecat = 0;
+ if ($mobilecat = $this->template->content->categories->current()) {
+ $mobilecat = $mobilecat->id;
+ }
+ $this->template->content->mobilecategory = $mobilecat;
$this->template->content->cities = $this->_get_cities();
$this->template->header->js = new View('mobile/reports_submit_js');
+ /*
if (!$form['latitude'] || !$form['latitude'])
{
$this->template->header->js->latitude = Kohana::config('settings.default_lat');
@@ -323,6 +338,7 @@ public function submit($saved = false)
$this->template->header->js->latitude = $form['latitude'];
$this->template->header->js->longitude = $form['longitude'];
}
+ */
}
// http://ushahidi.dev/mobile
@@ -341,6 +357,7 @@ private function _get_categories($selected_categories)
->where('category_visible', '1')
->where('parent_id', '0')
->where('category_trusted != 1')
+ ->where("category_title = 'Mobile'")
->orderby('category_title', 'ASC')
->find_all();
View
15 views/mobile/reports_submit.php
@@ -1,8 +1,11 @@
<div class="report_submit">
<h2 class="main_title">Submit A Report</h2>
<?php print form::open(NULL, array('enctype' => 'multipart/form-data', 'id' => 'reportForm', 'name' => 'reportForm')); ?>
+<?php /*
<input type="hidden" name="latitude" id="latitude" value="<?php echo $form['latitude']; ?>">
<input type="hidden" name="longitude" id="longitude" value="<?php echo $form['longitude']; ?>">
+ */
+?>
<div class="report_form">
<?php
@@ -34,7 +37,7 @@
<h4><?php echo Kohana::lang('ui_main.reports_description'); ?></h4>
<?php print form::textarea('incident_description', $form['incident_description'], ' rows="10" class="textarea long" ') ?>
</div>
-
+<?php /*
<div class="report_row">
<h4><?php echo Kohana::lang('ui_main.reports_date'); ?></h4>
<?php
@@ -78,7 +81,6 @@
print form::dropdown('incident_ampm',$ampm_array,$form['incident_ampm']);
?>
</div>
-
<div class="report_row">
<h4><?php echo Kohana::lang('ui_main.reports_categories'); ?> (Select All That Apply)</h4>
<div class="report_category" id="categories">
@@ -92,19 +94,20 @@
?>
</div>
</div>
-
- <div class="report_row">
<h4>Location</h4>
<span class="location">Select A Location from the Drop-Down</span>
<?php print form::dropdown('select_city',$cities,'', ' class="select" '); ?>
<span class="location">OR Enter A Location</span>
+*/ ?>
+ <div class="report_row">
+ <span class="location">Enter A Location</span>
<?php print form::input('location_name', $form['location_name'], ' class="text long"'); ?>
</div>
<div class="report_row">
<input name="submit" type="submit" value="<?php echo Kohana::lang('ui_main.reports_btn_submit'); ?>" class="btn_submit" />
</div>
-
+ <input type="hidden" name="incident_category[]" value="<?php echo $mobilecategory ?>" />
</div>
</form>
-</div>
+</div>
Please sign in to comment.
Something went wrong with that request. Please try again.