دليل الحسابات يُعتبر أحد العناصر الأساسية في إدارة الحسابات المالية لأي منظمة أو شركة. يتمثل دليل الحسابات في مجموعة هرمية من الحسابات المالية المنظمة بشكل منطقي وهرمي يعكس هيكل الشركة ونشاطاتها المالية
Chart of Accounts by php and javascript
انشاء قواعد البيانات
في البداية يجب انشاء قاعدة بيانات phpmyadmin باسم ChartOfAccounts كما موضح بالصورة وباستخدام الكود التالي:
CREATE DATABASE ChartOfAccounts ;
ثم نضغط زر Go
بذلك قد انشانا قاعدة بيانات . بعد ذلك نقوم بانشاء الجداول عن طريق الاكواد التالية
// category جدول
CREATE TABLE category (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
parent_id VARCHAR(25),
code VARCHAR(25),
coins_id int(11),
levels_id int(11)
)
جدول الفئات يحتوي علي اسماء دليل الحسابات واسم الاب والكود والعملة والمستوي
// levels جدول
CREATE TABLE levels (
id INT AUTO_INCREMENT PRIMARY KEY,
level VARCHAR(255) NOT NULL
)
جدول المستويات يحتوي علي مستوي كل بند في دليل الحسابات وتكون من مستوي رئيسي و مستوي فرعي
// coins جدول
CREATE TABLE coins (
id INT AUTO_INCREMENT PRIMARY KEY,
coin VARCHAR(255) NOT NULL
)
جدول العملات يحتوي علي العملات المستخدمة في كل بند في دليل الحسابات وتكون حسب العملات المستخدمة لديك مثال الدولار الامريكي والجنية المصري
ولتصبح في النهاية بهذا الشكل
database_connection.php
ننشئ صفحة database_connection.php ثم ننسخ بداخلها الكود التالي:
ويحتوي الكود علي لينك يربط localhost مع database تحت اسم chart of account ويوز باسم root وباسوورد فارغ بدون اسم
يجب ان يكون اسم الداتا بيس مطابق للاسم في mysql الذي انشاناها في البداية
انشاء صفحات العرض والاضافة
index.php
ننشئ صفحة index.php ثم ننسخ بداخلها الكود التالي:
ويحتوي الكود علي لينك ajax,bootstrap,datatable وفي الاستايل يحتوي علي خط كوفي عربي وهو المفضل و صورة باسم b1.jpg ويمكنك وضع الصورة الانسب لك
وتنقسم الصفحة الي قسمين لاضافة او لعرض شجرة الحسابات كما تري.
وفي النهاية ياتي الاسكربت الخاص بتوجيهك للصفحة المراد استدعاء منها المعلومات
دليـــــــــل الحســـــــــــابات
دليـــــــــل الحســـــــــــابات
التعديل والحذف
Back
اضافة بيان لدليل الحسابات
اضافة فئـــــــة
شجرة الحسابات
add.php
هي الصفحة المسئولة عن اضافة بيان جديد لدليل الحسابات عن طريق اضافتة لل database
ننشئ صفحة باسم add.php وننسخ بداخلها الكود التالي
$_POST['name'],
':parent_id' => $_POST['parent_code'],
':code' => $_POST['code'],
':coins_id' => $_POST['coins_id'],
':levels_id' => $_POST['levels_id']
);
$errors = [];
if (empty($_POST['name']) || empty($_POST['code'])) {
$errors = "ادخـــــل بيـــــان";
}
if (count($errors) == 0) {
$query = "
INSERT INTO category (name, parent_id, code, coins_id, levels_id)
VALUES (:name, :parent_id, :code, :coins_id, :levels_id)
";
$statement = $connect->prepare($query);
if($statement->execute($data))
{
echo 'Category Added';
}
}else{
echo $errors;
}
?>
fetch.php
هي الصفحة المسئولة عن استدعاء البيانات لدليل الحسابات من ال database
ننشئ صفحة باسم fetch.php وننسخ بداخلها الكود التالي
prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$data = get_node_data($parent_id, $connect);
}
echo json_encode(array_values($data));
function get_node_data($parent_id, $connect)
{
$query = "SELECT * FROM category WHERE parent_id = '".$parent_id."'";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = array();
foreach($result as $row)
{
$sub_array = array();
$sub_array['text'] = ' '.$row['code'].' '.$row['name'].' ';
$sub_array['nodes'] = array_values(get_node_data($row['code'], $connect));
$output[] =$sub_array;
}
return $output;
}
?>
fill_coins.php
هي الصفحة المسئولة عن استدعاء البيانات الخاصة بنوع العملة حين اضافة بيان جديد لدليل الحسابات داخل ال database
ننشئ صفحة باسم fill_coins.php وننسخ بداخلها الكود التالي
prepare($query);
$statement->execute();
$result = $statement->fetchAll();
//$output = '';
foreach($result as $row)
{
$output .= '';
}
echo $output;
?>
fill_levels.php
هي الصفحة المسئولة عن استدعاء البيانات الخاصة بمستوي كل بيان جديد حيث انه يكون رئيسي او فرعي وذلك حين اضافة بيان جديد لدليل الحسابات داخل ال database
ننشئ صفحة باسم fill_levels.php وننسخ بداخلها الكود التالي
prepare($query);
$statement->execute();
$result = $statement->fetchAll();
//$output = '';
foreach($result as $row)
{
$output .= '';
}
echo $output;
?>
fill_parent_category.php
هي الصفحة المسئولة عن استدعاء البيانات الخاصة بالتابع او الاب وذلك حين اضافة بيان جديد لدليل الحسابات داخل ال database
ننشئ صفحة باسم fill_parent_category.php وننسخ بداخلها الكود التالي
prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '';
foreach($result as $row)
{
$output .= '';
}
echo $output;
?>
يجب ادخال البيانات الموضحة في الصورة يدويا علي اعتبار انها بيانات يبني عليها شجرة الحسابات
انشاء صفحات التعديل
بعد ان انشائنا صفحات العرض والاضافة نقوم بانشاء صفحات التعديل علي البيانات وذلك بانشاء فولدر edit داخل فولدر chart-of-accounts وكما هو موضح بالصورة
وداخل فولدر edit نقوم بانشاء ملفات index.php , action.php and fetch.php
index.php
هي صفحة عرض البيانات التي نقوم بالحذف او التعديل عليها وتحتوي علي datatable , اسكربت يقوم بالتوجية الي fetch للقيام بعملية الحذف او التعديل من الداتا بيس
ننشئ صفحة باسم index.php داخل فولدر edit وننسخ بداخلها الكود التالي
accounting
تعديل بيانات دليل الحسابات
Back
تعديل بيانات
ID
رقم الحساب
اسم الحساب
حسابة الاعلي
نوع الحساب
العملة
المستوي
التقرير
action.php
هي صفحة تعمل في الخلفية علي تعديل او حذف البيانات
ننشئ صفحة باسم action.php داخل فولدر edit وننسخ بداخلها الكود التالي
$_POST['id'],
':name'=> $_POST['name'],
':coins_id'=> $_POST['coins_id'],
':levels_id'=> $_POST['levels_id']
);
$query = "
UPDATE category SET
name = :name ,
levels_id = :levels_id ,
coins_id = :coins_id
WHERE id = :id
";
$statement = $connect->prepare($query);
$statement->execute($data);
echo json_encode($_POST);
}
if($_POST['action'] == 'delete')
{
$query = "
DELETE FROM category
WHERE id = '".$_POST["id"]."' AND parent_id !=0
";
$statement = $connect->prepare($query);
$statement->execute();
echo json_encode($_POST);
}
?>
fetch.php
هي صفحة تعمل في الخلفية علي استدعاء البيانات من قاعدة البيانات بعد عملية الحذف او التعديل
ننشئ صفحة باسم fetch.php داخل فولدر edit وننسخ بداخلها الكود التالي
= 3) THEN 'قائمة الدخل'
ELSE '0'
END stat
FROM category
LEFT JOIN coins ON coins.id = coins_id
LEFT JOIN levels ON levels.id = levels_id
";
if(isset($_POST["search"]["value"]))
{
$query .= '
WHERE name LIKE "%'.$_POST["search"]["value"].'%"
OR parent_id LIKE "%'.$_POST["search"]["value"].'%"
';
}
if(isset($_POST["order"]))
{
$query .= 'ORDER BY '.$column[$_POST['order']['0']['column']].' '.$_POST['order']['0']['dir'].' ';
}
else
{
$query .= 'ORDER BY code asc ';
}
$query1 = '';
if($_POST["length"] != -1)
{
$query1 = 'LIMIT ' . $_POST['start'] . ', ' . $_POST['length'];
}
$statement = $connect->prepare($query);
$statement->execute();
$number_filter_row = $statement->rowCount();
$statement = $connect->prepare($query . $query1);
$statement->execute();
$result = $statement->fetchAll();
$data = array();
foreach($result as $row)
{
$sub_array = array();
$sub_array[] = $row['id'];
$sub_array[] = $row['code'];
$sub_array[] = $row['name'];
$sub_array[] = $row['parent_id'];
$sub_array[] = $row['typ'];
$sub_array[] = $row['coin'];
$sub_array[] = $row['level'];
$sub_array[] = $row['stat'];
$data[] = $sub_array;
}
function count_all_data($connect)
{
$query = "SELECT * FROM category";
$statement = $connect->prepare($query);
$statement->execute();
return $statement->rowCount();
}
$output = array(
'draw' => intval($_POST['draw']),
'recordsTotal' => count_all_data($connect),
'recordsFiltered' => $number_filter_row,
'data' => $data
);
echo json_encode($output);
?>
وتكون صفحة التعديل والحذف بالشكل التالي داخل جدول datatable الشهير و امكانية البحث او الطباعه والعرض
Sharing to
Hi! Someone in my Facebook group shared this website with us so I came to check it out. I’m definitely loving the information. I’m bookmarking and will be tweeting this to my followers! Terrific blog and amazing design and style.
You should take part in a contest for one of the greatest blogs on the web. I’m going to recommend this website!
I was curious if you ever considered changing the layout of your website? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having one or two pictures. Maybe you could space it out better?
Whoa a lot of helpful knowledge.
Wow tons of valuable info!
You actually reported it very well.
Thanks! Good stuff!
Wonderful postings. With thanks!
Appreciate it. Quite a lot of forum posts.
Nicely put, Kudos.
Fine content, Regards.
Thanks a lot, An abundance of advice.
Hey there! Quick question that’s totally off topic.
Do you know how to make your site mobile friendly? My web site looks weird when viewing from my
iphone. I’m trying to find a theme or plugin that might be able to correct this problem.
If you have any recommendations, please share.
Appreciate it!
You ought to be a part of a contest for one of the most
useful sites on the internet. I’m going to recommend this
web site!
It’s an amazing piece of writing for all the web viewers; they
will get advantage from it I am sure.
I’ve learn some good stuff here. Certainly worth
bookmarking for revisiting. I wonder how a lot effort you put to
make one of these fantastic informative site.
I go to see day-to-day a few web pages and websites to read articles, except this web site gives
quality based posts.
Greetings! I’ve been reading your website for a long time now and finally got the bravery to go ahead
and give you a shout out from Houston Texas! Just
wanted to tell you keep up the great work!
This design is steller! You certainly know how to keep a reader entertained.
Between your wit and your videos, I was almost moved to start my own blog (well,
almost…HaHa!) Excellent job. I really loved what you had to say, and
more than that, how you presented it. Too cool!
Its such as you learn my mind! You appear to know so much approximately this,
like you wrote the e book in it or something.
I believe that you just can do with some % to power the message house a little bit, however instead of
that, that is excellent blog. A fantastic read. I’ll certainly
be back.
If some one desires expert view regarding running a blog afterward
i suggest him/her to pay a visit this blog, Keep up the
pleasant job.
Great blog! Is your theme custom made or did you
download it from somewhere? A design like yours with
a few simple adjustements would really make my blog stand out.
Please let me know where you got your theme. Cheers
This is my first time pay a visit at here and i am genuinely pleassant to read everthing at alone place.
Hey there! I just wanted to ask if you ever have any trouble with hackers?
My last blog (wordpress) was hacked and I ended up losing a few months of hard
work due to no backup. Do you have any solutions to stop hackers?
Contact me on WhatsApp and I will help you
Heya! I’m at work browsing your blog from my new iphone 3gs!
Just wanted to say I love reading through your blog and look forward to all your posts!
Carry on the fantastic work!
I’m happy about that.thank you
Wonderful blog! I found it while searching on Yahoo News.
Do you have any suggestions on how to get listed in Yahoo News?
I’ve been trying for a while but I never seem to get there!
Cheers
It takes effort.
This is really interesting, You’re a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your great
post. Also, I’ve shared your web site in my social networks!
Thank you for your support
What i don’t realize is in reality how you are now
not really a lot more smartly-favored than you might be now.
You are so intelligent. You recognize thus significantly with regards to this topic, produced me in my view
believe it from so many numerous angles. Its like men and women are not involved except it’s one thing to accomplish with Lady gaga!
Your individual stuffs nice. Always maintain it up!
Hello, i read your blog occasionally and i
own a similar one and i was just wondering if you get a lot of spam comments?
If so how do you prevent it, any plugin or anything you can recommend?
I get so much lately it’s driving me insane
so any help is very much appreciated.
Contact me privately on WhatsApp or info@onemoka
you’re truly a just right webmaster. The web site loading
velocity is amazing. It seems that you’re doing any unique trick.
In addition, The contents are masterwork. you’ve performed a magnificent
process on this subject!
Thank you. If you have a software project, ask for it and it will be in my next article. I wish you a happy day.
Hello there! I know this is kinda off topic but I was wondering if you knew where I could get a
captcha plugin for my comment form? I’m using the same blog platform as yours and I’m having problems finding one?
Thanks a lot!
Contact me privately and I will help you
Very good info. Lucky me I discovered your blog by chance (stumbleupon).
I’ve saved as a favorite for later!
thank you
Hi there just wanted to give you a quick heads up.
The words in your content seem to be running off the screen in Safari.
I’m not sure if this is a format issue or something to do with
internet browser compatibility but I figured I’d post to let you
know. The layout look great though! Hope you get the
issue solved soon. Thanks
Unfortunately, I could not adjust the settings for all browsers, but I will look into the subject soon. Thank you for your comment.
What i don’t understood is if truth be told how you’re no longer really much more well-preferred than you may be now.
You are very intelligent. You already know therefore
significantly on the subject of this matter, made me in my view believe it from numerous numerous angles.
Its like women and men aren’t interested until it’s something to do with Girl gaga!
Your own stuffs nice. All the time take care of it up!
I couldn’t refrain from commenting. Exceptionally well written!
Thank you sir
I enjoy, cause I discovered just what I was looking for.
You have ended my four day long hunt! God Bless you man. Have a great day.
Bye
Thank you and good luck always