public function write()
 {
     $input = Input::all();
     $data = Document::find($input['id']);
     $document = $data->converted_name;
     $fileNameSent = basename($document, ".pdf");
     $saveFile = public_path() . '/uploads/compiled_html/' . $fileNameSent . '.html';
     if (isset($input['frameData']) && $input['frameData']) {
         $ff = fopen($saveFile, 'w');
         fwrite($ff, $input['frameData']);
         fclose($ff);
     }
     $modifiedFile = public_path() . '/uploads/compiled_html/' . $fileNameSent . '.html';
     $document_name = !empty($data->document_name) ? $data->document_name : $data->name;
     $downloadUrl = Document::updateHtmlGoogleDoc($document_name, $modifiedFile, $data->google_doc_id, $input['id']);
     $data->case_name = $input['case_name'];
     $data->document_name = $input['document_name'];
     if (isset($input['objections_id']) && $input['objections_id']) {
         $data->objections_id = $input['objections_id'];
     }
     if (isset($input['deadline']) && $input['deadline']) {
         $data->deadline = $input['deadline'];
     }
     if (isset($input['is_reminder_allow']) && $input['is_reminder_allow']) {
         $data->is_reminder_allow = 1;
     } else {
         $data->is_reminder_allow = 0;
     }
     if (isset($input['footer_id']) && $input['footer_id']) {
         $data->footer_id = $input['footer_id'];
     }
     // echo $data->is_reminder_allow;exit;
     $data->save();
     if ($input['footer_id']) {
         $footerData = Footer::find($input['footer_id']);
         Document::docScriptRun($data->google_doc_id, $footerData->footer);
     }
     //Document::docScriptRun($data->google_doc_id);
     //exit;
     //$convertedData = Document::HtmlToDocUpload($saveFile);
     return Redirect::to('document/edit/' . $data->id);
 }