コード例 #1
0
 /**
  * Add or Remove an order item to/from a server
  * 
  * 
  * @param integer $orderItemID
  * @param integer $serverID
  */
 private static function doAddRemove($orderItemID, $serverID, $action = '')
 {
     $ret = false;
     if (is_numeric($orderItemID) && is_numeric($serverID) && ($action == 'add' || $action == 'remove')) {
         $serverID = intval($serverID);
         $itemID = intval($orderItemID);
         if ($action == 'remove') {
             $record = self::findByServerAndItem($serverID, $itemID);
             $record->delete();
             $ret = true;
         } else {
             $order = OrdersItems::find($orderItemID, 'order_id', true);
             if (!empty($order) && is_array($order) && count($order) > 0) {
                 $order = $order[0];
                 if (!isset($order['order_id']) || intval($order['order_id']) == 0) {
                     $ret = false;
                 }
                 $orderID = intval($order['order_id']);
                 $OrdersItemsServers = new self();
                 $OrdersItemsServers->server_id = $serverID;
                 $OrdersItemsServers->order_id = $orderID;
                 $OrdersItemsServers->orderitem_id = $itemID;
                 $OrdersItemsServers->save();
                 $ret = true;
             }
         }
         // Always update server stats
         $Server = Servers::find($serverID);
         $Server->services = OrdersItemsServers::countByServerId($serverID);
         $Server->save();
         return $ret;
     }
     return false;
 }
コード例 #2
0
ファイル: ServersController.php プロジェクト: kokkez/shineisp
 /**
  * confirmAction
  * Ask to the user a confirmation before to execute the task
  * @return null
  */
 public function confirmAction()
 {
     $id = $this->getRequest()->getParam('id');
     $controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();
     try {
         if (is_numeric($id)) {
             $this->view->back = "/admin/{$controller}/edit/id/{$id}";
             $this->view->goto = "/admin/{$controller}/delete/id/{$id}";
             $this->view->title = $this->translator->translate('Are you sure you want to delete this server?');
             $this->view->description = $this->translator->translate('If you delete this server all the data will no longer be available.');
             $record = Servers::find($id);
         } else {
             $this->_helper->redirector('list', $controller, 'admin', array('mex' => $this->translator->translate('Unable to process the request at this time.'), 'status' => 'danger'));
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }