private function testCopyExistingReport()
 {
     $UshApiLib_Site_Info = new UshApiLib_Site_Info(url::base() . "api");
     echo "<br/><br/><br/><br/><h1>Copy an existing report</h1><strong>URL:</strong> " . $UshApiLib_Site_Info->getUrl() . "<br/><br/><br/>";
     $report = ORM::factory('incident')->find();
     echo "<strong>Coping Report With ID:</strong> " . $report->id . "<br/><br/>";
     $reportParams = UshApiLib_Report_Task_Parameter::fromORM($report);
     $reportTask = new UshApiLib_Report_Task($reportParams, $UshApiLib_Site_Info);
     $reportResponse = $reportTask->execute();
     echo "<strong>Query String:</strong> " . Kohana::debug($reportParams->get_query_string()) . "<br/><br/><br/>";
     echo "<strong>JSON:</strong> " . $reportTask->getJson() . "<br/><br/><br/>";
     echo "<strong>Code:</strong> " . $reportResponse->getError_code() . " <strong>Message:</strong> " . $reportResponse->getError_message();
 }
 /**
  * This function takes a ORM incident model and creates the required parameter for the report task.
  * 
  * @param ORM Object of an Ushahidi incident $incident
  */
 public static function fromORM($incident)
 {
     $category_str = "";
     $i = 0;
     foreach ($incident->incident_category as $cat) {
         $i++;
         if ($i > 1) {
             $category_str .= ",";
         }
         $category_str .= $cat->category->id;
     }
     $retVal = new UshApiLib_Report_Task_Parameter($incident->incident_title, $incident->incident_description, date("m/d/Y", strtotime($incident->incident_date)), date("h", strtotime($incident->incident_date)), date("i", strtotime($incident->incident_date)), date("a", strtotime($incident->incident_date)), $category_str, $incident->location->latitude, $incident->location->longitude, $incident->location->location_name);
     if (isset($incident->incident_person->person_first)) {
         $retVal->setPerson_first($incident->incident_person->person_first);
     }
     if (isset($incident->incident_person->person_last)) {
         $retVal->setPerson_last($incident->incident_person->person_last);
     }
     if (isset($incident->incident_person->person_email)) {
         $retVal->setPerson_email($incident->incident_person->person_email);
     }
     //save the media elements
     foreach ($incident->media as $media) {
         switch ($media->media_type) {
             case 4:
                 $retVal->addIncident_news($media->media_link);
                 break;
             case 2:
                 $retVal->addIncident_video($media->media_link);
                 break;
             case 1:
                 $retVal->addIncident_photo("@" . Kohana::config('upload.directory', TRUE) . $media->media_link);
                 break;
         }
     }
     return $retVal;
 }