Source of file CountryPrice_CopyPrices_Controller.php
Size: 1,383 Bytes - Last Modified: 2021-12-23T10:40:38+00:00
/var/www/docs.ssmods.com/process/src/code/control/CountryPrice_CopyPrices_Controller.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445 | <?php class CountryPrice_CopyPrices_Controller extends ContentController { private static $url_segment = 'shoppingcart-copy-prices'; private static $allowed_actions = array( "index" => 'ADMIN' ); public static function get_link(DataObject $object) { return Injector::inst()->get('CountryPrice_CopyPrices_Controller')->Link()."?class={$object->ClassName}&id={$object->ID}"; } /** * requires the following _GET variables: * - class * - id * - from (country code) * - to (country code or codes!), using commas ... * */ public function index() { if (Permission::check('ADMIN')) { $object = $_REQUEST['class']::get()->byID(intval($_REQUEST['id'])); if ($object && $object->hasMethod('updatePrices')) { $object->updatePrices(Convert::raw2sql($_REQUEST['From']), explode(',', Convert::raw2sql($_REQUEST['To']))); echo '<p>All prices updated from <strong>'.$_REQUEST['From'].'</strong> to <strong>'.$_REQUEST['To'].'</strong></p>'; return; } } else { echo "please log in as admin first"; } } public function Link($action = null) { return Controller::join_links(Config::inst()->get('CountryPrice_CopyPrices_Controller', 'url_segment'), $action); } } |