コード例 #1
0
ファイル: edititem.php プロジェクト: MichaelGreenNZ/itdb
        db_exec($dbh, $sql);
    }
} elseif (isset($_POST['itemtypeid']) && $_GET['id'] == "new" && isvalidfrm()) {
    //ok, save new item
    //find a new ID
    //handle file uploads
    $photofn = "";
    $manualfn = "";
    foreach ($_POST as $k => $v) {
        if (!is_array($v)) {
            ${$k} = trim($v);
        }
    }
    $purchasedate2 = ymd2sec($purchasedate);
    // mktime(0, 0, 0, $x[1], $x[0], $x[2]);
    $mend = ymd2sec($maintend);
    if ($switchid == "") {
        $switchid = "NULL";
    }
    if ($usize == "") {
        $usize = "NULL";
    }
    if ($locationid == "") {
        $locationid = "NULL";
    }
    if ($locareaid == "") {
        $locareaid = "NULL";
    }
    if ($rackid == "") {
        $rackid = "NULL";
    }
コード例 #2
0
} else {
    require_once "../init.php";
}
//print_r($_POST);
//form submit
if (isset($_POST['eventid'])) {
    $eventid = $_POST['eventid'];
    foreach ($_POST as $k => $v) {
        ${$k} = $v;
    }
    if ($eventid == "new") {
        $sql = "INSERT into contractevents " . " (contractid,siblingid , startdate , enddate, description) " . " VALUES ('{$contractid}','{$ev_siblingid}','" . ymd2sec($ev_startdate) . "','" . ymd2sec($ev_enddate) . "','{$ev_description}') ";
        db_exec($dbh, $sql, 0, 0, $lastid);
        //echo "Added $lastid, $ev_startdate";
    } elseif (is_numeric($eventid)) {
        $sql = "UPDATE contractevents " . " SET siblingid='{$ev_siblingid}', startdate='" . ymd2sec($ev_startdate) . "',enddate='" . ymd2sec($ev_enddate) . "',description='{$ev_description}' " . " WHERE id='{$eventid}'";
        db_exec($dbh, $sql, 0, 0, $lastid);
        //echo "UPDATED $eventid";
    }
} elseif (isset($_POST['deleventid'])) {
    $sql = "DELETE FROM contractevents WHERE id='{$_POST['deleventid']}'";
    db_exec($dbh, $sql);
    //echo "DELETED ".$_POST['deleventid'];
}
?>
    <!-- print contract events table -->
    <table width='100%' class='tbl2 brdr sortable'  id='eventslisttbl'>
      <thead>
	<tr><th style='width:40px;'><?php 
