array_push($stage2, substr($stage, $i, 1) . "2");
            }
            array_push($stage2, substr($stage, $len - 1, 1) . "1");
        }
        #print_r($stage2);
        ## get or add row to Stages and write cells
        $subid = "CSP-" . $row['subprojectstatus'];
        $nrnb = $row['nrnbcontact'];
        $title = $row['projecttitle'];
        $uprow = array('projecttitle' => $title, 'nrnbcontact' => $nrnb, 'subprojectstatus' => $subid);
        foreach ($stage2 as $st) {
            $col = "st" . $st;
            $uprow[$col] = $st;
        }
        ## UPDATE GOOGLE DOC
        $rowcheck = $ss2->getRows("subprojectstatus=\"{$subid}\"");
        if ($rowcheck) {
            if ($ss2->updateRow($uprow, "subprojectstatus=\"{$subid}\"")) {
                echo "Data successfully updated for subproject ID: {$subid}\n";
            } else {
                echo "Error, unable to update data for subproject ID: {$subid}\n";
            }
        } else {
            if ($ss2->addRow($uprow)) {
                echo "Data successfully added for subproject ID: {$subid}\n";
            } else {
                echo "Error, unable to add data for subproject ID: {$subid}\n";
            }
        }
    }
}
示例#2
0
 $msg = "Please update the following information:";
 if ('POST' == $_SERVER['REQUEST_METHOD']) {
     $update2 = check_input($_POST['update']);
     $feedback2 = check_input($_POST['feedback']);
     $pubmed2 = check_input($_POST['pubmed']);
     $grant2 = check_input($_POST['grant']);
     $status2 = check_input($_POST['status']);
     $st1 = check_input($_POST['stage1']);
     $st2 = check_input($_POST['stage2']);
     $st3 = check_input($_POST['stage3']);
     $st4 = check_input($_POST['stage4']);
     $stage2 = implode(",", array($st1, $st2, $st3, $st4));
     $uptime2 = date('n/j/Y G:i:s');
     $uprow = array('projectupdate' => $update2, 'collaborationfeedback' => $feedback2, 'pubmedids' => $pubmed2, 'grantids' => $grant2, 'projectstatus' => $status2, 'updatetimestamp' => $uptime2, 'projectstage' => $stage2);
     //UPDATE GOOGLE DOC
     if ($ss->updateRow($uprow, "subprojectstatus={$subid}")) {
         $msg = "<em><font color=\"green\">Data successfully updated!</font></em>";
     } else {
         $msg = "<em><font color=\"red\">Error, unable to update spreadsheet data.</font></em> <br />\n\t\t\tPlease try again or contact Alex at \n\t\t\t<a href=\"mailto:apico@gladstone.ucsf.edu?Subject=Error updating subproject {$subid}!\">apico@gladstone.ucsf.edu</a>";
     }
 }
 $rows = $ss->getRows("subprojectstatus={$subid}");
 if ($rows) {
     $names = $rows[0]['fullnamesanddegrees'];
     $inst = $rows[0]['departmentandinstitution'];
     $email = $rows[0]['email'];
     $url = $rows[0]['projecturl'];
     $nrnb = $rows[0]['nrnbcontact'];
     $nrnbemail = str_replace(' ', '', $rows[0]['nrnbemail']);
     $desc = $rows[0]['projectdescription'];
     $title = $rows[0]['projecttitle'];