Example #1
0
     $asn->insert();
     header('Location: index.php');
 }
 // Initialize values!
 $name = '';
 $phone = '';
 $year = '';
 $month = '';
 $day = '';
 $desc = '';
 $checked = '';
 $id = isset($_GET['id']) ? $_GET['id'] : null;
 if ($id) {
     $req = new Request();
     $req->id = $id;
     $req->find();
     $name = $req->name;
     $phone = parse_phone($req->phone);
     $y = substr($req->deadline, 0, 4);
     $m = substr($req->deadline, 5, 2);
     $d = substr($req->deadline, 8, 2);
     $time = strtotime("{$y}/{$m}/{$d}");
     $year = '<option>' . date('Y', $time) . '</option>';
     $month = '<option>' . date('F', $time) . '</option>';
     $day = '<option>' . date('j', $time) . '</option>';
     $desc = $req->description;
     $checked = $req->approved ? 'checked="checked"' : '';
     //update size of textarea to fit description
     $row_size = 1 + strlen($desc) / 40;
 }
 ?>
 public static function edit($id)
 {
     $request = Request::find($id);
     View::make('request/edit.html', array('attributes' => $request));
 }