<?php include_once 'dbconfig.php'; if (!$user->is_loggedin()) { $user->redirect('index.php'); } $supplier_code = $_SESSION['user_session']; $stmt = $DB_con->prepare("SELECT * FROM suppliers WHERE supplier_code=:supplier_code"); $stmt->execute(array(":supplier_code" => $supplier_code)); $userRow = $stmt->fetch(PDO::FETCH_ASSOC); include_once 'class.suppliers.php'; $supplier = new Supplier(); $code = $userRow['supplier_code']; $sql = "SELECT * FROM `suppliers` WHERE supplier_code = {$code}"; $getdata = $supplier->runQuery($sql); $getdata->execute(); if (!empty($code)) { if ($getdata->rowCount() > 0) { while ($row = $getdata->FETCH(PDO::FETCH_ASSOC)) { $name = $row['f_name'] . " " . $row['l_name']; $addr = $row['address_1']; $mobile = $row['mobile_no']; $email = $row['e_mail']; } } } if (isset($_POST['sendmsg'])) { $selectservice = $_POST['selectservice']; $amount = $_POST['amount']; $qty = $_POST['qty']; $category = $_POST['category'];
$nic = trim($_POST['nic']); $iCheck = trim($_POST['iCheck']); $email = trim($_POST['uemail']); $address_1 = trim($_POST['address_1']); $mobile = trim($_POST['mobile']); $estate = trim($_POST['estate']); $estate_name = trim($_POST['estate_name']); $reg_no = trim($_POST['reg_no']); $size_of_estate = trim($_POST['size_of_estate']); $estate_address = trim($_POST['estate_address']); $bankn = trim($_POST['bankn']); $branch = trim($_POST['branch']); $account = trim($_POST['account']); $bankacc = trim($_POST['bankacc']); $editor = $row['id']; $stmt = $supplier->runQuery("SELECT * FROM suppliers WHERE supplier_code=:sup_code"); $stmt->execute(array(":sup_code" => $scode)); $row = $stmt->fetch(PDO::FETCH_ASSOC); if ($stmt->rowCount() > 0) { $msg = '<div class="alert alert-warning alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <h4> <i class="icon fa fa-check"></i> Sorry!</h4> supplier allready exists , Please Try another one. </div>'; // $msg = " // <div class='alert alert-error'> // <button class='close' data-dismiss='alert'>×</button> // <strong>Sorry !</strong> email allready exists , Please Try another one // </div> // "; } else {
function myTotalSupplyOf6Months($code) { //to get total supply for perticular supplier in LAST 6 months $resarr = array(); $curyear = substr($formateddate, 0, 4); $curmonth = substr($formateddate, 5, 7); $lstrunningmonth = substr($formateddate, 5, 7); for ($i = 1; $i < 7; $i++) { $lstrunningmonth = $curmonth - $i; $m = $curmonth - $i; if ($lstrunningmonth == "0") { $curyear = $curyear - 1; $m = 12 + ($curmonth - $i); } if ($lstrunningmonth < 0) { $m = 12 + ($curmonth - $i); } if (strlen($m) == 1) { $m = "0" . $m; } $startday = $curyear . "-" . $m . "-01"; $enddate = $curyear . "-" . $m . "-31"; $condition = "SELECT *FROM daily_supply WHERE supplier_code='" . $code . "' AND date BETWEEN '" . $startday . "' AND '" . $enddate . "'"; $getdata = Supplier::runQuery($sql); $getdata->execute(); $total = 0; if ($getdata->rowCount() > 0) { while ($row = $getdata->FETCH(PDO::FETCH_ASSOC)) { $total = $total + $row['approved_kgs']; } $resarr[$i - 1] = $total; } else { $resarr[$i - 1] = 0; } } return $resarr; }