Source of file OrdersFront_Controller.php
Size: 3,504 Bytes - Last Modified: 2021-12-24T05:16:53+00:00
/var/www/docs.ssmods.com/process/src/code/control/OrdersFront_Controller.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 | <?php /** * Controller responsible for displaying either an rendered order or a * rendered quote that can be emailed or printed. * * @package Orders */ class OrdersFront_Controller extends Controller { /** * ClassName of Order object * * @var string * @config */ private static $url_segment = "orders/front"; private static $allowed_actions = array( "invoice", "quote" ); /** * ClassName of Order object * * @var string * @config */ private static $order_class = "Order"; /** * ClassName of Order object * * @var string * @config */ private static $estimate_class = "Estimate"; /** * Get a relative link to anorder or invoice * * NOTE: this controller will always require an ID of an order and * access key to be passed (as well as an action). * * @param $action Action we would like to view. * @param $id ID or the order we want to view. * @param $key Access key of the order (for security). * @return string */ public function Link($action = "invoice") { return Controller::join_links( $this->config()->url_segment, $action ); } /** * Get an absolute link to an order or invoice * * NOTE: this controller will always require an ID of an order and * access key to be passed (as well as an action). * * @param $action Action we would like to view. * @param $id ID or the order we want to view. * @param $key Access key of the order (for security). * @return string */ public function AbsoluteLink($action = "invoice") { return Controller::join_links( Director::absoluteBaseURL(), $this->Link($action) ); } public function invoice() { $object = Order::get() ->filter(array( "ClassName" => $this->config()->order_class, "ID" => $this->request->param("ID") ))->first(); if ($object && $object->AccessKey && $object->AccessKey == $this->request->param("OtherID")) { return $this ->customise(array( "SiteConfig" => SiteConfig::current_site_config(), "MetaTitle" => _t("Orders.InvoiceTitle", "Invoice"), "Object" => $object ))->renderWith(array( "OrderFront_invoice", "Orders", "Page" )); } else { return $this->httpError(404); } } public function quote() { $object = Order::get() ->filter(array( "ClassName" => $this->config()->estimate_class, "ID" => $this->request->param("ID") ))->first(); if ($object && $object->AccessKey && $object->AccessKey == $this->request->param("OtherID")) { return $this ->customise(array( "SiteConfig" => SiteConfig::current_site_config(), "MetaTitle" => _t("Orders.QuoteTitle", "Quote"), "Object" => $object ))->renderWith(array( "OrderFront_quote", "Orders", "Page" )); } else { return $this->httpError(404); } } } |