-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing the behaviour of the page class. Now we separate the page::c…
…ontent function in different process: page::add, page::edit, page::delete, page::listing inspired in Akelos framework. This is an experimental change wroking only in the Billing cycle page. Fixing also some Billing template names.
- Loading branch information
Showing
8 changed files
with
196 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
<?php | ||
/* For licensing terms, see /license.txt */ | ||
|
||
/** | ||
* | ||
/** | ||
* @author Julio Montoya <[email protected]> BeezNest 2010 | ||
*/ | ||
|
||
|
@@ -15,22 +14,64 @@ class page { | |
|
||
public function __construct() { | ||
$this->navtitle = "Billing Sub Menu"; | ||
|
||
$this->navlist[] = array("View All Billing cycles", "package_add.png", "view"); | ||
$this->navlist[] = array("Add Billing cycle", "add.png", "add"); | ||
|
||
$this->pagename = 'billing'; | ||
$this->navlist[] = array("List All Billing cycles", "package_add.png", "listing"); | ||
$this->navlist[] = array("Add Billing cycle", "add.png", "add"); | ||
} | ||
|
||
public function description() { | ||
return "<strong>Managing Billing cycles</strong><br /> | ||
Welcome to the Package Management Area. Here you can add, edit and delete web hosting packages. Have fun :)<br /> | ||
To get started, choose a link from the sidebar's SubMenu."; | ||
} | ||
|
||
public function add() { | ||
global $main, $style, $billing; | ||
|
||
if($_POST && $main->checkToken()) { | ||
foreach($main->postvar as $key => $value) { | ||
if($value == "" && !$n && $key != "admin") { | ||
$main->errors("Please fill in all the fields!"); | ||
$n++; | ||
} | ||
} | ||
if(!$n) { | ||
foreach($main->postvar as $key => $value) { | ||
if($key != "name" && $key != "number_months") { | ||
if($n) { | ||
$additional .= ","; | ||
} | ||
$additional .= $key."=".$value; | ||
$n++; | ||
} | ||
} | ||
|
||
if ($main->postvar['status'] == 'on') { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_ACTIVE; | ||
} else { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_INACTIVE; | ||
} | ||
$billing->create($main->postvar); | ||
$main->errors("Billing cycle has been added!"); | ||
$main->redirect('?page=billing&sub=listing&msg=1'); | ||
} | ||
} | ||
|
||
for($i = 1; $i<=MAX_NUMBER_MONTHS; $i++) { | ||
$values[] = array($i,$i); | ||
} | ||
$array['NUMBER_MONTHS'] = $main->dropDown("number_months", $values, ''); | ||
$array['STATUS'] = $main->createCheckbox('', 'status'); | ||
echo $style->replaceVar("tpl/billing/add.tpl", $array); | ||
} | ||
|
||
public function content() { # Displays the page | ||
public function edit() { | ||
global $main, $style, $db, $billing; | ||
switch($main->getvar['sub']) { | ||
default: | ||
if(isset($main->getvar['do'])) { | ||
$query = $db->query("SELECT * FROM `<PRE>billing_cycles` WHERE `id` = '{$main->getvar['do']}'"); | ||
if($db->num_rows($query) == 0) { | ||
echo "That billing cycle doesn't exist!"; | ||
} else { | ||
if($_POST && $main->checkToken()) { | ||
foreach($main->postvar as $key => $value) { | ||
if($value == "" && !$n && $key != "admin") { | ||
|
@@ -48,93 +89,74 @@ public function content() { # Displays the page | |
$n++; | ||
} | ||
} | ||
|
||
if ($main->postvar['status'] == 'on') { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_ACTIVE; | ||
} else { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_INACTIVE; | ||
} | ||
$billing->create($main->postvar); | ||
$main->errors("Biiling cycle has been added!"); | ||
$main->redirect('?page=billing&sub=edit&msg=1'); | ||
} | ||
} | ||
$billing->edit($main->getvar['do'],$main->postvar); | ||
$main->errors('Billing cycle has been edited!'); | ||
$main->redirect('?page=billing&sub=listing&msg=1'); | ||
} | ||
} | ||
|
||
$data = $db->fetch_array($query); | ||
$array['ID'] = $data['id']; | ||
$array['NAME'] = $data['name']; | ||
|
||
for($i = 1; $i<=MAX_NUMBER_MONTHS; $i++) { | ||
$values[] = array($i,$i); | ||
} | ||
$array['NUMBER_MONTHS'] = $main->dropDown("number_months", $values, ''); | ||
$array['STATUS'] = $main->createCheckbox('', 'status'); | ||
echo $style->replaceVar("tpl/billing/addbillingcycle.tpl", $array); | ||
break; | ||
case 'view': | ||
case 'edit': | ||
if(isset($main->getvar['do'])) { | ||
$query = $db->query("SELECT * FROM `<PRE>billing_cycles` WHERE `id` = '{$main->getvar['do']}'"); | ||
if($db->num_rows($query) == 0) { | ||
echo "That billing cycle doesn't exist!"; | ||
} else { | ||
if($_POST && $main->checkToken()) { | ||
foreach($main->postvar as $key => $value) { | ||
if($value == "" && !$n && $key != "admin") { | ||
$main->errors("Please fill in all the fields!"); | ||
$n++; | ||
} | ||
} | ||
if(!$n) { | ||
foreach($main->postvar as $key => $value) { | ||
if($key != "name" && $key != "number_months") { | ||
if($n) { | ||
$additional .= ","; | ||
} | ||
$additional .= $key."=".$value; | ||
$n++; | ||
} | ||
} | ||
if ($main->postvar['status'] == 'on') { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_ACTIVE; | ||
} else { | ||
$main->postvar['status'] = BILLING_CYCLE_STATUS_INACTIVE; | ||
} | ||
$billing->edit($main->getvar['do'],$main->postvar); | ||
$main->errors('Billing cycle has been edited!'); | ||
$main->redirect('?page=billing&sub=edit&msg=1'); | ||
} | ||
} | ||
|
||
$data = $db->fetch_array($query); | ||
$array['ID'] = $data['id']; | ||
$array['NAME'] = $data['name']; | ||
|
||
for($i = 1; $i<=MAX_NUMBER_MONTHS; $i++) { | ||
$values[] = array($i,$i); | ||
} | ||
$array['NUMBER_MONTHS'] = $main->dropDown("number_months", $values, $data['number_months']); | ||
$array['STATUS'] = $main->createCheckbox('', 'status', $data['status']); | ||
|
||
echo $style->replaceVar("tpl/billing/editbillingcycles.tpl", $array); | ||
} | ||
} else { | ||
$query = $db->query("SELECT * FROM `<PRE>billing_cycles`"); | ||
if($db->num_rows($query) == 0) { | ||
echo "There are no billing cycles to edit!"; | ||
} else { | ||
echo "<ERRORS>"; | ||
while($data = $db->fetch_array($query)) { | ||
echo $main->sub("<strong>".$data['name']."</strong>", '<a href="?page=billing&sub=edit&do='.$data['id'].'"><img src="'. URL .'themes/icons/pencil.png"></a> <a href="?page=billing&sub=delete&do='.$data['id'].'"><img src="'. URL .'themes/icons/delete.png"></a>'); | ||
$n++; | ||
} | ||
} | ||
} | ||
break; | ||
case 'delete': | ||
if($main->getvar['do'] && $main->checkToken()) { | ||
$billing->setId($main->getvar['do']); | ||
$billing->delete(); | ||
$main->errors("Billing cycle #{$main->getvar['do']} has been deleted!"); | ||
$main->redirect('?page=billing&sub=edit&msg=1'); | ||
} | ||
break; | ||
$array['NUMBER_MONTHS'] = $main->dropDown("number_months", $values, $data['number_months']); | ||
$array['STATUS'] = $main->createCheckbox('', 'status', $data['status']); | ||
|
||
echo $style->replaceVar("tpl/billing/edit.tpl", $array); | ||
|
||
} | ||
} | ||
} | ||
|
||
public function delete() { | ||
global $main, $billing; | ||
if($main->getvar['do'] && $main->checkToken()) { | ||
$billing->setId($main->getvar['do']); | ||
$billing->delete(); | ||
$main->errors("Billing cycle #{$main->getvar['do']} has been deleted!"); | ||
$main->redirect('?page=billing&sub=listing&msg=1'); | ||
} | ||
} | ||
|
||
/** | ||
* Experimental changes | ||
* | ||
* */ | ||
public function listing() { | ||
global $main, $style, $db, $billing; | ||
$query = $db->query("SELECT * FROM `<PRE>billing_cycles`"); | ||
if($db->num_rows($query) == 0) { | ||
echo "There are no billing cycles to edit!"; | ||
} else { | ||
echo "<ERRORS>"; | ||
while($data = $db->fetch_array($query)) { | ||
echo $main->sub('<strong><a href="?page=billing&sub=show&do='.$data['id'].'">'.$data['name']."</a></strong>", '<a href="?page=billing&sub=edit&do='.$data['id'].'"><img src="'. URL .'themes/icons/pencil.png"></a> <a href="?page=billing&sub=delete&do='.$data['id'].'"><img src="'. URL .'themes/icons/delete.png"></a>'); | ||
|
||
} | ||
} | ||
} | ||
|
||
public function show() { | ||
global $style, $main, $billing; | ||
if ($main->getvar['do']) { | ||
$result = $billing->find($main->getvar['do']); | ||
$array['id'] = $result->id; | ||
$array['number_months'] = $result->number_months; | ||
$array['name'] = $result->name; | ||
$array['status'] = ($result->status)? 'Active': 'Inactive'; | ||
echo $style->replaceVar("tpl/billing/show.tpl", $array); | ||
} | ||
} | ||
|
||
public function content() { # Displays the page | ||
//default page | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,13 @@ <h1>Core developers</h1> | |
<li>Julio Allen Montoya Armas ([email protected]) - Lead developer</li> | ||
</ul> | ||
</li> | ||
|
||
<li>Independant</li> | ||
<ul> | ||
<li>ispcomm (Paolo) - Client Company changes</li> | ||
</ul> | ||
</li> | ||
|
||
<li>THT (2008-2009) </li> | ||
<ul> | ||
<li>Jonny [email protected]</li> | ||
|
@@ -32,12 +39,12 @@ <h1>Core developers</h1> | |
<li>KuJoe [email protected]</li> | ||
<li>Matt [email protected]</li> | ||
</ul> | ||
</li> | ||
</li> | ||
</ol> | ||
|
||
<hr /> | ||
<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" style="margin: 1em; float: right;" height="31" width="88" /></a> | ||
<a href="http://jigsaw.w3.org/css-validator/"> | ||
<img src="http://jigsaw.w3.org/css-validator/images/vcss-blue" style="margin: 1em; float: right;" alt="Valid CSS" /> | ||
</a> | ||
</body></html> | ||
</body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.