Annotation of /com_supacart/trunk/admin_files/classes/ps_order_status.php
Parent Directory
|
Revision Log
Revision 4 - (view) (download)
| 1 : | andphe | 4 | <?php |
| 2 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 3 : | /** | ||
| 4 : | * | ||
| 5 : | * @version $Id: ps_order_status.php 617 2007-01-04 19:43:08Z soeren_nb $ | ||
| 6 : | * @package SupaCart | ||
| 7 : | * @subpackage classes | ||
| 8 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 9 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 10 : | * SupaCart is free software, originally derived from Virtuemart. This version may have been modified pursuant | ||
| 11 : | * to the GNU General Public License, and as distributed it includes or | ||
| 12 : | * is derivative of works licensed under the GNU General Public License or | ||
| 13 : | * other free or open source software licenses. | ||
| 14 : | * See /administrator/components/com_supacart/COPYRIGHT.php for copyright notices and details. | ||
| 15 : | * | ||
| 16 : | * http://www.supacart.com | ||
| 17 : | */ | ||
| 18 : | |||
| 19 : | |||
| 20 : | class ps_order_status { | ||
| 21 : | var $classname = "ps_order_status"; | ||
| 22 : | |||
| 23 : | /* | ||
| 24 : | ** VALIDATION FUNCTIONS | ||
| 25 : | ** | ||
| 26 : | */ | ||
| 27 : | |||
| 28 : | function validate_add(&$d) { | ||
| 29 : | |||
| 30 : | $db = new ps_DB; | ||
| 31 : | |||
| 32 : | if (!$d["order_status_code"]) { | ||
| 33 : | $d["error"] = "ERROR: You this order status type is already defined."; | ||
| 34 : | return False; | ||
| 35 : | } | ||
| 36 : | |||
| 37 : | return True; | ||
| 38 : | } | ||
| 39 : | |||
| 40 : | function validate_delete($d) { | ||
| 41 : | |||
| 42 : | if (!$d["order_status_id"]) { | ||
| 43 : | $d["error"] = "ERROR: Please select an order status type to delete."; | ||
| 44 : | return False; | ||
| 45 : | } | ||
| 46 : | else { | ||
| 47 : | return True; | ||
| 48 : | } | ||
| 49 : | } | ||
| 50 : | |||
| 51 : | function validate_update(&$d) { | ||
| 52 : | $db = new ps_DB; | ||
| 53 : | |||
| 54 : | if (!$d["order_status_id"]) { | ||
| 55 : | $d["error"] = "ERROR: You must select an order status to update."; | ||
| 56 : | return False; | ||
| 57 : | } | ||
| 58 : | if (!$d["order_status_code"]) { | ||
| 59 : | $d["error"] = "ERROR: You must enter a order status code."; | ||
| 60 : | return False; | ||
| 61 : | } | ||
| 62 : | return True; | ||
| 63 : | } | ||
| 64 : | |||
| 65 : | |||
| 66 : | /************************************************************************** | ||
| 67 : | * name: add() | ||
| 68 : | * created by: pablo | ||
| 69 : | * description: creates a new tax rate record | ||
| 70 : | * parameters: | ||
| 71 : | * returns: | ||
| 72 : | **************************************************************************/ | ||
| 73 : | function add(&$d) { | ||
| 74 : | $db = new ps_DB; | ||
| 75 : | $ps_vendor_id = $_SESSION["ps_vendor_id"]; | ||
| 76 : | $timestamp = time(); | ||
| 77 : | |||
| 78 : | if (!$this->validate_add($d)) { | ||
| 79 : | return False; | ||
| 80 : | } | ||
| 81 : | $q = "INSERT INTO #__{sc}_order_status (vendor_id, order_status_code,"; | ||
| 82 : | $q .= "order_status_name, list_order) "; | ||
| 83 : | $q .= "VALUES ("; | ||
| 84 : | $q .= "'$ps_vendor_id','"; | ||
| 85 : | $q .= $d["order_status_code"] . "','"; | ||
| 86 : | $q .= $d["order_status_name"] . "','"; | ||
| 87 : | $q .= $d["list_order"] . "')"; | ||
| 88 : | $db->query($q); | ||
| 89 : | $db->next_record(); | ||
| 90 : | return True; | ||
| 91 : | |||
| 92 : | } | ||
| 93 : | |||
| 94 : | /************************************************************************** | ||
| 95 : | * name: update() | ||
| 96 : | * created by: pablo | ||
| 97 : | * description: updates function information | ||
| 98 : | * parameters: | ||
| 99 : | * returns: | ||
| 100 : | **************************************************************************/ | ||
| 101 : | function update(&$d) { | ||
| 102 : | $db = new ps_DB; | ||
| 103 : | $ps_vendor_id = $_SESSION["ps_vendor_id"]; | ||
| 104 : | $timestamp = time(); | ||
| 105 : | |||
| 106 : | if (!$this->validate_update($d)) { | ||
| 107 : | return False; | ||
| 108 : | } | ||
| 109 : | $q = "UPDATE #__{sc}_order_status SET "; | ||
| 110 : | $q .= "order_status_code='" . $d["order_status_code"]; | ||
| 111 : | $q .= "',order_status_name='" . $d["order_status_name"]; | ||
| 112 : | $q .= "',list_order='" . $d["list_order"]; | ||
| 113 : | $q .= "' WHERE order_status_id='" . $d["order_status_id"] . "'"; | ||
| 114 : | $q .= " AND vendor_id='$ps_vendor_id'"; | ||
| 115 : | $db->query($q); | ||
| 116 : | $db->next_record(); | ||
| 117 : | return True; | ||
| 118 : | } | ||
| 119 : | |||
| 120 : | /** | ||
| 121 : | * Controller for Deleting Records. | ||
| 122 : | */ | ||
| 123 : | function delete(&$d) { | ||
| 124 : | |||
| 125 : | if (!$this->validate_delete($d)) { | ||
| 126 : | return False; | ||
| 127 : | } | ||
| 128 : | $record_id = $d["order_status_id"]; | ||
| 129 : | |||
| 130 : | if( is_array( $record_id)) { | ||
| 131 : | foreach( $record_id as $record) { | ||
| 132 : | if( !$this->delete_record( $record, $d )) | ||
| 133 : | return false; | ||
| 134 : | } | ||
| 135 : | return true; | ||
| 136 : | } | ||
| 137 : | else { | ||
| 138 : | return $this->delete_record( $record_id, $d ); | ||
| 139 : | } | ||
| 140 : | } | ||
| 141 : | /** | ||
| 142 : | * Deletes one Record. | ||
| 143 : | */ | ||
| 144 : | function delete_record( $record_id, &$d ) { | ||
| 145 : | global $db; | ||
| 146 : | $ps_vendor_id = $_SESSION["ps_vendor_id"]; | ||
| 147 : | |||
| 148 : | $q = "DELETE from #__{sc}_order_status WHERE order_status_id='$record_id'"; | ||
| 149 : | $q .= " AND vendor_id='$ps_vendor_id'"; | ||
| 150 : | $db->query($q); | ||
| 151 : | return True; | ||
| 152 : | } | ||
| 153 : | |||
| 154 : | |||
| 155 : | function list_order_status($order_status_code, $extra="") { | ||
| 156 : | echo $this->getOrderStatus( $order_status_code, $extra ); | ||
| 157 : | } | ||
| 158 : | |||
| 159 : | function getOrderStatus( $order_status_code, $extra="") { | ||
| 160 : | $db = new ps_DB; | ||
| 161 : | |||
| 162 : | $q = "SELECT order_status_id, order_status_code, order_status_name FROM #__{sc}_order_status ORDER BY list_order"; | ||
| 163 : | $db->query($q); | ||
| 164 : | $html = "<select name=\"order_status\" class=\"inputbox\" $extra>\n"; | ||
| 165 : | while ($db->next_record()) { | ||
| 166 : | $html .= "<option value=\"" . $db->f("order_status_code")."\""; | ||
| 167 : | if ($order_status_code == $db->f("order_status_code")) | ||
| 168 : | $html .= " selected=\"selected\">"; | ||
| 169 : | else | ||
| 170 : | $html .= ">"; | ||
| 171 : | $html .= $db->f("order_status_name") . "</option>\n"; | ||
| 172 : | } | ||
| 173 : | $html .= "</select>\n"; | ||
| 174 : | |||
| 175 : | return $html; | ||
| 176 : | } | ||
| 177 : | |||
| 178 : | function getOrderStatusName( $order_status_code ) { | ||
| 179 : | $db = new ps_DB; | ||
| 180 : | |||
| 181 : | $q = "SELECT order_status_id, order_status_name FROM #__{sc}_order_status WHERE `order_status_code`='".$order_status_code."'"; | ||
| 182 : | $db->query($q); | ||
| 183 : | $db->next_record(); | ||
| 184 : | return $db->f("order_status_name"); | ||
| 185 : | } | ||
| 186 : | } | ||
| 187 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

