Skip to content
This repository
tree: 8b5fb13b60
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 37 lines (28 sloc) 0.914 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
<?php
exit;

//rename all invoice files


chdir("..");

require("init.php");

echo "<pre>";

/* Spiros Ioannou 2009 , sivann _at_ gmail.com */
  $sql="SELECT * from invoices ";
  $sth=db_execute($dbh,$sql);
  while ($r=$sth->fetch(PDO::FETCH_ASSOC)) {
    if (!strlen($r['fname'])) continue; //if no file associated continue
    $path_parts = pathinfo($r["fname"]);
    $invoiceext=$path_parts['extension'];
    $dymd=strftime("%Y%m%d",$r['date']);

//new filename
    $invoicefn="inv-".validfn($r["vendor"]).
    "-". validfn($r["number"]). "-$dymd-".
    $r['id'].".$invoiceext";
    $invoicefn=strtolower($invoicefn);

    echo "will move {$r['fname']} to $invoicefn\n";
    $ret=rename ($uploaddir.$r['fname'],$uploaddir.$invoicefn);
    if ($ret) {
$sql="UPDATE invoices set fname='$invoicefn' WHERE id='{$r['id']}'";
        db_exec($dbh,$sql);
    }
    else
      echo "<b>ERROR moving </b><br>\n";
}
Something went wrong with that request. Please try again.