public function execute(&$params) { if (!wa()->getUser()->getRights('shop', 'orders')) { return null; } $contact_id = $params; $om = new shopOrderModel(); $total_orders = $om->countByField('contact_id', $contact_id); if (!$total_orders) { return null; } return array('html' => '', 'url' => wa()->getAppUrl('shop') . '?module=customers&action=profileTab&id=' . $contact_id, 'count' => 0, 'title' => _wd('shop', 'Shop') . ($total_orders ? ' (' . $total_orders . ')' : '')); }
/** * @param array $params deleted contact_id * @return array|void */ public function execute(&$params) { waLocale::loadByDomain('shop'); // TODO: take a look to other models related with contacts $links = array(); $product_reviews_model = new shopProductReviewsModel(); $order_model = new shopOrderModel(); foreach ($params as $contact_id) { $links[$contact_id] = array(); if ($count = $product_reviews_model->countByField('contact_id', $contact_id)) { $links[$contact_id][] = array('role' => _wd('shop', 'Reviews author'), 'links_number' => $count); } if ($count = $order_model->countByField('contact_id', $contact_id)) { $links[$contact_id][] = array('role' => _wd('shop', 'Order customer'), 'links_number' => $count); } } return $links; }
public function execute() { $id = waRequest::post('id'); if (!$id) { $this->errors = _w("Unknown state"); return; } $order_model = new shopOrderModel(); if ($order_model->countByField('state_id', $id)) { $this->errors = _w("Cannot delete order status while there are active orders in this status"); return; } $config = shopWorkflow::getConfig(); if (isset($config['states'][$id])) { unset($config['states'][$id]); } shopWorkflow::setConfig($config); }