1: <?php
2:
3: require('../qcubed.inc.php');
4:
5:
6: require ('./records.summary.php');
7:
8: class ProjectListForm extends QForm {
9:
10: protected $dtgProjects;
11:
12: protected function Form_Create() {
13:
14: $this->dtgProjects = new QDataGrid($this);
15:
16:
17:
18: $this->dtgProjects->AlternateRowCssClass = 'alternate';
19:
20:
21: $this->dtgProjects->Paginator = new QPaginator($this->dtgProjects);
22: $this->dtgProjects->ItemsPerPage = 3;
23:
24:
25:
26:
27: $col = $this->dtgProjects->CreateCallableColumn('', [$this, 'render_btnToggleRecordsSummary']);
28: $col->HtmlEntities = false;
29: $col->CellStyler->Width = "1%";
30:
31: $this->dtgProjects->CreateNodeColumn('Id', QQN::Project()->Id);
32: $this->dtgProjects->CreateNodeColumn('Name', QQN::Project()->Name);
33: $this->dtgProjects->CreateNodeColumn('Status', QQN::Project()->ProjectStatusType);
34: $this->dtgProjects->CreateNodeColumn('Description', QQN::Project()->Description);
35: $this->dtgProjects->CreateNodeColumn('Start Date', QQN::Project()->StartDate);
36: $this->dtgProjects->CreateNodeColumn('End Date', QQN::Project()->EndDate);
37: $this->dtgProjects->CreateNodeColumn('Budget', QQN::Project()->Budget);
38: $this->dtgProjects->CreateNodeColumn('Spent', QQN::Project()->Spent);
39:
40:
41:
42: $col = $this->dtgProjects->CreateCallableColumn('', [$this, 'render_ucRecordsSummary']);
43: $col->HtmlEntities = false;
44: $col->CellStyler->Width = 0;
45:
46:
47: $this->dtgProjects->SetDataBinder('dtgProjects_Bind');
48:
49:
50:
51: $this->dtgProjects->AddCssFile(__QCUBED_ASSETS__ . '/php/examples/master_detail/styles.css');
52: }
53:
54: protected function dtgProjects_Bind() {
55: $this->dtgProjects->TotalItemCount = Project::QueryCount(QQ::All());
56:
57:
58:
59: if ($objClause = $this->dtgProjects->OrderByClause) {
60: $objClauses[] = $objClause;
61: }
62:
63:
64: if ($objClause = $this->dtgProjects->LimitClause) {
65: $objClauses[] = $objClause;
66: }
67:
68: $this->dtgProjects->DataSource = Project::LoadAll($objClauses);
69: }
70:
71:
72:
73:
74: public function render_btnToggleRecordsSummary(Project $objProject) {
75:
76: $objControlId = 'btnToggleRecordsSummary' . $objProject->Id;
77:
78: if (!$objControl = $this->GetControl($objControlId)) {
79: $intTeamMemberCount = Person::CountByProjectAsTeamMember($objProject->Id);
80: if ($intTeamMemberCount > 0) {
81:
82:
83:
84: $objControl = new QButton($this->dtgProjects, $objControlId);
85: $objControl->Width = 25;
86: $objControl->Text = '+' . $intTeamMemberCount;
87: $objControl->CssClass = 'inputbutton';
88:
89:
90:
91:
92: $objControl->ActionParameter = $objProject->Id;
93:
94:
95: $objControl->AddAction(new QClickEvent(), new QAjaxAction( 'btnToggleRecordsSummary_Click'));
96: }
97: }
98:
99:
100: return $objControl->Render(false);
101: }
102:
103:
104:
105: public function btnToggleRecordsSummary_Click($strFormId, $strControlId, $strParameter) {
106:
107: $srcControl = $this->GetControl($strControlId);
108:
109: $intProjectId = intval($strParameter);
110:
111:
112: $objControlId = 'ucRecordsSummary' . $intProjectId;
113: $objControl = $this->GetControl($objControlId);
114:
115: $intTeamMemberCount = Person::CountByProjectAsTeamMember($intProjectId);
116: if ($intTeamMemberCount > 0) {
117: if ($objControl) {
118:
119: if ($objControl->Visible) {
120:
121: $objControl->Visible = false;
122: $srcControl->Text = '+';
123: } else {
124:
125: $objControl->Visible = true;
126: $srcControl->Text = '-';
127: }
128:
129:
130: $this->dtgProjects->Refresh();
131: }
132: }
133: }
134:
135:
136: public function render_ucRecordsSummary(Project $objProject) {
137: $objControlId = 'ucRecordsSummary' . $objProject->Id;
138:
139: if (!$objControl = $this->GetControl($objControlId)) {
140:
141:
142: $objControl = new RecordsSummary($this->dtgProjects, $objProject, $objControlId);
143:
144:
145:
146: $objControl->Visible = false;
147: }
148:
149: return $objControl->Render(false);
150: }
151: }
152:
153:
154:
155: ProjectListForm::Run('ProjectListForm');
156: ?>