te("Edit");
?>
コード例 #3
0
ファイル: editactions.php プロジェクト: MichaelGreenNZ/itdb
if (isset($_POST['description'])) {
    $nrows = count($_POST['id']);
    //number of rows
    for ($rn = 0; $rn < $nrows; $rn++) {
        $id = $_POST['id'][$rn];
        if ($id == "new" && strlen($_POST['description'][$rn]) > 1) {
            //new item -- insert
            if (empty($_POST['actiondate'][$rn])) {
                $adate = time();
            } else {
                $adate = ymd2sec($_POST['actiondate'][$rn]);
            }
            $sql = "INSERT into actions " . "(itemid, actiondate,description,invoiceinfo,isauto,entrydate) " . " values (" . "{$itemid}," . $adate . "," . "'" . $_POST['description'][$rn] . "'," . "'" . $_POST['invoiceinfo'][$rn] . "',0," . time() . ")";
        } elseif ($id != "new") {
            //existing item -- update
            $sql = "UPDATE actions set " . " actiondate=" . ymd2sec($_POST['actiondate'][$rn]) . ", " . " description='" . $_POST['description'][$rn] . "', " . " invoiceinfo='" . $_POST['invoiceinfo'][$rn] . "', " . " isauto=0" . " WHERE id={$id}";
        } else {
            continue;
        }
        $r = db_exec($dbh, $sql);
    }
    //for
}
//if
if (!isset($_GET['itemid']) || !strlen($_GET['itemid'])) {
    echo "{$scriptname}: wrong arguments";
    exit;
}
$itemid = $_GET['itemid'];
$sql = "SELECT * from actions where itemid={$itemid} order by actiondate";
/// make db query
コード例 #4
0
ファイル: editinvoice.php プロジェクト: MichaelGreenNZ/itdb
    }
    //echo "$nlinks DELETED ".$_GET['delfid'];
    echo "<script>window.location='{$scriptname}?action={$action}&id={$id}'</script> ";
    echo "<br><a href='{$scriptname}?action={$action}&id={$id}'>Go here</a></body></html>";
    exit;
}
if (isset($_POST['id'])) {
    //if we came from a post (save) then update invoice
    $id = $_POST['id'];
    $description = $_POST['description'];
    //don't accept empty fields
    if (empty($vendorid) || empty($buyerid) || !strlen($number) || !strlen($date)) {
        echo "\n<br><b>Some mandatory fields are missing.</b><br><a href='javascript:history.go(-1);'>Go back</a>\n</body></html>";
        exit;
    }
    $d = ymd2sec($date);
    if ($_POST['id'] == "new") {
        //if we came from a post (save) then add invoice
        $sql = "INSERT into invoices (vendorid,buyerid,number,description,date)" . " VALUEs ('{$vendorid}','{$buyerid}','{$number}','{$description}','{$d}')";
        db_exec($dbh, $sql, 0, 0, $lastid);
        $lastid = $dbh->lastInsertId();
        print "\n<br><b>Added Invoice <a href='{$scriptname}?action={$action}&amp;id={$lastid}'>{$lastid}</a></b><br>\n";
        echo "<script>window.location='{$scriptname}?action={$action}&id={$lastid}'</script> ";
        //go to the new invoice
        $id = $lastid;
    } else {
        $sql = "UPDATE invoices SET vendorid='{$vendorid}', buyerid='{$buyerid}', " . " number='{$number}', description='{$description}', date='{$d}' WHERE id={$id}";
        db_exec($dbh, $sql);
    }
    //SAVE ASSOCIATIONS
    //update item - invoice links
コード例 #5
0
ファイル: editrack.php プロジェクト: MichaelGreenNZ/itdb
        echo "<b>Rack not deleted: Please remove items first from this rack<br></b>\n";
        echo "<br><a href='javascript:history.go(-1);'>Go back</a>\n</body></html>";
        exit;
    } else {
        delrack($delid, $dbh);
        echo "<script>document.location='{$scriptname}?action=listracks'</script>\n";
        echo "<a href='{$scriptname}?action=listracks'>Go here</a>\n</body></html>";
        exit;
    }
}
if (isset($_POST['id'])) {
    //if we came from a post (save), update the rack
    $id = $_POST['id'];
    $title = $_POST['title'];
    $type = $_POST['type'];
    $date = ymd2sec($_POST['date']);
    //don't accept empty fields
    if (empty($_POST['usize']) || empty($_POST['depth'])) {
        echo "<br><b>Some <span class='mandatory'> mandatory</span> fields are missing.</b><br>" . "<a href='javascript:history.go(-1);'>Go back</a></body></html>";
        exit;
    }
    if ($_POST['id'] == "new") {
        //if we came from a post (save) the add software
        $sql = "INSERT into racks (locationid , usize , depth , comments,model,label, revnums , locareaid) " . " VALUES ('{$locationid}','{$usize}','{$depth}','{$comments}','{$model}','{$label}','{$revnums}','{$locareaid}')";
        db_exec($dbh, $sql, 0, 0, $lastid);
        $lastid = $dbh->lastInsertId();
        print "<br><b>Added Rack <a href='{$scriptname}?action={$action}&amp;id={$lastid}'>{$lastid}</a></b><br>";
        echo "<script>window.location='{$scriptname}?action={$action}&id={$lastid}'</script> ";
        //go to the new rack
        echo "\n</body></html>";
        $id = $lastid;
コード例 #6
0
ファイル: upload_inc.php プロジェクト: MichaelGreenNZ/itdb
function upload($file_id, $folder = "", $ftype, $title, $date, $id, $assoctable = "", $colname = "", $uploader = "")
{
    global $dbh, $uploadErrors;
    if ($_FILES[$file_id]["error"] > 0) {
        $result = $uploadErrors[$_FILES[$file_id]["error"]];
        return array('', $result);
    }
    if (!$_FILES[$file_id]['name']) {
        return array('', 'No file specified');
    }
    if (!$_FILES[$file_id]['size']) {
        return array('', 'File is zero length');
    }
    if (!is_numeric($ftype)) {
        return array('', "No type specified ({$ftype})");
    }
    if (!strlen($title)) {
        return array('', 'No title specified');
    }
    if (!strlen($date)) {
        return array('', 'No date specified');
    }
    if (!strlen($assoctable)) {
        return array('', 'No table specified');
    }
    if (!strlen($colname)) {
        return array('', 'No colname specified');
    }
    if (!strlen($folder)) {
        return array('', 'No folder specified');
    }
    $ftypestr = ftype2str($ftype, $dbh);
    $path_parts = pathinfo($_FILES[$file_id]["name"]);
    $fileext = $path_parts['extension'];
    $unique = substr(uniqid(), -4, 4);
    $filefn = "{$ftypestr}-" . validfn($title) . "-{$unique}.{$fileext}";
    $filefn = strtolower($filefn);
    $uploadfile = $folder . $filefn;
    $result = '';
    //Move the file from the stored location to the new location
    if (!move_uploaded_file($_FILES[$file_id]['tmp_name'], $uploadfile)) {
        $result = "Cannot upload the file '" . $_FILES[$file_id]['name'] . "'";
        if (!file_exists($folder)) {
            $result .= " : Folder doesn't exist.";
        } elseif (!is_writable($folder)) {
            $result .= " : Folder not writable.";
        } elseif (!is_writable($uploadfile)) {
            $result .= " : File not writable.";
        }
        $filefn = '';
        return array($filefn, $result);
    }
    //else file was written
    //chmod($uploadfile,0777);//Make it universally writable.
    //add file to files table
    $datesec = ymd2sec($date);
    $sql = "INSERT into files (type,title,date,fname,uploader,uploaddate) VALUES ({$ftype},'{$title}','{$datesec}','{$filefn}','{$uploader}','" . time() . "')";
    db_exec($dbh, $sql);
    $lastid = $dbh->lastInsertId();
    //make association
    $sql = "INSERT into {$assoctable} ({$colname},fileid) VALUES ({$id},{$lastid})";
    db_exec($dbh, $sql);
    return array($filefn, $result);
}
コード例 #7
0
ファイル: editcontract.php プロジェクト: MichaelGreenNZ/itdb
     $_POST['ren_notes'] = preg_replace('/[\\|#]/', ' ', $_POST['ren_notes']);
     $_POST['ren_dateentered'] = preg_replace('/[\\|#]/', ' ', $_POST['ren_dateentered']);
     $_POST['ren_enteredby'] = preg_replace('/[\\|#]/', ' ', $_POST['ren_enteredby']);
     $row[$i] = implode("#", array($_POST['ren_enddatebefore'][$i], $_POST['ren_enddateafter'][$i], $_POST['ren_effectivedate'][$i], $_POST['ren_notes'][$i], $_POST['ren_dateentered'][$i], $_POST['ren_enteredby'][$i]));
 }
 $renewals = implode("|", $row);
 $title = $_POST['title'];
 $number = $_POST['number'];
 $typex = $_POST['typex'];
 $description = $_POST['description'];
 $comments = $_POST['comments'];
 $parentid = $_POST['parentid'];
 $totalcost = $_POST['totalcost'];
 $contractorid = $_POST['contractorid'];
 $startdate = ymd2sec($_POST['startdate']);
 $currentenddate = ymd2sec($_POST['currentenddate']);
 //don't accept empty mandatory fields
 $missing = "";
 if (!strlen($title)) {
     $missing .= "<br><b>Title is missing.</b><br>";
 }
 if (!strlen($number)) {
     $missing .= "<br><b>Number is missing.</b><br>";
 }
 if (!strlen($typex)) {
     $missing .= "<br><b>Type is missing.</b><br>";
 }
 if (!strlen($contractorid)) {
     $missing .= "<br><b>Contractor is missing.</b><br>";
 }
 if (!strlen($startdate)) {