Skip to content

Commit 5d0cb4e

Browse files
committed
Switch demo to use phpGrid Lite
Updated the demo to use phpGrid Lite
1 parent 507b856 commit 5d0cb4e

File tree

8 files changed

+60
-125
lines changed

8 files changed

+60
-125
lines changed

css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ body {
1717
margin: 0;
1818
padding: 0;
1919
overflow: hidden;
20-
background-color: #4CB6EA;
20+
background-color: #1590C2;
2121
}
2222

2323
#menu ul li {

index.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>
5+
PHP FOR BEGINNERS: BUILD YOUR FIRST SIMPLE CRM FROM SCRATCH
6+
</title>
7+
</head>
8+
<body>
9+
<h1>PHP FOR BEGINNERS: BUILD YOUR FIRST SIMPLE CRM FROM SCRATCH</h1>
10+
11+
<div>
12+
Demo:
13+
<div>
14+
<a href="sales/tasks.php">Sales</a> | <a href="managers/pipeline.php">Manager</a>
15+
</div>
16+
</div>
17+
18+
</body>
19+
</html>

managers/pipeline.php

Lines changed: 25 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
4+
5+
$tableName = (isset($_GET['gn']) && $_GET['gn'] !== '') ? $_GET['gn'] : 'users';
76
?>
87

98
<h1>My Custom CRM - Sales Pipeline</h1>
109

1110
<section id="subtitle">
12-
<h2>Welcome! Manager</h2>
13-
<div>
14-
You can manage your sales team and contacts here.
11+
<h2>Welcome! Manager</h2>
12+
<div>
13+
You can manage your sales team and contacts here.
14+
</div>
15+
<br />
16+
</section>
17+
18+
<div id="menu">
19+
<ul>
20+
<li><a href="?gn=users" <?php if($tableName == 'users') echo 'class="active"'; ?>>My Sales Reps</a></li>
21+
<li><a href="?gn=notes" <?php if($tableName == 'notes') echo 'class="active"'; ?>>Tasks</a></li>
22+
<li><a href="?gn=contact" <?php if($tableName == 'contact') echo 'class="active"'; ?>>Contact</a></li>
23+
</ul>
1524
</div>
1625
<br />
17-
</section>
1826

1927
<?php
20-
//$_GET['currentPage'] = 'pipeline';
21-
//include_once('../inc/menu.php');
22-
$tableName = (isset($_GET['gn']) && isset($_GET['gn']) !== '') ? $_GET['gn'] : 'users';
23-
2428
switch($tableName){
2529
case "users":
2630
$dg = new C_DataGrid("SELECT id, Name_First, Name_Last, Email, Password FROM users", "id", "users");
2731
$dg->set_query_filter(" user_roles = 1 ");
2832
$dg->set_col_hidden('id')->set_col_hidden('User_Roles')->set_col_hidden('User_Status')->set_col_hidden('Password');
29-
$dg->set_caption(' ');
30-
$dg->set_dimension(600, 420);
33+
$dg->set_caption('Sales Rep');
3134

3235
$sdg = new C_DataGrid("SELECT id, contact_last, contact_title, company, industry, status, budget, sales_rep, rating FROM contact", "id", "contact");
3336
$sdg->set_col_hidden('id')->set_col_hidden('sales_rep', false);
34-
$sdg->set_caption(' ');
3537
$sdg->set_col_edittype('sales_rep', 'select', "select id, concat(name_first, ' ', name_last) from users");
3638
$sdg->set_col_currency('budget');
39+
$sdg->set_scroll(true);
40+
3741
//$sdg->set_col_format('rating', 'rating');
3842

3943
$gridComplete = <<<GRIDCOMPLETE
@@ -53,7 +57,7 @@ function ()
5357
case "notes":
5458
$dg = new C_DataGrid("SELECT id, Todo_Desc_ID, Todo_Due_Date, Contact, Task_Status, Sales_Rep FROM notes", "id", "notes");
5559
$dg->set_query_filter(" Todo_Due_Date != '' ");
56-
$dg->set_col_hidden('id')->set_caption(' ');;
60+
$dg->set_col_hidden('id')->set_caption('Tasks');
5761
$dg->set_col_edittype('Todo_Desc_ID', 'select', "select id, description from todo_desc");
5862
$dg->set_col_edittype('Contact', 'select', "select id, concat(contact_first, ' ', contact_last) from contact");
5963
$dg->set_col_edittype('Task_Status', 'select', "select id, status from task_status");
@@ -62,12 +66,10 @@ function ()
6266

6367
case "contact":
6468
$dg = new C_DataGrid("SELECT id, contact_last, contact_title, company, industry, status, budget, sales_rep, rating FROM contact", "id", "contact");
65-
$dg->set_col_hidden('id')->set_caption(' ');
69+
$dg->set_col_hidden('id');
6670
$dg->set_col_edittype('sales_rep', 'select', "select id, concat(name_first, ' ', name_last) from users");
6771
$dg->set_col_currency('budget');
68-
$dg->enable_global_search(true);
69-
70-
$dg->set_col_format('rating', 'rating');
72+
$dg->enable_search(true);
7173

7274
$sdg = new C_DataGrid("SELECT * FROM notes", "id", "notes");
7375
// $sdg->set_query_filter(" Sales_Rep = 1 ");
@@ -81,83 +83,14 @@ function ()
8183
$sdg->set_col_edittype('Sales_Rep', 'select', "select id, concat(name_first, ' ', name_last) from users");
8284
$sdg->enable_edit();
8385

84-
$dg->set_masterdetail($sdg, 'Contact', 'id');
86+
$dg->set_subgrid($sdg, 'Contact', 'id');
8587
break;
8688
}
8789

