-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjournal.php
More file actions
68 lines (60 loc) · 2.59 KB
/
journal.php
File metadata and controls
68 lines (60 loc) · 2.59 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
include('db.php');
//if(isset($_POST['submit'])){
function arraytoarray($item_name){
$a = array();
foreach($item_name as $cur)
{
array_push($a,$cur);
}
return $a;
}
/*********************************************************************************************/
/*********************************************************************************************
Create payment Voucher
*********************************************************************************************/
/*********************************************************************************************/
if(isset($_POST['entry_type']) && $_POST['entry_type'] =='journal'){
$number = $_POST['number'];
$date = $_POST['date'];
$date = date('Y-m-d', strtotime($date));
$dabit_total = $_POST['dabit_total'];
$credit_total = $_POST['credit_total'];
if($dabit_total == $credit_total){
$sqls="INSERT INTO `transaction` (`entry_type`, `cat_type`, `total`, `date`, `company_email`, `transaction_number`) VALUES ('Journal', 'Journal', '$dabit_total', '$date', '$company_email', '$number')";
if (mysqli_query($conn, $sqls)) {
echo $last_ids = mysqli_insert_id($conn);
$data = json_decode($_POST['data']);
$datas = arraytoarray($data);
foreach ($datas as $key) {
$item_row = (array)$key;
$account = $item_row['id'];
$credit = $item_row['credit'];
$debit = $item_row['debit'];
$notes = $item_row['notes'];
$sql="INSERT INTO `journal` (`date`, `number`, `account`, `debit`, `credit`, `notes`, `dabit_total`, `credit_total`, `type`, `company_email`, `transaction_id`) VALUES ('$date', '$number', '$account', '$debit', '$credit', '$notes', '$dabit_total', '$credit_total', 'Journal', '$company_email', '$last_ids')";
if (mysqli_query($conn, $sql)) {
echo $last_id = mysqli_insert_id($conn);
//////////////////////////////////////////////////////////////////////////////////////////
$condition = basename($_FILES["file"]["name"]);
if(isset($condition)){
$target_dir = "emoji/".$name.'/';
$target_file = $target_dir.$last_id. basename($_FILES["file"]["name"]);
if (!file_exists('/'.$target_dir)) {
mkdir('./'.$target_dir, 0777, true);
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
} else {
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file);
}
$fname = $target_file;
$sqlz="UPDATE `journal` SET `file` = '$fname' WHERE `id` = '$last_id'";
$conn->query($sqlz);
}
//////////////////////////////////////////////////////////////////////////////////////////
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
}
}
}