Merge branch 'Jagadees-zyxware-master'
[com.zyxware.civiwci.git] / CRM / Wci / Page / ProgressBarList.php
1 <?php
2
3 require_once 'CRM/Core/Page.php';
4 require_once 'CRM/Wci/DAO/ProgressBar.php';
5
6 class CRM_Wci_Page_ProgressBarList extends CRM_Core_Page {
7 private static $_actionLinks;
8 function run() {
9 // get the requested action
10 $action = CRM_Utils_Request::retrieve('action', 'String',
11 // default to 'browse'
12 $this, FALSE, 'browse'
13 );
14 echo $action;
15 // assign vars to templates
16 $this->assign('action', $action);
17 $id = CRM_Utils_Request::retrieve('id', 'Positive',
18 $this, FALSE, 0
19 );
20
21
22 if ($action & CRM_Core_Action::UPDATE) {
23 echo "UPDATE clicked";
24 $controller = new CRM_Core_Controller_Simple('CRM_Wci_Form_ProgressBar',
25 'Edit Progressbar',
26 CRM_Core_Action::UPDATE
27 );
28 $controller->set('id', $id);
29 $controller->process();
30 return $controller->run();
31 // return;
32 } elseif ($action & CRM_Core_Action::DELETE) {
33 echo "delete clicked";
34 // return;
35 }
36
37 // Example: Set the page-title dynamically; alternatively, declare a static title in xml/Menu/*.xml
38 CRM_Utils_System::setTitle(ts('ProgressBarList'));
39
40 // Example: Assign a variable for use in a template
41 $this->assign('currentTime', date('Y-m-d H:i:s'));
42
43 $query = "SELECT * FROM civicrm_wci_progress_bar";
44 $params = array();
45
46 $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_WCI_DAO_ProgressBar');
47
48 while ($dao->fetch()) {
49 $con_page[$dao->id] = array();
50 CRM_Core_DAO::storeValues($dao, $con_page[$dao->id]);
51 //print_r($con_page[$dao->id]['starting_amount']);
52
53 $action = array_sum(array_keys($this->actionLinks()));
54 //build the normal action links.
55 $con_page[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(),
56 $action,
57 array('id' => $dao->id),
58 ts('more'),
59 TRUE
60 );
61 }
62
63 if (isset($con_page)) {
64 $this->assign('rows', $con_page);
65 }
66
67 /*
68 $query = "SELECT * FROM civicrm_wci_progress_bar";
69 $dao = CRM_Core_DAO::singleValueQuery($query);
70 print_r($dao);
71 */
72 return parent::run();
73 }
74
75 function &actionLinks() {
76 // check if variable _actionsLinks is populated
77 if (!isset(self::$_actionLinks)) {
78 // helper variable for nicer formatting
79 $deleteExtra = ts('Are you sure you want to delete this Contribution page?');
80 $copyExtra = ts('Are you sure you want to make a copy of this Contribution page?');
81
82 self::$_actionLinks = array(
83 CRM_Core_Action::UPDATE => array(
84 'name' => ts('Update'),
85 'url' => CRM_Utils_System::currentPath(),
86 'qs' => 'action=update&reset=1&id=%%id%%',
87 'title' => ts('Update'),
88 ),
89 CRM_Core_Action::DELETE => array(
90 'name' => ts('Delete'),
91 'url' => CRM_Utils_System::currentPath(),
92 'qs' => 'action=delete&reset=1&id=%%id%%',
93 'title' => ts('Delete Custom Field'),
94 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"',
95 ),
96 );
97 }
98 return self::$_actionLinks;
99 }
100 }