88-
$dg->enable_edit()->set_dimension('1100');
89-
90-
$dg -> display(false);
91-
$grid = $dg -> get_display(false);
92-
93-
$dg -> display_script_includeonce();
90+
$dg->enable_edit();
91+
$dg -> display();
9492
?>
95-
<script>
96-
$( function() {
97-
$( "#tabs" ).tabs({
98-
beforeLoad: function(event, ui) {
99-
if(ui.panel.html() == ""){
100-
ui.panel.html('<div class="loading">Loading...</div>');
101-
return true;
102-
} else {
103-
return false;
104-
}
105-
}
106-
});
107-
} );
108-
</script>
109-
110-
111-
<style>
112-
.loading {
113-
position: fixed;
114-
top: 350px;
115-
left: 50%;
116-
margin-top: -96px;
117-
margin-left: -96px;
118-
opacity: .85;
119-
border-radius: 25px;
120-
width: 50px;
121-
height: 50px;
122-
}
123-
124-
#tabs ul{
125-
width:1093px;
126-
}
127-
128-
#tabs h1,
129-
.hidetab ul{
130-
display: none;
131-
}
132-
.ui-tabs-panel.ui-widget-content.ui-corner-bottom{
133-
padding:0;
134-
}
135-
.ui-tabs .ui-tabs-nav li a{
136-
padding:.5em;
137-
font-weight: 600;
138-
}
139-
</style>
140-
141-
142-
<div id="tabs" class="<?php echo (isset($_GET['gn'])) ? 'hidetab' : ''; ?>">
143-
<ul>
144-
<li><a href="#tabs-1">My Sales Reps</a></li>
145-
<li><a href="?gn=notes">Tasks</a></li>
146-
<li><a href="?gn=contact">Contact</a></li>
147-
</ul>
148-
149-
<div id="tabs-1" style="padding:0">
150-
<?php
151-
echo $grid;
152-
?>
153-
</div>
154-
</div>
15593

156-
<script>
157-
$('#tabs').find('li a').one("click", function (e) {
158-
e.preventDefault();
159-
});
160-
</script>
16194

16295
<?php
16396
include_once('../inc/footer.php');

sales/customerwon.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
74
?>
85

@@ -19,7 +16,7 @@
1916
$dg = new C_DataGrid("SELECT * FROM contact", "id", "contact");
2017
$dg->set_query_filter(" Status = 3 && sales_rep = 1 ");
2118

22-
$dg->set_col_hidden('id')->set_col_hidden('Status')->set_caption(' ');
19+
$dg->set_col_hidden('id')->set_col_hidden('Status')->set_caption('Customers');
2320
$dg->set_col_hidden('Date_of_Initial_Contact');
2421
$dg->set_col_hidden('Contact_Title')->set_col_hidden('Contact_Middle')->set_col_hidden('Lead_Referral_Source');
2522
$dg->set_col_hidden('Address')->set_col_hidden('Address_Street_1')->set_col_hidden('Address_Street_2');
@@ -43,7 +40,8 @@
4340
$sdg->set_col_default('Sales_Rep', 1); // TODO: obtain from SESSION
4441
$sdg->enable_edit();
4542

46-
$dg->set_masterdetail($sdg, 'Contact', 'id');
43+
44+
$dg->set_subgrid($sdg, 'Contact', 'id');
4745
$dg -> display();
4846
?>
4947

sales/leads.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
74
?>
85

@@ -16,14 +13,13 @@
1613
<h3>My Leads</h2>
1714
<?php
1815
$dg = new C_DataGrid("SELECT id, contact_first, contact_last, company, phone, email, website, status, lead_referral_source, sales_rep, lead_referral_source, date_of_initial_contact, title, industry, background_info, rating, project_type, project_description, budget FROM contact", "id", "contact");
19-
$dg->set_query_filter(" status = 1 && sales_rep = 1 ");
16+
$dg->set_query_filter(" status = 1 && sales_rep = 1 ")->set_caption('Contact');
2017
$dg->set_col_hidden('id')->set_col_hidden('Status')->set_col_hidden('sales_rep', false);
2118
$dg->set_col_hidden('lead_referral_source, title, industry, background_info, rating, project_type, project_description, budget');
2219
$dg -> set_col_format("email", "email");
2320
$dg->set_col_edittype('status', 'select', 'SELECT ID, status FROM contact_status');
2421
$dg -> set_col_link("website");
2522
$dg->enable_edit();
26-
$dg->set_scroll(true, 200);
2723

