<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$formname = 'Series Update';
$maindb = 'item';
$trandb = 'itemsub';
$proddb = 'product';
$grpdb = 'prodgrp';
$proddbtran = 'prodtran';

$printfile = "itemlst.php";
$invprintfile = "";
$file = 'itemupdent.php';
$trandbexist = 1;
$keyfld = "code";
$focusfield = "code";

$zseries = $_SESSION['user_series'];
$keycond = "";
$msource = "";

$myear = $_SESSION["tit_" . $dbname];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
$usertype = $_SESSION["usertype"];

//include("includes/vouchno_generate.php");
//include("includes/prev&next.php");


$sql = "SHOW TABLES FROM $zdb";
$result = mysqli_query($conn, $sql);
$num_tabs = mysqli_num_rows($result);
$arraytab = 0;
while ($row = mysqli_fetch_row($result)) {
    $tableNames[$arraytab] = $row[0];
    $arraytab++; //only do this to make sure it starts at index 0
}

foreach ($tableNames as & $tname) {
    $chkcol = mysqli_query($conn, "SELECT COLUMN_TYPE, EXTRA FROM information_schema.columns 
                                        WHERE  `table_schema` = '$zdb'  AND `table_name` = '$tname' AND  column_name = 'series'")or die(mysqli_error($conn));
    $tno = mysqli_num_rows($chkcol);
    if ($tno > 0) {
        mysqli_query($conn, "Update $zdb.`$tname` set series='ZB1' where (series = '' or series ='ZB')") or die(mysqli_error($conn));
    }
}
############################## MAIN  - challan part ######################################################
mysqli_query($conn, "UNLOCK TABLES");


browse("Records Updated Successfully");





include("includes/linkshead.php");
if ($addflag != 1) {
    $read = 'readonly';
}
?>

<?php include("includes/linksfoot.php"); ?>
</body>
</html>
