0byt3m1n1
Path:
C:
/
wamp64
/
www
/
cpms_new
/
USER
/
[
Home
]
File: pi_add_budget_form_cntrl.php
<?php include( "../lib/config.php"); include_once("../model/defaults_mdl.php"); //require_once "../model/Notification_mdl.php"; require_once BASE_DIR."/lib/db/connection.php"; require_once "../model/uploader_mdl.php"; require_once "../model/defaultValues_mdl.php"; require_once "pi_models.php"; //$arr_img_type = array( "image/bmp" => "bmp", "image/gif" => "gif", // "image/jpeg" => "jpeg", "image/png" => "png", "image/pjpeg" => "jpeg"); // $project_id= @$_POST['project_id']; // $date_current= @$_POST['date_current']; // $debit_head=@$_POST['debit_head']; // $invoice_date=@$_POST['invoice_date']; // $invoice_number=@$_POST['invoice_number']; // $amount= ""; $con= mysqli_connect("localhost","root", "", "cpms"); $u_id = @$_SESSION['user_id']; $p_id = @$_SESSION['project_id']; $project_details = array(); $sql = "SELECT project_code, project_id, project_title FROM addproject WHERE user_id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("i", $u_id); $stmt->execute(); $result = $stmt->get_result(); while ($row = $result->fetch_assoc()) { $arr = array("project_code" => $row['project_code'], "project_title" => $row['project_title']); $project_details[$row['project_id']] = $arr; } reset($project_details); $first_key = key($project_details); $debit_head_details = Pi_Models::getBudgetHead($first_key); $installment_details = Pi_Models::getInstallmentDetails($first_key); if (isset($_POST['save'])) { $error_flag = 0; $project_id = @$_POST['project_id']; $date_current = @$_POST['date_current']; $debit_head = @$_POST['debit_head']; $debit_master = @$_POST['debit_master']; $invoice_date = @$_POST['invoice_date']; $invoice_number = @$_POST['invoice_number']; $amount = @$_POST['amount']; if ($project_id == "") { $error['project_id'] = "Please Enter Projectcode"; $error_flag = 1; } $post = @$_POST; $post['date_current'] = date("Y-m-d"); if (empty($post['invoice_date'])) { $post['invoice_date'] = "0000-00-00"; } $post['invoice_date'] = date("Y-m-d", strtotime($post['invoice_date'])); $post['created_on'] = date("Y-m-d H:i:s"); $post['created_by'] = $u_id; if ($debit_master == 1) { unset($post['invoice_date']); unset($post['invoice_number']); } unset($post['debit_master']); $post['amount_init'] = $post['amount']; $installment_details = Pi_Models::getInstallmentDetails($post['project_id']); if (!empty($installment_details)) { $post['installment_id'] = $installment_details['id']; unset($post['save']); $result = Pi_Models::addBudgetHead($post); if (!$result) { $message = "Try Again"; $key = "error"; } else { $message = "Successfully inserted"; $key = "message"; } } else { $message = "No Installment details found"; $key = "error"; } $url = $server_ip . "user/pi_add_budget_form.php?$key=$message"; echo "<script>window.location='$url'</script>"; } ?>