2824
$sdg = new C_DataGrid("SELECT * FROM notes", "id", "notes");
2925
$sdg->set_query_filter(" Sales_Rep = 1 ");
@@ -35,10 +31,10 @@
3531
$sdg->set_col_edittype('Todo_Desc_ID', 'select', 'Select id, description From todo_desc');
3632
//$sdg->set_col_default('Contact', ###current####);
3733
$sdg->set_col_default('Sales_Rep', 1); // TODO: obtain from SESSION
38-
3934
$sdg->enable_edit();
40-
$dg->set_masterdetail($sdg, 'Contact', 'id');
4135

36+
37+
$dg->set_subgrid($sdg, 'Contact', 'id');
4238
$dg -> display();
4339
?>
4440

sales/opportunities.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
74
?>
85

@@ -18,7 +15,7 @@
1815
// $dg = new C_DataGrid("SELECT id, contact_last, company, phone, email, website, Status, project_type, budget FROM contact", "id", "contact");
1916
$dg = new C_DataGrid("SELECT * FROM contact", "id", "contact");
2017
$dg->set_query_filter(" Status = 2 && sales_rep = 1 ");
21-
$dg->set_col_hidden('id')->set_col_hidden('Status')->set_caption(' ');
18+
$dg->set_col_hidden('id')->set_col_hidden('Status')->set_caption('Contact');
2219
$dg->set_col_hidden('Date_of_Initial_Contact');
2320
$dg->set_col_hidden('Contact_Title')->set_col_hidden('Contact_Middle')->set_col_hidden('Lead_Referral_Source');
2421
$dg->set_col_hidden('Address')->set_col_hidden('Address_Street_1')->set_col_hidden('Address_Street_2');
@@ -43,7 +40,7 @@
4340
$sdg->enable_edit();
4441

4542

46-
$dg->set_masterdetail($sdg, 'Contact', 'id');
43+
$dg->set_subgrid($sdg, 'Contact', 'id');
4744
$dg -> display();
4845
?>
4946

sales/tasks-completed.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
74
?>
85

@@ -19,7 +16,7 @@
1916
$dg = new C_DataGrid("SELECT ID, `Date`, Contact, Todo_Type_ID, Todo_Desc_ID, Task_Status, Task_Update, Sales_Rep, Todo_Due_Date FROM notes", "ID", "notes");
2017
$dg->set_query_filter(" Sales_Rep = 1 && Task_Status = 2");
2118

22-
$dg->set_col_hidden('ID')->set_col_hidden('Sales_Rep', false)->set_caption(' ');
19+
$dg->set_col_hidden('ID')->set_col_hidden('Sales_Rep', false)->set_caption('Completed');
2320

2421
$dg->set_col_title('Todo_Type_ID', 'Type');
2522
$dg->set_col_title('Todo_Desc_ID', 'Description');
@@ -30,7 +27,6 @@
3027
$dg->set_col_edittype('Todo_Type_ID', 'select', 'SELECT ID, type FROM todo_type');
3128
$dg->set_col_edittype('Todo_Desc_ID', 'select', 'SELECT ID, description FROM todo_desc');
3229

33-
$dg->set_scroll(true, 200);
3430
$dg -> display();
3531
?>
3632

sales/tasks.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
<?php
2-
use phpGrid\C_DataGrid;
3-
4-
require_once("../phpGrid/conf.php");
5-
2+
include_once("../phpGrid_Lite/conf.php");
63
include_once('../inc/head.php');
74
?>
85

@@ -19,7 +16,7 @@
1916
$dg = new C_DataGrid("SELECT ID, `Date`, contact, todo_type_id, todo_desc_id, task_status, Task_Update, sales_rep, todo_due_date FROM notes", "ID", "notes");
2017
$dg->set_query_filter(" sales_rep = 1 && task_status != 2");
2118

22-
$dg->set_col_hidden('ID')->set_col_hidden('sales_rep', false)->set_caption(' ');
19+
$dg->set_col_hidden('ID')->set_col_hidden('sales_rep', false)->set_caption('Current');
2320

2421
$dg->set_col_title('todo_type_id', 'Type');
2522
$dg->set_col_title('todo_desc_id', 'Description');
@@ -39,7 +36,6 @@
3936
$dg->set_col_readonly('Date, contact, todo_type_id, todo_desc_id, sales_rep, todo_due_date');
4037

4138
$dg->enable_edit('INLINE');
42-
$dg->set_scroll(true, 200);
4339
$dg -> display();
4440
?>
4541

0 commit comments

Comments
 (0)